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 <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 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 PrefService* pref_service, | 198 PrefService* pref_service, |
199 Profile* profile) { | 199 Profile* profile) { |
200 scoped_refptr<net::URLRequestContextGetter> request_context = | 200 scoped_refptr<net::URLRequestContextGetter> request_context = |
201 content::BrowserContext::GetDefaultStoragePartition(profile) | 201 content::BrowserContext::GetDefaultStoragePartition(profile) |
202 ->GetURLRequestContext(); | 202 ->GetURLRequestContext(); |
203 | 203 |
204 base::FilePath database_dir( | 204 base::FilePath database_dir( |
205 profile->GetPath().Append(ntp_snippets::kDatabaseFolder)); | 205 profile->GetPath().Append(ntp_snippets::kDatabaseFolder)); |
206 scoped_refptr<base::SequencedTaskRunner> task_runner = | 206 scoped_refptr<base::SequencedTaskRunner> task_runner = |
207 base::CreateSequencedTaskRunnerWithTraits( | 207 base::CreateSequencedTaskRunnerWithTraits( |
208 base::TaskTraits() | 208 {base::MayBlock(), base::TaskPriority::BACKGROUND, |
209 .MayBlock() | 209 base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN}); |
210 .WithPriority(base::TaskPriority::BACKGROUND) | |
211 .WithShutdownBehavior( | |
212 base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN)); | |
213 std::string api_key; | 210 std::string api_key; |
214 // The API is private. If we don't have the official API key, don't even try. | 211 // The API is private. If we don't have the official API key, don't even try. |
215 if (google_apis::IsGoogleChromeAPIKeyUsed()) { | 212 if (google_apis::IsGoogleChromeAPIKeyUsed()) { |
216 bool is_stable_channel = | 213 bool is_stable_channel = |
217 chrome::GetChannel() == version_info::Channel::STABLE; | 214 chrome::GetChannel() == version_info::Channel::STABLE; |
218 api_key = is_stable_channel ? google_apis::GetAPIKey() | 215 api_key = is_stable_channel ? google_apis::GetAPIKey() |
219 : google_apis::GetNonStableAPIKey(); | 216 : google_apis::GetNonStableAPIKey(); |
220 } | 217 } |
221 | 218 |
222 // Pass the pref name associated to the search suggest toggle, and use it to | 219 // Pass the pref name associated to the search suggest toggle, and use it to |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 ntp_snippets::kForeignSessionsSuggestionsFeature)) { | 402 ntp_snippets::kForeignSessionsSuggestionsFeature)) { |
406 RegisterForeignSessionsProvider(sync_service, service, pref_service); | 403 RegisterForeignSessionsProvider(sync_service, service, pref_service); |
407 } | 404 } |
408 | 405 |
409 return service; | 406 return service; |
410 | 407 |
411 #else | 408 #else |
412 return nullptr; | 409 return nullptr; |
413 #endif // CONTENT_SUGGESTIONS_ENABLED | 410 #endif // CONTENT_SUGGESTIONS_ENABLED |
414 } | 411 } |
OLD | NEW |