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 df0f5e09aaf29a4bc72abe3bce5a78427e3ae6df..c3e43a307c2950abba5c781675e0211e8c6ef6e6 100644 |
| --- a/chrome/browser/resources/options/content_settings_exceptions_area.js |
| +++ b/chrome/browser/resources/options/content_settings_exceptions_area.js |
| @@ -309,8 +309,10 @@ cr.define('options.contentSettings', function() { |
| this.pattern = newPattern; |
| this.setting = newSetting; |
| + // TODO(estade): this will need to be updated if geolocation/notifications |
| + // become editable. |
| if (oldPattern != newPattern) { |
| - chrome.send('removeExceptions', |
| + chrome.send('removeException', |
| [this.contentType, this.mode, oldPattern]); |
| } |
| @@ -401,7 +403,16 @@ cr.define('options.contentSettings', function() { |
| decorate: function() { |
| DeletableItemList.prototype.decorate.call(this); |
| - this.contentType = this.parentNode.getAttribute('contentType'); |
| + this.classList.add('framed-list'); |
| + |
| + for (var parentNode = this.parentNode; parentNode; |
| + parentNode = parentNode.parentNode) { |
| + if (parentNode.hasAttribute('contentType')) { |
| + this.contentType = parentNode.getAttribute('contentType'); |
| + break; |
| + } |
| + } |
| + |
| this.mode = this.getAttribute('mode'); |
| var exceptionList = this; |
| @@ -502,37 +513,22 @@ cr.define('options.contentSettings', function() { |
| /** @inheritDoc */ |
| deleteItemAtIndex: function(index) { |
| var listItem = this.getListItemByIndex(index).contentItem; |
| + |
| if (listItem.undeletable) { |
| console.log('Tried to delete an undeletable row.'); |
| return; |
| } |
| - chrome.send( |
| - 'removeExceptions', |
| - [listItem.contentType, listItem.mode, listItem.pattern]); |
| - }, |
| - /** |
| - * Removes all selected rows from browser's model. |
| - */ |
| - removeSelectedRows: function() { |
| - // The first member is the content type; the rest of the values describe |
| - // the patterns we are removing. |
| - var args = [this.contentType]; |
| - var selectedItems = this.selectedItems; |
| - for (var i = 0; i < selectedItems.length; i++) { |
| - if (this.contentType == 'location') { |
| - args.push(selectedItems[i]['origin']); |
| - args.push(selectedItems[i]['embeddingOrigin']); |
| - } else if (this.contentType == 'notifications') { |
| - args.push(selectedItems[i]['origin']); |
| - args.push(selectedItems[i]['setting']); |
| - } else { |
| - args.push(this.mode); |
| - args.push(selectedItems[i]['displayPattern']); |
| - } |
| - } |
| + var dataItem = listItem.dataItem; |
| + var args = [listItem.contentType]; |
| + if (listItem.contentType == 'location') |
| + args.push(dataItem['origin'], dataItem['embeddingOrigin']); |
| + else if (listItem.contentType == 'notifications') |
| + args.push(dataItem['origin'], dataItem['setting']); |
| + else |
| + args.push(listItem.mode, listItem.pattern); |
| - chrome.send('removeExceptions', args); |
| + chrome.send('removeException', args); |
| }, |
| /** |
| @@ -545,9 +541,74 @@ cr.define('options.contentSettings', function() { |
| } |
| }; |
| + var OptionsPage = options.OptionsPage; |
| + |
| + function ContentSettingsExceptionsArea() { |
| + OptionsPage.call(this, 'contentExceptions', |
| + '', 'contentSettingsExceptionsArea'); |
| + } |
| + |
| + cr.addSingletonGetter(ContentSettingsExceptionsArea); |
| + |
| + /** |
| + * Encapsulated handling of content settings list subpage. |
|
arv (Not doing code reviews)
2010/12/21 19:08:54
This goes on the ContentSettingsExceptionArea func
Evan Stade
2010/12/21 19:54:08
Done.
|
| + * @constructor |
| + */ |
| + ContentSettingsExceptionsArea.prototype = { |
| + __proto__: OptionsPage.prototype, |
| + |
| + initializePage: function() { |
| + OptionsPage.prototype.initializePage.call(this); |
| + |
| + var exceptionsLists = this.pageDiv.querySelectorAll('list'); |
| + for (var i = 0; i < exceptionsLists.length; i++) { |
| + options.contentSettings.ExceptionsList.decorate(exceptionsLists[i]); |
| + } |
| + |
| + ContentSettingsExceptionsArea.hideOTRLists(); |
| + }, |
| + |
| + /** |
| + * Shows one list and hides all others. |
| + * @param {string} type The content type. |
| + */ |
| + showList: function(type) { |
| + var header = this.pageDiv.querySelector('h1'); |
| + header.textContent = templateData[type + '_header']); |
| + |
| + var divs = this.pageDiv.querySelectorAll('div[contentType]'); |
| + for (var i = 0; i < divs.length; i++) { |
| + if (divs[i].getAttribute('contentType') == type) |
| + divs[i].classList.remove('hidden'); |
| + else |
| + divs[i].classList.add('hidden'); |
| + } |
| + }, |
| + }; |
| + |
| + /** |
| + * Called when the last incognito window is closed. |
| + */ |
| + ContentSettingsExceptionsArea.OTRProfileDestroyed = function() { |
| + this.hideOTRLists(); |
| + }; |
| + |
| + /** |
| + * Clears and hides the incognito exceptions lists. |
| + */ |
| + ContentSettingsExceptionsArea.hideOTRLists = function() { |
| + var otrLists = document.querySelectorAll('list[mode=otr]'); |
| + |
| + for (var i = 0; i < otrLists.length; i++) { |
| + otrLists[i].reset(); |
| + otrLists[i].parentNode.classList.add('hidden'); |
| + } |
| + }; |
| + |
| return { |
| ExceptionsListItem: ExceptionsListItem, |
| ExceptionsAddRowListItem: ExceptionsAddRowListItem, |
| ExceptionsList: ExceptionsList, |
| + ContentSettingsExceptionsArea: ContentSettingsExceptionsArea, |
| }; |
| }); |