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 #include "chrome/browser/dom_distiller/dom_distiller_service_factory.h" | 5 #include "chrome/browser/dom_distiller/dom_distiller_service_factory.h" |
6 | 6 |
7 #include "base/threading/sequenced_worker_pool.h" | 7 #include "base/threading/sequenced_worker_pool.h" |
| 8 #include "chrome/browser/profiles/profile.h" |
8 #include "components/dom_distiller/content/distiller_page_web_contents.h" | 9 #include "components/dom_distiller/content/distiller_page_web_contents.h" |
9 #include "components/dom_distiller/core/distiller.h" | 10 #include "components/dom_distiller/core/distiller.h" |
10 #include "components/dom_distiller/core/dom_distiller_store.h" | 11 #include "components/dom_distiller/core/dom_distiller_store.h" |
11 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 12 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
12 #include "content/public/browser/browser_context.h" | 13 #include "content/public/browser/browser_context.h" |
13 #include "content/public/browser/browser_thread.h" | 14 #include "content/public/browser/browser_thread.h" |
14 | 15 |
15 namespace dom_distiller { | 16 namespace dom_distiller { |
16 | 17 |
17 DomDistillerContextKeyedService::DomDistillerContextKeyedService( | 18 DomDistillerContextKeyedService::DomDistillerContextKeyedService( |
18 scoped_ptr<DomDistillerStoreInterface> store, | 19 scoped_ptr<DomDistillerStoreInterface> store, |
19 scoped_ptr<DistillerFactory> distiller_factory, | 20 scoped_ptr<DistillerFactory> distiller_factory, |
20 scoped_ptr<DistillerPageFactory> distiller_page_factory) | 21 scoped_ptr<DistillerPageFactory> distiller_page_factory, |
| 22 scoped_ptr<ReaderModePrefs> reader_mode_prefs) |
21 : DomDistillerService(store.Pass(), | 23 : DomDistillerService(store.Pass(), |
22 distiller_factory.Pass(), | 24 distiller_factory.Pass(), |
23 distiller_page_factory.Pass()) { | 25 distiller_page_factory.Pass(), |
| 26 reader_mode_prefs.Pass()) { |
24 } | 27 } |
25 | 28 |
26 // static | 29 // static |
27 DomDistillerServiceFactory* DomDistillerServiceFactory::GetInstance() { | 30 DomDistillerServiceFactory* DomDistillerServiceFactory::GetInstance() { |
28 return Singleton<DomDistillerServiceFactory>::get(); | 31 return Singleton<DomDistillerServiceFactory>::get(); |
29 } | 32 } |
30 | 33 |
31 // static | 34 // static |
32 DomDistillerContextKeyedService* | 35 DomDistillerContextKeyedService* |
33 DomDistillerServiceFactory::GetForBrowserContext( | 36 DomDistillerServiceFactory::GetForBrowserContext( |
(...skipping 30 matching lines...) Expand all Loading... |
64 new DistillerURLFetcherFactory(profile->GetRequestContext())); | 67 new DistillerURLFetcherFactory(profile->GetRequestContext())); |
65 | 68 |
66 dom_distiller::proto::DomDistillerOptions options; | 69 dom_distiller::proto::DomDistillerOptions options; |
67 if (VLOG_IS_ON(1)) { | 70 if (VLOG_IS_ON(1)) { |
68 options.set_debug_level( | 71 options.set_debug_level( |
69 logging::GetVlogLevelHelper(FROM_HERE.file_name(), | 72 logging::GetVlogLevelHelper(FROM_HERE.file_name(), |
70 ::strlen(FROM_HERE.file_name()))); | 73 ::strlen(FROM_HERE.file_name()))); |
71 } | 74 } |
72 scoped_ptr<DistillerFactory> distiller_factory( | 75 scoped_ptr<DistillerFactory> distiller_factory( |
73 new DistillerFactoryImpl(distiller_url_fetcher_factory.Pass(), options)); | 76 new DistillerFactoryImpl(distiller_url_fetcher_factory.Pass(), options)); |
| 77 scoped_ptr<ReaderModePrefs> reader_mode_prefs( |
| 78 new ReaderModePrefs(Profile::FromBrowserContext(profile)->GetPrefs())); |
| 79 |
74 | 80 |
75 DomDistillerContextKeyedService* service = | 81 DomDistillerContextKeyedService* service = |
76 new DomDistillerContextKeyedService( | 82 new DomDistillerContextKeyedService( |
77 dom_distiller_store.PassAs<DomDistillerStoreInterface>(), | 83 dom_distiller_store.PassAs<DomDistillerStoreInterface>(), |
78 distiller_factory.Pass(), | 84 distiller_factory.Pass(), |
79 distiller_page_factory.Pass()); | 85 distiller_page_factory.Pass(), |
| 86 reader_mode_prefs.Pass()); |
80 | 87 |
81 return service; | 88 return service; |
82 } | 89 } |
83 | 90 |
84 content::BrowserContext* DomDistillerServiceFactory::GetBrowserContextToUse( | 91 content::BrowserContext* DomDistillerServiceFactory::GetBrowserContextToUse( |
85 content::BrowserContext* context) const { | 92 content::BrowserContext* context) const { |
86 // TODO(cjhopman): Do we want this to be | 93 // TODO(cjhopman): Do we want this to be |
87 // GetBrowserContextRedirectedInIncognito? | 94 // GetBrowserContextRedirectedInIncognito? |
88 return context; | 95 return context; |
89 } | 96 } |
90 | 97 |
91 } // namespace dom_distiller | 98 } // namespace dom_distiller |
OLD | NEW |