OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/ntp_snippets/content_suggestions_service_factory.h" | 5 #include "chrome/browser/ntp_snippets/content_suggestions_service_factory.h" |
6 | 6 |
7 #include "base/feature_list.h" | 7 #include "base/feature_list.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
10 #include "base/memory/singleton.h" | 10 #include "base/memory/singleton.h" |
(...skipping 24 matching lines...) Expand all Loading... | |
35 #include "content/public/browser/browser_context.h" | 35 #include "content/public/browser/browser_context.h" |
36 #include "content/public/browser/browser_thread.h" | 36 #include "content/public/browser/browser_thread.h" |
37 #include "content/public/browser/storage_partition.h" | 37 #include "content/public/browser/storage_partition.h" |
38 #include "net/url_request/url_request_context_getter.h" | 38 #include "net/url_request/url_request_context_getter.h" |
39 | 39 |
40 #if defined(OS_ANDROID) | 40 #if defined(OS_ANDROID) |
41 #include "chrome/browser/android/chrome_feature_list.h" | 41 #include "chrome/browser/android/chrome_feature_list.h" |
42 #include "chrome/browser/android/ntp/ntp_snippets_launcher.h" | 42 #include "chrome/browser/android/ntp/ntp_snippets_launcher.h" |
43 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h" | 43 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h" |
44 #include "components/ntp_snippets/offline_pages/offline_page_suggestions_provide r.h" | 44 #include "components/ntp_snippets/offline_pages/offline_page_suggestions_provide r.h" |
45 #include "components/ntp_snippets/physical_web_pages/physical_web_page_suggestio ns_provider.h" | |
45 #include "components/offline_pages/offline_page_model.h" | 46 #include "components/offline_pages/offline_page_model.h" |
46 | 47 |
47 using ntp_snippets::OfflinePageSuggestionsProvider; | 48 using ntp_snippets::OfflinePageSuggestionsProvider; |
48 using offline_pages::OfflinePageModel; | 49 using offline_pages::OfflinePageModel; |
49 using offline_pages::OfflinePageModelFactory; | 50 using offline_pages::OfflinePageModelFactory; |
51 using ntp_snippets::PhysicalWebPageSuggestionsProvider; | |
tschumann
2016/08/09 15:24:59
please sort in alphabetically (after ntp_snippets:
vitaliii
2016/08/10 14:18:40
Done.
| |
50 #endif // OS_ANDROID | 52 #endif // OS_ANDROID |
51 | 53 |
52 using content::BrowserThread; | 54 using content::BrowserThread; |
53 using image_fetcher::ImageFetcherImpl; | 55 using image_fetcher::ImageFetcherImpl; |
54 using ntp_snippets::ContentSuggestionsService; | 56 using ntp_snippets::ContentSuggestionsService; |
55 using ntp_snippets::NTPSnippetsDatabase; | 57 using ntp_snippets::NTPSnippetsDatabase; |
56 using ntp_snippets::NTPSnippetsFetcher; | 58 using ntp_snippets::NTPSnippetsFetcher; |
57 using ntp_snippets::NTPSnippetsService; | 59 using ntp_snippets::NTPSnippetsService; |
58 using ntp_snippets::NTPSnippetsScheduler; | 60 using ntp_snippets::NTPSnippetsScheduler; |
59 using ntp_snippets::NTPSnippetsStatusService; | 61 using ntp_snippets::NTPSnippetsStatusService; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
112 OfflinePageModelFactory::GetForBrowserContext(profile); | 114 OfflinePageModelFactory::GetForBrowserContext(profile); |
113 | 115 |
114 std::unique_ptr<OfflinePageSuggestionsProvider> | 116 std::unique_ptr<OfflinePageSuggestionsProvider> |
115 offline_page_suggestions_provider = | 117 offline_page_suggestions_provider = |
116 base::MakeUnique<OfflinePageSuggestionsProvider>( | 118 base::MakeUnique<OfflinePageSuggestionsProvider>( |
117 service, service->category_factory(), offline_page_model); | 119 service, service->category_factory(), offline_page_model); |
118 service->RegisterProvider(std::move(offline_page_suggestions_provider)); | 120 service->RegisterProvider(std::move(offline_page_suggestions_provider)); |
119 } | 121 } |
120 #endif // OS_ANDROID | 122 #endif // OS_ANDROID |
121 | 123 |
124 // Create the PhysicalWebPageSuggestionsProvider. | |
125 #if defined(OS_ANDROID) | |
126 if (base::FeatureList::IsEnabled( | |
127 chrome::android::kNTPPhysicalWebPageSuggestionsFeature)) { | |
128 std::unique_ptr<PhysicalWebPageSuggestionsProvider> | |
129 physical_web_page_suggestions_provider = | |
130 base::MakeUnique<PhysicalWebPageSuggestionsProvider>( | |
131 service, service->category_factory()); | |
132 service->RegisterProvider(std::move(physical_web_page_suggestions_provider)) ; | |
133 } | |
134 #endif // OS_ANDROID | |
135 | |
122 // Create the NTPSnippetsService (articles provider). | 136 // Create the NTPSnippetsService (articles provider). |
123 SigninManagerBase* signin_manager = | 137 SigninManagerBase* signin_manager = |
124 SigninManagerFactory::GetForProfile(profile); | 138 SigninManagerFactory::GetForProfile(profile); |
125 OAuth2TokenService* token_service = | 139 OAuth2TokenService* token_service = |
126 ProfileOAuth2TokenServiceFactory::GetForProfile(profile); | 140 ProfileOAuth2TokenServiceFactory::GetForProfile(profile); |
127 scoped_refptr<net::URLRequestContextGetter> request_context = | 141 scoped_refptr<net::URLRequestContextGetter> request_context = |
128 content::BrowserContext::GetDefaultStoragePartition(context) | 142 content::BrowserContext::GetDefaultStoragePartition(context) |
129 ->GetURLRequestContext(); | 143 ->GetURLRequestContext(); |
130 SuggestionsService* suggestions_service = | 144 SuggestionsService* suggestions_service = |
131 SuggestionsServiceFactory::GetForProfile(profile); | 145 SuggestionsServiceFactory::GetForProfile(profile); |
(...skipping 21 matching lines...) Expand all Loading... | |
153 base::MakeUnique<ImageDecoderImpl>(), request_context.get()), | 167 base::MakeUnique<ImageDecoderImpl>(), request_context.get()), |
154 base::MakeUnique<ImageDecoderImpl>(), | 168 base::MakeUnique<ImageDecoderImpl>(), |
155 base::MakeUnique<NTPSnippetsDatabase>(database_dir, task_runner), | 169 base::MakeUnique<NTPSnippetsDatabase>(database_dir, task_runner), |
156 base::MakeUnique<NTPSnippetsStatusService>(signin_manager, | 170 base::MakeUnique<NTPSnippetsStatusService>(signin_manager, |
157 profile->GetPrefs())); | 171 profile->GetPrefs())); |
158 service->set_ntp_snippets_service(ntp_snippets_service.get()); | 172 service->set_ntp_snippets_service(ntp_snippets_service.get()); |
159 service->RegisterProvider(std::move(ntp_snippets_service)); | 173 service->RegisterProvider(std::move(ntp_snippets_service)); |
160 | 174 |
161 return service; | 175 return service; |
162 } | 176 } |
OLD | NEW |