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

Side by Side Diff: chrome/browser/resources/feedback/js/event_handler.js

Issue 2600683002: Run tools/clang-format-js on some of chrome/browser/resources/ (Closed)
Patch Set: hackhackhack Created 3 years, 11 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 <include src="data.js"> 5 // <include src="data.js">
6 6
7 /** 7 /**
8 * @type {number} 8 * @type {number}
9 * @const 9 * @const
10 */ 10 */
11 var FEEDBACK_WIDTH = 500; 11 var FEEDBACK_WIDTH = 500;
12 /** 12 /**
13 * @type {number} 13 * @type {number}
14 * @const 14 * @const
15 */ 15 */
16 var FEEDBACK_HEIGHT = 610; 16 var FEEDBACK_HEIGHT = 610;
17 17
18 /** 18 /**
19 * @type {string} 19 * @type {string}
20 * @const 20 * @const
21 */ 21 */
22 var FEEDBACK_DEFAULT_WINDOW_ID = 'default_window'; 22 var FEEDBACK_DEFAULT_WINDOW_ID = 'default_window';
23 23
24 // To generate a hashed extension ID, use a sha-1 hash, all in lower case. 24 // To generate a hashed extension ID, use a sha-1 hash, all in lower case.
25 // Example: 25 // Example:
26 // echo -n 'abcdefghijklmnopqrstuvwxyzabcdef' | sha1sum | \ 26 // echo -n 'abcdefghijklmnopqrstuvwxyzabcdef' | sha1sum | \
27 // awk '{print toupper($1)}' 27 // awk '{print toupper($1)}'
28 var whitelistedExtensionIds = [ 28 var whitelistedExtensionIds = [
29 '12E618C3C6E97495AAECF2AC12DEB082353241C6', // QuickOffice 29 '12E618C3C6E97495AAECF2AC12DEB082353241C6', // QuickOffice
30 '3727DD3E564B6055387425027AD74C58784ACC15', // QuickOffice 30 '3727DD3E564B6055387425027AD74C58784ACC15', // QuickOffice
31 '2FC374607C2DF285634B67C64A2E356C607091C3', // QuickOffice 31 '2FC374607C2DF285634B67C64A2E356C607091C3', // QuickOffice
32 '2843C1E82A9B6C6FB49308FDDF4E157B6B44BC2B', // G+ Photos 32 '2843C1E82A9B6C6FB49308FDDF4E157B6B44BC2B', // G+ Photos
33 '5B5DA6D054D10DB917AF7D9EAE3C56044D1B0B03', // G+ Photos 33 '5B5DA6D054D10DB917AF7D9EAE3C56044D1B0B03', // G+ Photos
34 '986913085E3E3C3AFDE9B7A943149C4D3F4C937B', // Feedback Extension 34 '986913085E3E3C3AFDE9B7A943149C4D3F4C937B', // Feedback Extension
35 '7AE714FFD394E073F0294CFA134C9F91DB5FBAA4', // Connectivity Diagnostics 35 '7AE714FFD394E073F0294CFA134C9F91DB5FBAA4', // Connectivity Diagnostics
36 'C7DA3A55C2355F994D3FDDAD120B426A0DF63843', // Connectivity Diagnostics 36 'C7DA3A55C2355F994D3FDDAD120B426A0DF63843', // Connectivity Diagnostics
37 '75E3CFFFC530582C583E4690EF97C70B9C8423B7', // Connectivity Diagnostics 37 '75E3CFFFC530582C583E4690EF97C70B9C8423B7', // Connectivity Diagnostics
38 '32A1BA997F8AB8DE29ED1BA94AAF00CF2A3FEFA7', // Connectivity Diagnostics 38 '32A1BA997F8AB8DE29ED1BA94AAF00CF2A3FEFA7', // Connectivity Diagnostics
39 'A291B26E088FA6BA53FFD72F0916F06EBA7C585A', // Chrome OS Recovery Tool 39 'A291B26E088FA6BA53FFD72F0916F06EBA7C585A', // Chrome OS Recovery Tool
40 'D7986543275120831B39EF28D1327552FC343960', // Chrome OS Recovery Tool 40 'D7986543275120831B39EF28D1327552FC343960', // Chrome OS Recovery Tool
41 '8EBDF73405D0B84CEABB8C7513C9B9FA9F1DC2CE', // GetHelp app. 41 '8EBDF73405D0B84CEABB8C7513C9B9FA9F1DC2CE', // GetHelp app.
42 '97B23E01B2AA064E8332EE43A7A85C628AADC3F2', // Chrome Remote Desktop Dev 42 '97B23E01B2AA064E8332EE43A7A85C628AADC3F2', // Chrome Remote Desktop Dev
43 '9E527CDA9D7C50844E8A5DB964A54A640AE48F98', // Chrome Remote Desktop Stable 43 '9E527CDA9D7C50844E8A5DB964A54A640AE48F98', // Chrome Remote Desktop Stable
44 'DF52618D0B040D8A054D8348D2E84DDEEE5974E7', // Chrome Remote Desktop QA 44 'DF52618D0B040D8A054D8348D2E84DDEEE5974E7', // Chrome Remote Desktop QA
45 '269D721F163E587BC53C6F83553BF9CE2BB143CD', // Chrome Remote Desktop QA backup 45 '269D721F163E587BC53C6F83553BF9CE2BB143CD', // Chrome Remote Desktop QA
46 'C449A798C495E6CF7D6AF10162113D564E67AD12', // Chrome Remote Desktop Apps V2 46 // backup
47 '981974CD1832B87BE6B21BE78F7249BB501E0DE6', // Play Movies Dev 47 'C449A798C495E6CF7D6AF10162113D564E67AD12', // Chrome Remote Desktop Apps V2
48 '32FD7A816E47392C92D447707A89EB07EEDE6FF7', // Play Movies Nightly 48 '981974CD1832B87BE6B21BE78F7249BB501E0DE6', // Play Movies Dev
49 '3F3CEC4B9B2B5DC2F820CE917AABDF97DB2F5B49', // Play Movies Beta 49 '32FD7A816E47392C92D447707A89EB07EEDE6FF7', // Play Movies Nightly
50 'F92FAC70AB68E1778BF62D9194C25979596AA0E6', // Play Movies Stable 50 '3F3CEC4B9B2B5DC2F820CE917AABDF97DB2F5B49', // Play Movies Beta
51 '0F585FB1D0FDFBEBCE1FEB5E9DFFB6DA476B8C9B', // Hangouts Extension 51 'F92FAC70AB68E1778BF62D9194C25979596AA0E6', // Play Movies Stable
52 '2D22CDB6583FD0A13758AEBE8B15E45208B4E9A7', // Hangouts Extension 52 '0F585FB1D0FDFBEBCE1FEB5E9DFFB6DA476B8C9B', // Hangouts Extension
53 '49DA0B9CCEEA299186C6E7226FD66922D57543DC', // Hangouts Extension 53 '2D22CDB6583FD0A13758AEBE8B15E45208B4E9A7', // Hangouts Extension
54 'E7E2461CE072DF036CF9592740196159E2D7C089', // Hangouts Extension 54 '49DA0B9CCEEA299186C6E7226FD66922D57543DC', // Hangouts Extension
55 'A74A4D44C7CFCD8844830E6140C8D763E12DD8F3', // Hangouts Extension 55 'E7E2461CE072DF036CF9592740196159E2D7C089', // Hangouts Extension
56 '312745D9BF916161191143F6490085EEA0434997', // Hangouts Extension 56 'A74A4D44C7CFCD8844830E6140C8D763E12DD8F3', // Hangouts Extension
57 '53041A2FA309EECED01FFC751E7399186E860B2C', // Hangouts Extension 57 '312745D9BF916161191143F6490085EEA0434997', // Hangouts Extension
58 '0F42756099D914A026DADFA182871C015735DD95', // Hangouts Extension 58 '53041A2FA309EECED01FFC751E7399186E860B2C', // Hangouts Extension
59 '1B7734733E207CCE5C33BFAA544CA89634BF881F', // GLS nightly 59 '0F42756099D914A026DADFA182871C015735DD95', // Hangouts Extension
60 'E2ACA3D943A3C96310523BCDFD8C3AF68387E6B7', // GLS stable 60 '1B7734733E207CCE5C33BFAA544CA89634BF881F', // GLS nightly
61 '11B478CEC461C766A2DC1E5BEEB7970AE06DC9C2', // http://crbug.com/463552 61 'E2ACA3D943A3C96310523BCDFD8C3AF68387E6B7', // GLS stable
62 '0EFB879311E9EFBB7C45251F89EC655711B1F6ED', // http://crbug.com/463552 62 '11B478CEC461C766A2DC1E5BEEB7970AE06DC9C2', // http://crbug.com/463552
63 '9193D3A51E2FE33B496CDA53EA330423166E7F02', // http://crbug.com/463552 63 '0EFB879311E9EFBB7C45251F89EC655711B1F6ED', // http://crbug.com/463552
64 'F9119B8B18C7C82B51E7BC6FF816B694F2EC3E89', // http://crbug.com/463552 64 '9193D3A51E2FE33B496CDA53EA330423166E7F02', // http://crbug.com/463552
65 'BA007D8D52CC0E2632EFCA03ACD003B0F613FD71', // http://crbug.com/470411 65 'F9119B8B18C7C82B51E7BC6FF816B694F2EC3E89', // http://crbug.com/463552
66 '5260FA31DE2007A837B7F7B0EB4A47CE477018C8', // http://crbug.com/470411 66 'BA007D8D52CC0E2632EFCA03ACD003B0F613FD71', // http://crbug.com/470411
67 '4F4A25F31413D9B9F80E61D096DEB09082515267', // http://crbug.com/470411 67 '5260FA31DE2007A837B7F7B0EB4A47CE477018C8', // http://crbug.com/470411
68 'FBA0DE4D3EFB5485FC03760F01F821466907A743', // http://crbug.com/470411 68 '4F4A25F31413D9B9F80E61D096DEB09082515267', // http://crbug.com/470411
69 'E216473E4D15C5FB14522D32C5F8DEAAB2CECDC6', // http://crbug.com/470411 69 'FBA0DE4D3EFB5485FC03760F01F821466907A743', // http://crbug.com/470411
70 '676A08383D875E51CE4C2308D875AE77199F1413', // http://crbug.com/473845 70 'E216473E4D15C5FB14522D32C5F8DEAAB2CECDC6', // http://crbug.com/470411
71 '869A23E11B308AF45A68CC386C36AADA4BE44A01', // http://crbug.com/473845 71 '676A08383D875E51CE4C2308D875AE77199F1413', // http://crbug.com/473845
72 'E9CE07C7EDEFE70B9857B312E88F94EC49FCC30F', // http://crbug.com/473845 72 '869A23E11B308AF45A68CC386C36AADA4BE44A01', // http://crbug.com/473845
73 'A4577D8C2AF4CF26F40CBCA83FFA4251D6F6C8F8', // http://crbug.com/478929 73 'E9CE07C7EDEFE70B9857B312E88F94EC49FCC30F', // http://crbug.com/473845
74 'A8208CCC87F8261AFAEB6B85D5E8D47372DDEA6B', // http://crbug.com/478929 74 'A4577D8C2AF4CF26F40CBCA83FFA4251D6F6C8F8', // http://crbug.com/478929
75 'A8208CCC87F8261AFAEB6B85D5E8D47372DDEA6B', // http://crbug.com/478929
75 // TODO (ntang) Remove the following 2 hashes by 12/31/2017. 76 // TODO (ntang) Remove the following 2 hashes by 12/31/2017.
76 'B620CF4203315F9F2E046EDED22C7571A935958D', // http://crbug.com/510270 77 'B620CF4203315F9F2E046EDED22C7571A935958D', // http://crbug.com/510270
77 'B206D8716769728278D2D300349C6CB7D7DE2EF9', // http://crbug.com/510270 78 'B206D8716769728278D2D300349C6CB7D7DE2EF9', // http://crbug.com/510270
78 'EFCF5358672FEE04789FD2EC3638A67ADEDB6C8C', // http://crbug.com/514696 79 'EFCF5358672FEE04789FD2EC3638A67ADEDB6C8C', // http://crbug.com/514696
79 'FAD85BC419FE00995D196312F53448265EFA86F1', // http://crbug.com/516527 80 'FAD85BC419FE00995D196312F53448265EFA86F1', // http://crbug.com/516527
80 'F33B037DEDA65F226B7409C2ADB0CF3F8565AB03', // http://crbug.com/541769 81 'F33B037DEDA65F226B7409C2ADB0CF3F8565AB03', // http://crbug.com/541769
81 '969C788BCBC82FBBE04A17360CA165C23A419257', // http://crbug.com/541769 82 '969C788BCBC82FBBE04A17360CA165C23A419257', // http://crbug.com/541769
82 '3BC3740BFC58F06088B300274B4CFBEA20136342', // http://crbug.com/541769 83 '3BC3740BFC58F06088B300274B4CFBEA20136342', // http://crbug.com/541769
83 '2B6C6A4A5940017146F3E58B7F90116206E84685', // http://crbug.com/642141 84 '2B6C6A4A5940017146F3E58B7F90116206E84685', // http://crbug.com/642141
84 '96FF2FFA5C9173C76D47184B3E86D267B37781DE', // http://crbug.com/642141 85 '96FF2FFA5C9173C76D47184B3E86D267B37781DE', // http://crbug.com/642141
85 ]; 86 ];
86 87
87 /** 88 /**
88 * Used to generate unique IDs for FeedbackRequest objects. 89 * Used to generate unique IDs for FeedbackRequest objects.
89 * @type {number} 90 * @type {number}
90 */ 91 */
91 var lastUsedId = 0; 92 var lastUsedId = 0;
92 93
93 /** 94 /**
94 * A FeedbackRequest object represents a unique feedback report, requested by an 95 * A FeedbackRequest object represents a unique feedback report, requested by an
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 * sent. 175 * sent.
175 */ 176 */
176 sendReportNow() { 177 sendReportNow() {
177 if (!this.useSystemInfo_) { 178 if (!this.useSystemInfo_) {
178 // Clear the system information if the user doesn't want it to be sent. 179 // Clear the system information if the user doesn't want it to be sent.
179 this.feedbackInfo_.systemInformation = null; 180 this.feedbackInfo_.systemInformation = null;
180 } 181 }
181 182
182 /** @const */ var ID = this.id_; 183 /** @const */ var ID = this.id_;
183 /** @const */ var FLOW = this.feedbackInfo_.flow; 184 /** @const */ var FLOW = this.feedbackInfo_.flow;
184 chrome.feedbackPrivate.sendFeedback(this.feedbackInfo_, 185 chrome.feedbackPrivate.sendFeedback(this.feedbackInfo_, function(result) {
185 function(result) { 186 if (result == ReportStatus.SUCCESS) {
186 if (result == ReportStatus.SUCCESS) { 187 console.log('Feedback: Report sent for request with ID ' + ID);
187 console.log('Feedback: Report sent for request with ID ' + ID); 188 if (FLOW != FeedbackFlow.LOGIN)
188 if (FLOW != FeedbackFlow.LOGIN) 189 window.open(FEEDBACK_LANDING_PAGE, '_blank');
189 window.open(FEEDBACK_LANDING_PAGE, '_blank'); 190 } else {
190 } else { 191 console.log(
191 console.log('Feedback: Report for request with ID ' + ID + 192 'Feedback: Report for request with ID ' + ID +
192 ' will be sent later.'); 193 ' will be sent later.');
193 } 194 }
194 }); 195 });
195 } 196 }
196 197
197 /** 198 /**
198 * Handles the event when the feedback UI window corresponding to this 199 * Handles the event when the feedback UI window corresponding to this
199 * FeedbackRequest instance is closed. 200 * FeedbackRequest instance is closed.
200 */ 201 */
201 onWindowClosed() { 202 onWindowClosed() {
202 if (!this.reportIsBeingSent_) 203 if (!this.reportIsBeingSent_)
203 this.isRequestCanceled_ = true; 204 this.isRequestCanceled_ = true;
204 } 205 }
205 }; 206 };
206 207
207 /** 208 /**
208 * Function to determine whether or not a given extension id is whitelisted to 209 * Function to determine whether or not a given extension id is whitelisted to
209 * invoke the feedback UI. If the extension is whitelisted, the callback to 210 * invoke the feedback UI. If the extension is whitelisted, the callback to
210 * start the Feedback UI will be called. 211 * start the Feedback UI will be called.
211 * @param {string} id the id of the sender extension. 212 * @param {string} id the id of the sender extension.
212 * @param {Function} startFeedbackCallback The callback function that will 213 * @param {Function} startFeedbackCallback The callback function that will
213 * will start the feedback UI. 214 * will start the feedback UI.
214 * @param {Object} feedbackInfo The feedback info object to pass to the 215 * @param {Object} feedbackInfo The feedback info object to pass to the
215 * start feedback UI callback. 216 * start feedback UI callback.
216 */ 217 */
217 function senderWhitelisted(id, startFeedbackCallback, feedbackInfo) { 218 function senderWhitelisted(id, startFeedbackCallback, feedbackInfo) {
218 crypto.subtle.digest('SHA-1', new TextEncoder().encode(id)).then( 219 crypto.subtle.digest('SHA-1', new TextEncoder().encode(id))
219 function(hashBuffer) { 220 .then(function(hashBuffer) {
220 var hashString = ''; 221 var hashString = '';
221 var hashView = new Uint8Array(hashBuffer); 222 var hashView = new Uint8Array(hashBuffer);
222 for (var i = 0; i < hashView.length; ++i) { 223 for (var i = 0; i < hashView.length; ++i) {
223 var n = hashView[i]; 224 var n = hashView[i];
224 hashString += n < 0x10 ? '0' : ''; 225 hashString += n < 0x10 ? '0' : '';
225 hashString += n.toString(16); 226 hashString += n.toString(16);
226 } 227 }
227 if (whitelistedExtensionIds.indexOf(hashString.toUpperCase()) != -1) 228 if (whitelistedExtensionIds.indexOf(hashString.toUpperCase()) != -1)
228 startFeedbackCallback(feedbackInfo); 229 startFeedbackCallback(feedbackInfo);
229 }); 230 });
230 } 231 }
231 232
232 /** 233 /**
233 * Callback which gets notified once our feedback UI has loaded and is ready to 234 * Callback which gets notified once our feedback UI has loaded and is ready to
234 * receive its initial feedback info object. 235 * receive its initial feedback info object.
235 * @param {Object} request The message request object. 236 * @param {Object} request The message request object.
236 * @param {Object} sender The sender of the message. 237 * @param {Object} sender The sender of the message.
237 * @param {function(Object)} sendResponse Callback for sending a response. 238 * @param {function(Object)} sendResponse Callback for sending a response.
238 */ 239 */
239 function feedbackReadyHandler(request, sender, sendResponse) { 240 function feedbackReadyHandler(request, sender, sendResponse) {
(...skipping 15 matching lines...) Expand all
255 /** 256 /**
256 * Callback which starts up the feedback UI. 257 * Callback which starts up the feedback UI.
257 * @param {Object} feedbackInfo Object containing any initial feedback info. 258 * @param {Object} feedbackInfo Object containing any initial feedback info.
258 */ 259 */
259 function startFeedbackUI(feedbackInfo) { 260 function startFeedbackUI(feedbackInfo) {
260 var win = chrome.app.window.get(FEEDBACK_DEFAULT_WINDOW_ID); 261 var win = chrome.app.window.get(FEEDBACK_DEFAULT_WINDOW_ID);
261 if (win) { 262 if (win) {
262 win.show(); 263 win.show();
263 return; 264 return;
264 } 265 }
265 chrome.app.window.create('html/default.html', { 266 chrome.app.window.create(
266 frame: feedbackInfo.useSystemWindowFrame ? 'chrome' : 'none', 267 'html/default.html', {
267 id: FEEDBACK_DEFAULT_WINDOW_ID, 268 frame: feedbackInfo.useSystemWindowFrame ? 'chrome' : 'none',
268 innerBounds: { 269 id: FEEDBACK_DEFAULT_WINDOW_ID,
269 minWidth: FEEDBACK_WIDTH, 270 innerBounds: {
270 minHeight: FEEDBACK_HEIGHT, 271 minWidth: FEEDBACK_WIDTH,
272 minHeight: FEEDBACK_HEIGHT,
273 },
274 hidden: true,
275 resizable: false
271 }, 276 },
272 hidden: true,
273 resizable: false },
274 function(appWindow) { 277 function(appWindow) {
275 var request = new FeedbackRequest(feedbackInfo); 278 var request = new FeedbackRequest(feedbackInfo);
276 279
277 // The feedbackInfo member of the new window should refer to the one in 280 // The feedbackInfo member of the new window should refer to the one in
278 // its corresponding FeedbackRequest object to avoid copying and 281 // its corresponding FeedbackRequest object to avoid copying and
279 // duplicatations. 282 // duplicatations.
280 appWindow.contentWindow.feedbackInfo = request.feedbackInfo_; 283 appWindow.contentWindow.feedbackInfo = request.feedbackInfo_;
281 284
282 // Define some functions for the new window so that it can call back 285 // Define some functions for the new window so that it can call back
283 // into here. 286 // into here.
(...skipping 11 matching lines...) Expand all
295 // Observe when the window is closed. 298 // Observe when the window is closed.
296 appWindow.onClosed.addListener(function() { 299 appWindow.onClosed.addListener(function() {
297 request.onWindowClosed(); 300 request.onWindowClosed();
298 }); 301 });
299 }); 302 });
300 } 303 }
301 304
302 chrome.runtime.onMessage.addListener(feedbackReadyHandler); 305 chrome.runtime.onMessage.addListener(feedbackReadyHandler);
303 chrome.runtime.onMessageExternal.addListener(requestFeedbackHandler); 306 chrome.runtime.onMessageExternal.addListener(requestFeedbackHandler);
304 chrome.feedbackPrivate.onFeedbackRequested.addListener(startFeedbackUI); 307 chrome.feedbackPrivate.onFeedbackRequested.addListener(startFeedbackUI);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698