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.
5 // Note: the native-side handler for this is AutomaticSettingsResetHandler.
7 cr
.define('options', function() {
8 /** @const */ var SettingsBannerBase
= options
.SettingsBannerBase
;
9 /** @const */ var PageManager
= cr
.ui
.pageManager
.PageManager
;
12 * AutomaticSettingsResetBanner class
13 * Provides encapsulated handling of the Reset Profile Settings banner.
15 * @extends {options.SettingsBannerBase}
17 function AutomaticSettingsResetBanner() {}
19 cr
.addSingletonGetter(AutomaticSettingsResetBanner
);
21 AutomaticSettingsResetBanner
.prototype = {
22 __proto__
: SettingsBannerBase
.prototype,
25 * Initializes the banner's event handlers.
26 * @suppress {checkTypes}
27 * TODO(vitalyp): remove the suppression. Suppression is needed because
28 * method dismiss() is attached to AutomaticSettingsResetBanner at run-time
29 * via "Forward public APIs to protected implementations" pattern (see
30 * below). Currently the compiler pass and cr.js handles only forwarding to
31 * private implementations using cr.makePublic().
33 initialize: function() {
34 this.showMetricName
= 'AutomaticSettingsReset_WebUIBanner_BannerShown';
36 this.dismissNativeCallbackName
=
37 'onDismissedAutomaticSettingsResetBanner';
39 this.visibilityDomElement
= $('automatic-settings-reset-banner');
41 $('automatic-settings-reset-banner-close').onclick = function(event
) {
42 chrome
.send('metricsHandler:recordAction',
43 ['AutomaticSettingsReset_WebUIBanner_ManuallyClosed']);
44 AutomaticSettingsResetBanner
.dismiss();
46 $('automatic-settings-reset-learn-more').onclick = function(event
) {
47 chrome
.send('metricsHandler:recordAction',
48 ['AutomaticSettingsReset_WebUIBanner_LearnMoreClicked']);
50 $('automatic-settings-reset-banner-activate-reset').onclick
=
52 chrome
.send('metricsHandler:recordAction',
53 ['AutomaticSettingsReset_WebUIBanner_ResetClicked']);
54 PageManager
.showPageByName('resetProfileSettings');
59 // Forward public APIs to protected implementations.
63 ].forEach(function(name
) {
64 AutomaticSettingsResetBanner
[name
] = function() {
65 var instance
= AutomaticSettingsResetBanner
.getInstance();
66 return instance
[name
].apply(instance
, arguments
);
72 AutomaticSettingsResetBanner
: AutomaticSettingsResetBanner