Commit 07619eb1 authored by David Tseng's avatar David Tseng Committed by Commit Bot

Clear inapplicable disable reasons for component extensions

This change ensures that all component extensions are allowed to be activated  despite having some inapplicable disable reasons set.

In particular, this fixes any specific observed on-device instances where ChromeVox or tts had a disable reason of blocked by policy which prevented it from being activated.

Bug: 946839,947305
Test: manually. With a device enterprise enrolled, push down kiosk apps to the device from an admin console. Ensure that ChromeVox still works on all screens.
Change-Id: I2cedafeb16d4420702188f1516825ce1bad52802
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1553017
Commit-Queue: David Tseng <dtseng@chromium.org>
Reviewed-by: default avatarDevlin <rdevlin.cronin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#648464}
parent 22e8d717
......@@ -1208,6 +1208,8 @@ void ExtensionService::AddExtension(const Extension* extension) {
}
void ExtensionService::AddComponentExtension(const Extension* extension) {
extension_prefs_->ClearInapplicableDisableReasonsForComponentExtension(
extension->id());
const std::string old_version_string(
extension_prefs_->GetVersionString(extension->id()));
const base::Version old_version(old_version_string);
......
......@@ -17,6 +17,9 @@ namespace disable_reason {
// Also carefully consider if your reason should sync to other devices, and if
// so, add it to kKnownSyncableDisableReasons in
// chrome/browser/extensions/extension_sync_service.cc.
// Finally, consider whether your disable reason applies to component
// extensions. Reference/update the existing list of applicable reasons in
// ExtensionsPrefs::ClearInapplicableDisableReasonsForComponentExtension.
enum DisableReason {
DISABLE_NONE = 0,
DISABLE_USER_ACTION = 1 << 0,
......
......@@ -783,6 +783,22 @@ void ExtensionPrefs::ClearDisableReasons(const std::string& extension_id) {
DISABLE_REASON_CLEAR);
}
void ExtensionPrefs::ClearInapplicableDisableReasonsForComponentExtension(
const std::string& component_extension_id) {
static constexpr int kAllowDisableReasons =
disable_reason::DISABLE_RELOAD |
disable_reason::DISABLE_UNSUPPORTED_REQUIREMENT |
disable_reason::DISABLE_CORRUPTED;
// Some disable reasons incorrectly cause component extensions to never
// activate on load. See https://crbug.com/946839 for more details on why we
// do this.
ModifyDisableReasons(
component_extension_id,
kAllowDisableReasons & GetDisableReasons(component_extension_id),
DISABLE_REASON_REPLACE);
}
void ExtensionPrefs::ModifyDisableReasons(const std::string& extension_id,
int reasons,
DisableReasonChange change) {
......
......@@ -281,6 +281,10 @@ class ExtensionPrefs : public KeyedService {
int disable_reasons);
void ClearDisableReasons(const std::string& extension_id);
// Clears disable reasons that do not apply to component extensions.
void ClearInapplicableDisableReasonsForComponentExtension(
const std::string& component_extension_id);
// Gets the set of extensions that have been blacklisted in prefs. This will
// return only the blocked extensions, not the "greylist" extensions.
// TODO(oleg): Make method names consistent here, in extension service and in
......
......@@ -111,6 +111,7 @@ void ExtensionRegistrar::AddExtension(
void ExtensionRegistrar::AddNewExtension(
scoped_refptr<const Extension> extension) {
if (extension_prefs_->IsExtensionBlacklisted(extension->id())) {
DCHECK(!Manifest::IsComponentLocation(extension->location()));
// Only prefs is checked for the blacklist. We rely on callers to check the
// blacklist before calling into here, e.g. CrxInstaller checks before
// installation then threads through the install and pending install flow
......@@ -118,6 +119,7 @@ void ExtensionRegistrar::AddNewExtension(
// extensions.
registry_->AddBlacklisted(extension);
} else if (delegate_->ShouldBlockExtension(extension.get())) {
DCHECK(!Manifest::IsComponentLocation(extension->location()));
registry_->AddBlocked(extension);
} else if (extension_prefs_->IsExtensionDisabled(extension->id())) {
registry_->AddDisabled(extension);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment