Chromium Code Reviews| 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 7d63dee77b7622080903bcccdf624cae624f2f6c..58a4feae351d9747cc4e47b298f3cf85d5914645 100644 |
| --- a/chrome/browser/resources/options/content_settings_exceptions_area.js |
| +++ b/chrome/browser/resources/options/content_settings_exceptions_area.js |
| @@ -21,7 +21,26 @@ cr.define('options.contentSettings', function() { |
| contentType == 'media-stream-mic' || |
| contentType == 'media-stream-camera' || |
| contentType == 'midi-sysex' || |
| - contentType == 'zoomlevels'); |
| + contentType == 'zoomlevels' || |
| + IsChosenObjectType(contentType)); |
| + } |
| + |
| + /** |
| + * Returns whether exceptions of this type represent chosen objects. |
| + * |
| + * @param {string} contentType The type of the list. |
| + */ |
| + function IsChosenObjectType(contentType) { |
| + return contentType == 'usb-devices'; |
| + } |
| + |
| + function ValueColumnForContentType(contentType) { |
| + if (contentType == 'usb-devices') |
| + return 'exception-usb-device-column'; |
| + else if (contentType == 'zoomlevels') |
|
Bernhard Bauer
2015/11/16 12:53:30
Else is not necessary if the previous branch retur
Reilly Grant (use Gerrit)
2015/11/16 22:18:27
Done.
|
| + return 'exception-zoom-column'; |
| + else |
| + return 'exception-behavior-column'; |
| } |
| /** |
| @@ -114,12 +133,14 @@ cr.define('options.contentSettings', function() { |
| this.editable = false; |
| } |
| - if (this.contentType != 'zoomlevels') { |
| + if (this.contentType != 'zoomlevels' && |
| + !IsChosenObjectType(this.contentType)) { |
| this.addEditField(select, this.settingLabel); |
| this.contentElement.appendChild(select); |
| } |
| select.className = 'exception-setting'; |
| - select.setAttribute('aria-labelledby', 'exception-behavior-column'); |
| + select.setAttribute('aria-labelledby', |
| + ValueColumnForContentType(this.contentType)); |
| if (this.pattern) |
| select.setAttribute('displaymode', 'edit'); |
| @@ -131,11 +152,22 @@ cr.define('options.contentSettings', function() { |
| zoomLabel.textContent = this.dataItem.zoom; |
| zoomLabel.className = 'exception-setting'; |
| zoomLabel.setAttribute('displaymode', 'static'); |
| - zoomLabel.setAttribute('aria-labelledby', 'exception-zoom-column'); |
| this.contentElement.appendChild(zoomLabel); |
| this.zoomLabel = zoomLabel; |
| } |
| + if (IsChosenObjectType(this.contentType) && |
| + this.dataItem.hasOwnProperty('object')) { |
|
Bernhard Bauer
2015/11/16 12:53:30
I don't think you need to work around any Javascri
Reilly Grant (use Gerrit)
2015/11/16 22:18:27
Done.
|
| + this.deletable = true; |
| + |
| + var objectLabel = cr.doc.createElement('span'); |
| + objectLabel.textContent = this.dataItem.objectName; |
| + objectLabel.className = 'exception-setting'; |
| + objectLabel.setAttribute('displaymode', 'static'); |
| + this.contentElement.appendChild(objectLabel); |
| + this.objectLabel = objectLabel; |
| + } |
| + |
| // Used to track whether the URL pattern in the input is valid. |
| // This will be true if the browser process has informed us that the |
| // current text in the input is valid. Changing the text resets this to |
| @@ -549,10 +581,18 @@ cr.define('options.contentSettings', function() { |
| return; |
| var dataItem = listItem.dataItem; |
| - chrome.send('removeException', [listItem.contentType, |
| - listItem.mode, |
| - dataItem.origin, |
| - dataItem.embeddingOrigin]); |
| + if (IsChosenObjectType(this.contentType)) { |
| + chrome.send('removeException', [listItem.contentType, |
| + listItem.mode, |
| + dataItem.origin, |
| + dataItem.embeddingOrigin, |
| + dataItem.object]); |
| + } else { |
| + chrome.send('removeException', [listItem.contentType, |
| + listItem.mode, |
| + dataItem.origin, |
| + dataItem.embeddingOrigin]); |
| + } |
| }, |
| }; |
| @@ -617,8 +657,9 @@ cr.define('options.contentSettings', function() { |
| divs[i].hidden = true; |
| } |
| - $('exception-behavior-column').hidden = type == 'zoomlevels'; |
| - $('exception-zoom-column').hidden = type != 'zoomlevels'; |
| + var valueColumnId = ValueColumnForContentType(type); |
| + this.pageDiv.querySelectorAll('div.exception-value-column-header') |
| + .forEach(function(div) { div.hidden = (div.id != valueColumnId); }); |
|
Bernhard Bauer
2015/11/16 12:53:30
Move the code inside the loop to a new line?
Reilly Grant (use Gerrit)
2015/11/16 22:18:27
Done.
|
| }, |
| /** |