Update To 11.40.268.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    * @extends {options.SettingsBannerBase}
16    */
17   function AutomaticSettingsResetBanner() {}
18
19   cr.addSingletonGetter(AutomaticSettingsResetBanner);
20
21   AutomaticSettingsResetBanner.prototype = {
22     __proto__: SettingsBannerBase.prototype,
23
24     /**
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().
32      */
33     initialize: function() {
34       this.showMetricName = 'AutomaticSettingsReset_WebUIBanner_BannerShown';
35
36       this.dismissNativeCallbackName =
37           'onDismissedAutomaticSettingsResetBanner';
38
39       this.visibilityDomElement = $('automatic-settings-reset-banner');
40
41       $('automatic-settings-reset-banner-close').onclick = function(event) {
42         chrome.send('metricsHandler:recordAction',
43             ['AutomaticSettingsReset_WebUIBanner_ManuallyClosed']);
44         AutomaticSettingsResetBanner.dismiss();
45       };
46       $('automatic-settings-reset-learn-more').onclick = function(event) {
47         chrome.send('metricsHandler:recordAction',
48             ['AutomaticSettingsReset_WebUIBanner_LearnMoreClicked']);
49       };
50       $('automatic-settings-reset-banner-activate-reset').onclick =
51           function(event) {
52         chrome.send('metricsHandler:recordAction',
53             ['AutomaticSettingsReset_WebUIBanner_ResetClicked']);
54         PageManager.showPageByName('resetProfileSettings');
55       };
56     },
57   };
58
59   // Forward public APIs to protected implementations.
60   [
61     'show',
62     'dismiss',
63   ].forEach(function(name) {
64     AutomaticSettingsResetBanner[name] = function() {
65       var instance = AutomaticSettingsResetBanner.getInstance();
66       return instance[name].apply(instance, arguments);
67     };
68   });
69
70   // Export
71   return {
72     AutomaticSettingsResetBanner: AutomaticSettingsResetBanner
73   };
74 });