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

Side by Side Diff: chrome/browser/resources/options/hotword_confirm_dialog.js

Issue 426723004: options: Remove a bunch of useless: (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 cr.define('options', function() { 5 cr.define('options', function() {
6 /** @const */ var ConfirmDialog = options.ConfirmDialog; 6 /** @const */ var ConfirmDialog = options.ConfirmDialog;
7 /** @const */ var SettingsDialog = options.SettingsDialog; 7 /** @const */ var SettingsDialog = options.SettingsDialog;
8 /** @const */ var OptionsPage = options.OptionsPage; 8 /** @const */ var OptionsPage = options.OptionsPage;
9 9
10 /** 10 /**
(...skipping 13 matching lines...) Expand all
24 'hotword-confirm-overlay', // pageDivName 24 'hotword-confirm-overlay', // pageDivName
25 $('hotword-confirm-ok'), // okButton 25 $('hotword-confirm-ok'), // okButton
26 $('hotword-confirm-cancel'), // cancelButton 26 $('hotword-confirm-cancel'), // cancelButton
27 $('hotword-search-enable').pref, // pref 27 $('hotword-search-enable').pref, // pref
28 $('hotword-search-enable').metric); // metric 28 $('hotword-search-enable').metric); // metric
29 29
30 this.indicator = $('hotword-search-setting-indicator'); 30 this.indicator = $('hotword-search-setting-indicator');
31 } 31 }
32 32
33 HotwordConfirmDialog.prototype = { 33 HotwordConfirmDialog.prototype = {
34 // Set up the prototype chain 34 // TODO(dbeam): this class should probably derive SettingsDialog again as it
35 // evily duplicates much of ConfirmDialog's functionality, calls methods
36 // on SettingsDialog.prototype, and shadows private method names.
35 __proto__: ConfirmDialog.prototype, 37 __proto__: ConfirmDialog.prototype,
36 38
37 /** 39 /**
38 * Handle changes to |pref|. Only uncommitted changes are relevant as these 40 * Handle changes to |pref|. Only uncommitted changes are relevant as these
39 * originate from user and need to be explicitly committed to take effect. 41 * originate from user and need to be explicitly committed to take effect.
40 * Pop up the dialog if there are no errors from the indicator or commit the 42 * Pop up the dialog if there are no errors from the indicator or commit the
41 * change, depending on whether confirmation is needed. 43 * change, depending on whether confirmation is needed.
42 * @param {Event} event Change event. 44 * @param {Event} event Change event.
43 * @private 45 * @private
44 */ 46 */
45 onPrefChanged_: function(event) { 47 onPrefChanged_: function(event) {
46 if (!event.value.uncommitted) 48 if (!event.value.uncommitted)
47 return; 49 return;
48 50
49 if (event.value.value && !this.confirmed_) { 51 if (event.value.value && !this.confirmed_) {
50 if (!this.indicator.errorText) { 52 if (!this.indicator.errorText) {
51 OptionsPage.showPageByName(this.name, false); 53 OptionsPage.showPageByName(this.name, false);
52 } else { 54 } else {
53 this.indicator.updateBasedOnError(); 55 this.indicator.updateBasedOnError();
54 this.handleCancel(); 56 this.handleCancel();
55 } 57 }
56 } else { 58 } else {
57 Preferences.getInstance().commitPref(this.pref, this.metric); 59 Preferences.getInstance().commitPref(this.pref, this.metric);
58 } 60 }
59 }, 61 },
60 62
61 /** 63 /**
62 * Override the initializePage function so that an updated version of 64 * Override the initializePage function so that an updated version of
63 * onPrefChanged_ can be used. 65 * onPrefChanged_ can be used.
64 * @override */ 66 * @override
67 */
65 initializePage: function() { 68 initializePage: function() {
66 SettingsDialog.prototype.initializePage.call(this); 69 SettingsDialog.prototype.initializePage.call(this);
67 70
68 this.okButton.onclick = this.handleConfirm.bind(this); 71 this.okButton.onclick = this.handleConfirm.bind(this);
69 this.cancelButton.onclick = this.handleCancel.bind(this); 72 this.cancelButton.onclick = this.handleCancel.bind(this);
70 Preferences.getInstance().addEventListener( 73 Preferences.getInstance().addEventListener(
71 this.pref, this.onPrefChanged_.bind(this)); 74 this.pref, this.onPrefChanged_.bind(this));
72 } 75 }
73 }; 76 };
74 77
75 return { 78 return {
76 HotwordConfirmDialog: HotwordConfirmDialog 79 HotwordConfirmDialog: HotwordConfirmDialog
77 }; 80 };
78 }); 81 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/options/home_page_overlay.js ('k') | chrome/browser/resources/options/import_data_overlay.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698