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

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

Issue 7327007: Moving notification types which are chrome specific to a new header file chrome_notification_type... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 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"
11 #include "base/stl_util-inl.h" 11 #include "base/stl_util-inl.h"
12 #include "base/stringprintf.h" 12 #include "base/stringprintf.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 #include "chrome/browser/extensions/extension_event_router.h" 14 #include "chrome/browser/extensions/extension_event_router.h"
15 #include "chrome/browser/extensions/extension_preference_api_constants.h" 15 #include "chrome/browser/extensions/extension_preference_api_constants.h"
16 #include "chrome/browser/extensions/extension_preference_helpers.h" 16 #include "chrome/browser/extensions/extension_preference_helpers.h"
17 #include "chrome/browser/extensions/extension_prefs.h" 17 #include "chrome/browser/extensions/extension_prefs.h"
18 #include "chrome/browser/extensions/extension_prefs_scope.h" 18 #include "chrome/browser/extensions/extension_prefs_scope.h"
19 #include "chrome/browser/extensions/extension_proxy_api.h" 19 #include "chrome/browser/extensions/extension_proxy_api.h"
20 #include "chrome/browser/extensions/extension_service.h" 20 #include "chrome/browser/extensions/extension_service.h"
21 #include "chrome/browser/profiles/profile.h" 21 #include "chrome/browser/profiles/profile.h"
22 #include "chrome/common/chrome_notification_types.h"
22 #include "chrome/common/extensions/extension_error_utils.h" 23 #include "chrome/common/extensions/extension_error_utils.h"
23 #include "chrome/common/extensions/extension_permission_set.h" 24 #include "chrome/common/extensions/extension_permission_set.h"
24 #include "chrome/common/pref_names.h" 25 #include "chrome/common/pref_names.h"
25 #include "content/common/notification_type.h"
26 #include "content/common/notification_service.h" 26 #include "content/common/notification_service.h"
27 27
28 namespace { 28 namespace {
29 29
30 struct PrefMappingEntry { 30 struct PrefMappingEntry {
31 const char* extension_pref; 31 const char* extension_pref;
32 const char* browser_pref; 32 const char* browser_pref;
33 ExtensionAPIPermission::ID permission; 33 ExtensionAPIPermission::ID permission;
34 }; 34 };
35 35
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 incognito_registrar_.Init(profile_->GetOffTheRecordPrefs()); 226 incognito_registrar_.Init(profile_->GetOffTheRecordPrefs());
227 for (size_t i = 0; i < arraysize(kPrefMapping); ++i) { 227 for (size_t i = 0; i < arraysize(kPrefMapping); ++i) {
228 registrar_.Add(kPrefMapping[i].browser_pref, this); 228 registrar_.Add(kPrefMapping[i].browser_pref, this);
229 incognito_registrar_.Add(kPrefMapping[i].browser_pref, this); 229 incognito_registrar_.Add(kPrefMapping[i].browser_pref, this);
230 } 230 }
231 } 231 }
232 232
233 ExtensionPreferenceEventRouter::~ExtensionPreferenceEventRouter() { } 233 ExtensionPreferenceEventRouter::~ExtensionPreferenceEventRouter() { }
234 234
235 void ExtensionPreferenceEventRouter::Observe( 235 void ExtensionPreferenceEventRouter::Observe(
236 NotificationType type, 236 int type,
237 const NotificationSource& source, 237 const NotificationSource& source,
238 const NotificationDetails& details) { 238 const NotificationDetails& details) {
239 if (type == NotificationType::PREF_CHANGED) { 239 if (type == chrome::NOTIFICATION_PREF_CHANGED) {
240 const std::string* pref_key = 240 const std::string* pref_key =
241 Details<const std::string>(details).ptr(); 241 Details<const std::string>(details).ptr();
242 OnPrefChanged(Source<PrefService>(source).ptr(), *pref_key); 242 OnPrefChanged(Source<PrefService>(source).ptr(), *pref_key);
243 } else { 243 } else {
244 NOTREACHED(); 244 NOTREACHED();
245 } 245 }
246 } 246 }
247 247
248 void ExtensionPreferenceEventRouter::OnPrefChanged( 248 void ExtensionPreferenceEventRouter::OnPrefChanged(
249 PrefService* pref_service, 249 PrefService* pref_service,
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 pref_key, &browser_pref, &permission)); 470 pref_key, &browser_pref, &permission));
471 if (!GetExtension()->HasAPIPermission(permission)) { 471 if (!GetExtension()->HasAPIPermission(permission)) {
472 error_ = ExtensionErrorUtils::FormatErrorMessage( 472 error_ = ExtensionErrorUtils::FormatErrorMessage(
473 keys::kPermissionErrorMessage, pref_key); 473 keys::kPermissionErrorMessage, pref_key);
474 return false; 474 return false;
475 } 475 }
476 ExtensionPrefs* prefs = profile_->GetExtensionService()->extension_prefs(); 476 ExtensionPrefs* prefs = profile_->GetExtensionService()->extension_prefs();
477 prefs->RemoveExtensionControlledPref(extension_id(), browser_pref, scope); 477 prefs->RemoveExtensionControlledPref(extension_id(), browser_pref, scope);
478 return true; 478 return true;
479 } 479 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_preference_api.h ('k') | chrome/browser/extensions/extension_prefs.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698