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 | |
13 */ | 12 */ |
14 function SettingsBannerBase() {} | 13 function SettingsBannerBase() {} |
15 | 14 |
16 cr.addSingletonGetter(SettingsBannerBase); | 15 cr.addSingletonGetter(SettingsBannerBase); |
17 | 16 |
18 SettingsBannerBase.prototype = { | 17 SettingsBannerBase.prototype = { |
19 /** | 18 /** |
20 * Whether or not the banner has already been dismissed. | 19 * Whether or not the banner has already been dismissed. |
21 * | 20 * |
22 * This is needed because of the surprising ordering of asynchronous | 21 * This is needed because of the surprising ordering of asynchronous |
(...skipping 20 matching lines...) Expand all Loading... |
43 * Name of the native callback invoked when the banner is dismised. | 42 * Name of the native callback invoked when the banner is dismised. |
44 */ | 43 */ |
45 dismissNativeCallbackName_: '', | 44 dismissNativeCallbackName_: '', |
46 | 45 |
47 /** | 46 /** |
48 * DOM element whose visibility is set when setVisibility_ is called. | 47 * DOM element whose visibility is set when setVisibility_ is called. |
49 */ | 48 */ |
50 setVisibilibyDomElement_: null, | 49 setVisibilibyDomElement_: null, |
51 | 50 |
52 /** | 51 /** |
| 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 /** |
53 * 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. |
54 * @param {boolean} show Whether or not to show the banner. | 76 * @param {boolean} show Whether or not to show the banner. |
55 * @protected | 77 * @private |
56 */ | 78 */ |
57 setVisibility: function(show) { | 79 setVisibility_: function(show) { |
58 this.setVisibilibyDomElement_.hidden = !show; | 80 this.setVisibilibyDomElement_.hidden = !show; |
59 }, | 81 }, |
| 82 |
60 }; | 83 }; |
61 | 84 |
62 // Export | 85 // Export |
63 return { | 86 return { |
64 SettingsBannerBase: SettingsBannerBase | 87 SettingsBannerBase: SettingsBannerBase |
65 }; | 88 }; |
66 }); | 89 }); |
OLD | NEW |