Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(199)

Side by Side Diff: chrome/browser/resources/options/reset_profile_settings_overlay.js

Issue 2236663002: Add origin of settings reset request to feedback reports. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adressed Dan's comments Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 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 cr.define('options', function() { 5 cr.define('options', function() {
6 var Page = cr.ui.pageManager.Page; 6 var Page = cr.ui.pageManager.Page;
7 7
8 var AutomaticSettingsResetBanner = options.AutomaticSettingsResetBanner; 8 var AutomaticSettingsResetBanner = options.AutomaticSettingsResetBanner;
9 9
10 /** 10 /**
11 * ResetProfileSettingsOverlay class 11 * ResetProfileSettingsOverlay class
12 * Encapsulated handling of the 'Reset Profile Settings' overlay page. 12 * Encapsulated handling of the 'Reset Profile Settings' overlay page.
13 * @constructor 13 * @constructor
14 * @extends {cr.ui.pageManager.Page} 14 * @extends {cr.ui.pageManager.Page}
15 */ 15 */
16 function ResetProfileSettingsOverlay() { 16 function ResetProfileSettingsOverlay() {
17 Page.call(this, 'resetProfileSettings', 17 Page.call(this, 'resetProfileSettings',
18 loadTimeData.getString('resetProfileSettingsOverlayTabTitle'), 18 loadTimeData.getString('resetProfileSettingsOverlayTabTitle'),
19 'reset-profile-settings-overlay'); 19 'reset-profile-settings-overlay');
20 } 20 }
21 21
22 cr.addSingletonGetter(ResetProfileSettingsOverlay); 22 cr.addSingletonGetter(ResetProfileSettingsOverlay);
23 23
24 ResetProfileSettingsOverlay.prototype = { 24 ResetProfileSettingsOverlay.prototype = {
25 // Inherit ResetProfileSettingsOverlay from Page. 25 // Inherit ResetProfileSettingsOverlay from Page.
26 __proto__: Page.prototype, 26 __proto__: Page.prototype,
27 27
28 /** @private {string} */
29 resetRequestOrigin_: '',
30
28 /** @override */ 31 /** @override */
29 initializePage: function() { 32 initializePage: function() {
30 Page.prototype.initializePage.call(this); 33 Page.prototype.initializePage.call(this);
31 34
32 $('reset-profile-settings-dismiss').onclick = function(e) { 35 $('reset-profile-settings-dismiss').onclick = function(e) {
33 ResetProfileSettingsOverlay.dismiss(); 36 ResetProfileSettingsOverlay.dismiss();
34 }; 37 };
35 $('reset-profile-settings-commit').onclick = function(e) { 38 $('reset-profile-settings-commit').onclick = function(e) {
36 ResetProfileSettingsOverlay.setResettingState(true); 39 ResetProfileSettingsOverlay.setResettingState(true);
37 chrome.send('performResetProfileSettings', 40 chrome.send('performResetProfileSettings',
38 [$('send-settings').checked]); 41 [$('send-settings').checked,
42 ResetProfileSettingsOverlay.getInstance()
Dan Beam 2016/08/23 05:48:23 this.resetRequestOrigin_
alito 2016/08/23 18:20:34 Can't use 'this' here. See explanation in the comm
43 .getResetRequestOrigin()]);
39 }; 44 };
Dan Beam 2016/08/23 05:48:22 }.bind(this);
alito 2016/08/23 18:20:34 This doesn't work on Windows. On Windows, Triggere
Dan Beam 2016/08/23 22:46:53 they're the same object with a different prototype
alito 2016/08/24 21:17:01 Well, my explanation for why .bind(this) doesn't w
alito 2016/08/24 21:49:22 I've used the debugger and the console. From what
40 $('expand-feedback').onclick = function(e) { 45 $('expand-feedback').onclick = function(e) {
41 var feedbackTemplate = $('feedback-template'); 46 var feedbackTemplate = $('feedback-template');
42 feedbackTemplate.hidden = !feedbackTemplate.hidden; 47 feedbackTemplate.hidden = !feedbackTemplate.hidden;
43 e.preventDefault(); 48 e.preventDefault();
44 }; 49 };
45 }, 50 },
46 51
47 /** 52 /**
48 * @override 53 * @override
49 * @suppress {checkTypes} 54 * @suppress {checkTypes}
50 * TODO(vitalyp): remove the suppression. See the explanation in 55 * TODO(vitalyp): remove the suppression. See the explanation in
51 * chrome/browser/resources/options/automatic_settings_reset_banner.js. 56 * chrome/browser/resources/options/automatic_settings_reset_banner.js.
52 */ 57 */
53 didShowPage: function() { 58 didShowPage: function() {
Dan Beam 2016/08/23 05:48:22 var hash = this.hash.slice(1).toLowerCase(); this.
alito 2016/08/23 18:20:34 Done.
59 if (this.hash === '#userClick') {
60 // A '#userClick' hash indicates that the reset request came from the
61 // user clicking on the reset settings button. This hash is set by the
62 // browser_options page.
63 this.setResetRequestOrigin('userClick');
64 this.setHash('');
65 } else if (this.hash == '#CCT') {
66 // A '#CCT' hash indicates that the reset request came from the CCT by
67 // launching Chrome with the startup URL
68 // chrome://settings/resetProfileSettings#CCT.
69 this.setResetRequestOrigin('CCT');
70 this.setHash('');
71 } else {
72 this.setResetRequestOrigin('');
73 }
74
54 $('reset-profile-settings-title').textContent = 75 $('reset-profile-settings-title').textContent =
55 loadTimeData.getString('resetProfileSettingsOverlay'); 76 loadTimeData.getString('resetProfileSettingsOverlay');
56 $('reset-profile-settings-explanation').textContent = 77 $('reset-profile-settings-explanation').textContent =
57 loadTimeData.getString('resetProfileSettingsExplanation'); 78 loadTimeData.getString('resetProfileSettingsExplanation');
58 79
59 chrome.send('onShowResetProfileDialog'); 80 chrome.send('onShowResetProfileDialog');
60 }, 81 },
61 82
62 /** @override */ 83 /** @override */
63 didClosePage: function() { 84 didClosePage: function() {
64 chrome.send('onHideResetProfileDialog'); 85 chrome.send('onHideResetProfileDialog');
65 }, 86 },
87
88 /**
89 * Sets the reset request origin string. To be used also by subclasses, such
90 * as TriggeredResetProfileSettingsOverlay.
91 * @param {string} origin Origin of the reset request.
Dan Beam 2016/08/23 05:48:22 can you make this @protected?
alito 2016/08/23 18:20:34 Removed the setter. Now setting resetRequestOrigin
92 */
93 setResetRequestOrigin: function(origin) {
94 this.resetRequestOrigin_ = origin;
Dan Beam 2016/08/23 05:48:22 why not set this directly?
alito 2016/08/23 18:20:34 I assumed you meant that TriggeredResetProfileSett
95 },
96
97 getResetRequestOrigin: function() {
Dan Beam 2016/08/23 05:48:23 remove this getter
alito 2016/08/23 18:20:34 Done.
98 return this.resetRequestOrigin_;
99 },
66 }; 100 };
67 101
68 /** 102 /**
69 * Enables/disables UI elements after/while Chrome is performing a reset. 103 * Enables/disables UI elements after/while Chrome is performing a reset.
70 * @param {boolean} state If true, UI elements are disabled. 104 * @param {boolean} state If true, UI elements are disabled.
71 */ 105 */
72 ResetProfileSettingsOverlay.setResettingState = function(state) { 106 ResetProfileSettingsOverlay.setResettingState = function(state) {
73 $('reset-profile-settings-throbber').style.visibility = 107 $('reset-profile-settings-throbber').style.visibility =
74 state ? 'visible' : 'hidden'; 108 state ? 'visible' : 'hidden';
75 $('reset-profile-settings-dismiss').disabled = state; 109 $('reset-profile-settings-dismiss').disabled = state;
(...skipping 24 matching lines...) Expand all
100 var input = new JsEvalContext(feedbackListData); 134 var input = new JsEvalContext(feedbackListData);
101 var output = $('feedback-template'); 135 var output = $('feedback-template');
102 jstProcess(input, output); 136 jstProcess(input, output);
103 }; 137 };
104 138
105 // Export 139 // Export
106 return { 140 return {
107 ResetProfileSettingsOverlay: ResetProfileSettingsOverlay 141 ResetProfileSettingsOverlay: ResetProfileSettingsOverlay
108 }; 142 };
109 }); 143 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698