Add ICU message format support
[chromium-blink-merge.git] / chrome / browser / dom_distiller / lazy_dom_distiller_service.cc
blob8c90afeb7dbb03e10eca6fe5c0aef921dee01813
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/distilled_page_prefs.h"
11 #include "components/dom_distiller/core/distiller_page.h"
12 #include "components/dom_distiller/core/dom_distiller_service.h"
13 #include "content/public/browser/notification_source.h"
15 namespace dom_distiller {
17 LazyDomDistillerService::LazyDomDistillerService(
18 Profile* profile,
19 const DomDistillerServiceFactory* service_factory)
20 : profile_(profile), service_factory_(service_factory) {
21 registrar_.Add(this,
22 chrome::NOTIFICATION_PROFILE_DESTROYED,
23 content::Source<Profile>(profile));
26 LazyDomDistillerService::~LazyDomDistillerService() {
29 // This will create an object and schedule work the first time it's called
30 // and just return an existing object after that.
31 DomDistillerServiceInterface* LazyDomDistillerService::instance() const {
32 return service_factory_->GetForBrowserContext(profile_);
35 void LazyDomDistillerService::Observe(
36 int type,
37 const content::NotificationSource& source,
38 const content::NotificationDetails& details) {
39 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_DESTROYED, type);
40 DCHECK_EQ(profile_, content::Source<Profile>(source).ptr());
41 delete this;
44 syncer::SyncableService* LazyDomDistillerService::GetSyncableService() const {
45 return instance()->GetSyncableService();
48 bool LazyDomDistillerService::HasEntry(const std::string& entry_id) {
49 return instance()->HasEntry(entry_id);
52 std::string LazyDomDistillerService::GetUrlForEntry(
53 const std::string& entry_id) {
54 return instance()->GetUrlForEntry(entry_id);
57 const std::string LazyDomDistillerService::AddToList(
58 const GURL& url,
59 scoped_ptr<DistillerPage> distiller_page,
60 const ArticleAvailableCallback& article_cb) {
61 return instance()->AddToList(url, distiller_page.Pass(), article_cb);
64 std::vector<ArticleEntry> LazyDomDistillerService::GetEntries() const {
65 return instance()->GetEntries();
68 scoped_ptr<ArticleEntry> LazyDomDistillerService::RemoveEntry(
69 const std::string& entry_id) {
70 return instance()->RemoveEntry(entry_id);
73 scoped_ptr<ViewerHandle> LazyDomDistillerService::ViewEntry(
74 ViewRequestDelegate* delegate,
75 scoped_ptr<DistillerPage> distiller_page,
76 const std::string& entry_id) {
77 return instance()->ViewEntry(delegate, distiller_page.Pass(), entry_id);
80 scoped_ptr<ViewerHandle> LazyDomDistillerService::ViewUrl(
81 ViewRequestDelegate* delegate,
82 scoped_ptr<DistillerPage> distiller_page,
83 const GURL& url) {
84 return instance()->ViewUrl(delegate, distiller_page.Pass(), url);
87 scoped_ptr<DistillerPage>
88 LazyDomDistillerService::CreateDefaultDistillerPage(
89 const gfx::Size& render_view_size) {
90 return instance()->CreateDefaultDistillerPage(render_view_size);
93 scoped_ptr<DistillerPage>
94 LazyDomDistillerService::CreateDefaultDistillerPageWithHandle(
95 scoped_ptr<SourcePageHandle> handle) {
96 return instance()->CreateDefaultDistillerPageWithHandle(handle.Pass());
99 void LazyDomDistillerService::AddObserver(DomDistillerObserver* observer) {
100 instance()->AddObserver(observer);
103 void LazyDomDistillerService::RemoveObserver(DomDistillerObserver* observer) {
104 instance()->RemoveObserver(observer);
107 DistilledPagePrefs* LazyDomDistillerService::GetDistilledPagePrefs() {
108 return instance()->GetDistilledPagePrefs();
111 } // namespace dom_distiller