OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef COMPONENTS_DOM_DISTILLER_CORE_DOM_DISTILLER_SERVICE_H_ | 5 #ifndef COMPONENTS_DOM_DISTILLER_CORE_DOM_DISTILLER_SERVICE_H_ |
6 #define COMPONENTS_DOM_DISTILLER_CORE_DOM_DISTILLER_SERVICE_H_ | 6 #define COMPONENTS_DOM_DISTILLER_CORE_DOM_DISTILLER_SERVICE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/memory/scoped_vector.h" | 13 #include "base/memory/scoped_vector.h" |
14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
15 #include "components/dom_distiller/core/article_entry.h" | 15 #include "components/dom_distiller/core/article_entry.h" |
16 #include "components/dom_distiller/core/distiller_page.h" | 16 #include "components/dom_distiller/core/distiller_page.h" |
17 #include "components/dom_distiller/core/reader_mode_preferences.h" | |
17 | 18 |
18 class GURL; | 19 class GURL; |
19 | 20 |
20 namespace syncer { | 21 namespace syncer { |
21 class SyncableService; | 22 class SyncableService; |
22 } | 23 } |
23 | 24 |
24 namespace dom_distiller { | 25 namespace dom_distiller { |
25 | 26 |
26 class DistilledArticleProto; | 27 class DistilledArticleProto; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
83 const GURL& url) = 0; | 84 const GURL& url) = 0; |
84 | 85 |
85 // Creates a default DistillerPage. | 86 // Creates a default DistillerPage. |
86 virtual scoped_ptr<DistillerPage> CreateDefaultDistillerPage() = 0; | 87 virtual scoped_ptr<DistillerPage> CreateDefaultDistillerPage() = 0; |
87 virtual scoped_ptr<DistillerPage> CreateDefaultDistillerPageWithHandle( | 88 virtual scoped_ptr<DistillerPage> CreateDefaultDistillerPageWithHandle( |
88 scoped_ptr<SourcePageHandle> handle) = 0; | 89 scoped_ptr<SourcePageHandle> handle) = 0; |
89 | 90 |
90 virtual void AddObserver(DomDistillerObserver* observer) = 0; | 91 virtual void AddObserver(DomDistillerObserver* observer) = 0; |
91 virtual void RemoveObserver(DomDistillerObserver* observer) = 0; | 92 virtual void RemoveObserver(DomDistillerObserver* observer) = 0; |
92 | 93 |
93 protected: | 94 // Returns the ReaderModePrefs owned by the instance of DomDistillerService |
nyquist
2014/06/26 20:39:58
Add period at the end of the comment.
smaslo
2014/06/27 18:33:17
Done.
| |
95 virtual ReaderModePrefs* GetReaderModePrefs() = 0; | |
96 | |
97 protected: | |
94 DomDistillerServiceInterface() {} | 98 DomDistillerServiceInterface() {} |
95 | 99 |
96 private: | 100 private: |
97 DISALLOW_COPY_AND_ASSIGN(DomDistillerServiceInterface); | 101 DISALLOW_COPY_AND_ASSIGN(DomDistillerServiceInterface); |
98 }; | 102 }; |
99 | 103 |
100 // Provide a view of the article list and ways of interacting with it. | 104 // Provide a view of the article list and ways of interacting with it. |
101 class DomDistillerService : public DomDistillerServiceInterface { | 105 class DomDistillerService : public DomDistillerServiceInterface { |
102 public: | 106 public: |
103 DomDistillerService(scoped_ptr<DomDistillerStoreInterface> store, | 107 DomDistillerService(scoped_ptr<DomDistillerStoreInterface> store, |
104 scoped_ptr<DistillerFactory> distiller_factory, | 108 scoped_ptr<DistillerFactory> distiller_factory, |
105 scoped_ptr<DistillerPageFactory> distiller_page_factory); | 109 scoped_ptr<DistillerPageFactory> distiller_page_factory, |
110 scoped_ptr<ReaderModePrefs> reader_mode_prefs); | |
106 virtual ~DomDistillerService(); | 111 virtual ~DomDistillerService(); |
107 | 112 |
108 // DomDistillerServiceInterface implementation. | 113 // DomDistillerServiceInterface implementation. |
109 virtual syncer::SyncableService* GetSyncableService() const OVERRIDE; | 114 virtual syncer::SyncableService* GetSyncableService() const OVERRIDE; |
110 virtual const std::string AddToList( | 115 virtual const std::string AddToList( |
111 const GURL& url, | 116 const GURL& url, |
112 scoped_ptr<DistillerPage> distiller_page, | 117 scoped_ptr<DistillerPage> distiller_page, |
113 const ArticleAvailableCallback& article_cb) OVERRIDE; | 118 const ArticleAvailableCallback& article_cb) OVERRIDE; |
114 virtual std::vector<ArticleEntry> GetEntries() const OVERRIDE; | 119 virtual std::vector<ArticleEntry> GetEntries() const OVERRIDE; |
115 virtual scoped_ptr<ArticleEntry> RemoveEntry( | 120 virtual scoped_ptr<ArticleEntry> RemoveEntry( |
116 const std::string& entry_id) OVERRIDE; | 121 const std::string& entry_id) OVERRIDE; |
117 virtual scoped_ptr<ViewerHandle> ViewEntry( | 122 virtual scoped_ptr<ViewerHandle> ViewEntry( |
118 ViewRequestDelegate* delegate, | 123 ViewRequestDelegate* delegate, |
119 scoped_ptr<DistillerPage> distiller_page, | 124 scoped_ptr<DistillerPage> distiller_page, |
120 const std::string& entry_id) OVERRIDE; | 125 const std::string& entry_id) OVERRIDE; |
121 virtual scoped_ptr<ViewerHandle> ViewUrl( | 126 virtual scoped_ptr<ViewerHandle> ViewUrl( |
122 ViewRequestDelegate* delegate, | 127 ViewRequestDelegate* delegate, |
123 scoped_ptr<DistillerPage> distiller_page, | 128 scoped_ptr<DistillerPage> distiller_page, |
124 const GURL& url) OVERRIDE; | 129 const GURL& url) OVERRIDE; |
125 virtual scoped_ptr<DistillerPage> CreateDefaultDistillerPage() OVERRIDE; | 130 virtual scoped_ptr<DistillerPage> CreateDefaultDistillerPage() OVERRIDE; |
126 virtual scoped_ptr<DistillerPage> CreateDefaultDistillerPageWithHandle( | 131 virtual scoped_ptr<DistillerPage> CreateDefaultDistillerPageWithHandle( |
127 scoped_ptr<SourcePageHandle> handle) OVERRIDE; | 132 scoped_ptr<SourcePageHandle> handle) OVERRIDE; |
128 virtual void AddObserver(DomDistillerObserver* observer) OVERRIDE; | 133 virtual void AddObserver(DomDistillerObserver* observer) OVERRIDE; |
129 virtual void RemoveObserver(DomDistillerObserver* observer) OVERRIDE; | 134 virtual void RemoveObserver(DomDistillerObserver* observer) OVERRIDE; |
135 virtual ReaderModePrefs* GetReaderModePrefs() OVERRIDE; | |
130 | 136 |
131 private: | 137 private: |
132 void CancelTask(TaskTracker* task); | 138 void CancelTask(TaskTracker* task); |
133 void AddDistilledPageToList(const ArticleEntry& entry, | 139 void AddDistilledPageToList(const ArticleEntry& entry, |
134 const DistilledArticleProto* article_proto, | 140 const DistilledArticleProto* article_proto, |
135 bool distillation_succeeded); | 141 bool distillation_succeeded); |
136 | 142 |
137 TaskTracker* CreateTaskTracker(const ArticleEntry& entry); | 143 TaskTracker* CreateTaskTracker(const ArticleEntry& entry); |
138 | 144 |
139 TaskTracker* GetTaskTrackerForEntry(const ArticleEntry& entry) const; | 145 TaskTracker* GetTaskTrackerForEntry(const ArticleEntry& entry) const; |
140 | 146 |
141 // Gets the task tracker for the given |url| or |entry|. If no appropriate | 147 // Gets the task tracker for the given |url| or |entry|. If no appropriate |
142 // tracker exists, this will create one, initialize it, and add it to | 148 // tracker exists, this will create one, initialize it, and add it to |
143 // |tasks_|. | 149 // |tasks_|. |
144 TaskTracker* GetOrCreateTaskTrackerForUrl(const GURL& url); | 150 TaskTracker* GetOrCreateTaskTrackerForUrl(const GURL& url); |
145 TaskTracker* GetOrCreateTaskTrackerForEntry(const ArticleEntry& entry); | 151 TaskTracker* GetOrCreateTaskTrackerForEntry(const ArticleEntry& entry); |
146 | 152 |
147 scoped_ptr<DomDistillerStoreInterface> store_; | 153 scoped_ptr<DomDistillerStoreInterface> store_; |
148 scoped_ptr<DistilledContentStore> content_store_; | 154 scoped_ptr<DistilledContentStore> content_store_; |
149 scoped_ptr<DistillerFactory> distiller_factory_; | 155 scoped_ptr<DistillerFactory> distiller_factory_; |
150 scoped_ptr<DistillerPageFactory> distiller_page_factory_; | 156 scoped_ptr<DistillerPageFactory> distiller_page_factory_; |
157 scoped_ptr<ReaderModePrefs> reader_mode_prefs_; | |
151 | 158 |
152 typedef ScopedVector<TaskTracker> TaskList; | 159 typedef ScopedVector<TaskTracker> TaskList; |
153 TaskList tasks_; | 160 TaskList tasks_; |
154 | 161 |
155 DISALLOW_COPY_AND_ASSIGN(DomDistillerService); | 162 DISALLOW_COPY_AND_ASSIGN(DomDistillerService); |
156 }; | 163 }; |
157 | 164 |
158 } // namespace dom_distiller | 165 } // namespace dom_distiller |
159 | 166 |
160 #endif // COMPONENTS_DOM_DISTILLER_CORE_DOM_DISTILLER_SERVICE_H_ | 167 #endif // COMPONENTS_DOM_DISTILLER_CORE_DOM_DISTILLER_SERVICE_H_ |
OLD | NEW |