diff options
author | binjin <binjin@chromium.org> | 2014-11-18 04:10:24 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-11-18 12:10:54 +0000 |
commit | 47947f841e18fa93ff2ec76ab731a57965dc98ec (patch) | |
tree | 85ae503334f2a9187872a83bbf9dcbecefe7b157 /extensions | |
parent | b8dde40da782604227baee3cd28c774920a13470 (diff) | |
download | chromium_src-47947f841e18fa93ff2ec76ab731a57965dc98ec.zip chromium_src-47947f841e18fa93ff2ec76ab731a57965dc98ec.tar.gz chromium_src-47947f841e18fa93ff2ec76ab731a57965dc98ec.tar.bz2 |
Add more management policy checking after extension installed
This CL adds checking for MustRemainDisabled() from management policy after an extension is installed or updated, so that extensions supposed to be disabled will be disabled initially with proper disabled reason set.
This CL also assumes that all disabled extension comes with proper disabled reason, so there are additional changes to ensure this.
1) Another extension disabled reason DISABLE_EXTERNAL_EXTENSION is added for external extensions. These extensions will be disabled initially on windows for user prompting.
2) Two tests from extension_disabled_ui_browsertest.cc is removed since these two tests are meant for legacy disables with not disabled reason set in user pref, which should be rarely seen now. And these rare cases are handled by presuming it's disabled by user action as well.
BUG=None
Review URL: https://codereview.chromium.org/714133002
Cr-Commit-Position: refs/heads/master@{#304587}
Diffstat (limited to 'extensions')
-rw-r--r-- | extensions/browser/extension_prefs.cc | 23 | ||||
-rw-r--r-- | extensions/browser/extension_prefs.h | 7 | ||||
-rw-r--r-- | extensions/common/extension.h | 4 |
3 files changed, 21 insertions, 13 deletions
diff --git a/extensions/browser/extension_prefs.cc b/extensions/browser/extension_prefs.cc index 4d476f5..dc91d2e 100644 --- a/extensions/browser/extension_prefs.cc +++ b/extensions/browser/extension_prefs.cc @@ -746,31 +746,36 @@ bool ExtensionPrefs::HasDisableReason( void ExtensionPrefs::AddDisableReason(const std::string& extension_id, Extension::DisableReason disable_reason) { - ModifyDisableReason(extension_id, disable_reason, DISABLE_REASON_ADD); + ModifyDisableReasons(extension_id, disable_reason, DISABLE_REASON_ADD); +} + +void ExtensionPrefs::AddDisableReasons(const std::string& extension_id, + int disable_reasons) { + ModifyDisableReasons(extension_id, disable_reasons, DISABLE_REASON_ADD); } void ExtensionPrefs::RemoveDisableReason( const std::string& extension_id, Extension::DisableReason disable_reason) { - ModifyDisableReason(extension_id, disable_reason, DISABLE_REASON_REMOVE); + ModifyDisableReasons(extension_id, disable_reason, DISABLE_REASON_REMOVE); } void ExtensionPrefs::ClearDisableReasons(const std::string& extension_id) { - ModifyDisableReason( - extension_id, Extension::DISABLE_NONE, DISABLE_REASON_CLEAR); + ModifyDisableReasons(extension_id, Extension::DISABLE_NONE, + DISABLE_REASON_CLEAR); } -void ExtensionPrefs::ModifyDisableReason(const std::string& extension_id, - Extension::DisableReason reason, - DisableReasonChange change) { +void ExtensionPrefs::ModifyDisableReasons(const std::string& extension_id, + int reasons, + DisableReasonChange change) { int old_value = GetDisableReasons(extension_id); int new_value = old_value; switch (change) { case DISABLE_REASON_ADD: - new_value |= static_cast<int>(reason); + new_value |= reasons; break; case DISABLE_REASON_REMOVE: - new_value &= ~static_cast<int>(reason); + new_value &= ~reasons; break; case DISABLE_REASON_CLEAR: new_value = Extension::DISABLE_NONE; diff --git a/extensions/browser/extension_prefs.h b/extensions/browser/extension_prefs.h index cdfb278..91a8dab8a 100644 --- a/extensions/browser/extension_prefs.h +++ b/extensions/browser/extension_prefs.h @@ -262,6 +262,7 @@ class ExtensionPrefs : public ExtensionScopedPrefs, public KeyedService { Extension::DisableReason disable_reason) const; void AddDisableReason(const std::string& extension_id, Extension::DisableReason disable_reason); + void AddDisableReasons(const std::string& extension_id, int disable_reasons); void RemoveDisableReason(const std::string& extension_id, Extension::DisableReason disable_reason); void ClearDisableReasons(const std::string& extension_id); @@ -601,9 +602,9 @@ class ExtensionPrefs : public ExtensionScopedPrefs, public KeyedService { // existing reason, or clear all reasons. Notifies observers if the set of // DisableReasons has changed. // If |change| is DISABLE_REASON_CLEAR, then |reason| is ignored. - void ModifyDisableReason(const std::string& extension_id, - Extension::DisableReason reason, - DisableReasonChange change); + void ModifyDisableReasons(const std::string& extension_id, + int reasons, + DisableReasonChange change); // Fix missing preference entries in the extensions that are were introduced // in a later Chrome version. diff --git a/extensions/common/extension.h b/extensions/common/extension.h index 4c76478..391c7e5 100644 --- a/extensions/common/extension.h +++ b/extensions/common/extension.h @@ -102,7 +102,9 @@ class Extension : public base::RefCountedThreadSafe<Extension> { DISABLE_REMOTE_INSTALL = 1 << 11, DISABLE_INACTIVE_EPHEMERAL_APP = 1 << 12, // Cached ephemeral apps are // disabled to prevent activity. - DISABLE_REASON_LAST = 1 << 13, // This should always be the last value + DISABLE_EXTERNAL_EXTENSION = 1 << 13, // External extensions might be + // disabled for user prompting. + DISABLE_REASON_LAST = 1 << 14, // This should always be the last value }; // A base class for parsed manifest data that APIs want to store on |