| OLD | NEW |
| 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 <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 } | 181 } |
| 182 if (!settings->startup_pages.empty()) { | 182 if (!settings->startup_pages.empty()) { |
| 183 SetPref(extension->id(), | 183 SetPref(extension->id(), |
| 184 prefs::kRestoreOnStartup, | 184 prefs::kRestoreOnStartup, |
| 185 new base::FundamentalValue(SessionStartupPref::kPrefValueURLs)); | 185 new base::FundamentalValue(SessionStartupPref::kPrefValueURLs)); |
| 186 if (settings->startup_pages.size() > 1) { | 186 if (settings->startup_pages.size() > 1) { |
| 187 VLOG(1) << extensions::ErrorUtils::FormatErrorMessage( | 187 VLOG(1) << extensions::ErrorUtils::FormatErrorMessage( |
| 188 kManyStartupPagesWarning, | 188 kManyStartupPagesWarning, |
| 189 manifest_keys::kSettingsOverride); | 189 manifest_keys::kSettingsOverride); |
| 190 } | 190 } |
| 191 scoped_ptr<base::ListValue> url_list(new base::ListValue); | 191 std::unique_ptr<base::ListValue> url_list(new base::ListValue); |
| 192 url_list->Append(new base::StringValue(SubstituteInstallParam( | 192 url_list->Append(new base::StringValue(SubstituteInstallParam( |
| 193 settings->startup_pages[0].spec(), install_parameter))); | 193 settings->startup_pages[0].spec(), install_parameter))); |
| 194 SetPref( | 194 SetPref( |
| 195 extension->id(), prefs::kURLsToRestoreOnStartup, url_list.release()); | 195 extension->id(), prefs::kURLsToRestoreOnStartup, url_list.release()); |
| 196 } | 196 } |
| 197 if (settings->search_engine) { | 197 if (settings->search_engine) { |
| 198 // Bring the preference to the correct state. Before this code set it | 198 // Bring the preference to the correct state. Before this code set it |
| 199 // to "true" for all search engines. Thus, we should overwrite it for | 199 // to "true" for all search engines. Thus, we should overwrite it for |
| 200 // all search engines. | 200 // all search engines. |
| 201 if (settings->search_engine->is_default) { | 201 if (settings->search_engine->is_default) { |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 pending_extensions_.clear(); | 260 pending_extensions_.clear(); |
| 261 } | 261 } |
| 262 | 262 |
| 263 void SettingsOverridesAPI::RegisterSearchProvider( | 263 void SettingsOverridesAPI::RegisterSearchProvider( |
| 264 const Extension* extension) const { | 264 const Extension* extension) const { |
| 265 DCHECK(url_service_); | 265 DCHECK(url_service_); |
| 266 DCHECK(extension); | 266 DCHECK(extension); |
| 267 const SettingsOverrides* settings = SettingsOverrides::Get(extension); | 267 const SettingsOverrides* settings = SettingsOverrides::Get(extension); |
| 268 DCHECK(settings); | 268 DCHECK(settings); |
| 269 DCHECK(settings->search_engine); | 269 DCHECK(settings->search_engine); |
| 270 scoped_ptr<TemplateURL::AssociatedExtensionInfo> info( | 270 std::unique_ptr<TemplateURL::AssociatedExtensionInfo> info( |
| 271 new TemplateURL::AssociatedExtensionInfo( | 271 new TemplateURL::AssociatedExtensionInfo( |
| 272 TemplateURL::NORMAL_CONTROLLED_BY_EXTENSION, extension->id())); | 272 TemplateURL::NORMAL_CONTROLLED_BY_EXTENSION, extension->id())); |
| 273 info->wants_to_be_default_engine = settings->search_engine->is_default; | 273 info->wants_to_be_default_engine = settings->search_engine->is_default; |
| 274 ExtensionPrefs* prefs = ExtensionPrefs::Get(profile_); | 274 ExtensionPrefs* prefs = ExtensionPrefs::Get(profile_); |
| 275 info->install_time = prefs->GetInstallTime(extension->id()); | 275 info->install_time = prefs->GetInstallTime(extension->id()); |
| 276 std::string install_parameter = prefs->GetInstallParam(extension->id()); | 276 std::string install_parameter = prefs->GetInstallParam(extension->id()); |
| 277 TemplateURLData data = ConvertSearchProvider( | 277 TemplateURLData data = ConvertSearchProvider( |
| 278 profile_->GetPrefs(), *settings->search_engine, install_parameter); | 278 profile_->GetPrefs(), *settings->search_engine, install_parameter); |
| 279 data.show_in_default_list = info->wants_to_be_default_engine; | 279 data.show_in_default_list = info->wants_to_be_default_engine; |
| 280 url_service_->AddExtensionControlledTURL(new TemplateURL(data), | 280 url_service_->AddExtensionControlledTURL(new TemplateURL(data), |
| 281 std::move(info)); | 281 std::move(info)); |
| 282 } | 282 } |
| 283 | 283 |
| 284 template <> | 284 template <> |
| 285 void BrowserContextKeyedAPIFactory< | 285 void BrowserContextKeyedAPIFactory< |
| 286 SettingsOverridesAPI>::DeclareFactoryDependencies() { | 286 SettingsOverridesAPI>::DeclareFactoryDependencies() { |
| 287 DependsOn(ExtensionPrefsFactory::GetInstance()); | 287 DependsOn(ExtensionPrefsFactory::GetInstance()); |
| 288 DependsOn(PreferenceAPI::GetFactoryInstance()); | 288 DependsOn(PreferenceAPI::GetFactoryInstance()); |
| 289 DependsOn(TemplateURLServiceFactory::GetInstance()); | 289 DependsOn(TemplateURLServiceFactory::GetInstance()); |
| 290 } | 290 } |
| 291 | 291 |
| 292 } // namespace extensions | 292 } // namespace extensions |
| OLD | NEW |