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

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

Issue 178193030: Rename ProfileKeyedAPI to BrowserContextKeyedAPI and GetProfile to Get. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nits Created 6 years, 9 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 | Annotate | Revision Log
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 "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/prefs/session_startup_pref.h" 11 #include "chrome/browser/prefs/session_startup_pref.h"
12 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/search_engines/template_url.h" 13 #include "chrome/browser/search_engines/template_url.h"
14 #include "chrome/browser/search_engines/template_url_service_factory.h" 14 #include "chrome/browser/search_engines/template_url_service_factory.h"
15 #include "chrome/common/extensions/manifest_handlers/settings_overrides_handler. h" 15 #include "chrome/common/extensions/manifest_handlers/settings_overrides_handler. h"
16 #include "chrome/common/pref_names.h" 16 #include "chrome/common/pref_names.h"
17 #include "content/public/browser/notification_details.h" 17 #include "content/public/browser/notification_details.h"
18 #include "content/public/browser/notification_source.h" 18 #include "content/public/browser/notification_source.h"
19 #include "extensions/browser/extension_prefs.h" 19 #include "extensions/browser/extension_prefs.h"
20 #include "extensions/browser/extension_prefs_factory.h" 20 #include "extensions/browser/extension_prefs_factory.h"
21 #include "extensions/common/error_utils.h" 21 #include "extensions/common/error_utils.h"
22 #include "extensions/common/manifest_constants.h" 22 #include "extensions/common/manifest_constants.h"
23 23
24 namespace extensions { 24 namespace extensions {
25 25
26 namespace { 26 namespace {
27 base::LazyInstance<ProfileKeyedAPIFactory<SettingsOverridesAPI> > 27 base::LazyInstance<BrowserContextKeyedAPIFactory<SettingsOverridesAPI> >
28 g_factory = LAZY_INSTANCE_INITIALIZER; 28 g_factory = LAZY_INSTANCE_INITIALIZER;
29 29
30 const char kManyStartupPagesWarning[] = "* specifies more than 1 startup URL. " 30 const char kManyStartupPagesWarning[] = "* specifies more than 1 startup URL. "
31 "All but the first will be ignored."; 31 "All but the first will be ignored.";
32 32
33 using api::manifest_types::ChromeSettingsOverrides; 33 using api::manifest_types::ChromeSettingsOverrides;
34 34
35 TemplateURLData ConvertSearchProvider( 35 TemplateURLData ConvertSearchProvider(
36 const ChromeSettingsOverrides::Search_provider& search_provider) { 36 const ChromeSettingsOverrides::Search_provider& search_provider) {
37 TemplateURLData data; 37 TemplateURLData data;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 chrome::NOTIFICATION_EXTENSION_LOADED, 78 chrome::NOTIFICATION_EXTENSION_LOADED,
79 content::Source<Profile>(profile_)); 79 content::Source<Profile>(profile_));
80 registrar_.Add(this, 80 registrar_.Add(this,
81 chrome::NOTIFICATION_EXTENSION_UNLOADED, 81 chrome::NOTIFICATION_EXTENSION_UNLOADED,
82 content::Source<Profile>(profile_)); 82 content::Source<Profile>(profile_));
83 } 83 }
84 84
85 SettingsOverridesAPI::~SettingsOverridesAPI() { 85 SettingsOverridesAPI::~SettingsOverridesAPI() {
86 } 86 }
87 87
88 ProfileKeyedAPIFactory<SettingsOverridesAPI>* 88 BrowserContextKeyedAPIFactory<SettingsOverridesAPI>*
89 SettingsOverridesAPI::GetFactoryInstance() { 89 SettingsOverridesAPI::GetFactoryInstance() {
90 return g_factory.Pointer(); 90 return g_factory.Pointer();
91 } 91 }
92 92
93 void SettingsOverridesAPI::SetPref(const std::string& extension_id, 93 void SettingsOverridesAPI::SetPref(const std::string& extension_id,
94 const std::string& pref_key, 94 const std::string& pref_key,
95 base::Value* value) { 95 base::Value* value) {
96 PreferenceAPI::Get(profile_)->SetExtensionControlledPref( 96 PreferenceAPI::Get(profile_)->SetExtensionControlledPref(
97 extension_id, 97 extension_id,
98 pref_key, 98 pref_key,
99 kExtensionPrefsScopeRegular, 99 kExtensionPrefsScopeRegular,
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 info->extension_id = extension->id(); 214 info->extension_id = extension->id();
215 info->wants_to_be_default_engine = settings->search_engine->is_default; 215 info->wants_to_be_default_engine = settings->search_engine->is_default;
216 info->install_time = 216 info->install_time =
217 ExtensionPrefs::Get(profile_)->GetInstallTime(extension->id()); 217 ExtensionPrefs::Get(profile_)->GetInstallTime(extension->id());
218 TemplateURLData data = ConvertSearchProvider(*settings->search_engine); 218 TemplateURLData data = ConvertSearchProvider(*settings->search_engine);
219 url_service_->AddExtensionControlledTURL(new TemplateURL(profile_, data), 219 url_service_->AddExtensionControlledTURL(new TemplateURL(profile_, data),
220 info.Pass()); 220 info.Pass());
221 } 221 }
222 222
223 template <> 223 template <>
224 void ProfileKeyedAPIFactory<SettingsOverridesAPI>:: 224 void BrowserContextKeyedAPIFactory<
225 DeclareFactoryDependencies() { 225 SettingsOverridesAPI>::DeclareFactoryDependencies() {
226 DependsOn(ExtensionPrefsFactory::GetInstance()); 226 DependsOn(ExtensionPrefsFactory::GetInstance());
227 DependsOn(PreferenceAPI::GetFactoryInstance()); 227 DependsOn(PreferenceAPI::GetFactoryInstance());
228 DependsOn(TemplateURLServiceFactory::GetInstance()); 228 DependsOn(TemplateURLServiceFactory::GetInstance());
229 } 229 }
230 230
231 } // namespace extensions 231 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698