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