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 // Note: the native-side handler for this is AutomaticSettingsResetHandler. | 5 // Note: the native-side handler for this is AutomaticSettingsResetHandler. |
6 | 6 |
7 cr.define('options', function() { | 7 cr.define('options', function() { |
8 /** @const */ var SettingsBannerBase = options.SettingsBannerBase; | 8 /** @const */ var SettingsBannerBase = options.SettingsBannerBase; |
9 /** @const */ var PageManager = cr.ui.pageManager.PageManager; | 9 /** @const */ var PageManager = cr.ui.pageManager.PageManager; |
10 | 10 |
11 /** | 11 /** |
12 * AutomaticSettingsResetBanner class | 12 * AutomaticSettingsResetBanner class |
13 * Provides encapsulated handling of the Reset Profile Settings banner. | 13 * Provides encapsulated handling of the Reset Profile Settings banner. |
14 * @constructor | 14 * @constructor |
| 15 * @extends {options.SettingsBannerBase} |
15 */ | 16 */ |
16 function AutomaticSettingsResetBanner() {} | 17 function AutomaticSettingsResetBanner() {} |
17 | 18 |
18 cr.addSingletonGetter(AutomaticSettingsResetBanner); | 19 cr.addSingletonGetter(AutomaticSettingsResetBanner); |
19 | 20 |
20 AutomaticSettingsResetBanner.prototype = { | 21 AutomaticSettingsResetBanner.prototype = { |
21 __proto__: SettingsBannerBase.prototype, | 22 __proto__: SettingsBannerBase.prototype, |
22 | 23 |
23 /** | 24 /** |
24 * Initializes the banner's event handlers. | 25 * Initializes the banner's event handlers. |
(...skipping 15 matching lines...) Expand all Loading... |
40 chrome.send('metricsHandler:recordAction', | 41 chrome.send('metricsHandler:recordAction', |
41 ['AutomaticSettingsReset_WebUIBanner_LearnMoreClicked']); | 42 ['AutomaticSettingsReset_WebUIBanner_LearnMoreClicked']); |
42 }; | 43 }; |
43 $('automatic-settings-reset-banner-activate-reset').onclick = | 44 $('automatic-settings-reset-banner-activate-reset').onclick = |
44 function(event) { | 45 function(event) { |
45 chrome.send('metricsHandler:recordAction', | 46 chrome.send('metricsHandler:recordAction', |
46 ['AutomaticSettingsReset_WebUIBanner_ResetClicked']); | 47 ['AutomaticSettingsReset_WebUIBanner_ResetClicked']); |
47 PageManager.showPageByName('resetProfileSettings'); | 48 PageManager.showPageByName('resetProfileSettings'); |
48 }; | 49 }; |
49 }, | 50 }, |
| 51 |
| 52 /** |
| 53 * Called by the native code to show the banner if needed. |
| 54 * @private |
| 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 * @private |
| 68 */ |
| 69 dismiss_: function() { |
| 70 chrome.send(this.dismissNativeCallbackName_); |
| 71 this.hadBeenDismissed_ = true; |
| 72 this.setVisibility(false); |
| 73 }, |
50 }; | 74 }; |
51 | 75 |
52 // Forward public APIs to private implementations. | 76 // Forward public APIs to private implementations. |
53 [ | 77 cr.makePublic(AutomaticSettingsResetBanner, [ |
54 'show', | 78 'show', |
55 'dismiss', | 79 'dismiss', |
56 ].forEach(function(name) { | 80 ]); |
57 AutomaticSettingsResetBanner[name] = function() { | |
58 var instance = AutomaticSettingsResetBanner.getInstance(); | |
59 return instance[name + '_'].apply(instance, arguments); | |
60 }; | |
61 }); | |
62 | 81 |
63 // Export | 82 // Export |
64 return { | 83 return { |
65 AutomaticSettingsResetBanner: AutomaticSettingsResetBanner | 84 AutomaticSettingsResetBanner: AutomaticSettingsResetBanner |
66 }; | 85 }; |
67 }); | 86 }); |
OLD | NEW |