Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / resources / options / automatic_settings_reset_banner.js
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   /** @const */ var PageManager = cr.ui.pageManager.PageManager;
10
11   /**
12    * AutomaticSettingsResetBanner class
13    * Provides encapsulated handling of the Reset Profile Settings banner.
14    * @constructor
15    */
16   function AutomaticSettingsResetBanner() {}
17
18   cr.addSingletonGetter(AutomaticSettingsResetBanner);
19
20   AutomaticSettingsResetBanner.prototype = {
21     __proto__: SettingsBannerBase.prototype,
22
23     /**
24      * Initializes the banner's event handlers.
25      */
26     initialize: function() {
27       this.showMetricName_ = 'AutomaticSettingsReset_WebUIBanner_BannerShown';
28
29       this.dismissNativeCallbackName_ =
30           'onDismissedAutomaticSettingsResetBanner';
31
32       this.setVisibilibyDomElement_ = $('automatic-settings-reset-banner');
33
34       $('automatic-settings-reset-banner-close').onclick = function(event) {
35         chrome.send('metricsHandler:recordAction',
36             ['AutomaticSettingsReset_WebUIBanner_ManuallyClosed']);
37         AutomaticSettingsResetBanner.dismiss();
38       };
39       $('automatic-settings-reset-learn-more').onclick = function(event) {
40         chrome.send('metricsHandler:recordAction',
41             ['AutomaticSettingsReset_WebUIBanner_LearnMoreClicked']);
42       };
43       $('automatic-settings-reset-banner-activate-reset').onclick =
44           function(event) {
45         chrome.send('metricsHandler:recordAction',
46             ['AutomaticSettingsReset_WebUIBanner_ResetClicked']);
47         PageManager.showPageByName('resetProfileSettings');
48       };
49     },
50   };
51
52   // Forward public APIs to private implementations.
53   [
54     'show',
55     'dismiss',
56   ].forEach(function(name) {
57     AutomaticSettingsResetBanner[name] = function() {
58       var instance = AutomaticSettingsResetBanner.getInstance();
59       return instance[name + '_'].apply(instance, arguments);
60     };
61   });
62
63   // Export
64   return {
65     AutomaticSettingsResetBanner: AutomaticSettingsResetBanner
66   };
67 });