| 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 | 5 // TODO(engedy): AutomaticSettingsResetBanner is the sole class to derive from |
| 6 // SettingsBannerBase. Refactor this into automatic_settings_reset_banner.js. | 6 // SettingsBannerBase. Refactor this into automatic_settings_reset_banner.js. |
| 7 | 7 |
| 8 cr.define('options', function() { | 8 cr.define('options', function() { |
| 9 | 9 |
| 10 /** | 10 /** |
| 11 * Base class for banners that appear at the top of the settings page. | 11 * Base class for banners that appear at the top of the settings page. |
| 12 * @constructor |
| 12 */ | 13 */ |
| 13 function SettingsBannerBase() {} | 14 function SettingsBannerBase() {} |
| 14 | 15 |
| 15 cr.addSingletonGetter(SettingsBannerBase); | 16 cr.addSingletonGetter(SettingsBannerBase); |
| 16 | 17 |
| 17 SettingsBannerBase.prototype = { | 18 SettingsBannerBase.prototype = { |
| 18 /** | 19 /** |
| 19 * Whether or not the banner has already been dismissed. | 20 * Whether or not the banner has already been dismissed. |
| 20 * | 21 * |
| 21 * This is needed because of the surprising ordering of asynchronous | 22 * This is needed because of the surprising ordering of asynchronous |
| (...skipping 20 matching lines...) Expand all Loading... |
| 42 * Name of the native callback invoked when the banner is dismised. | 43 * Name of the native callback invoked when the banner is dismised. |
| 43 */ | 44 */ |
| 44 dismissNativeCallbackName_: '', | 45 dismissNativeCallbackName_: '', |
| 45 | 46 |
| 46 /** | 47 /** |
| 47 * DOM element whose visibility is set when setVisibility_ is called. | 48 * DOM element whose visibility is set when setVisibility_ is called. |
| 48 */ | 49 */ |
| 49 setVisibilibyDomElement_: null, | 50 setVisibilibyDomElement_: null, |
| 50 | 51 |
| 51 /** | 52 /** |
| 52 * Called by the native code to show the banner if needed. | |
| 53 * @private | |
| 54 */ | |
| 55 show_: function() { | |
| 56 if (!this.hadBeenDismissed_) { | |
| 57 chrome.send('metricsHandler:recordAction', [this.showMetricName_]); | |
| 58 this.setVisibility_(true); | |
| 59 } | |
| 60 }, | |
| 61 | |
| 62 /** | |
| 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 | |
| 65 * the confirmation dialog for the profile settings reset feature is opened. | |
| 66 * @private | |
| 67 */ | |
| 68 dismiss_: function() { | |
| 69 chrome.send(this.dismissNativeCallbackName_); | |
| 70 this.hadBeenDismissed_ = true; | |
| 71 this.setVisibility_(false); | |
| 72 }, | |
| 73 | |
| 74 /** | |
| 75 * Sets whether or not the reset profile settings banner shall be visible. | 53 * Sets whether or not the reset profile settings banner shall be visible. |
| 76 * @param {boolean} show Whether or not to show the banner. | 54 * @param {boolean} show Whether or not to show the banner. |
| 77 * @private | 55 * @protected |
| 78 */ | 56 */ |
| 79 setVisibility_: function(show) { | 57 setVisibility: function(show) { |
| 80 this.setVisibilibyDomElement_.hidden = !show; | 58 this.setVisibilibyDomElement_.hidden = !show; |
| 81 }, | 59 }, |
| 82 | |
| 83 }; | 60 }; |
| 84 | 61 |
| 85 // Export | 62 // Export |
| 86 return { | 63 return { |
| 87 SettingsBannerBase: SettingsBannerBase | 64 SettingsBannerBase: SettingsBannerBase |
| 88 }; | 65 }; |
| 89 }); | 66 }); |
| OLD | NEW |