summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/app/generated_resources.grd3
-rw-r--r--chrome/browser/dom_ui/options/content_settings_handler.cc39
-rw-r--r--chrome/browser/resources/options/content_settings_exceptions_area.js35
3 files changed, 35 insertions, 42 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index 38d07a7..87009de 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -4970,6 +4970,9 @@ Keep your key file in a safe place. You will need it to create new versions of y
<message name="IDS_EXCEPTIONS_OTR_LABEL" desc="A label informing the user that the table below the label shows incognito-only exceptions">
Exceptions below only apply to the current incognito session.
</message>
+ <message translateable="false" name="IDS_EXCEPTIONS_PATTERN_EXAMPLE" desc="Placeholder text when the user adds a new exception" >
+ [*.]example.com
+ </message>
<message name="IDS_EXCEPTIONS_NOT_SET_BUTTON" desc="A label to display in the exception page's action column when a site's content setting has not yet been set for a given domain.">
Not set
</message>
diff --git a/chrome/browser/dom_ui/options/content_settings_handler.cc b/chrome/browser/dom_ui/options/content_settings_handler.cc
index 2a21f27..f3b21f54 100644
--- a/chrome/browser/dom_ui/options/content_settings_handler.cc
+++ b/chrome/browser/dom_ui/options/content_settings_handler.cc
@@ -175,6 +175,8 @@ void ContentSettingsHandler::GetLocalizedValues(
l10n_util::GetStringUTF16(IDS_EXCEPTIONS_EDIT_BUTTON));
localized_strings->SetString("otr_exceptions_explanation",
l10n_util::GetStringUTF16(IDS_EXCEPTIONS_OTR_LABEL));
+ localized_strings->SetString("examplePattern",
+ l10n_util::GetStringUTF16(IDS_EXCEPTIONS_PATTERN_EXAMPLE));
// Cookies filter.
localized_strings->SetString("cookies_tab_label",
@@ -278,37 +280,22 @@ void ContentSettingsHandler::Initialize() {
notification_registrar_.Add(
this, NotificationType::CONTENT_SETTINGS_CHANGED,
Source<const HostContentSettingsMap>(settings_map));
- notification_registrar_.Add(
- this, NotificationType::GEOLOCATION_SETTINGS_CHANGED,
- NotificationService::AllSources());
}
void ContentSettingsHandler::Observe(NotificationType type,
const NotificationSource& source,
const NotificationDetails& details) {
- switch (type.value) {
- case NotificationType::CONTENT_SETTINGS_CHANGED: {
- const ContentSettingsDetails* settings_details =
- static_cast<Details<const ContentSettingsDetails> >(details).ptr();
-
- // TODO(estade): we pretend update_all() is always true.
- if (settings_details->update_all_types())
- UpdateAllExceptionsViewsFromModel();
- else
- UpdateExceptionsViewFromModel(settings_details->type());
- break;
- }
- case NotificationType::GEOLOCATION_SETTINGS_CHANGED: {
- UpdateGeolocationExceptionsView();
- break;
- }
- case NotificationType::DESKTOP_NOTIFICATION_SETTINGS_CHANGED: {
- UpdateNotificationExceptionsView();
- break;
- }
- default:
- OptionsPageUIHandler::Observe(type, source, details);
- }
+ if (type != NotificationType::CONTENT_SETTINGS_CHANGED)
+ return OptionsPageUIHandler::Observe(type, source, details);
+
+ const ContentSettingsDetails* settings_details =
+ static_cast<Details<const ContentSettingsDetails> >(details).ptr();
+
+ // TODO(estade): we pretend update_all() is always true.
+ if (settings_details->update_all_types())
+ UpdateAllExceptionsViewsFromModel();
+ else
+ UpdateExceptionsViewFromModel(settings_details->type());
}
void ContentSettingsHandler::UpdateSettingDefaultFromModel(
diff --git a/chrome/browser/resources/options/content_settings_exceptions_area.js b/chrome/browser/resources/options/content_settings_exceptions_area.js
index 1273967..f570706 100644
--- a/chrome/browser/resources/options/content_settings_exceptions_area.js
+++ b/chrome/browser/resources/options/content_settings_exceptions_area.js
@@ -13,7 +13,8 @@ cr.define('options.contentSettings', function() {
* @param {string} mode The browser mode, 'otr' or 'normal'.
* @param {boolean} enableAskOption Whether to show an 'ask every time'
* option in the select.
- * @param {Array} exception A pair of the form [filter, setting].
+ * @param {Object} exception A dictionary that contains the data of the
+ * exception.
* @constructor
* @extends {cr.ui.ListItem}
*/
@@ -100,6 +101,8 @@ cr.define('options.contentSettings', function() {
this.optionBlock = optionBlock;
this.updateEditables();
+ if (!this.pattern)
+ input.value = templateData.examplePattern;
var listItem = this;
this.ondblclick = function(event) {
@@ -125,7 +128,7 @@ cr.define('options.contentSettings', function() {
// Reset the inputs.
listItem.updateEditables();
if (listItem.pattern)
- listItem.maybeSetPatternValidity(listItem.pattern, true);
+ listItem.maybeSetPatternValid(listItem.pattern, true);
case 'Enter':
if (listItem.parentNode)
listItem.parentNode.focus();
@@ -216,9 +219,6 @@ cr.define('options.contentSettings', function() {
* Copy the data model values to the editable nodes.
*/
updateEditables: function() {
- if (!(this.pattern && this.setting))
- return;
-
this.input.value = this.pattern;
if (this.setting == 'allow')
@@ -255,18 +255,18 @@ cr.define('options.contentSettings', function() {
var optionSession = this.optionSession;
var optionAsk = this.optionAsk;
+ // Just delete this row if it was added via the Add button.
+ if (!editing && !pattern && !input.value) {
+ var model = listItem.parentNode.dataModel;
+ model.splice(model.indexOf(listItem.dataItem), 1);
+ return;
+ }
+
// Check that we have a valid pattern and if not we do not change the
// editing mode.
if (!editing && (!this.inputValidityKnown || !this.inputIsValid)) {
- if (this.pattern) {
- input.focus();
- input.select();
- } else {
- // Just delete this row if it was added via the Add button.
- var model = listItem.parentNode.dataModel;
- model.splice(model.indexOf(listItem.dataItem), 1);
- }
-
+ input.focus();
+ input.select();
return;
}
@@ -350,7 +350,7 @@ cr.define('options.contentSettings', function() {
/**
* Adds an exception to the js model.
- * @param {Array} entry A pair of the form [filter, setting].
+ * @param {Object} entry A dictionary of values for the exception.
*/
addException: function(entry) {
this.dataModel.push(entry);
@@ -445,7 +445,10 @@ cr.define('options.contentSettings', function() {
this.appendChild(addRow);
addRow.onclick = function(event) {
- self.exceptionsList.addException(['', '']);
+ var emptyException = new Object;
+ emptyException.displayPattern = '';
+ emptyException.setting = '';
+ self.exceptionsList.addException(emptyException);
};
var editRow = cr.doc.createElement('button');