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 */ | 15 */ |
16 function AutomaticSettingsResetBanner() {} | 16 function AutomaticSettingsResetBanner() {} |
17 | 17 |
18 cr.addSingletonGetter(AutomaticSettingsResetBanner); | 18 cr.addSingletonGetter(AutomaticSettingsResetBanner); |
19 | 19 |
20 AutomaticSettingsResetBanner.prototype = { | 20 AutomaticSettingsResetBanner.prototype = { |
21 __proto__: SettingsBannerBase.prototype, | 21 __proto__: SettingsBannerBase.prototype, |
22 | 22 |
23 /** | 23 /** |
24 * Initializes the banner's event handlers. | 24 * Initializes the banner's event handlers. |
25 */ | 25 */ |
26 initialize: function() { | 26 initialize: function() { |
27 this.showMetricName_ = 'AutomaticSettingsReset_WebUIBanner_BannerShown'; | 27 this.showMetricName = 'AutomaticSettingsReset_WebUIBanner_BannerShown'; |
28 | 28 |
29 this.dismissNativeCallbackName_ = | 29 this.dismissNativeCallbackName = |
30 'onDismissedAutomaticSettingsResetBanner'; | 30 'onDismissedAutomaticSettingsResetBanner'; |
31 | 31 |
32 this.setVisibilibyDomElement_ = $('automatic-settings-reset-banner'); | 32 this.visibilityDomElement = $('automatic-settings-reset-banner'); |
33 | 33 |
34 $('automatic-settings-reset-banner-close').onclick = function(event) { | 34 $('automatic-settings-reset-banner-close').onclick = function(event) { |
35 chrome.send('metricsHandler:recordAction', | 35 chrome.send('metricsHandler:recordAction', |
36 ['AutomaticSettingsReset_WebUIBanner_ManuallyClosed']); | 36 ['AutomaticSettingsReset_WebUIBanner_ManuallyClosed']); |
37 AutomaticSettingsResetBanner.dismiss(); | 37 AutomaticSettingsResetBanner.dismiss(); |
38 }; | 38 }; |
39 $('automatic-settings-reset-learn-more').onclick = function(event) { | 39 $('automatic-settings-reset-learn-more').onclick = function(event) { |
40 chrome.send('metricsHandler:recordAction', | 40 chrome.send('metricsHandler:recordAction', |
41 ['AutomaticSettingsReset_WebUIBanner_LearnMoreClicked']); | 41 ['AutomaticSettingsReset_WebUIBanner_LearnMoreClicked']); |
42 }; | 42 }; |
43 $('automatic-settings-reset-banner-activate-reset').onclick = | 43 $('automatic-settings-reset-banner-activate-reset').onclick = |
44 function(event) { | 44 function(event) { |
45 chrome.send('metricsHandler:recordAction', | 45 chrome.send('metricsHandler:recordAction', |
46 ['AutomaticSettingsReset_WebUIBanner_ResetClicked']); | 46 ['AutomaticSettingsReset_WebUIBanner_ResetClicked']); |
47 PageManager.showPageByName('resetProfileSettings'); | 47 PageManager.showPageByName('resetProfileSettings'); |
48 }; | 48 }; |
49 }, | 49 }, |
50 }; | 50 }; |
51 | 51 |
52 // Forward public APIs to private implementations. | 52 // Forward public APIs to protected implementations. |
53 [ | 53 [ |
54 'show', | 54 'show', |
55 'dismiss', | 55 'dismiss', |
56 ].forEach(function(name) { | 56 ].forEach(function(name) { |
57 AutomaticSettingsResetBanner[name] = function() { | 57 AutomaticSettingsResetBanner[name] = function() { |
58 var instance = AutomaticSettingsResetBanner.getInstance(); | 58 var instance = AutomaticSettingsResetBanner.getInstance(); |
59 return instance[name + '_'].apply(instance, arguments); | 59 return instance[name].apply(instance, arguments); |
60 }; | 60 }; |
61 }); | 61 }); |
62 | 62 |
63 // Export | 63 // Export |
64 return { | 64 return { |
65 AutomaticSettingsResetBanner: AutomaticSettingsResetBanner | 65 AutomaticSettingsResetBanner: AutomaticSettingsResetBanner |
66 }; | 66 }; |
67 }); | 67 }); |
OLD | NEW |