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 virtual ReaderModePrefs* GetReaderModePrefs() const; |
| 95 |
| 96 protected: |
94 DomDistillerServiceInterface() {} | 97 DomDistillerServiceInterface() {} |
95 | 98 |
96 private: | 99 private: |
97 DISALLOW_COPY_AND_ASSIGN(DomDistillerServiceInterface); | 100 DISALLOW_COPY_AND_ASSIGN(DomDistillerServiceInterface); |
98 }; | 101 }; |
99 | 102 |
100 // Provide a view of the article list and ways of interacting with it. | 103 // Provide a view of the article list and ways of interacting with it. |
101 class DomDistillerService : public DomDistillerServiceInterface { | 104 class DomDistillerService : public DomDistillerServiceInterface { |
102 public: | 105 public: |
103 DomDistillerService(scoped_ptr<DomDistillerStoreInterface> store, | 106 DomDistillerService(scoped_ptr<DomDistillerStoreInterface> store, |
104 scoped_ptr<DistillerFactory> distiller_factory, | 107 scoped_ptr<DistillerFactory> distiller_factory, |
105 scoped_ptr<DistillerPageFactory> distiller_page_factory); | 108 scoped_ptr<DistillerPageFactory> distiller_page_factory, |
| 109 scoped_ptr<ReaderModePrefs> reader_mode_prefs); |
106 virtual ~DomDistillerService(); | 110 virtual ~DomDistillerService(); |
107 | 111 |
108 // DomDistillerServiceInterface implementation. | 112 // DomDistillerServiceInterface implementation. |
109 virtual syncer::SyncableService* GetSyncableService() const OVERRIDE; | 113 virtual syncer::SyncableService* GetSyncableService() const OVERRIDE; |
110 virtual const std::string AddToList( | 114 virtual const std::string AddToList( |
111 const GURL& url, | 115 const GURL& url, |
112 scoped_ptr<DistillerPage> distiller_page, | 116 scoped_ptr<DistillerPage> distiller_page, |
113 const ArticleAvailableCallback& article_cb) OVERRIDE; | 117 const ArticleAvailableCallback& article_cb) OVERRIDE; |
114 virtual std::vector<ArticleEntry> GetEntries() const OVERRIDE; | 118 virtual std::vector<ArticleEntry> GetEntries() const OVERRIDE; |
115 virtual scoped_ptr<ArticleEntry> RemoveEntry( | 119 virtual scoped_ptr<ArticleEntry> RemoveEntry( |
116 const std::string& entry_id) OVERRIDE; | 120 const std::string& entry_id) OVERRIDE; |
117 virtual scoped_ptr<ViewerHandle> ViewEntry( | 121 virtual scoped_ptr<ViewerHandle> ViewEntry( |
118 ViewRequestDelegate* delegate, | 122 ViewRequestDelegate* delegate, |
119 scoped_ptr<DistillerPage> distiller_page, | 123 scoped_ptr<DistillerPage> distiller_page, |
120 const std::string& entry_id) OVERRIDE; | 124 const std::string& entry_id) OVERRIDE; |
121 virtual scoped_ptr<ViewerHandle> ViewUrl( | 125 virtual scoped_ptr<ViewerHandle> ViewUrl( |
122 ViewRequestDelegate* delegate, | 126 ViewRequestDelegate* delegate, |
123 scoped_ptr<DistillerPage> distiller_page, | 127 scoped_ptr<DistillerPage> distiller_page, |
124 const GURL& url) OVERRIDE; | 128 const GURL& url) OVERRIDE; |
125 virtual scoped_ptr<DistillerPage> CreateDefaultDistillerPage() OVERRIDE; | 129 virtual scoped_ptr<DistillerPage> CreateDefaultDistillerPage() OVERRIDE; |
126 virtual scoped_ptr<DistillerPage> CreateDefaultDistillerPageWithHandle( | 130 virtual scoped_ptr<DistillerPage> CreateDefaultDistillerPageWithHandle( |
127 scoped_ptr<SourcePageHandle> handle) OVERRIDE; | 131 scoped_ptr<SourcePageHandle> handle) OVERRIDE; |
128 virtual void AddObserver(DomDistillerObserver* observer) OVERRIDE; | 132 virtual void AddObserver(DomDistillerObserver* observer) OVERRIDE; |
129 virtual void RemoveObserver(DomDistillerObserver* observer) OVERRIDE; | 133 virtual void RemoveObserver(DomDistillerObserver* observer) OVERRIDE; |
| 134 virtual ReaderModePrefs* GetReaderModePrefs() const OVERRIDE; |
130 | 135 |
131 private: | 136 private: |
132 void CancelTask(TaskTracker* task); | 137 void CancelTask(TaskTracker* task); |
133 void AddDistilledPageToList(const ArticleEntry& entry, | 138 void AddDistilledPageToList(const ArticleEntry& entry, |
134 const DistilledArticleProto* article_proto, | 139 const DistilledArticleProto* article_proto, |
135 bool distillation_succeeded); | 140 bool distillation_succeeded); |
136 | 141 |
137 TaskTracker* CreateTaskTracker(const ArticleEntry& entry); | 142 TaskTracker* CreateTaskTracker(const ArticleEntry& entry); |
138 | 143 |
139 TaskTracker* GetTaskTrackerForEntry(const ArticleEntry& entry) const; | 144 TaskTracker* GetTaskTrackerForEntry(const ArticleEntry& entry) const; |
140 | 145 |
141 // Gets the task tracker for the given |url| or |entry|. If no appropriate | 146 // 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 | 147 // tracker exists, this will create one, initialize it, and add it to |
143 // |tasks_|. | 148 // |tasks_|. |
144 TaskTracker* GetOrCreateTaskTrackerForUrl(const GURL& url); | 149 TaskTracker* GetOrCreateTaskTrackerForUrl(const GURL& url); |
145 TaskTracker* GetOrCreateTaskTrackerForEntry(const ArticleEntry& entry); | 150 TaskTracker* GetOrCreateTaskTrackerForEntry(const ArticleEntry& entry); |
146 | 151 |
147 scoped_ptr<DomDistillerStoreInterface> store_; | 152 scoped_ptr<DomDistillerStoreInterface> store_; |
148 scoped_ptr<DistilledContentStore> content_store_; | 153 scoped_ptr<DistilledContentStore> content_store_; |
149 scoped_ptr<DistillerFactory> distiller_factory_; | 154 scoped_ptr<DistillerFactory> distiller_factory_; |
150 scoped_ptr<DistillerPageFactory> distiller_page_factory_; | 155 scoped_ptr<DistillerPageFactory> distiller_page_factory_; |
| 156 scoped_ptr<ReaderModePrefs> reader_mode_prefs_; |
151 | 157 |
152 typedef ScopedVector<TaskTracker> TaskList; | 158 typedef ScopedVector<TaskTracker> TaskList; |
153 TaskList tasks_; | 159 TaskList tasks_; |
154 | 160 |
155 DISALLOW_COPY_AND_ASSIGN(DomDistillerService); | 161 DISALLOW_COPY_AND_ASSIGN(DomDistillerService); |
156 }; | 162 }; |
157 | 163 |
158 } // namespace dom_distiller | 164 } // namespace dom_distiller |
159 | 165 |
160 #endif // COMPONENTS_DOM_DISTILLER_CORE_DOM_DISTILLER_SERVICE_H_ | 166 #endif // COMPONENTS_DOM_DISTILLER_CORE_DOM_DISTILLER_SERVICE_H_ |
OLD | NEW |