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