Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / resources / options / reset_profile_settings_overlay.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 cr.define('options', function() {
6   var Page = cr.ui.pageManager.Page;
7
8   var AutomaticSettingsResetBanner = options.AutomaticSettingsResetBanner;
9   var ResetProfileSettingsBanner = options.ResetProfileSettingsBanner;
10
11   /**
12    * ResetProfileSettingsOverlay class
13    * Encapsulated handling of the 'Reset Profile Settings' overlay page.
14    * @class
15    */
16   function ResetProfileSettingsOverlay() {
17     Page.call(this, 'resetProfileSettings',
18               loadTimeData.getString('resetProfileSettingsOverlayTabTitle'),
19               'reset-profile-settings-overlay');
20   }
21
22   cr.addSingletonGetter(ResetProfileSettingsOverlay);
23
24   ResetProfileSettingsOverlay.prototype = {
25     // Inherit ResetProfileSettingsOverlay from Page.
26     __proto__: Page.prototype,
27
28     /** @override */
29     initializePage: function() {
30       Page.prototype.initializePage.call(this);
31
32       $('reset-profile-settings-dismiss').onclick = function(e) {
33         ResetProfileSettingsOverlay.dismiss();
34       };
35       $('reset-profile-settings-commit').onclick = function(e) {
36         ResetProfileSettingsOverlay.setResettingState(true);
37         chrome.send('performResetProfileSettings',
38                     [$('send-settings').checked]);
39       };
40       $('expand-feedback').onclick = function(e) {
41         var feedbackTemplate = $('feedback-template');
42         feedbackTemplate.hidden = !feedbackTemplate.hidden;
43         e.preventDefault();
44       };
45     },
46
47     /**
48      * @override
49      * @suppress {checkTypes}
50      * TODO(vitalyp): remove the suppression. See the explanation in
51      * chrome/browser/resources/options/automatic_settings_reset_banner.js.
52      */
53     didShowPage: function() {
54       ResetProfileSettingsBanner.dismiss();
55       chrome.send('onShowResetProfileDialog');
56     },
57
58     /** @override */
59     didClosePage: function() {
60       chrome.send('onHideResetProfileDialog');
61     },
62   };
63
64   /**
65    * Enables/disables UI elements after/while Chrome is performing a reset.
66    * @param {boolean} state If true, UI elements are disabled.
67    */
68   ResetProfileSettingsOverlay.setResettingState = function(state) {
69     $('reset-profile-settings-throbber').style.visibility =
70         state ? 'visible' : 'hidden';
71     $('reset-profile-settings-dismiss').disabled = state;
72     $('reset-profile-settings-commit').disabled = state;
73   };
74
75   /**
76    * Chrome callback to notify ResetProfileSettingsOverlay that the reset
77    * operation has terminated.
78    * @suppress {checkTypes}
79    * TODO(vitalyp): remove the suppression. See the explanation in
80    * chrome/browser/resources/options/automatic_settings_reset_banner.js.
81    */
82   ResetProfileSettingsOverlay.doneResetting = function() {
83     AutomaticSettingsResetBanner.dismiss();
84     ResetProfileSettingsOverlay.dismiss();
85   };
86
87   /**
88    * Dismisses the overlay.
89    */
90   ResetProfileSettingsOverlay.dismiss = function() {
91     PageManager.closeOverlay();
92     ResetProfileSettingsOverlay.setResettingState(false);
93   };
94
95   ResetProfileSettingsOverlay.setFeedbackInfo = function(feedbackListData) {
96     var input = new JsEvalContext(feedbackListData);
97     var output = $('feedback-template');
98     jstProcess(input, output);
99   };
100
101   // Export
102   return {
103     ResetProfileSettingsOverlay: ResetProfileSettingsOverlay
104   };
105 });