Index: chrome/browser/resources/settings/prefs/prefs_behavior.js |
diff --git a/chrome/browser/resources/settings/prefs/prefs_behavior.js b/chrome/browser/resources/settings/prefs/prefs_behavior.js |
index 5a4c15d379b9112b08205b1b528a410c0024dc50..8c9446000eff99dfe1d3c4ef2970328a52305880 100644 |
--- a/chrome/browser/resources/settings/prefs/prefs_behavior.js |
+++ b/chrome/browser/resources/settings/prefs/prefs_behavior.js |
@@ -32,4 +32,31 @@ var PrefsBehavior = { |
this.getPref(prefPath); // Ensures we throw if the pref is not found. |
this.set('prefs.' + prefPath + '.value', value); |
}, |
+ |
+ /** |
+ * Appends the item to the pref list at the given key if the item is not |
+ * already in the list. Asserts if the pref itself is not found or is not an |
+ * Array type. |
+ * @param {string} key |
+ * @param {*} item |
+ * @protected |
+ */ |
+ appendPrefListItem: function(key, item) { |
+ var pref = this.getPref(key); |
+ assert(pref && pref.type == chrome.settingsPrivate.PrefType.LIST); |
+ if (pref.value.indexOf(item) == -1) |
+ this.push('prefs.' + key + '.value', item); |
+ }, |
+ |
+ /** |
+ * Deletes the given item from the pref at the given key if the item is found. |
+ * Asserts if the pref itself is not found or is not an Array type. |
+ * @param {string} key |
+ * @param {*} item |
+ * @protected |
+ */ |
+ deletePrefListItem: function(key, item) { |
+ assert(this.getPref(key).type == chrome.settingsPrivate.PrefType.LIST); |
+ this.arrayDelete('prefs.' + key + '.value', item); |
+ }, |
}; |