OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * @fileoverview | 6 * @fileoverview |
7 * | 7 * |
8 * 'settings-reset-profile-dialog' is the dialog shown for clearing profile | 8 * 'settings-reset-profile-dialog' is the dialog shown for clearing profile |
9 * settings. A triggered variant of this dialog can be shown under certain | 9 * settings. A triggered variant of this dialog can be shown under certain |
10 * circumstances. See triggered_profile_resetter.h for when the triggered | 10 * circumstances. See triggered_profile_resetter.h for when the triggered |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 | 43 |
44 /** @private {!settings.ResetBrowserProxy} */ | 44 /** @private {!settings.ResetBrowserProxy} */ |
45 browserProxy_: null, | 45 browserProxy_: null, |
46 | 46 |
47 /** | 47 /** |
48 * @private | 48 * @private |
49 * @return {string} | 49 * @return {string} |
50 */ | 50 */ |
51 getExplanationText_: function() { | 51 getExplanationText_: function() { |
52 if (this.isTriggered_) { | 52 if (this.isTriggered_) { |
53 return loadTimeData.getStringF('triggeredResetPageExplanation', | 53 return loadTimeData.getStringF( |
54 this.triggeredResetToolName_); | 54 'triggeredResetPageExplanation', this.triggeredResetToolName_); |
55 } | 55 } |
56 return loadTimeData.getStringF('resetPageExplanation'); | 56 return loadTimeData.getStringF('resetPageExplanation'); |
57 }, | 57 }, |
58 | 58 |
59 /** | 59 /** |
60 * @private | 60 * @private |
61 * @return {string} | 61 * @return {string} |
62 */ | 62 */ |
63 getPageTitle_: function() { | 63 getPageTitle_: function() { |
64 if (this.isTriggered_) { | 64 if (this.isTriggered_) { |
65 return loadTimeData.getStringF('triggeredResetPageTitle', | 65 return loadTimeData.getStringF( |
66 this.triggeredResetToolName_); | 66 'triggeredResetPageTitle', this.triggeredResetToolName_); |
67 } | 67 } |
68 return loadTimeData.getStringF('resetPageTitle'); | 68 return loadTimeData.getStringF('resetPageTitle'); |
69 }, | 69 }, |
70 | 70 |
71 /** @override */ | 71 /** @override */ |
72 ready: function() { | 72 ready: function() { |
73 this.browserProxy_ = settings.ResetBrowserProxyImpl.getInstance(); | 73 this.browserProxy_ = settings.ResetBrowserProxyImpl.getInstance(); |
74 | 74 |
75 this.addEventListener('cancel', function() { | 75 this.addEventListener('cancel', function() { |
76 this.browserProxy_.onHideResetProfileDialog(); | 76 this.browserProxy_.onHideResetProfileDialog(); |
77 }.bind(this)); | 77 }.bind(this)); |
78 | 78 |
79 this.$$('paper-checkbox a').addEventListener( | 79 this.$$('paper-checkbox a') |
80 'tap', this.onShowReportedSettingsTap_.bind(this)); | 80 .addEventListener('tap', this.onShowReportedSettingsTap_.bind(this)); |
81 // Prevent toggling of the checkbox when hitting the "Enter" key on the | 81 // Prevent toggling of the checkbox when hitting the "Enter" key on the |
82 // link. | 82 // link. |
83 this.$$('paper-checkbox a').addEventListener( | 83 this.$$('paper-checkbox a').addEventListener('keydown', function(e) { |
84 'keydown', function(e) { e.stopPropagation(); }); | 84 e.stopPropagation(); |
| 85 }); |
85 }, | 86 }, |
86 | 87 |
87 /** @private */ | 88 /** @private */ |
88 showDialog_: function() { | 89 showDialog_: function() { |
89 this.$.dialog.showModal(); | 90 this.$.dialog.showModal(); |
90 this.browserProxy_.onShowResetProfileDialog(); | 91 this.browserProxy_.onShowResetProfileDialog(); |
91 }, | 92 }, |
92 | 93 |
93 /** @override */ | 94 /** @override */ |
94 attached: function() { | 95 attached: function() { |
95 this.isTriggered_ = | 96 this.isTriggered_ = |
96 settings.getCurrentRoute() == settings.Route.TRIGGERED_RESET_DIALOG; | 97 settings.getCurrentRoute() == settings.Route.TRIGGERED_RESET_DIALOG; |
97 if (this.isTriggered_) { | 98 if (this.isTriggered_) { |
98 this.browserProxy_.getTriggeredResetToolName().then(function(name) { | 99 this.browserProxy_.getTriggeredResetToolName().then(function(name) { |
99 this.resetRequestOrigin_ = 'triggeredreset'; | 100 this.resetRequestOrigin_ = 'triggeredreset'; |
100 this.triggeredResetToolName_ = name; | 101 this.triggeredResetToolName_ = name; |
101 this.showDialog_(); | 102 this.showDialog_(); |
102 }.bind(this)); | 103 }.bind(this)); |
103 } else { | 104 } else { |
104 // For the non-triggered reset dialog, a '#cct' hash indicates that the | 105 // For the non-triggered reset dialog, a '#cct' hash indicates that the |
105 // reset request came from the Chrome Cleanup Tool by launching Chrome | 106 // reset request came from the Chrome Cleanup Tool by launching Chrome |
106 // with the startup URL chrome://settings/resetProfileSettings#cct. | 107 // with the startup URL chrome://settings/resetProfileSettings#cct. |
107 var origin = window.location.hash.slice(1).toLowerCase() == 'cct' ? | 108 var origin = window.location.hash.slice(1).toLowerCase() == 'cct' ? |
108 'cct' : settings.getQueryParameters().get('origin'); | 109 'cct' : |
| 110 settings.getQueryParameters().get('origin'); |
109 this.resetRequestOrigin_ = origin || ''; | 111 this.resetRequestOrigin_ = origin || ''; |
110 this.showDialog_(); | 112 this.showDialog_(); |
111 } | 113 } |
112 }, | 114 }, |
113 | 115 |
114 /** @private */ | 116 /** @private */ |
115 onCancelTap_: function() { | 117 onCancelTap_: function() { |
116 this.$.dialog.cancel(); | 118 this.$.dialog.cancel(); |
117 }, | 119 }, |
118 | 120 |
119 /** @private */ | 121 /** @private */ |
120 onResetTap_: function() { | 122 onResetTap_: function() { |
121 this.clearingInProgress_ = true; | 123 this.clearingInProgress_ = true; |
122 this.browserProxy_.performResetProfileSettings( | 124 this.browserProxy_ |
123 this.$.sendSettings.checked, this.resetRequestOrigin_).then(function() { | 125 .performResetProfileSettings( |
124 this.clearingInProgress_ = false; | 126 this.$.sendSettings.checked, this.resetRequestOrigin_) |
125 if (this.$.dialog.open) | 127 .then(function() { |
126 this.$.dialog.close(); | 128 this.clearingInProgress_ = false; |
127 this.fire('reset-done'); | 129 if (this.$.dialog.open) |
128 }.bind(this)); | 130 this.$.dialog.close(); |
| 131 this.fire('reset-done'); |
| 132 }.bind(this)); |
129 }, | 133 }, |
130 | 134 |
131 /** | 135 /** |
132 * Displays the settings that will be reported in a new tab. | 136 * Displays the settings that will be reported in a new tab. |
133 * @param {!Event} e | 137 * @param {!Event} e |
134 * @private | 138 * @private |
135 */ | 139 */ |
136 onShowReportedSettingsTap_: function(e) { | 140 onShowReportedSettingsTap_: function(e) { |
137 this.browserProxy_.showReportedSettings(); | 141 this.browserProxy_.showReportedSettings(); |
138 e.stopPropagation(); | 142 e.stopPropagation(); |
139 }, | 143 }, |
140 }); | 144 }); |
OLD | NEW |