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..f7d50b5f8a63bdf02e0a5723998f473951422ea9 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,26 @@ 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']); |
arv (Not doing code reviews)
2010/12/21 00:34:27
push takes var args
args.push(ataItem['origin'],
Evan Stade
2010/12/21 02:09:00
Done.
|
+ args.push(dataItem['embeddingOrigin']); |
+ } else if (listItem.contentType == 'notifications') { |
+ args.push(dataItem['origin']); |
+ args.push(dataItem['setting']); |
+ } else { |
+ args.push(listItem.mode); |
+ args.push(listItem.pattern); |
} |
- chrome.send('removeExceptions', args); |
+ chrome.send('removeException', args); |
}, |
/** |
@@ -545,9 +545,70 @@ cr.define('options.contentSettings', function() { |
} |
}; |
+ var OptionsPage = options.OptionsPage; |
+ |
+ function ContentSettingsExceptionsArea() { |
arv (Not doing code reviews)
2010/12/21 00:34:27
JSDoc?
Evan Stade
2010/12/21 02:09:00
Done.
|
+ OptionsPage.call(this, 'contentExceptions', |
+ '', 'contentSettingsExceptionsArea'); |
+ } |
+ |
+ cr.addSingletonGetter(ContentSettingsExceptionsArea); |
+ |
+ 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 = eval('templateData.' + type + '_header'); |
arv (Not doing code reviews)
2010/12/21 00:34:27
Do not use eval
object.foo is just syntactic suga
Evan Stade
2010/12/21 02:09:00
Done.
|
+ |
+ 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, |
}; |
}); |