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

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

Issue 2245583002: Split OfflinePageSuggestions into two categories (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@offlinedismissed
Patch Set: Created 4 years, 4 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
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 "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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 ContentSuggestionsService* service = new ContentSuggestionsService(state); 119 ContentSuggestionsService* service = new ContentSuggestionsService(state);
120 if (state == State::DISABLED) { 120 if (state == State::DISABLED) {
121 // Since we won't initialise the services, they won't get a chance to 121 // Since we won't initialise the services, they won't get a chance to
122 // unschedule their tasks. We do it explicitly here instead. 122 // unschedule their tasks. We do it explicitly here instead.
123 ClearScheduledTasks(); 123 ClearScheduledTasks();
124 return service; 124 return service;
125 } 125 }
126 126
127 #if defined(OS_ANDROID) 127 #if defined(OS_ANDROID)
128 // Create the OfflinePageSuggestionsProvider. 128 // Create the OfflinePageSuggestionsProvider.
129 if (base::FeatureList::IsEnabled( 129 bool recent_tabs_enabled = base::FeatureList::IsEnabled(
130 ntp_snippets::kOfflinePageSuggestionsFeature)) { 130 ntp_snippets::kRecentOfflineTabSuggestionsFeature);
131 bool downloads_enabled =
132 base::FeatureList::IsEnabled(ntp_snippets::kDownloadSuggestionsFeature);
133 if (recent_tabs_enabled || downloads_enabled) {
131 OfflinePageModel* offline_page_model = 134 OfflinePageModel* offline_page_model =
132 OfflinePageModelFactory::GetForBrowserContext(profile); 135 OfflinePageModelFactory::GetForBrowserContext(profile);
133 136
134 std::unique_ptr<OfflinePageSuggestionsProvider> 137 std::unique_ptr<OfflinePageSuggestionsProvider>
135 offline_page_suggestions_provider = 138 offline_page_suggestions_provider =
136 base::MakeUnique<OfflinePageSuggestionsProvider>( 139 base::MakeUnique<OfflinePageSuggestionsProvider>(
137 service, service->category_factory(), offline_page_model, 140 recent_tabs_enabled, downloads_enabled, service,
141 service->category_factory(), offline_page_model,
138 profile->GetPrefs()); 142 profile->GetPrefs());
139 service->RegisterProvider(std::move(offline_page_suggestions_provider)); 143 service->RegisterProvider(std::move(offline_page_suggestions_provider));
140 } 144 }
141 #endif // OS_ANDROID 145 #endif // OS_ANDROID
142 146
143 // Create the BookmarkSuggestionsProvider. 147 // Create the BookmarkSuggestionsProvider.
144 if (base::FeatureList::IsEnabled( 148 if (base::FeatureList::IsEnabled(
145 ntp_snippets::kBookmarkSuggestionsFeature)) { 149 ntp_snippets::kBookmarkSuggestionsFeature)) {
146 BookmarkModel* bookmark_model = 150 BookmarkModel* bookmark_model =
147 BookmarkModelFactory::GetForBrowserContext(profile); 151 BookmarkModelFactory::GetForBrowserContext(profile);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 base::MakeUnique<ImageDecoderImpl>(), 193 base::MakeUnique<ImageDecoderImpl>(),
190 base::MakeUnique<NTPSnippetsDatabase>(database_dir, task_runner), 194 base::MakeUnique<NTPSnippetsDatabase>(database_dir, task_runner),
191 base::MakeUnique<NTPSnippetsStatusService>(signin_manager, 195 base::MakeUnique<NTPSnippetsStatusService>(signin_manager,
192 profile->GetPrefs())); 196 profile->GetPrefs()));
193 service->set_ntp_snippets_service(ntp_snippets_service.get()); 197 service->set_ntp_snippets_service(ntp_snippets_service.get());
194 service->RegisterProvider(std::move(ntp_snippets_service)); 198 service->RegisterProvider(std::move(ntp_snippets_service));
195 } 199 }
196 200
197 return service; 201 return service;
198 } 202 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698