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

Side by Side Diff: chrome/browser/extensions/extension_preference_api.cc

Issue 6961027: Change event routers from singletons to being owned by the ExtensionService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixes for ChromeOS Created 9 years, 7 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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/extension_preference_api.h" 5 #include "chrome/browser/extensions/extension_preference_api.h"
6 6
7 #include <map> 7 #include <map>
8 8
9 #include "base/json/json_writer.h" 9 #include "base/json/json_writer.h"
10 #include "base/memory/singleton.h" 10 #include "base/memory/singleton.h"
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 std::map<std::string, PrefTransformerInterface*> transformers_; 192 std::map<std::string, PrefTransformerInterface*> transformers_;
193 193
194 scoped_ptr<PrefTransformerInterface> identity_transformer_; 194 scoped_ptr<PrefTransformerInterface> identity_transformer_;
195 195
196 DISALLOW_COPY_AND_ASSIGN(PrefMapping); 196 DISALLOW_COPY_AND_ASSIGN(PrefMapping);
197 }; 197 };
198 198
199 } // namespace 199 } // namespace
200 200
201 ExtensionPreferenceEventRouter::ExtensionPreferenceEventRouter( 201 ExtensionPreferenceEventRouter::ExtensionPreferenceEventRouter(
202 Profile* profile) : profile_(profile) { 202 Profile* profile) : profile_(profile) {
asargent_no_longer_on_chrome 2011/05/24 19:53:31 did you mean to include this extra space be here?
Yoyo Zhou 2011/05/25 00:48:47 Nope, thanks.
203 }
204
205 ExtensionPreferenceEventRouter::~ExtensionPreferenceEventRouter() {}
206
207 void ExtensionPreferenceEventRouter::Init() {
203 registrar_.Init(profile_->GetPrefs()); 208 registrar_.Init(profile_->GetPrefs());
204 incognito_registrar_.Init(profile_->GetOffTheRecordPrefs()); 209 incognito_registrar_.Init(profile_->GetOffTheRecordPrefs());
205 for (size_t i = 0; i < arraysize(kPrefMapping); ++i) { 210 for (size_t i = 0; i < arraysize(kPrefMapping); ++i) {
206 registrar_.Add(kPrefMapping[i].browser_pref, this); 211 registrar_.Add(kPrefMapping[i].browser_pref, this);
207 incognito_registrar_.Add(kPrefMapping[i].browser_pref, this); 212 incognito_registrar_.Add(kPrefMapping[i].browser_pref, this);
208 } 213 }
209 } 214 }
210 215
211 ExtensionPreferenceEventRouter::~ExtensionPreferenceEventRouter() { }
212
213 void ExtensionPreferenceEventRouter::Observe( 216 void ExtensionPreferenceEventRouter::Observe(
214 NotificationType type, 217 NotificationType type,
215 const NotificationSource& source, 218 const NotificationSource& source,
216 const NotificationDetails& details) { 219 const NotificationDetails& details) {
217 if (type == NotificationType::PREF_CHANGED) { 220 if (type == NotificationType::PREF_CHANGED) {
218 const std::string* pref_key = 221 const std::string* pref_key =
219 Details<const std::string>(details).ptr(); 222 Details<const std::string>(details).ptr();
220 OnPrefChanged(Source<PrefService>(source).ptr(), *pref_key); 223 OnPrefChanged(Source<PrefService>(source).ptr(), *pref_key);
221 } else { 224 } else {
222 NOTREACHED(); 225 NOTREACHED();
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 PrefMapping::GetInstance()->FindBrowserPrefForExtensionPref( 410 PrefMapping::GetInstance()->FindBrowserPrefForExtensionPref(
408 pref_key, &browser_pref, &permission)); 411 pref_key, &browser_pref, &permission));
409 if (!GetExtension()->HasApiPermission(permission)) { 412 if (!GetExtension()->HasApiPermission(permission)) {
410 error_ = base::StringPrintf(kPermissionErrorMessage, pref_key.c_str()); 413 error_ = base::StringPrintf(kPermissionErrorMessage, pref_key.c_str());
411 return false; 414 return false;
412 } 415 }
413 ExtensionPrefs* prefs = profile_->GetExtensionService()->extension_prefs(); 416 ExtensionPrefs* prefs = profile_->GetExtensionService()->extension_prefs();
414 prefs->RemoveExtensionControlledPref(extension_id(), browser_pref, incognito); 417 prefs->RemoveExtensionControlledPref(extension_id(), browser_pref, incognito);
415 return true; 418 return true;
416 } 419 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_preference_api.h ('k') | chrome/browser/extensions/extension_processes_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698