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

Unified Diff: chrome/browser/resources/options2/pref_ui.js

Issue 9296038: [uber] Redoing the homepage selection UI (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 10 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/options2/pref_ui.js
diff --git a/chrome/browser/resources/options2/pref_ui.js b/chrome/browser/resources/options2/pref_ui.js
index cbe3bd4895281f5e0db3ad32170f805e46f1623c..efb866ef9b08b9b2a3d7d4d7b3767db932774679 100644
--- a/chrome/browser/resources/options2/pref_ui.js
+++ b/chrome/browser/resources/options2/pref_ui.js
@@ -611,6 +611,29 @@ cr.define('options', function() {
// Set up the prototype chain
__proto__: HTMLInputElement.prototype,
+ prefValue_: null,
+
+ savePrefState: function() {
+ switch(this.dataType) {
+ case 'number':
+ Preferences.setIntegerPref(this.pref, this.value, this.metric);
+ break;
+ case 'double':
+ Preferences.setDoublePref(this.pref, this.value, this.metric);
+ break;
+ case 'url':
+ Preferences.setURLPref(this.pref, this.value, this.metric);
+ break;
+ default:
+ Preferences.setStringPref(this.pref, this.value, this.metric);
+ break;
+ }
+ },
+
+ resetPrefState: function() {
+ this.value = this.prefValue_;
+ },
+
/**
* Initialization function for the cr.ui framework.
*/
@@ -624,26 +647,16 @@ cr.define('options', function() {
event.value['value'] : event.value;
updateElementState_(self, event);
+
+ self.prefValue_ = self.value;
});
// Listen to user events.
- this.addEventListener('change',
- function(e) {
- switch(self.dataType) {
- case 'number':
- Preferences.setIntegerPref(self.pref, self.value, self.metric);
- break;
- case 'double':
- Preferences.setDoublePref(self.pref, self.value, self.metric);
- break;
- case 'url':
- Preferences.setURLPref(self.pref, self.value, self.metric);
- break;
- default:
- Preferences.setStringPref(self.pref, self.value, self.metric);
- break;
- }
- });
+ if (!self.dialogPref) {
+ this.addEventListener('change', function(e) {
+ self.savePrefState.bind(self);
+ });
+ }
window.addEventListener('unload',
function() {
« no previous file with comments | « chrome/browser/resources/options2/options_page.css ('k') | chrome/browser/resources/options2/settings_dialog.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698