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 * @constructor | 9 * @constructor |
13 */ | 10 */ |
14 function SettingsBannerBase() {} | 11 function SettingsBannerBase() {} |
15 | 12 |
16 cr.addSingletonGetter(SettingsBannerBase); | 13 cr.addSingletonGetter(SettingsBannerBase); |
17 | 14 |
(...skipping 11 matching lines...) Expand all Loading... |
29 * our show() method. This would mean that the banner would be first | 26 * our show() method. This would mean that the banner would be first |
30 * dismissed, then shown. We want to prevent this. | 27 * dismissed, then shown. We want to prevent this. |
31 * | 28 * |
32 * @type {boolean} | 29 * @type {boolean} |
33 * @private | 30 * @private |
34 */ | 31 */ |
35 hadBeenDismissed_: false, | 32 hadBeenDismissed_: false, |
36 | 33 |
37 /** | 34 /** |
38 * Metric name to send when a show event occurs. | 35 * Metric name to send when a show event occurs. |
| 36 * @protected |
39 */ | 37 */ |
40 showMetricName_: '', | 38 showMetricName: '', |
41 | 39 |
42 /** | 40 /** |
43 * Name of the native callback invoked when the banner is dismised. | 41 * Name of the native callback invoked when the banner is dismised. |
| 42 * @protected |
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. |
| 48 * @protected |
49 */ | 49 */ |
50 setVisibilibyDomElement_: null, | 50 visibilityDomElement: null, |
| 51 |
| 52 /** |
| 53 * Called by the native code to show the banner if needed. |
| 54 * @protected |
| 55 */ |
| 56 show: function() { |
| 57 if (!this.hadBeenDismissed_) { |
| 58 chrome.send('metricsHandler:recordAction', [this.showMetricName]); |
| 59 this.setVisibility_(true); |
| 60 } |
| 61 }, |
| 62 |
| 63 /** |
| 64 * Called when the banner should be closed as a result of something taking |
| 65 * place on the WebUI page, i.e. when its close button is pressed, or when |
| 66 * the confirmation dialog for the profile settings reset feature is opened. |
| 67 * @protected |
| 68 */ |
| 69 dismiss: function() { |
| 70 chrome.send(this.dismissNativeCallbackName); |
| 71 this.hadBeenDismissed_ = true; |
| 72 this.setVisibility_(false); |
| 73 }, |
51 | 74 |
52 /** | 75 /** |
53 * Sets whether or not the reset profile settings banner shall be visible. | 76 * Sets whether or not the reset profile settings banner shall be visible. |
54 * @param {boolean} show Whether or not to show the banner. | 77 * @param {boolean} show Whether or not to show the banner. |
55 * @protected | 78 * @private |
56 */ | 79 */ |
57 setVisibility: function(show) { | 80 setVisibility_: function(show) { |
58 this.setVisibilibyDomElement_.hidden = !show; | 81 this.visibilityDomElement.hidden = !show; |
59 }, | 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 |