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

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

Issue 2227953002: [NTP Snippets] Add kArticleSuggestionsFeature (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
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
« no previous file with comments | « no previous file | components/ntp_snippets/features.h » ('j') | components/ntp_snippets/features.h » ('J')
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 "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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 ntp_snippets::kBookmarkSuggestionsFeature)) { 129 ntp_snippets::kBookmarkSuggestionsFeature)) {
130 // TODO(pke): GetForBrowserContext 130 // TODO(pke): GetForBrowserContext
131 BookmarkModel* bookmark_model = 131 BookmarkModel* bookmark_model =
132 BookmarkModelFactory::GetForProfile(profile); 132 BookmarkModelFactory::GetForProfile(profile);
133 std::unique_ptr<BookmarkSuggestionsProvider> bookmark_suggestions_provider = 133 std::unique_ptr<BookmarkSuggestionsProvider> bookmark_suggestions_provider =
134 base::MakeUnique<BookmarkSuggestionsProvider>( 134 base::MakeUnique<BookmarkSuggestionsProvider>(
135 service, service->category_factory(), bookmark_model); 135 service, service->category_factory(), bookmark_model);
136 service->RegisterProvider(std::move(bookmark_suggestions_provider)); 136 service->RegisterProvider(std::move(bookmark_suggestions_provider));
137 } 137 }
138 138
139 // Create the NTPSnippetsService (articles provider). 139 if (base::FeatureList::IsEnabled(ntp_snippets::kArticleSuggestionsFeature)) {
140 SigninManagerBase* signin_manager = 140 // Create the NTPSnippetsService (articles provider).
141 SigninManagerFactory::GetForProfile(profile); 141 SigninManagerBase* signin_manager =
142 OAuth2TokenService* token_service = 142 SigninManagerFactory::GetForProfile(profile);
143 ProfileOAuth2TokenServiceFactory::GetForProfile(profile); 143 OAuth2TokenService* token_service =
144 scoped_refptr<net::URLRequestContextGetter> request_context = 144 ProfileOAuth2TokenServiceFactory::GetForProfile(profile);
145 content::BrowserContext::GetDefaultStoragePartition(context) 145 scoped_refptr<net::URLRequestContextGetter> request_context =
146 ->GetURLRequestContext(); 146 content::BrowserContext::GetDefaultStoragePartition(context)
147 SuggestionsService* suggestions_service = 147 ->GetURLRequestContext();
148 SuggestionsServiceFactory::GetForProfile(profile); 148 SuggestionsService* suggestions_service =
149 NTPSnippetsScheduler* scheduler = nullptr; 149 SuggestionsServiceFactory::GetForProfile(profile);
150 NTPSnippetsScheduler* scheduler = nullptr;
150 #if defined(OS_ANDROID) 151 #if defined(OS_ANDROID)
151 scheduler = NTPSnippetsLauncher::Get(); 152 scheduler = NTPSnippetsLauncher::Get();
152 #endif // OS_ANDROID 153 #endif // OS_ANDROID
153 base::FilePath database_dir( 154 base::FilePath database_dir(
154 profile->GetPath().Append(ntp_snippets::kDatabaseFolder)); 155 profile->GetPath().Append(ntp_snippets::kDatabaseFolder));
155 scoped_refptr<base::SequencedTaskRunner> task_runner = 156 scoped_refptr<base::SequencedTaskRunner> task_runner =
156 BrowserThread::GetBlockingPool() 157 BrowserThread::GetBlockingPool()
157 ->GetSequencedTaskRunnerWithShutdownBehavior( 158 ->GetSequencedTaskRunnerWithShutdownBehavior(
158 base::SequencedWorkerPool::GetSequenceToken(), 159 base::SequencedWorkerPool::GetSequenceToken(),
159 base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN); 160 base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN);
160 std::unique_ptr<NTPSnippetsService> ntp_snippets_service = 161 bool is_stable_channel =
161 base::MakeUnique<NTPSnippetsService>( 162 chrome::GetChannel() == version_info::Channel::STABLE;
162 service, service->category_factory(), profile->GetPrefs(), 163 std::unique_ptr<NTPSnippetsService> ntp_snippets_service =
163 suggestions_service, g_browser_process->GetApplicationLocale(), 164 base::MakeUnique<NTPSnippetsService>(
164 scheduler, base::MakeUnique<NTPSnippetsFetcher>( 165 service, service->category_factory(), profile->GetPrefs(),
165 signin_manager, token_service, request_context, 166 suggestions_service, g_browser_process->GetApplicationLocale(),
166 profile->GetPrefs(), 167 scheduler, base::MakeUnique<NTPSnippetsFetcher>(
167 base::Bind(&safe_json::SafeJsonParser::Parse), 168 signin_manager, token_service, request_context,
168 chrome::GetChannel() == version_info::Channel::STABLE), 169 profile->GetPrefs(),
169 base::MakeUnique<ImageFetcherImpl>( 170 base::Bind(&safe_json::SafeJsonParser::Parse),
170 base::MakeUnique<ImageDecoderImpl>(), request_context.get()), 171 is_stable_channel),
171 base::MakeUnique<ImageDecoderImpl>(), 172 base::MakeUnique<ImageFetcherImpl>(
172 base::MakeUnique<NTPSnippetsDatabase>(database_dir, task_runner), 173 base::MakeUnique<ImageDecoderImpl>(), request_context.get()),
173 base::MakeUnique<NTPSnippetsStatusService>(signin_manager, 174 base::MakeUnique<ImageDecoderImpl>(),
174 profile->GetPrefs())); 175 base::MakeUnique<NTPSnippetsDatabase>(database_dir, task_runner),
175 service->set_ntp_snippets_service(ntp_snippets_service.get()); 176 base::MakeUnique<NTPSnippetsStatusService>(signin_manager,
176 service->RegisterProvider(std::move(ntp_snippets_service)); 177 profile->GetPrefs()));
178 service->set_ntp_snippets_service(ntp_snippets_service.get());
179 service->RegisterProvider(std::move(ntp_snippets_service));
180 }
177 181
178 return service; 182 return service;
179 } 183 }
OLDNEW
« no previous file with comments | « no previous file | components/ntp_snippets/features.h » ('j') | components/ntp_snippets/features.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698