OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // Note: the native-side handler for this is AutomaticSettingsResetHandler. |
| 6 |
| 7 cr.define('options', function() { |
| 8 /** @const */ var SettingsBannerBase = options.SettingsBannerBase; |
| 9 |
| 10 /** |
| 11 * AutomaticSettingsResetBanner class |
| 12 * Provides encapsulated handling of the Reset Profile Settings banner. |
| 13 * @constructor |
| 14 */ |
| 15 function AutomaticSettingsResetBanner() {} |
| 16 |
| 17 cr.addSingletonGetter(AutomaticSettingsResetBanner); |
| 18 |
| 19 AutomaticSettingsResetBanner.prototype = { |
| 20 __proto__: SettingsBannerBase.prototype, |
| 21 |
| 22 /** |
| 23 * Initializes the banner's event handlers. |
| 24 */ |
| 25 initialize: function() { |
| 26 this.showMetricName_ = 'AutomaticSettingsReset_WebUIBanner_BannerShown'; |
| 27 |
| 28 this.dismissNativeCallbackName_ = |
| 29 'onDismissedAutomaticSettingsResetBanner'; |
| 30 |
| 31 this.setVisibilibyDomElement_ = $('automatic-settings-reset-banner'); |
| 32 |
| 33 $('automatic-settings-reset-banner-close').onclick = function(event) { |
| 34 chrome.send('metricsHandler:recordAction', |
| 35 ['AutomaticSettingsReset_WebUIBanner_ManuallyClosed']); |
| 36 AutomaticSettingsResetBanner.dismiss(); |
| 37 }; |
| 38 $('automatic-settings-reset-learn-more').onclick = function(event) { |
| 39 chrome.send('metricsHandler:recordAction', |
| 40 ['AutomaticSettingsReset_WebUIBanner_LearnMoreClicked']); |
| 41 }; |
| 42 }, |
| 43 }; |
| 44 |
| 45 // Forward public APIs to private implementations. |
| 46 [ |
| 47 'show', |
| 48 'dismiss', |
| 49 ].forEach(function(name) { |
| 50 AutomaticSettingsResetBanner[name] = function() { |
| 51 var instance = AutomaticSettingsResetBanner.getInstance(); |
| 52 return instance[name + '_'].apply(instance, arguments); |
| 53 }; |
| 54 }); |
| 55 |
| 56 // Export |
| 57 return { |
| 58 AutomaticSettingsResetBanner: AutomaticSettingsResetBanner |
| 59 }; |
| 60 }); |
OLD | NEW |