Chromium Code Reviews| 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 "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "chrome/browser/chrome_notification_types.h" | 9 #include "chrome/browser/chrome_notification_types.h" |
| 10 #include "chrome/browser/extensions/api/preference/preference_api.h" | 10 #include "chrome/browser/extensions/api/preference/preference_api.h" |
| 11 #include "chrome/browser/extensions/extension_prefs.h" | 11 #include "chrome/browser/extensions/extension_prefs.h" |
| 12 #include "chrome/browser/extensions/extension_prefs_factory.h" | |
| 12 #include "chrome/browser/prefs/session_startup_pref.h" | 13 #include "chrome/browser/prefs/session_startup_pref.h" |
| 13 #include "chrome/browser/search_engines/template_url.h" | 14 #include "chrome/browser/search_engines/template_url.h" |
| 14 #include "chrome/browser/search_engines/template_url_service_factory.h" | 15 #include "chrome/browser/search_engines/template_url_service_factory.h" |
| 15 #include "chrome/common/extensions/manifest_handlers/settings_overrides_handler. h" | 16 #include "chrome/common/extensions/manifest_handlers/settings_overrides_handler. h" |
| 16 #include "chrome/common/pref_names.h" | 17 #include "chrome/common/pref_names.h" |
| 17 #include "content/public/browser/notification_details.h" | 18 #include "content/public/browser/notification_details.h" |
| 18 #include "content/public/browser/notification_source.h" | 19 #include "content/public/browser/notification_source.h" |
| 19 #include "extensions/common/error_utils.h" | 20 #include "extensions/common/error_utils.h" |
| 20 #include "extensions/common/manifest_constants.h" | 21 #include "extensions/common/manifest_constants.h" |
| 21 | 22 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 82 } | 83 } |
| 83 | 84 |
| 84 ProfileKeyedAPIFactory<SettingsOverridesAPI>* | 85 ProfileKeyedAPIFactory<SettingsOverridesAPI>* |
| 85 SettingsOverridesAPI::GetFactoryInstance() { | 86 SettingsOverridesAPI::GetFactoryInstance() { |
| 86 return &g_factory.Get(); | 87 return &g_factory.Get(); |
| 87 } | 88 } |
| 88 | 89 |
| 89 void SettingsOverridesAPI::SetPref(const std::string& extension_id, | 90 void SettingsOverridesAPI::SetPref(const std::string& extension_id, |
| 90 const std::string& pref_key, | 91 const std::string& pref_key, |
| 91 base::Value* value) { | 92 base::Value* value) { |
| 92 PreferenceAPI::Get(profile_)->SetExtensionControlledPref( | 93 PreferenceAPI::Get(profile_)->SetExtensionControlledPref( |
|
not at google - send to devlin
2013/10/31 15:22:04
Do you need to add a dependency to PreferenceAPI a
vasilii
2013/10/31 15:39:26
Done.
| |
| 93 extension_id, | 94 extension_id, |
| 94 pref_key, | 95 pref_key, |
| 95 kExtensionPrefsScopeRegular, | 96 kExtensionPrefsScopeRegular, |
| 96 value); | 97 value); |
| 97 } | 98 } |
| 98 | 99 |
| 99 void SettingsOverridesAPI::UnsetPref(const std::string& extension_id, | 100 void SettingsOverridesAPI::UnsetPref(const std::string& extension_id, |
| 100 const std::string& pref_key) { | 101 const std::string& pref_key) { |
| 101 PreferenceAPI::Get(profile_)->RemoveExtensionControlledPref( | 102 PreferenceAPI::Get(profile_)->RemoveExtensionControlledPref( |
| 102 extension_id, | 103 extension_id, |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 205 scoped_ptr<AssociatedExtensionInfo> info(new AssociatedExtensionInfo); | 206 scoped_ptr<AssociatedExtensionInfo> info(new AssociatedExtensionInfo); |
| 206 info->extension_id = extension->id(); | 207 info->extension_id = extension->id(); |
| 207 info->wants_to_be_default_engine = settings->search_engine->is_default; | 208 info->wants_to_be_default_engine = settings->search_engine->is_default; |
| 208 info->install_time = | 209 info->install_time = |
| 209 ExtensionPrefs::Get(profile_)->GetInstallTime(extension->id()); | 210 ExtensionPrefs::Get(profile_)->GetInstallTime(extension->id()); |
| 210 TemplateURLData data = ConvertSearchProvider(*settings->search_engine); | 211 TemplateURLData data = ConvertSearchProvider(*settings->search_engine); |
| 211 url_service_->AddExtensionControlledTURL(new TemplateURL(profile_, data), | 212 url_service_->AddExtensionControlledTURL(new TemplateURL(profile_, data), |
| 212 info.Pass()); | 213 info.Pass()); |
| 213 } | 214 } |
| 214 | 215 |
| 216 template <> | |
| 217 void ProfileKeyedAPIFactory<SettingsOverridesAPI>:: | |
| 218 DeclareFactoryDependencies() { | |
| 219 DependsOn(ExtensionPrefsFactory::GetInstance()); | |
| 220 DependsOn(TemplateURLServiceFactory::GetInstance()); | |
| 221 } | |
| 222 | |
| 215 } // namespace extensions | 223 } // namespace extensions |
| OLD | NEW |