OLD | NEW |
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 21 matching lines...) Expand all Loading... |
32 const char kControlledByOtherExtensions[] = "ControlledByOtherExtensions"; | 32 const char kControlledByOtherExtensions[] = "ControlledByOtherExtensions"; |
33 const char kControllableByThisExtension[] = "ControllableByThisExtension"; | 33 const char kControllableByThisExtension[] = "ControllableByThisExtension"; |
34 const char kControlledByThisExtension[] = "ControlledByThisExtension"; | 34 const char kControlledByThisExtension[] = "ControlledByThisExtension"; |
35 | 35 |
36 const char kIncognito[] = "incognito"; | 36 const char kIncognito[] = "incognito"; |
37 const char kIncognitoSpecific[] = "incognitoSpecific"; | 37 const char kIncognitoSpecific[] = "incognitoSpecific"; |
38 const char kLevelOfControl[] = "levelOfControl"; | 38 const char kLevelOfControl[] = "levelOfControl"; |
39 const char kValue[] = "value"; | 39 const char kValue[] = "value"; |
40 | 40 |
41 const char kOnPrefChangeFormat[] = | 41 const char kOnPrefChangeFormat[] = |
42 "experimental.preferences.%s.onChange"; | 42 "preferences.%s.onChange"; |
43 | 43 |
44 const char kIncognitoErrorMessage[] = | 44 const char kIncognitoErrorMessage[] = |
45 "You do not have permission to access incognito preferences."; | 45 "You do not have permission to access incognito preferences."; |
46 | 46 |
47 const char kPermissionErrorMessage[] = | 47 const char kPermissionErrorMessage[] = |
48 "You do not have permission to access the preference '%s'. " | 48 "You do not have permission to access the preference '%s'. " |
49 "Be sure to declare in your manifest what permissions you need."; | 49 "Be sure to declare in your manifest what permissions you need."; |
50 | 50 |
51 PrefMappingEntry kPrefMapping[] = { | 51 PrefMappingEntry kPrefMapping[] = { |
52 { "blockThirdPartyCookies", | 52 { "blockThirdPartyCookies", |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
412 PrefMapping::GetInstance()->FindBrowserPrefForExtensionPref( | 412 PrefMapping::GetInstance()->FindBrowserPrefForExtensionPref( |
413 pref_key, &browser_pref, &permission)); | 413 pref_key, &browser_pref, &permission)); |
414 if (!GetExtension()->HasApiPermission(permission)) { | 414 if (!GetExtension()->HasApiPermission(permission)) { |
415 error_ = base::StringPrintf(kPermissionErrorMessage, pref_key.c_str()); | 415 error_ = base::StringPrintf(kPermissionErrorMessage, pref_key.c_str()); |
416 return false; | 416 return false; |
417 } | 417 } |
418 ExtensionPrefs* prefs = profile_->GetExtensionService()->extension_prefs(); | 418 ExtensionPrefs* prefs = profile_->GetExtensionService()->extension_prefs(); |
419 prefs->RemoveExtensionControlledPref(extension_id(), browser_pref, incognito); | 419 prefs->RemoveExtensionControlledPref(extension_id(), browser_pref, incognito); |
420 return true; | 420 return true; |
421 } | 421 } |
OLD | NEW |