GoogleURLTrackerInfoBarDelegate: Initialize uninitialized member in constructor.
[chromium-blink-merge.git] / chrome / browser / dom_distiller / lazy_dom_distiller_service.cc
blob3e7e74573a3ff01af226eebf8f8085897d7c8efc
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.
5 #include "chrome/browser/dom_distiller/lazy_dom_distiller_service.h"
7 #include "chrome/browser/chrome_notification_types.h"
8 #include "chrome/browser/dom_distiller/dom_distiller_service_factory.h"
9 #include "chrome/browser/profiles/profile.h"
10 #include "components/dom_distiller/core/distiller_page.h"
11 #include "components/dom_distiller/core/dom_distiller_service.h"
12 #include "content/public/browser/notification_source.h"
14 namespace dom_distiller {
16 LazyDomDistillerService::LazyDomDistillerService(
17 Profile* profile,
18 const DomDistillerServiceFactory* service_factory)
19 : profile_(profile), service_factory_(service_factory) {
20 registrar_.Add(this,
21 chrome::NOTIFICATION_PROFILE_DESTROYED,
22 content::Source<Profile>(profile));
25 LazyDomDistillerService::~LazyDomDistillerService() {
28 // This will create an object and schedule work the first time it's called
29 // and just return an existing object after that.
30 DomDistillerServiceInterface* LazyDomDistillerService::instance() const {
31 return service_factory_->GetForBrowserContext(profile_);
34 void LazyDomDistillerService::Observe(
35 int type,
36 const content::NotificationSource& source,
37 const content::NotificationDetails& details) {
38 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_DESTROYED, type);
39 DCHECK_EQ(profile_, content::Source<Profile>(source).ptr());
40 delete this;
43 syncer::SyncableService* LazyDomDistillerService::GetSyncableService() const {
44 return instance()->GetSyncableService();
47 const std::string LazyDomDistillerService::AddToList(
48 const GURL& url,
49 scoped_ptr<DistillerPage> distiller_page,
50 const ArticleAvailableCallback& article_cb) {
51 return instance()->AddToList(url, distiller_page.Pass(), article_cb);
54 std::vector<ArticleEntry> LazyDomDistillerService::GetEntries() const {
55 return instance()->GetEntries();
58 scoped_ptr<ArticleEntry> LazyDomDistillerService::RemoveEntry(
59 const std::string& entry_id) {
60 return instance()->RemoveEntry(entry_id);
63 scoped_ptr<ViewerHandle> LazyDomDistillerService::ViewEntry(
64 ViewRequestDelegate* delegate,
65 scoped_ptr<DistillerPage> distiller_page,
66 const std::string& entry_id) {
67 return instance()->ViewEntry(delegate, distiller_page.Pass(), entry_id);
70 scoped_ptr<ViewerHandle> LazyDomDistillerService::ViewUrl(
71 ViewRequestDelegate* delegate,
72 scoped_ptr<DistillerPage> distiller_page,
73 const GURL& url) {
74 return instance()->ViewUrl(delegate, distiller_page.Pass(), url);
77 scoped_ptr<DistillerPage>
78 LazyDomDistillerService::CreateDefaultDistillerPage() {
79 return instance()->CreateDefaultDistillerPage();
82 scoped_ptr<DistillerPage>
83 LazyDomDistillerService::CreateDefaultDistillerPageWithHandle(
84 scoped_ptr<SourcePageHandle> handle) {
85 return instance()->CreateDefaultDistillerPageWithHandle(handle.Pass());
88 void LazyDomDistillerService::AddObserver(DomDistillerObserver* observer) {
89 instance()->AddObserver(observer);
92 void LazyDomDistillerService::RemoveObserver(DomDistillerObserver* observer) {
93 instance()->RemoveObserver(observer);
96 } // namespace dom_distiller