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/incognito_helpers.h" | 8 #include "chrome/browser/profiles/incognito_helpers.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "components/dom_distiller/content/distiller_page_web_contents.h" | 10 #include "components/dom_distiller/content/distiller_page_web_contents.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 content::BrowserThread::GetBlockingPool()->GetSequencedTaskRunner( | 56 content::BrowserThread::GetBlockingPool()->GetSequencedTaskRunner( |
57 content::BrowserThread::GetBlockingPool()->GetSequenceToken()); | 57 content::BrowserThread::GetBlockingPool()->GetSequenceToken()); |
58 | 58 |
59 scoped_ptr<leveldb_proto::ProtoDatabaseImpl<ArticleEntry> > db( | 59 scoped_ptr<leveldb_proto::ProtoDatabaseImpl<ArticleEntry> > db( |
60 new leveldb_proto::ProtoDatabaseImpl<ArticleEntry>( | 60 new leveldb_proto::ProtoDatabaseImpl<ArticleEntry>( |
61 background_task_runner)); | 61 background_task_runner)); |
62 | 62 |
63 base::FilePath database_dir( | 63 base::FilePath database_dir( |
64 profile->GetPath().Append(FILE_PATH_LITERAL("Articles"))); | 64 profile->GetPath().Append(FILE_PATH_LITERAL("Articles"))); |
65 | 65 |
66 scoped_ptr<DomDistillerStore> dom_distiller_store(new DomDistillerStore( | 66 scoped_ptr<DomDistillerStore> dom_distiller_store( |
67 db.PassAs<leveldb_proto::ProtoDatabase<ArticleEntry> >(), database_dir)); | 67 new DomDistillerStore(db.Pass(), database_dir)); |
68 | 68 |
69 scoped_ptr<DistillerPageFactory> distiller_page_factory( | 69 scoped_ptr<DistillerPageFactory> distiller_page_factory( |
70 new DistillerPageWebContentsFactory(profile)); | 70 new DistillerPageWebContentsFactory(profile)); |
71 scoped_ptr<DistillerURLFetcherFactory> distiller_url_fetcher_factory( | 71 scoped_ptr<DistillerURLFetcherFactory> distiller_url_fetcher_factory( |
72 new DistillerURLFetcherFactory(profile->GetRequestContext())); | 72 new DistillerURLFetcherFactory(profile->GetRequestContext())); |
73 | 73 |
74 dom_distiller::proto::DomDistillerOptions options; | 74 dom_distiller::proto::DomDistillerOptions options; |
75 if (VLOG_IS_ON(1)) { | 75 if (VLOG_IS_ON(1)) { |
76 options.set_debug_level(logging::GetVlogLevelHelper( | 76 options.set_debug_level(logging::GetVlogLevelHelper( |
77 FROM_HERE.file_name(), ::strlen(FROM_HERE.file_name()))); | 77 FROM_HERE.file_name(), ::strlen(FROM_HERE.file_name()))); |
78 } | 78 } |
79 scoped_ptr<DistillerFactory> distiller_factory( | 79 scoped_ptr<DistillerFactory> distiller_factory( |
80 new DistillerFactoryImpl(distiller_url_fetcher_factory.Pass(), options)); | 80 new DistillerFactoryImpl(distiller_url_fetcher_factory.Pass(), options)); |
81 scoped_ptr<DistilledPagePrefs> distilled_page_prefs( | 81 scoped_ptr<DistilledPagePrefs> distilled_page_prefs( |
82 new DistilledPagePrefs(Profile::FromBrowserContext(profile)->GetPrefs())); | 82 new DistilledPagePrefs(Profile::FromBrowserContext(profile)->GetPrefs())); |
83 | 83 |
84 DomDistillerContextKeyedService* service = | 84 DomDistillerContextKeyedService* service = |
85 new DomDistillerContextKeyedService( | 85 new DomDistillerContextKeyedService(dom_distiller_store.Pass(), |
86 dom_distiller_store.PassAs<DomDistillerStoreInterface>(), | 86 distiller_factory.Pass(), |
87 distiller_factory.Pass(), | 87 distiller_page_factory.Pass(), |
88 distiller_page_factory.Pass(), | 88 distilled_page_prefs.Pass()); |
89 distilled_page_prefs.Pass()); | |
90 | 89 |
91 return service; | 90 return service; |
92 } | 91 } |
93 | 92 |
94 content::BrowserContext* DomDistillerServiceFactory::GetBrowserContextToUse( | 93 content::BrowserContext* DomDistillerServiceFactory::GetBrowserContextToUse( |
95 content::BrowserContext* context) const { | 94 content::BrowserContext* context) const { |
96 // Makes normal profile and off-the-record profile use same service instance. | 95 // Makes normal profile and off-the-record profile use same service instance. |
97 return chrome::GetBrowserContextRedirectedInIncognito(context); | 96 return chrome::GetBrowserContextRedirectedInIncognito(context); |
98 } | 97 } |
99 | 98 |
100 } // namespace dom_distiller | 99 } // namespace dom_distiller |
OLD | NEW |