Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / resources / options / reset_profile_settings_banner.js
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.
4
5 // Note: the native-side handler for this is ResetProfileSettingsHandler.
6
7 cr.define('options', function() {
8   /** @const */ var PageManager = cr.ui.pageManager.PageManager;
9   /** @const */ var SettingsBannerBase = options.SettingsBannerBase;
10
11   /**
12    * ResetProfileSettingsBanner class
13    * Provides encapsulated handling of the Reset Profile Settings banner.
14    * @constructor
15    * @extends {options.SettingsBannerBase}
16    */
17   function ResetProfileSettingsBanner() {}
18
19   cr.addSingletonGetter(ResetProfileSettingsBanner);
20
21   ResetProfileSettingsBanner.prototype = {
22     __proto__: SettingsBannerBase.prototype,
23
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';
32
33       this.dismissNativeCallbackName =
34           'onDismissedResetProfileSettingsBanner';
35
36       this.visibilityDomElement = $('reset-profile-settings-banner');
37
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   };
50
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   });
61
62   // Export
63   return {
64     ResetProfileSettingsBanner: ResetProfileSettingsBanner
65   };
66 });