Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 // TODO(engedy): AutomaticSettingsResetBanner is the sole class to derive from | |
| 6 // SettingsBannerBase. Refactor this into automatic_settings_reset_banner.js. | |
| 7 | |
| 8 cr.define('options', function() { | 5 cr.define('options', function() { |
| 9 | 6 |
| 10 /** | 7 /** |
| 11 * Base class for banners that appear at the top of the settings page. | 8 * Base class for banners that appear at the top of the settings page. |
| 12 */ | 9 */ |
| 13 function SettingsBannerBase() {} | 10 function SettingsBannerBase() {} |
| 14 | 11 |
| 15 cr.addSingletonGetter(SettingsBannerBase); | 12 cr.addSingletonGetter(SettingsBannerBase); |
| 16 | 13 |
| 17 SettingsBannerBase.prototype = { | 14 SettingsBannerBase.prototype = { |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 28 * our show() method. This would mean that the banner would be first | 25 * our show() method. This would mean that the banner would be first |
| 29 * dismissed, then shown. We want to prevent this. | 26 * dismissed, then shown. We want to prevent this. |
| 30 * | 27 * |
| 31 * @type {boolean} | 28 * @type {boolean} |
| 32 * @private | 29 * @private |
| 33 */ | 30 */ |
| 34 hadBeenDismissed_: false, | 31 hadBeenDismissed_: false, |
| 35 | 32 |
| 36 /** | 33 /** |
| 37 * Metric name to send when a show event occurs. | 34 * Metric name to send when a show event occurs. |
| 35 * @protected | |
| 38 */ | 36 */ |
| 39 showMetricName_: '', | 37 showMetricName: '', |
| 40 | 38 |
| 41 /** | 39 /** |
| 42 * Name of the native callback invoked when the banner is dismised. | 40 * Name of the native callback invoked when the banner is dismised. |
| 41 * @protected | |
| 43 */ | 42 */ |
| 44 dismissNativeCallbackName_: '', | 43 dismissNativeCallbackName: '', |
| 45 | 44 |
| 46 /** | 45 /** |
| 47 * DOM element whose visibility is set when setVisibility_ is called. | 46 * DOM element whose visibility is set when setVisibility_ is called. |
| 47 * @protected | |
| 48 */ | 48 */ |
| 49 setVisibilibyDomElement_: null, | 49 setVisibilityDomElement: null, |
|
Dan Beam
2014/09/10 19:13:37
nit: visibilityDomElement (prefixing with "set" de
engedy
2014/09/11 11:51:14
Done, renamed 4 occurrences.
| |
| 50 | 50 |
| 51 /** | 51 /** |
| 52 * Called by the native code to show the banner if needed. | 52 * Called by the native code to show the banner if needed. |
| 53 * @private | 53 * @protected |
| 54 */ | 54 */ |
| 55 show_: function() { | 55 show: function() { |
| 56 if (!this.hadBeenDismissed_) { | 56 if (!this.hadBeenDismissed_) { |
| 57 chrome.send('metricsHandler:recordAction', [this.showMetricName_]); | 57 chrome.send('metricsHandler:recordAction', [this.showMetricName]); |
| 58 this.setVisibility_(true); | 58 this.setVisibility_(true); |
| 59 } | 59 } |
| 60 }, | 60 }, |
| 61 | 61 |
| 62 /** | 62 /** |
| 63 * Called when the banner should be closed as a result of something taking | 63 * Called when the banner should be closed as a result of something taking |
| 64 * place on the WebUI page, i.e. when its close button is pressed, or when | 64 * place on the WebUI page, i.e. when its close button is pressed, or when |
| 65 * the confirmation dialog for the profile settings reset feature is opened. | 65 * the confirmation dialog for the profile settings reset feature is opened. |
| 66 * @private | 66 * @protected |
| 67 */ | 67 */ |
| 68 dismiss_: function() { | 68 dismiss: function() { |
| 69 chrome.send(this.dismissNativeCallbackName_); | 69 chrome.send(this.dismissNativeCallbackName); |
| 70 this.hadBeenDismissed_ = true; | 70 this.hadBeenDismissed_ = true; |
| 71 this.setVisibility_(false); | 71 this.setVisibility_(false); |
| 72 }, | 72 }, |
| 73 | 73 |
| 74 /** | 74 /** |
| 75 * Sets whether or not the reset profile settings banner shall be visible. | 75 * Sets whether or not the reset profile settings banner shall be visible. |
| 76 * @param {boolean} show Whether or not to show the banner. | 76 * @param {boolean} show Whether or not to show the banner. |
| 77 * @private | 77 * @private |
| 78 */ | 78 */ |
| 79 setVisibility_: function(show) { | 79 setVisibility_: function(show) { |
| 80 this.setVisibilibyDomElement_.hidden = !show; | 80 this.setVisibilityDomElement.hidden = !show; |
| 81 }, | 81 }, |
| 82 | 82 |
| 83 }; | 83 }; |
| 84 | 84 |
| 85 // Export | 85 // Export |
| 86 return { | 86 return { |
| 87 SettingsBannerBase: SettingsBannerBase | 87 SettingsBannerBase: SettingsBannerBase |
| 88 }; | 88 }; |
| 89 }); | 89 }); |
| OLD | NEW |