Commit 7dbf9517 authored by Toby Huang's avatar Toby Huang Committed by Commit Bot

Expose disable reason blockedByPolicy to chrome://extensions page

This disable reason will be used in a downstream CL to force-disable
the extension enable toggles when the extension state is BLOCKED. This
force-disabling will prevent a regression to crbug/1003014.

Bug: 1033687,1032352
Change-Id: I73788620179026f68a2b72ef9fc72429d7ab62ee
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1975456
Commit-Queue: Toby Huang <tobyhuang@chromium.org>
Reviewed-by: default avatarMichael Giuffrida <michaelpg@chromium.org>
Reviewed-by: default avatarIstiaque Ahmed <lazyboy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#728350}
parent 2c7489ad
......@@ -555,6 +555,8 @@ void ExtensionInfoGenerator::CreateExtensionInfoHelper(
info->disable_reasons.update_required =
(disable_reasons & disable_reason::DISABLE_UPDATE_REQUIRED_BY_POLICY) !=
0;
info->disable_reasons.blocked_by_policy =
(disable_reasons & disable_reason::DISABLE_BLOCKED_BY_POLICY) != 0;
// Error collection.
bool error_console_enabled =
......
......@@ -177,7 +177,8 @@ Polymer({
hasWarnings_: function() {
return this.data.disableReasons.corruptInstall ||
this.data.disableReasons.suspiciousInstall ||
this.data.disableReasons.updateRequired || !!this.data.blacklistText ||
this.data.disableReasons.updateRequired ||
this.data.disableReasons.blockedByPolicy || !!this.data.blacklistText ||
this.data.runtimeWarnings.length > 0;
},
......
......@@ -58,7 +58,8 @@ export function userCanChangeEnablement(item) {
// Item is forcefully disabled.
if (item.disableReasons.corruptInstall ||
item.disableReasons.suspiciousInstall ||
item.disableReasons.updateRequired) {
item.disableReasons.updateRequired ||
item.disableReasons.blockedByPolicy) {
return false;
}
// An item with dependent extensions can't be disabled (it would bork the
......
......@@ -136,6 +136,7 @@ namespace developerPrivate {
boolean suspiciousInstall;
boolean corruptInstall;
boolean updateRequired;
boolean blockedByPolicy;
};
dictionary OptionsPage {
......
......@@ -2,6 +2,7 @@
"dependentExtensions": [ ],
"description": "The first extension that I made.",
"disableReasons": {
"blockedByPolicy": false,
"corruptInstall": false,
"suspiciousInstall": false,
"updateRequired": false
......
......@@ -2,6 +2,7 @@
"dependentExtensions": [ ],
"description": "",
"disableReasons": {
"blockedByPolicy": false,
"corruptInstall": false,
"suspiciousInstall": false,
"updateRequired": false
......
......@@ -2,6 +2,7 @@
"dependentExtensions": [ ],
"description": "",
"disableReasons": {
"blockedByPolicy": false,
"corruptInstall": false,
"suspiciousInstall": false,
"updateRequired": false
......
......@@ -170,6 +170,17 @@ suite(extension_detail_view_tests.suiteName, function() {
expectTrue(testIsVisible('#enableToggle'));
expectFalse(testIsVisible('#terminated-reload-button'));
// This section tests that the enable toggle is visible but disabled when
// disableReasons.blockedByPolicy is true. This test prevents a regression
// to crbug/1003014.
item.set('data.disableReasons.blockedByPolicy', true);
flush();
expectTrue(testIsVisible('#enableToggle'));
expectTrue(item.$$('#enableToggle').disabled);
item.set('data.disableReasons.blockedByPolicy', false);
flush();
item.set('data.state', chrome.developerPrivate.ExtensionState.TERMINATED);
flush();
expectFalse(testIsVisible('#enableToggle'));
......
......@@ -333,6 +333,14 @@ suite(extension_item_tests.suiteName, function() {
item.set('data.state', 'BLACKLISTED');
flush();
expectTrue(item.$['enableToggle'].disabled);
// This section tests that the enable toggle is visible but disabled
// when disableReasons.blockedByPolicy is true. This test prevents a
// regression to crbug/1003014.
item.set('data.disableReasons.blockedByPolicy', true);
flush();
testVisible(item, '#enableToggle', true);
expectTrue(item.$['enableToggle'].disabled);
});
test(assert(extension_item_tests.TestNames.RemoveButton), function() {
......
......@@ -179,6 +179,7 @@ export function createExtensionInfo(opt_properties) {
suspiciousInstall: false,
corruptInstall: false,
updateRequired: false,
blockedByPolicy: false,
},
homePage: {specified: false, url: ''},
iconUrl: 'chrome://extension-icon/' + id + '/24/0',
......
......@@ -181,7 +181,8 @@ chrome.developerPrivate.RuntimeError;
* @typedef {{
* suspiciousInstall: boolean,
* corruptInstall: boolean,
* updateRequired: boolean
* updateRequired: boolean,
* blockedByPolicy: boolean
* }}
*/
chrome.developerPrivate.DisableReasons;
......
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