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} | |
16 */ | 15 */ |
17 function AutomaticSettingsResetBanner() {} | 16 function AutomaticSettingsResetBanner() {} |
18 | 17 |
19 cr.addSingletonGetter(AutomaticSettingsResetBanner); | 18 cr.addSingletonGetter(AutomaticSettingsResetBanner); |
20 | 19 |
21 AutomaticSettingsResetBanner.prototype = { | 20 AutomaticSettingsResetBanner.prototype = { |
22 __proto__: SettingsBannerBase.prototype, | 21 __proto__: SettingsBannerBase.prototype, |
23 | 22 |
24 /** | 23 /** |
25 * Initializes the banner's event handlers. | 24 * Initializes the banner's event handlers. |
(...skipping 15 matching lines...) Expand all Loading... |
41 chrome.send('metricsHandler:recordAction', | 40 chrome.send('metricsHandler:recordAction', |
42 ['AutomaticSettingsReset_WebUIBanner_LearnMoreClicked']); | 41 ['AutomaticSettingsReset_WebUIBanner_LearnMoreClicked']); |
43 }; | 42 }; |
44 $('automatic-settings-reset-banner-activate-reset').onclick = | 43 $('automatic-settings-reset-banner-activate-reset').onclick = |
45 function(event) { | 44 function(event) { |
46 chrome.send('metricsHandler:recordAction', | 45 chrome.send('metricsHandler:recordAction', |
47 ['AutomaticSettingsReset_WebUIBanner_ResetClicked']); | 46 ['AutomaticSettingsReset_WebUIBanner_ResetClicked']); |
48 PageManager.showPageByName('resetProfileSettings'); | 47 PageManager.showPageByName('resetProfileSettings'); |
49 }; | 48 }; |
50 }, | 49 }, |
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 }, | |
74 }; | 50 }; |
75 | 51 |
76 // Forward public APIs to private implementations. | 52 // Forward public APIs to private implementations. |
77 cr.makePublic(AutomaticSettingsResetBanner, [ | 53 [ |
78 'show', | 54 'show', |
79 'dismiss', | 55 'dismiss', |
80 ]); | 56 ].forEach(function(name) { |
| 57 AutomaticSettingsResetBanner[name] = function() { |
| 58 var instance = AutomaticSettingsResetBanner.getInstance(); |
| 59 return instance[name + '_'].apply(instance, arguments); |
| 60 }; |
| 61 }); |
81 | 62 |
82 // Export | 63 // Export |
83 return { | 64 return { |
84 AutomaticSettingsResetBanner: AutomaticSettingsResetBanner | 65 AutomaticSettingsResetBanner: AutomaticSettingsResetBanner |
85 }; | 66 }; |
86 }); | 67 }); |
OLD | NEW |