| 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" |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 } | 104 } |
| 105 | 105 |
| 106 BrowserContextKeyedAPIFactory<SettingsOverridesAPI>* | 106 BrowserContextKeyedAPIFactory<SettingsOverridesAPI>* |
| 107 SettingsOverridesAPI::GetFactoryInstance() { | 107 SettingsOverridesAPI::GetFactoryInstance() { |
| 108 return g_factory.Pointer(); | 108 return g_factory.Pointer(); |
| 109 } | 109 } |
| 110 | 110 |
| 111 void SettingsOverridesAPI::SetPref(const std::string& extension_id, | 111 void SettingsOverridesAPI::SetPref(const std::string& extension_id, |
| 112 const std::string& pref_key, | 112 const std::string& pref_key, |
| 113 base::Value* value) { | 113 base::Value* value) { |
| 114 PreferenceAPI::Get(profile_)->SetExtensionControlledPref( | 114 PreferenceAPI* prefs = PreferenceAPI::Get(profile_); |
| 115 extension_id, | 115 if (!prefs) |
| 116 pref_key, | 116 return; // Expected in unit tests. |
| 117 kExtensionPrefsScopeRegular, | 117 prefs->SetExtensionControlledPref(extension_id, |
| 118 value); | 118 pref_key, |
| 119 kExtensionPrefsScopeRegular, |
| 120 value); |
| 119 } | 121 } |
| 120 | 122 |
| 121 void SettingsOverridesAPI::UnsetPref(const std::string& extension_id, | 123 void SettingsOverridesAPI::UnsetPref(const std::string& extension_id, |
| 122 const std::string& pref_key) { | 124 const std::string& pref_key) { |
| 123 PreferenceAPI::Get(profile_)->RemoveExtensionControlledPref( | 125 PreferenceAPI* prefs = PreferenceAPI::Get(profile_); |
| 126 if (!prefs) |
| 127 return; // Expected in unit tests. |
| 128 prefs->RemoveExtensionControlledPref( |
| 124 extension_id, | 129 extension_id, |
| 125 pref_key, | 130 pref_key, |
| 126 kExtensionPrefsScopeRegular); | 131 kExtensionPrefsScopeRegular); |
| 127 } | 132 } |
| 128 | 133 |
| 129 void SettingsOverridesAPI::Observe( | 134 void SettingsOverridesAPI::Observe( |
| 130 int type, | 135 int type, |
| 131 const content::NotificationSource& source, | 136 const content::NotificationSource& source, |
| 132 const content::NotificationDetails& details) { | 137 const content::NotificationDetails& details) { |
| 133 switch (type) { | 138 switch (type) { |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 | 251 |
| 247 template <> | 252 template <> |
| 248 void BrowserContextKeyedAPIFactory< | 253 void BrowserContextKeyedAPIFactory< |
| 249 SettingsOverridesAPI>::DeclareFactoryDependencies() { | 254 SettingsOverridesAPI>::DeclareFactoryDependencies() { |
| 250 DependsOn(ExtensionPrefsFactory::GetInstance()); | 255 DependsOn(ExtensionPrefsFactory::GetInstance()); |
| 251 DependsOn(PreferenceAPI::GetFactoryInstance()); | 256 DependsOn(PreferenceAPI::GetFactoryInstance()); |
| 252 DependsOn(TemplateURLServiceFactory::GetInstance()); | 257 DependsOn(TemplateURLServiceFactory::GetInstance()); |
| 253 } | 258 } |
| 254 | 259 |
| 255 } // namespace extensions | 260 } // namespace extensions |
| OLD | NEW |