| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/scripting_permissions_modifier.h" | 5 #include "chrome/browser/extensions/scripting_permissions_modifier.h" |
| 6 | 6 |
| 7 #include "chrome/browser/extensions/extension_sync_service.h" | 7 #include "chrome/browser/extensions/extension_sync_service.h" |
| 8 #include "chrome/browser/extensions/permissions_updater.h" | 8 #include "chrome/browser/extensions/permissions_updater.h" |
| 9 #include "extensions/browser/extension_prefs.h" | 9 #include "extensions/browser/extension_prefs.h" |
| 10 #include "extensions/browser/extension_registry.h" | 10 #include "extensions/browser/extension_registry.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 } | 51 } |
| 52 | 52 |
| 53 // Sets the preference for whether the extension with |id| is allowed to execute | 53 // Sets the preference for whether the extension with |id| is allowed to execute |
| 54 // on all urls, and, if |by_user| is true, also updates preferences to indicate | 54 // on all urls, and, if |by_user| is true, also updates preferences to indicate |
| 55 // that the user has explicitly set a value (rather than using the default). | 55 // that the user has explicitly set a value (rather than using the default). |
| 56 void SetAllowedOnAllUrlsPref(bool by_user, | 56 void SetAllowedOnAllUrlsPref(bool by_user, |
| 57 bool allowed, | 57 bool allowed, |
| 58 const std::string& id, | 58 const std::string& id, |
| 59 ExtensionPrefs* prefs) { | 59 ExtensionPrefs* prefs) { |
| 60 prefs->UpdateExtensionPref(id, kExtensionAllowedOnAllUrlsPrefName, | 60 prefs->UpdateExtensionPref(id, kExtensionAllowedOnAllUrlsPrefName, |
| 61 new base::FundamentalValue(allowed)); | 61 new base::Value(allowed)); |
| 62 if (by_user) { | 62 if (by_user) { |
| 63 prefs->UpdateExtensionPref(id, kHasSetScriptOnAllUrlsPrefName, | 63 prefs->UpdateExtensionPref(id, kHasSetScriptOnAllUrlsPrefName, |
| 64 new base::FundamentalValue(true)); | 64 new base::Value(true)); |
| 65 } | 65 } |
| 66 } | 66 } |
| 67 | 67 |
| 68 } // namespace | 68 } // namespace |
| 69 | 69 |
| 70 ScriptingPermissionsModifier::ScriptingPermissionsModifier( | 70 ScriptingPermissionsModifier::ScriptingPermissionsModifier( |
| 71 content::BrowserContext* browser_context, | 71 content::BrowserContext* browser_context, |
| 72 const scoped_refptr<const Extension>& extension) | 72 const scoped_refptr<const Extension>& extension) |
| 73 : browser_context_(browser_context), | 73 : browser_context_(browser_context), |
| 74 extension_(extension), | 74 extension_(extension), |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 | 302 |
| 303 void ScriptingPermissionsModifier::CleanUpPrefsIfNecessary() { | 303 void ScriptingPermissionsModifier::CleanUpPrefsIfNecessary() { |
| 304 // From a bug, some extensions such as policy extensions could have the | 304 // From a bug, some extensions such as policy extensions could have the |
| 305 // preference set even if it should have been impossible. Reset the prefs to | 305 // preference set even if it should have been impossible. Reset the prefs to |
| 306 // a sane state. | 306 // a sane state. |
| 307 // See crbug.com/629927 | 307 // See crbug.com/629927 |
| 308 // TODO(devlin): Remove this in M56. | 308 // TODO(devlin): Remove this in M56. |
| 309 DCHECK(ExtensionMustBeAllowedOnAllUrls(*extension_)); | 309 DCHECK(ExtensionMustBeAllowedOnAllUrls(*extension_)); |
| 310 extension_prefs_->UpdateExtensionPref(extension_->id(), | 310 extension_prefs_->UpdateExtensionPref(extension_->id(), |
| 311 kExtensionAllowedOnAllUrlsPrefName, | 311 kExtensionAllowedOnAllUrlsPrefName, |
| 312 new base::FundamentalValue(true)); | 312 new base::Value(true)); |
| 313 extension_prefs_->UpdateExtensionPref( | 313 extension_prefs_->UpdateExtensionPref( |
| 314 extension_->id(), kHasSetScriptOnAllUrlsPrefName, nullptr); | 314 extension_->id(), kHasSetScriptOnAllUrlsPrefName, nullptr); |
| 315 } | 315 } |
| 316 | 316 |
| 317 } // namespace extensions | 317 } // namespace extensions |
| OLD | NEW |