[email protected] | 7e856dde | 2014-03-15 00:34:05 | [diff] [blame] | 1 | // Copyright 2014 The Chromium Authors. All rights reserved. |
2 | // Use of this source code is governed by a BSD-style license that can be | ||||
3 | // found in the LICENSE file. | ||||
4 | |||||
5 | #ifndef CHROME_BROWSER_DOM_DISTILLER_LAZY_DOM_DISTILLER_SERVICE_H_ | ||||
6 | #define CHROME_BROWSER_DOM_DISTILLER_LAZY_DOM_DISTILLER_SERVICE_H_ | ||||
7 | |||||
dcheng | c0e39d57 | 2016-04-19 06:15:17 | [diff] [blame] | 8 | #include <memory> |
9 | |||||
avi | e4d7b6f | 2015-12-26 00:59:18 | [diff] [blame] | 10 | #include "base/macros.h" |
Evan Stade | eb9d25f | 2019-10-03 16:21:11 | [diff] [blame^] | 11 | #include "base/supports_user_data.h" |
[email protected] | 7e856dde | 2014-03-15 00:34:05 | [diff] [blame] | 12 | #include "components/dom_distiller/core/dom_distiller_service.h" |
13 | #include "components/dom_distiller/core/task_tracker.h" | ||||
[email protected] | 7e856dde | 2014-03-15 00:34:05 | [diff] [blame] | 14 | |
15 | class Profile; | ||||
16 | |||||
17 | namespace dom_distiller { | ||||
18 | |||||
[email protected] | 7e856dde | 2014-03-15 00:34:05 | [diff] [blame] | 19 | // A class which helps with lazy instantiation of the DomDistillerService, using |
Evan Stade | eb9d25f | 2019-10-03 16:21:11 | [diff] [blame^] | 20 | // the BrowserContextKeyedServiceFactory for it. This class is owned by Profile. |
[email protected] | 7e856dde | 2014-03-15 00:34:05 | [diff] [blame] | 21 | class LazyDomDistillerService : public DomDistillerServiceInterface, |
Evan Stade | eb9d25f | 2019-10-03 16:21:11 | [diff] [blame^] | 22 | public base::SupportsUserData::Data { |
[email protected] | 7e856dde | 2014-03-15 00:34:05 | [diff] [blame] | 23 | public: |
Evan Stade | eb9d25f | 2019-10-03 16:21:11 | [diff] [blame^] | 24 | // Creates and returns an instance for |profile|. This does not pass ownership |
25 | // of the returned pointer. | ||||
26 | static LazyDomDistillerService* Create(Profile* profile); | ||||
27 | |||||
Daniel Cheng | a542fca | 2014-10-21 09:51:29 | [diff] [blame] | 28 | ~LazyDomDistillerService() override; |
[email protected] | 7e856dde | 2014-03-15 00:34:05 | [diff] [blame] | 29 | |
[email protected] | 7e856dde | 2014-03-15 00:34:05 | [diff] [blame] | 30 | // DomDistillerServiceInterface implementation: |
Daniel Cheng | a542fca | 2014-10-21 09:51:29 | [diff] [blame] | 31 | bool HasEntry(const std::string& entry_id) override; |
32 | std::string GetUrlForEntry(const std::string& entry_id) override; | ||||
dcheng | 4af4858 | 2016-04-19 00:29:35 | [diff] [blame] | 33 | std::unique_ptr<ViewerHandle> ViewEntry( |
34 | ViewRequestDelegate* delegate, | ||||
35 | std::unique_ptr<DistillerPage> distiller_page, | ||||
36 | const std::string& entry_id) override; | ||||
37 | std::unique_ptr<ViewerHandle> ViewUrl( | ||||
38 | ViewRequestDelegate* delegate, | ||||
39 | std::unique_ptr<DistillerPage> distiller_page, | ||||
40 | const GURL& url) override; | ||||
41 | std::unique_ptr<DistillerPage> CreateDefaultDistillerPage( | ||||
mostynb | 01d8b10e | 2014-10-13 09:44:44 | [diff] [blame] | 42 | const gfx::Size& render_view_size) override; |
dcheng | 4af4858 | 2016-04-19 00:29:35 | [diff] [blame] | 43 | std::unique_ptr<DistillerPage> CreateDefaultDistillerPageWithHandle( |
44 | std::unique_ptr<SourcePageHandle> handle) override; | ||||
Daniel Cheng | a542fca | 2014-10-21 09:51:29 | [diff] [blame] | 45 | DistilledPagePrefs* GetDistilledPagePrefs() override; |
[email protected] | 7e856dde | 2014-03-15 00:34:05 | [diff] [blame] | 46 | |
47 | private: | ||||
Evan Stade | eb9d25f | 2019-10-03 16:21:11 | [diff] [blame^] | 48 | explicit LazyDomDistillerService(Profile* profile); |
[email protected] | 7e856dde | 2014-03-15 00:34:05 | [diff] [blame] | 49 | |
Evan Stade | eb9d25f | 2019-10-03 16:21:11 | [diff] [blame^] | 50 | // Accessor method for the backing service instance. |
51 | DomDistillerServiceInterface* GetImpl() const; | ||||
[email protected] | 7e856dde | 2014-03-15 00:34:05 | [diff] [blame] | 52 | |
53 | // The Profile to use when retrieving the DomDistillerService and also the | ||||
54 | // profile to listen for destruction of. | ||||
55 | Profile* profile_; | ||||
56 | |||||
[email protected] | 7e856dde | 2014-03-15 00:34:05 | [diff] [blame] | 57 | DISALLOW_COPY_AND_ASSIGN(LazyDomDistillerService); |
58 | }; | ||||
59 | |||||
60 | } // namespace dom_distiller | ||||
61 | |||||
62 | #endif // CHROME_BROWSER_DOM_DISTILLER_LAZY_DOM_DISTILLER_SERVICE_H_ |