ffa2b07c1c5c4adfda5e0adf7d828b5c7c4aafda
[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 OptionsPage = options.OptionsPage;
9   /** @const */ var SettingsBannerBase = options.SettingsBannerBase;
10
11   /**
12    * ResetProfileSettingsBanner class
13    * Provides encapsulated handling of the Reset Profile Settings banner.
14    * @constructor
15    */
16   function ResetProfileSettingsBanner() {}
17
18   cr.addSingletonGetter(ResetProfileSettingsBanner);
19
20   ResetProfileSettingsBanner.prototype = {
21     __proto__: SettingsBannerBase.prototype,
22
23     /**
24      * Initializes the banner's event handlers.
25      */
26     initialize: function() {
27       this.showMetricName_ = 'AutomaticReset_WebUIBanner_BannerShown';
28
29       this.dismissNativeCallbackName_ =
30           'onDismissedResetProfileSettingsBanner';
31
32       this.setVisibilibyDomElement_ = $('reset-profile-settings-banner');
33
34       $('reset-profile-settings-banner-close').onclick = function(event) {
35         chrome.send('metricsHandler:recordAction',
36             ['AutomaticReset_WebUIBanner_ManuallyClosed']);
37         ResetProfileSettingsBanner.dismiss();
38       };
39       $('reset-profile-settings-banner-activate').onclick = function(event) {
40         chrome.send('metricsHandler:recordAction',
41             ['AutomaticReset_WebUIBanner_ResetClicked']);
42         OptionsPage.navigateToPage('resetProfileSettings');
43       };
44     },
45   };
46
47   // Forward public APIs to private implementations.
48   [
49     'show',
50     'dismiss',
51   ].forEach(function(name) {
52     ResetProfileSettingsBanner[name] = function() {
53       var instance = ResetProfileSettingsBanner.getInstance();
54       return instance[name + '_'].apply(instance, arguments);
55     };
56   });
57
58   // Export
59   return {
60     ResetProfileSettingsBanner: ResetProfileSettingsBanner
61   };
62 });