Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2921)

Unified Diff: chrome/browser/resources/options/autofill_options_list.js

Issue 6930037: Autofill DOMUI Prefs should work with i18n phone numbers (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Adding DEPS. Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/options/autofill_options_list.js
diff --git a/chrome/browser/resources/options/autofill_options_list.js b/chrome/browser/resources/options/autofill_options_list.js
index 61f563d800c07e7d2542cdbdc18e6849882b3cd3..3fadeab5ae1240efba55fc4c0aeda24a1d5814c3 100644
--- a/chrome/browser/resources/options/autofill_options_list.js
+++ b/chrome/browser/resources/options/autofill_options_list.js
@@ -125,7 +125,7 @@ cr.define('options.autofillOptions', function() {
if (this.input.value &&
this.list.dataModel.indexOf(this.input.value) == -1) {
// Update with new value.
- this.list.dataModel.splice(i, 1, this.input.value);
+ this.list.validateAndSave(i, 1, this.input.value);
} else {
// Reject empty values and duplicates.
this.list.dataModel.splice(i, 1);
@@ -174,7 +174,7 @@ cr.define('options.autofillOptions', function() {
if (this.input.value &&
this.list.dataModel.indexOf(this.input.value) == -1) {
- this.list.dataModel.splice(i, 0, this.input.value);
+ this.list.validateAndSave(i, 0, this.input.value);
} else {
this.input.value = '';
this.list.dataModel.updateIndex(i);
@@ -303,6 +303,69 @@ cr.define('options.autofillOptions', function() {
deleteItemAtIndex: function(index) {
this.dataModel.splice(index, 1);
},
+
+ /**
+ * Called when a new list item should be validated; subclasses are
+ * responsible for implementing if validation is required.
+ * @param {number} index The index of the item that was inserted or changed.
+ * @param {number} remove The number items to remove.
+ * @param {string} value The value of the item to insert.
+ */
+ validateAndSave: function(index, remove, value) {
+ this.dataModel.splice(index, remove, value);
+ },
+ };
+
+ /**
+ * Create a new value list for phone number validation.
+ * @constructor
+ * @extends {options.AutofillValuesList}
+ */
+ var AutofillPhoneValuesList = cr.ui.define('list');
+
+ AutofillPhoneValuesList.prototype = {
+ __proto__: AutofillValuesList.prototype,
+
+ decorate: function() {
+ AutofillValuesList.prototype.decorate.call(this);
+ },
+
+ /** @inheritDoc */
+ validateAndSave: function(index, remove, value) {
+ var numbers = this.dataModel.slice(0, this.dataModel.length - 1);
+ numbers.splice(index, remove, value);
+ var info = new Array();
+ info[0] = index;
+ info[1] = numbers;
+ info[2] = $('country').value;
+ chrome.send('validatePhoneNumbers', info);
+ },
+ };
+
+ /**
+ * Create a new value list for fax number validation.
+ * @constructor
+ * @extends {options.AutofillValuesList}
+ */
+ var AutofillFaxValuesList = cr.ui.define('list');
+
+ AutofillFaxValuesList.prototype = {
+ __proto__: AutofillValuesList.prototype,
+
+ decorate: function() {
+ AutofillValuesList.prototype.decorate.call(this);
+ },
+
+ /** @inheritDoc */
+ validateAndSave: function(index, remove, value) {
+ var numbers = this.dataModel.slice(0, this.dataModel.length - 1);
+ numbers.splice(index, remove, value);
+ var info = new Array();
+ info[0] = index;
+ info[1] = numbers;
+ info[2] = $('country').value;
+ chrome.send('validateFaxNumbers', info);
+ },
};
return {
@@ -313,5 +376,7 @@ cr.define('options.autofillOptions', function() {
AutofillAddressList: AutofillAddressList,
AutofillCreditCardList: AutofillCreditCardList,
AutofillValuesList: AutofillValuesList,
+ AutofillPhoneValuesList: AutofillPhoneValuesList,
+ AutofillFaxValuesList: AutofillFaxValuesList,
};
});

Powered by Google App Engine
This is Rietveld 408576698