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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 | 86 |
87 virtual Value* BrowserToExtensionPref(const Value* browser_pref) { | 87 virtual Value* BrowserToExtensionPref(const Value* browser_pref) { |
88 return InvertBooleanValue(browser_pref); | 88 return InvertBooleanValue(browser_pref); |
89 } | 89 } |
90 | 90 |
91 private: | 91 private: |
92 static Value* InvertBooleanValue(const Value* value) { | 92 static Value* InvertBooleanValue(const Value* value) { |
93 bool bool_value = false; | 93 bool bool_value = false; |
94 bool result = value->GetAsBoolean(&bool_value); | 94 bool result = value->GetAsBoolean(&bool_value); |
95 DCHECK(result); | 95 DCHECK(result); |
96 return Value::CreateBooleanValue(!bool_value); | 96 return base::BooleanValue::New(!bool_value); |
97 } | 97 } |
98 }; | 98 }; |
99 | 99 |
100 // Returns a string constant (defined in the API) indicating the level of | 100 // Returns a string constant (defined in the API) indicating the level of |
101 // control this extension has over the specified preference. | 101 // control this extension has over the specified preference. |
102 const char* GetLevelOfControl( | 102 const char* GetLevelOfControl( |
103 Profile* profile, | 103 Profile* profile, |
104 const std::string& extension_id, | 104 const std::string& extension_id, |
105 const std::string& browser_pref, | 105 const std::string& browser_pref, |
106 bool incognito) { | 106 bool incognito) { |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 } |
OLD | NEW |