Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1201)

Side by Side Diff: chrome/browser/ntp_snippets/content_suggestions_service_factory.cc

Issue 2609423002: [NTP::RecentTabs] Enable by default and depend on recent tabs flag. (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/resources/snippets_internals.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <utility> 7 #include <utility>
8 8
9 #include "base/feature_list.h" 9 #include "base/feature_list.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 #include "google_apis/google_api_keys.h" 54 #include "google_apis/google_api_keys.h"
55 #include "net/url_request/url_request_context_getter.h" 55 #include "net/url_request/url_request_context_getter.h"
56 56
57 #if defined(OS_ANDROID) 57 #if defined(OS_ANDROID)
58 #include "chrome/browser/android/chrome_feature_list.h" 58 #include "chrome/browser/android/chrome_feature_list.h"
59 #include "chrome/browser/android/ntp/ntp_snippets_launcher.h" 59 #include "chrome/browser/android/ntp/ntp_snippets_launcher.h"
60 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h" 60 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h"
61 #include "chrome/browser/ntp_snippets/download_suggestions_provider.h" 61 #include "chrome/browser/ntp_snippets/download_suggestions_provider.h"
62 #include "components/ntp_snippets/offline_pages/recent_tab_suggestions_provider. h" 62 #include "components/ntp_snippets/offline_pages/recent_tab_suggestions_provider. h"
63 #include "components/ntp_snippets/physical_web_pages/physical_web_page_suggestio ns_provider.h" 63 #include "components/ntp_snippets/physical_web_pages/physical_web_page_suggestio ns_provider.h"
64 #include "components/offline_pages/core/offline_page_feature.h"
64 #include "components/offline_pages/core/offline_page_model.h" 65 #include "components/offline_pages/core/offline_page_model.h"
65 #include "components/physical_web/data_source/physical_web_data_source.h" 66 #include "components/physical_web/data_source/physical_web_data_source.h"
66 67
67 using content::DownloadManager; 68 using content::DownloadManager;
68 using ntp_snippets::PhysicalWebPageSuggestionsProvider; 69 using ntp_snippets::PhysicalWebPageSuggestionsProvider;
69 using ntp_snippets::RecentTabSuggestionsProvider; 70 using ntp_snippets::RecentTabSuggestionsProvider;
70 using offline_pages::OfflinePageModel; 71 using offline_pages::OfflinePageModel;
71 using offline_pages::OfflinePageModelFactory; 72 using offline_pages::OfflinePageModelFactory;
72 using physical_web::PhysicalWebDataSource; 73 using physical_web::PhysicalWebDataSource;
73 #endif // OS_ANDROID 74 #endif // OS_ANDROID
(...skipping 20 matching lines...) Expand all
94 namespace { 95 namespace {
95 96
96 // Clear the tasks that can be scheduled by running services. 97 // Clear the tasks that can be scheduled by running services.
97 void ClearScheduledTasks() { 98 void ClearScheduledTasks() {
98 #if defined(OS_ANDROID) 99 #if defined(OS_ANDROID)
99 NTPSnippetsLauncher::Get()->Unschedule(); 100 NTPSnippetsLauncher::Get()->Unschedule();
100 #endif // OS_ANDROID 101 #endif // OS_ANDROID
101 } 102 }
102 103
103 #if defined(OS_ANDROID) 104 #if defined(OS_ANDROID)
105
106 bool IsRecentTabProviderEnabled() {
107 return base::FeatureList::IsEnabled(
108 ntp_snippets::kRecentOfflineTabSuggestionsFeature) &&
109 base::FeatureList::IsEnabled(
110 offline_pages::kOffliningRecentPagesFeature);
111 }
112
104 void RegisterRecentTabProvider(OfflinePageModel* offline_page_model, 113 void RegisterRecentTabProvider(OfflinePageModel* offline_page_model,
105 ContentSuggestionsService* service, 114 ContentSuggestionsService* service,
106 PrefService* pref_service) { 115 PrefService* pref_service) {
107 auto provider = base::MakeUnique<RecentTabSuggestionsProvider>( 116 auto provider = base::MakeUnique<RecentTabSuggestionsProvider>(
108 service, offline_page_model, pref_service); 117 service, offline_page_model, pref_service);
109 service->RegisterProvider(std::move(provider)); 118 service->RegisterProvider(std::move(provider));
110 } 119 }
111 120
112 void RegisterDownloadsProvider(OfflinePageModel* offline_page_model, 121 void RegisterDownloadsProvider(OfflinePageModel* offline_page_model,
113 DownloadManager* download_manager, 122 DownloadManager* download_manager,
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 BookmarkModel* bookmark_model = 287 BookmarkModel* bookmark_model =
279 BookmarkModelFactory::GetForBrowserContext(profile); 288 BookmarkModelFactory::GetForBrowserContext(profile);
280 OAuth2TokenService* token_service = 289 OAuth2TokenService* token_service =
281 ProfileOAuth2TokenServiceFactory::GetForProfile(profile); 290 ProfileOAuth2TokenServiceFactory::GetForProfile(profile);
282 SyncService* sync_service = 291 SyncService* sync_service =
283 ProfileSyncServiceFactory::GetSyncServiceForBrowserContext(profile); 292 ProfileSyncServiceFactory::GetSyncServiceForBrowserContext(profile);
284 LanguageModel* language_model = 293 LanguageModel* language_model =
285 LanguageModelFactory::GetInstance()->GetForBrowserContext(profile); 294 LanguageModelFactory::GetInstance()->GetForBrowserContext(profile);
286 295
287 #if defined(OS_ANDROID) 296 #if defined(OS_ANDROID)
288 if (base::FeatureList::IsEnabled( 297 if (IsRecentTabProviderEnabled()) {
289 ntp_snippets::kRecentOfflineTabSuggestionsFeature)) {
290 RegisterRecentTabProvider(offline_page_model, service, pref_service); 298 RegisterRecentTabProvider(offline_page_model, service, pref_service);
291 } 299 }
292 300
293 bool show_asset_downloads = 301 bool show_asset_downloads =
294 base::FeatureList::IsEnabled(features::kAssetDownloadSuggestionsFeature); 302 base::FeatureList::IsEnabled(features::kAssetDownloadSuggestionsFeature);
295 bool show_offline_page_downloads = base::FeatureList::IsEnabled( 303 bool show_offline_page_downloads = base::FeatureList::IsEnabled(
296 features::kOfflinePageDownloadSuggestionsFeature); 304 features::kOfflinePageDownloadSuggestionsFeature);
297 if (show_asset_downloads || show_offline_page_downloads) { 305 if (show_asset_downloads || show_offline_page_downloads) {
298 RegisterDownloadsProvider( 306 RegisterDownloadsProvider(
299 show_offline_page_downloads ? offline_page_model : nullptr, 307 show_offline_page_downloads ? offline_page_model : nullptr,
(...skipping 21 matching lines...) Expand all
321 language_model, pref_service, profile); 329 language_model, pref_service, profile);
322 } 330 }
323 331
324 if (base::FeatureList::IsEnabled( 332 if (base::FeatureList::IsEnabled(
325 ntp_snippets::kForeignSessionsSuggestionsFeature)) { 333 ntp_snippets::kForeignSessionsSuggestionsFeature)) {
326 RegisterForeignSessionsProvider(sync_service, service, pref_service); 334 RegisterForeignSessionsProvider(sync_service, service, pref_service);
327 } 335 }
328 336
329 return service; 337 return service;
330 } 338 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/snippets_internals.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698