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

Side by Side Diff: chrome/browser/extensions/api/preference/chrome_direct_setting_api.cc

Issue 166053003: Move ProfileKeyedAPI implementations to take BrowserContext in the constructor (part 2). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: | Created 6 years, 10 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/preference/chrome_direct_setting_api.h" 5 #include "chrome/browser/extensions/api/preference/chrome_direct_setting_api.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/containers/hash_tables.h" 8 #include "base/containers/hash_tables.h"
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/prefs/pref_change_registrar.h" 10 #include "base/prefs/pref_change_registrar.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 68
69 DISALLOW_COPY_AND_ASSIGN(PreferenceWhitelist); 69 DISALLOW_COPY_AND_ASSIGN(PreferenceWhitelist);
70 }; 70 };
71 71
72 base::LazyInstance<PreferenceWhitelist> preference_whitelist = 72 base::LazyInstance<PreferenceWhitelist> preference_whitelist =
73 LAZY_INSTANCE_INITIALIZER; 73 LAZY_INSTANCE_INITIALIZER;
74 74
75 static base::LazyInstance<ProfileKeyedAPIFactory<ChromeDirectSettingAPI> > 75 static base::LazyInstance<ProfileKeyedAPIFactory<ChromeDirectSettingAPI> >
76 g_factory = LAZY_INSTANCE_INITIALIZER; 76 g_factory = LAZY_INSTANCE_INITIALIZER;
77 77
78 ChromeDirectSettingAPI::ChromeDirectSettingAPI(Profile* profile) 78 ChromeDirectSettingAPI::ChromeDirectSettingAPI(content::BrowserContext* context)
79 : profile_(profile) { 79 : profile_(Profile::FromBrowserContext(context)) {
80 preference_whitelist.Get().RegisterEventListeners(profile, this); 80 preference_whitelist.Get().RegisterEventListeners(profile_, this);
81 } 81 }
82 82
83 ChromeDirectSettingAPI::~ChromeDirectSettingAPI() {} 83 ChromeDirectSettingAPI::~ChromeDirectSettingAPI() {}
84 84
85 // BrowserContextKeyedService implementation. 85 // BrowserContextKeyedService implementation.
86 void ChromeDirectSettingAPI::Shutdown() {} 86 void ChromeDirectSettingAPI::Shutdown() {}
87 87
88 // ProfileKeyedAPI implementation. 88 // ProfileKeyedAPI implementation.
89 ProfileKeyedAPIFactory<ChromeDirectSettingAPI>* 89 ProfileKeyedAPIFactory<ChromeDirectSettingAPI>*
90 ChromeDirectSettingAPI::GetFactoryInstance() { 90 ChromeDirectSettingAPI::GetFactoryInstance() {
(...skipping 10 matching lines...) Expand all
101 base::Bind(&ChromeDirectSettingAPI::OnPrefChanged, 101 base::Bind(&ChromeDirectSettingAPI::OnPrefChanged,
102 base::Unretained(this), 102 base::Unretained(this),
103 registrar_.prefs())); 103 registrar_.prefs()));
104 } 104 }
105 105
106 bool ChromeDirectSettingAPI::IsPreferenceOnWhitelist( 106 bool ChromeDirectSettingAPI::IsPreferenceOnWhitelist(
107 const std::string& pref_key) { 107 const std::string& pref_key) {
108 return preference_whitelist.Get().IsPreferenceOnWhitelist(pref_key); 108 return preference_whitelist.Get().IsPreferenceOnWhitelist(pref_key);
109 } 109 }
110 110
111 ChromeDirectSettingAPI* ChromeDirectSettingAPI::Get(Profile* profile) { 111 ChromeDirectSettingAPI* ChromeDirectSettingAPI::Get(
112 return 112 content::BrowserContext* context) {
113 ProfileKeyedAPIFactory<ChromeDirectSettingAPI>::GetForProfile(profile); 113 return ProfileKeyedAPIFactory<ChromeDirectSettingAPI>::GetForProfile(context);
114 } 114 }
115 115
116 // ProfileKeyedAPI implementation. 116 // ProfileKeyedAPI implementation.
117 const char* ChromeDirectSettingAPI::service_name() { 117 const char* ChromeDirectSettingAPI::service_name() {
118 return "ChromeDirectSettingAPI"; 118 return "ChromeDirectSettingAPI";
119 } 119 }
120 120
121 void ChromeDirectSettingAPI::OnPrefChanged( 121 void ChromeDirectSettingAPI::OnPrefChanged(
122 PrefService* pref_service, const std::string& pref_key) { 122 PrefService* pref_service, const std::string& pref_key) {
123 std::string event_name = base::StringPrintf(kOnPrefChangeFormat, 123 std::string event_name = base::StringPrintf(kOnPrefChangeFormat,
(...skipping 21 matching lines...) Expand all
145 scoped_ptr<Event> event(new Event(event_name, args_copy.Pass())); 145 scoped_ptr<Event> event(new Event(event_name, args_copy.Pass()));
146 router->DispatchEventToExtension(extension_id, event.Pass()); 146 router->DispatchEventToExtension(extension_id, event.Pass());
147 } 147 }
148 } 148 }
149 } 149 }
150 } 150 }
151 } 151 }
152 152
153 } // namespace chromedirectsetting 153 } // namespace chromedirectsetting
154 } // namespace extensions 154 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698