| 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/common/url_constants.h" | 8 #include "chrome/common/url_constants.h" |
| 9 #include "components/browser_context_keyed_service/browser_context_dependency_ma
nager.h" | 9 #include "components/browser_context_keyed_service/browser_context_dependency_ma
nager.h" |
| 10 #include "components/dom_distiller/content/distiller_page_web_contents.h" | 10 #include "components/dom_distiller/content/distiller_page_web_contents.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 | 37 |
| 38 DomDistillerServiceFactory::DomDistillerServiceFactory() | 38 DomDistillerServiceFactory::DomDistillerServiceFactory() |
| 39 : BrowserContextKeyedServiceFactory( | 39 : BrowserContextKeyedServiceFactory( |
| 40 "DomDistillerService", | 40 "DomDistillerService", |
| 41 BrowserContextDependencyManager::GetInstance()) {} | 41 BrowserContextDependencyManager::GetInstance()) {} |
| 42 | 42 |
| 43 DomDistillerServiceFactory::~DomDistillerServiceFactory() {} | 43 DomDistillerServiceFactory::~DomDistillerServiceFactory() {} |
| 44 | 44 |
| 45 BrowserContextKeyedService* DomDistillerServiceFactory::BuildServiceInstanceFor( | 45 BrowserContextKeyedService* DomDistillerServiceFactory::BuildServiceInstanceFor( |
| 46 content::BrowserContext* profile) const { | 46 content::BrowserContext* profile) const { |
| 47 content::URLDataSource::Add( | |
| 48 profile, new DomDistillerViewerSource(chrome::kDomDistillerScheme)); | |
| 49 | |
| 50 scoped_refptr<base::SequencedTaskRunner> background_task_runner = | 47 scoped_refptr<base::SequencedTaskRunner> background_task_runner = |
| 51 content::BrowserThread::GetBlockingPool()->GetSequencedTaskRunner( | 48 content::BrowserThread::GetBlockingPool()->GetSequencedTaskRunner( |
| 52 content::BrowserThread::GetBlockingPool()->GetSequenceToken()); | 49 content::BrowserThread::GetBlockingPool()->GetSequenceToken()); |
| 53 | 50 |
| 54 scoped_ptr<DomDistillerDatabase> db( | 51 scoped_ptr<DomDistillerDatabase> db( |
| 55 new DomDistillerDatabase(background_task_runner)); | 52 new DomDistillerDatabase(background_task_runner)); |
| 56 | 53 |
| 57 base::FilePath database_dir( | 54 base::FilePath database_dir( |
| 58 profile->GetPath().Append(FILE_PATH_LITERAL("Articles"))); | 55 profile->GetPath().Append(FILE_PATH_LITERAL("Articles"))); |
| 59 | 56 |
| 60 scoped_ptr<DomDistillerStore> dom_distiller_store( | 57 scoped_ptr<DomDistillerStore> dom_distiller_store(new DomDistillerStore( |
| 61 new DomDistillerStore(db.PassAs<DomDistillerDatabaseInterface>(), | 58 db.PassAs<DomDistillerDatabaseInterface>(), database_dir)); |
| 62 database_dir)); | |
| 63 | 59 |
| 64 scoped_ptr<DistillerPageFactory> distiller_page_factory( | 60 scoped_ptr<DistillerPageFactory> distiller_page_factory( |
| 65 new DistillerPageWebContentsFactory(profile)); | 61 new DistillerPageWebContentsFactory(profile)); |
| 66 scoped_ptr<DistillerURLFetcherFactory> distiller_url_fetcher_factory( | 62 scoped_ptr<DistillerURLFetcherFactory> distiller_url_fetcher_factory( |
| 67 new DistillerURLFetcherFactory(profile->GetRequestContext())); | 63 new DistillerURLFetcherFactory(profile->GetRequestContext())); |
| 68 scoped_ptr<DistillerFactory> distiller_factory( | 64 scoped_ptr<DistillerFactory> distiller_factory(new DistillerFactoryImpl( |
| 69 new DistillerFactoryImpl(distiller_page_factory.Pass(), | 65 distiller_page_factory.Pass(), distiller_url_fetcher_factory.Pass())); |
| 70 distiller_url_fetcher_factory.Pass())); | |
| 71 return new DomDistillerContextKeyedService( | |
| 72 dom_distiller_store.PassAs<DomDistillerStoreInterface>(), | |
| 73 distiller_factory.Pass()); | |
| 74 | 66 |
| 67 DomDistillerContextKeyedService* service = |
| 68 new DomDistillerContextKeyedService( |
| 69 dom_distiller_store.PassAs<DomDistillerStoreInterface>(), |
| 70 distiller_factory.Pass()); |
| 71 |
| 72 // Set up URL data source for the chrome-distiller:// scheme. |
| 73 content::URLDataSource::Add( |
| 74 profile, |
| 75 new DomDistillerViewerSource(service, chrome::kDomDistillerScheme)); |
| 76 |
| 77 return service; |
| 75 } | 78 } |
| 76 | 79 |
| 77 content::BrowserContext* DomDistillerServiceFactory::GetBrowserContextToUse( | 80 content::BrowserContext* DomDistillerServiceFactory::GetBrowserContextToUse( |
| 78 content::BrowserContext* context) const { | 81 content::BrowserContext* context) const { |
| 79 // TODO(cjhopman): Do we want this to be | 82 // TODO(cjhopman): Do we want this to be |
| 80 // GetBrowserContextRedirectedInIncognito? | 83 // GetBrowserContextRedirectedInIncognito? |
| 81 return context; | 84 return context; |
| 82 } | 85 } |
| 83 | 86 |
| 84 } // namespace dom_distiller | 87 } // namespace dom_distiller |
| OLD | NEW |