Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(19)

Unified Diff: chrome/browser/resources/options/content_settings_exceptions_area.js

Issue 1963203002: [Chrome Settings UI] Show overruled User Exceptions as strike-through. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move common code to appendIndicatorElement(). Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/options/content_settings_exceptions_area.js
diff --git a/chrome/browser/resources/options/content_settings_exceptions_area.js b/chrome/browser/resources/options/content_settings_exceptions_area.js
index 3ad7ac62a552f0e1079168e4d2c97cf12e4e61c1..2e6eccdde8da98911fa36162bf0abe7cbd4af12b 100644
--- a/chrome/browser/resources/options/content_settings_exceptions_area.js
+++ b/chrome/browser/resources/options/content_settings_exceptions_area.js
@@ -205,14 +205,7 @@ cr.define('options.contentSettings', function() {
if (controlledBy == 'policy' || controlledBy == 'extension') {
this.querySelector('.row-delete-button').hidden = true;
- var indicator = new ControlledSettingIndicator();
- indicator.setAttribute('content-exception', this.contentType);
- // Create a synthetic pref change event decorated as
- // CoreOptionsHandler::CreateValueForPref() does.
- var event = new Event(this.contentType);
- event.value = { controlledBy: controlledBy };
- indicator.handlePrefChange(event);
- this.appendChild(indicator);
+ this.appendIndicatorElement(controlledBy);
}
// If the exception comes from a hosted app, display the name and the
@@ -241,6 +234,22 @@ cr.define('options.contentSettings', function() {
this.addEventListener('commitedit', this.onEditCommitted_);
},
+ /**
+ * Appends an indicator element to the item. Should be called at most once.
+ *
+ * @param {string} controlledBy The source that controls the item.
+ */
+ appendIndicatorElement: function(controlledBy) {
+ var indicator = new ControlledSettingIndicator();
Dan Beam 2016/05/25 00:41:53 can't you just do indicator.controlledBy = contro
huangs 2016/05/25 15:58:50 I'm moving existing code to this routine for reuse
+ indicator.setAttribute('content-exception', this.contentType);
+ // Create a synthetic pref change event decorated as
+ // CoreOptionsHandler::CreateValueForPref() does.
+ var event = new Event(this.contentType);
+ event.value = { controlledBy: controlledBy };
Dan Beam 2016/05/25 00:41:54 no spaces between curlies: { controlledBy: cont
huangs 2016/05/25 15:58:50 Done.
+ indicator.handlePrefChange(event);
+ this.appendChild(indicator);
+ },
+
isEmbeddingRule: function() {
return this.dataItem.embeddingOrigin &&
this.dataItem.embeddingOrigin !== this.dataItem.origin;
@@ -345,6 +354,19 @@ cr.define('options.contentSettings', function() {
settingOption.selected = true;
},
+ /**
+ * Updates UI to indicate that the exception was overruled by a source.
+ *
+ * @param {string} overruledBy The source that overrules the exception.
+ */
+ setOverruledBy: function(overruledBy) {
+ this.classList.toggle('overruled', !!overruledBy);
+ var textElt = this.querySelector('.exception-pattern .static-text');
+ textElt.setAttribute('title',
+ loadTimeData.getString('exceptionDisabledByPolicy'));
+ this.appendIndicatorElement(overruledBy);
+ },
+
/** @override */
get currentInputIsValid() {
return this.inputValidityKnown && this.inputIsValid;
@@ -520,6 +542,20 @@ cr.define('options.contentSettings', function() {
},
/**
+ * Updates UI to indicate that user exceptions were overruled by a source.
+ *
+ * @param {string} overruledBy The source that overrules user exceptions.
+ */
+ setOverruledBy: function(overruledBy) {
+ for (var index = 0; index < this.dataModel.length; ++index) {
+ var item = this.getListItemByIndex(index);
+ if (item.dataItem.source == 'preference') {
Dan Beam 2016/05/25 00:41:53 no curlies
huangs 2016/05/25 15:58:50 Done.
+ item.setOverruledBy(overruledBy);
+ }
+ }
+ },
+
+ /**
* Sets the exceptions in the js model.
*
* @param {Array<options.Exception>} entries A list of dictionaries of

Powered by Google App Engine
This is Rietveld 408576698