Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(91)

Side by Side Diff: chrome/browser/dom_distiller/lazy_dom_distiller_service.cc

Issue 254483003: Start requiring DistillerPage for calls to DomDistillerService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Indent fixes (full git cl format) Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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 #include "chrome/browser/dom_distiller/lazy_dom_distiller_service.h" 5 #include "chrome/browser/dom_distiller/lazy_dom_distiller_service.h"
6 6
7 #include "chrome/browser/chrome_notification_types.h" 7 #include "chrome/browser/chrome_notification_types.h"
8 #include "chrome/browser/dom_distiller/dom_distiller_service_factory.h" 8 #include "chrome/browser/dom_distiller/dom_distiller_service_factory.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "components/dom_distiller/core/dom_distiller_service.h" 10 #include "components/dom_distiller/core/dom_distiller_service.h"
11 #include "content/public/browser/notification_source.h" 11 #include "content/public/browser/notification_source.h"
12 12
13 namespace dom_distiller { 13 namespace dom_distiller {
14 14
15 LazyDomDistillerService::LazyDomDistillerService( 15 LazyDomDistillerService::LazyDomDistillerService(
16 Profile* profile, 16 Profile* profile,
17 const DomDistillerServiceFactory* service_factory) 17 const DomDistillerServiceFactory* service_factory)
18 : profile_(profile), service_factory_(service_factory) { 18 : profile_(profile), service_factory_(service_factory) {
19 registrar_.Add(this, 19 registrar_.Add(this,
20 chrome::NOTIFICATION_PROFILE_DESTROYED, 20 chrome::NOTIFICATION_PROFILE_DESTROYED,
21 content::Source<Profile>(profile)); 21 content::Source<Profile>(profile));
22 } 22 }
23 23
24 LazyDomDistillerService::~LazyDomDistillerService() {} 24 LazyDomDistillerService::~LazyDomDistillerService() {
25 }
25 26
26 // This will create an object and schedule work the first time it's called 27 // This will create an object and schedule work the first time it's called
27 // and just return an existing object after that. 28 // and just return an existing object after that.
28 DomDistillerServiceInterface* LazyDomDistillerService::instance() const { 29 DomDistillerServiceInterface* LazyDomDistillerService::instance() const {
29 return service_factory_->GetForBrowserContext(profile_); 30 return service_factory_->GetForBrowserContext(profile_);
30 } 31 }
31 32
32 void LazyDomDistillerService::Observe( 33 void LazyDomDistillerService::Observe(
33 int type, 34 int type,
34 const content::NotificationSource& source, 35 const content::NotificationSource& source,
35 const content::NotificationDetails& details) { 36 const content::NotificationDetails& details) {
36 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_DESTROYED, type); 37 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_DESTROYED, type);
37 DCHECK_EQ(profile_, content::Source<Profile>(source).ptr()); 38 DCHECK_EQ(profile_, content::Source<Profile>(source).ptr());
38 delete this; 39 delete this;
39 } 40 }
40 41
41 syncer::SyncableService* LazyDomDistillerService::GetSyncableService() const { 42 syncer::SyncableService* LazyDomDistillerService::GetSyncableService() const {
42 return instance()->GetSyncableService(); 43 return instance()->GetSyncableService();
43 } 44 }
44 45
45 const std::string LazyDomDistillerService::AddToList( 46 const std::string LazyDomDistillerService::AddToList(
46 const GURL& url, 47 const GURL& url,
48 scoped_ptr<DistillerPage> distiller_page,
47 const ArticleAvailableCallback& article_cb) { 49 const ArticleAvailableCallback& article_cb) {
48 return instance()->AddToList(url, article_cb); 50 return instance()->AddToList(url, distiller_page.Pass(), article_cb);
49 } 51 }
50 52
51 std::vector<ArticleEntry> LazyDomDistillerService::GetEntries() const { 53 std::vector<ArticleEntry> LazyDomDistillerService::GetEntries() const {
52 return instance()->GetEntries(); 54 return instance()->GetEntries();
53 } 55 }
54 56
55 scoped_ptr<ArticleEntry> LazyDomDistillerService::RemoveEntry( 57 scoped_ptr<ArticleEntry> LazyDomDistillerService::RemoveEntry(
56 const std::string& entry_id) { 58 const std::string& entry_id) {
57 return instance()->RemoveEntry(entry_id); 59 return instance()->RemoveEntry(entry_id);
58 } 60 }
59 61
60 scoped_ptr<ViewerHandle> LazyDomDistillerService::ViewEntry( 62 scoped_ptr<ViewerHandle> LazyDomDistillerService::ViewEntry(
61 ViewRequestDelegate* delegate, 63 ViewRequestDelegate* delegate,
64 scoped_ptr<DistillerPage> distiller_page,
62 const std::string& entry_id) { 65 const std::string& entry_id) {
63 return instance()->ViewEntry(delegate, entry_id); 66 return instance()->ViewEntry(delegate, distiller_page.Pass(), entry_id);
64 } 67 }
65 68
66 scoped_ptr<ViewerHandle> LazyDomDistillerService::ViewUrl( 69 scoped_ptr<ViewerHandle> LazyDomDistillerService::ViewUrl(
67 ViewRequestDelegate* delegate, 70 ViewRequestDelegate* delegate,
71 scoped_ptr<DistillerPage> distiller_page,
68 const GURL& url) { 72 const GURL& url) {
69 return instance()->ViewUrl(delegate, url); 73 return instance()->ViewUrl(delegate, distiller_page.Pass(), url);
74 }
75
76 scoped_ptr<DistillerPage>
77 LazyDomDistillerService::CreateDefaultDistillerPage() {
78 return instance()->CreateDefaultDistillerPage();
70 } 79 }
71 80
72 void LazyDomDistillerService::AddObserver(DomDistillerObserver* observer) { 81 void LazyDomDistillerService::AddObserver(DomDistillerObserver* observer) {
73 instance()->AddObserver(observer); 82 instance()->AddObserver(observer);
74 } 83 }
75 84
76 void LazyDomDistillerService::RemoveObserver(DomDistillerObserver* observer) { 85 void LazyDomDistillerService::RemoveObserver(DomDistillerObserver* observer) {
77 instance()->RemoveObserver(observer); 86 instance()->RemoveObserver(observer);
78 } 87 }
79 88
80 } // namespace dom_distiller 89 } // namespace dom_distiller
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698