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

Side by Side Diff: chrome/browser/extensions/api/settings_overrides/settings_overrides_api.cc

Issue 2814743006: Refactoring after comments in https://codereview.chromium.org/2639153002 (Closed)
Patch Set: Fixed after review, round 2 Created 3 years, 8 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/search_engines/template_url_service_sync_unittest.cc » ('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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/extensions/api/settings_overrides/settings_overrides_ap i.h" 5 #include "chrome/browser/extensions/api/settings_overrides/settings_overrides_ap i.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <memory> 8 #include <memory>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 } 221 }
222 } 222 }
223 223
224 void SettingsOverridesAPI::RegisterSearchProvider( 224 void SettingsOverridesAPI::RegisterSearchProvider(
225 const Extension* extension) const { 225 const Extension* extension) const {
226 DCHECK(url_service_); 226 DCHECK(url_service_);
227 DCHECK(extension); 227 DCHECK(extension);
228 const SettingsOverrides* settings = SettingsOverrides::Get(extension); 228 const SettingsOverrides* settings = SettingsOverrides::Get(extension);
229 DCHECK(settings); 229 DCHECK(settings);
230 DCHECK(settings->search_engine); 230 DCHECK(settings->search_engine);
231 auto info =
232 base::MakeUnique<TemplateURL::AssociatedExtensionInfo>(extension->id());
233 info->wants_to_be_default_engine = settings->search_engine->is_default;
234 231
235 ExtensionPrefs* prefs = ExtensionPrefs::Get(profile_); 232 ExtensionPrefs* prefs = ExtensionPrefs::Get(profile_);
236 info->install_time = prefs->GetInstallTime(extension->id());
237 std::string install_parameter = prefs->GetInstallParam(extension->id()); 233 std::string install_parameter = prefs->GetInstallParam(extension->id());
238 std::unique_ptr<TemplateURLData> data = ConvertSearchProvider( 234 std::unique_ptr<TemplateURLData> data = ConvertSearchProvider(
239 profile_->GetPrefs(), *settings->search_engine, install_parameter); 235 profile_->GetPrefs(), *settings->search_engine, install_parameter);
240 auto turl = base::MakeUnique<TemplateURL>( 236 auto turl = base::MakeUnique<TemplateURL>(
241 *data, TemplateURL::NORMAL_CONTROLLED_BY_EXTENSION); 237 *data, TemplateURL::NORMAL_CONTROLLED_BY_EXTENSION, extension->id(),
238 prefs->GetInstallTime(extension->id()),
239 settings->search_engine->is_default);
242 240
243 url_service_->AddExtensionControlledTURL(std::move(turl), std::move(info)); 241 url_service_->Add(std::move(turl));
244 242
245 if (settings->search_engine->is_default) { 243 if (settings->search_engine->is_default) {
246 // Override current DSE pref to have extension overriden value. 244 // Override current DSE pref to have extension overriden value.
247 SetPref(extension->id(), 245 SetPref(extension->id(),
248 DefaultSearchManager::kDefaultSearchProviderDataPrefName, 246 DefaultSearchManager::kDefaultSearchProviderDataPrefName,
249 TemplateURLDataToDictionary(*data)); 247 TemplateURLDataToDictionary(*data));
250 } 248 }
251 } 249 }
252 250
253 template <> 251 template <>
254 void BrowserContextKeyedAPIFactory< 252 void BrowserContextKeyedAPIFactory<
255 SettingsOverridesAPI>::DeclareFactoryDependencies() { 253 SettingsOverridesAPI>::DeclareFactoryDependencies() {
256 DependsOn(ExtensionPrefsFactory::GetInstance()); 254 DependsOn(ExtensionPrefsFactory::GetInstance());
257 DependsOn(PreferenceAPI::GetFactoryInstance()); 255 DependsOn(PreferenceAPI::GetFactoryInstance());
258 DependsOn(TemplateURLServiceFactory::GetInstance()); 256 DependsOn(TemplateURLServiceFactory::GetInstance());
259 } 257 }
260 258
261 } // namespace extensions 259 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/search_engines/template_url_service_sync_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698