Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / browser / resources / options / reset_profile_settings_banner.js
blob4785113d17f67c3242809dc50d2b6c1df815812d
1 // Copyright 2013 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 ResetProfileSettingsHandler.
7 cr.define('options', function() {
8   /** @const */ var PageManager = cr.ui.pageManager.PageManager;
9   /** @const */ var SettingsBannerBase = options.SettingsBannerBase;
11   /**
12    * ResetProfileSettingsBanner class
13    * Provides encapsulated handling of the Reset Profile Settings banner.
14    * @constructor
15    * @extends {options.SettingsBannerBase}
16    */
17   function ResetProfileSettingsBanner() {}
19   cr.addSingletonGetter(ResetProfileSettingsBanner);
21   ResetProfileSettingsBanner.prototype = {
22     __proto__: SettingsBannerBase.prototype,
24     /**
25      * Initializes the banner's event handlers.
26      * @suppress {checkTypes}
27      * TODO(vitalyp): remove the suppression. See the explanation in
28      * chrome/browser/resources/options/automatic_settings_reset_banner.js.
29      */
30     initialize: function() {
31       this.showMetricName = 'AutomaticReset_WebUIBanner_BannerShown';
33       this.dismissNativeCallbackName =
34           'onDismissedResetProfileSettingsBanner';
36       this.visibilityDomElement = $('reset-profile-settings-banner');
38       $('reset-profile-settings-banner-close').onclick = function(event) {
39         chrome.send('metricsHandler:recordAction',
40             ['AutomaticReset_WebUIBanner_ManuallyClosed']);
41         ResetProfileSettingsBanner.dismiss();
42       };
43       $('reset-profile-settings-banner-activate').onclick = function(event) {
44         chrome.send('metricsHandler:recordAction',
45             ['AutomaticReset_WebUIBanner_ResetClicked']);
46         PageManager.showPageByName('resetProfileSettings');
47       };
48     },
49   };
51   // Forward public APIs to protected implementations.
52   [
53     'show',
54     'dismiss',
55   ].forEach(function(name) {
56     ResetProfileSettingsBanner[name] = function() {
57       var instance = ResetProfileSettingsBanner.getInstance();
58       return instance[name].apply(instance, arguments);
59     };
60   });
62   // Export
63   return {
64     ResetProfileSettingsBanner: ResetProfileSettingsBanner
65   };
66 });