OLD | NEW |
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 'BA007D8D52CC0E2632EFCA03ACD003B0F613FD71', // http://crbug.com/470411 | 61 'E2ACA3D943A3C96310523BCDFD8C3AF68387E6B7', // GLS stable |
62 '5260FA31DE2007A837B7F7B0EB4A47CE477018C8', // http://crbug.com/470411 | 62 'BA007D8D52CC0E2632EFCA03ACD003B0F613FD71', // http://crbug.com/470411 |
63 '4F4A25F31413D9B9F80E61D096DEB09082515267', // http://crbug.com/470411 | 63 '5260FA31DE2007A837B7F7B0EB4A47CE477018C8', // http://crbug.com/470411 |
64 'FBA0DE4D3EFB5485FC03760F01F821466907A743', // http://crbug.com/470411 | 64 '4F4A25F31413D9B9F80E61D096DEB09082515267', // http://crbug.com/470411 |
65 'E216473E4D15C5FB14522D32C5F8DEAAB2CECDC6', // http://crbug.com/470411 | 65 'FBA0DE4D3EFB5485FC03760F01F821466907A743', // http://crbug.com/470411 |
66 '676A08383D875E51CE4C2308D875AE77199F1413', // http://crbug.com/473845 | 66 'E216473E4D15C5FB14522D32C5F8DEAAB2CECDC6', // http://crbug.com/470411 |
67 '869A23E11B308AF45A68CC386C36AADA4BE44A01', // http://crbug.com/473845 | 67 '676A08383D875E51CE4C2308D875AE77199F1413', // http://crbug.com/473845 |
68 'E9CE07C7EDEFE70B9857B312E88F94EC49FCC30F', // http://crbug.com/473845 | 68 '869A23E11B308AF45A68CC386C36AADA4BE44A01', // http://crbug.com/473845 |
69 'A4577D8C2AF4CF26F40CBCA83FFA4251D6F6C8F8', // http://crbug.com/478929 | 69 'E9CE07C7EDEFE70B9857B312E88F94EC49FCC30F', // http://crbug.com/473845 |
70 'A8208CCC87F8261AFAEB6B85D5E8D47372DDEA6B', // http://crbug.com/478929 | 70 'A4577D8C2AF4CF26F40CBCA83FFA4251D6F6C8F8', // http://crbug.com/478929 |
| 71 'A8208CCC87F8261AFAEB6B85D5E8D47372DDEA6B', // http://crbug.com/478929 |
71 // TODO (ntang) Remove the following 2 hashes by 12/31/2017. | 72 // TODO (ntang) Remove the following 2 hashes by 12/31/2017. |
72 'B620CF4203315F9F2E046EDED22C7571A935958D', // http://crbug.com/510270 | 73 'B620CF4203315F9F2E046EDED22C7571A935958D', // http://crbug.com/510270 |
73 'B206D8716769728278D2D300349C6CB7D7DE2EF9', // http://crbug.com/510270 | 74 'B206D8716769728278D2D300349C6CB7D7DE2EF9', // http://crbug.com/510270 |
74 'EFCF5358672FEE04789FD2EC3638A67ADEDB6C8C', // http://crbug.com/514696 | 75 'EFCF5358672FEE04789FD2EC3638A67ADEDB6C8C', // http://crbug.com/514696 |
75 'FAD85BC419FE00995D196312F53448265EFA86F1', // http://crbug.com/516527 | 76 'FAD85BC419FE00995D196312F53448265EFA86F1', // http://crbug.com/516527 |
76 'F33B037DEDA65F226B7409C2ADB0CF3F8565AB03', // http://crbug.com/541769 | 77 'F33B037DEDA65F226B7409C2ADB0CF3F8565AB03', // http://crbug.com/541769 |
77 '969C788BCBC82FBBE04A17360CA165C23A419257', // http://crbug.com/541769 | 78 '969C788BCBC82FBBE04A17360CA165C23A419257', // http://crbug.com/541769 |
78 '3BC3740BFC58F06088B300274B4CFBEA20136342', // http://crbug.com/541769 | 79 '3BC3740BFC58F06088B300274B4CFBEA20136342', // http://crbug.com/541769 |
79 '2B6C6A4A5940017146F3E58B7F90116206E84685', // http://crbug.com/642141 | 80 '2B6C6A4A5940017146F3E58B7F90116206E84685', // http://crbug.com/642141 |
80 '96FF2FFA5C9173C76D47184B3E86D267B37781DE', // http://crbug.com/642141 | 81 '96FF2FFA5C9173C76D47184B3E86D267B37781DE', // http://crbug.com/642141 |
81 ]; | 82 ]; |
82 | 83 |
83 /** | 84 /** |
84 * Used to generate unique IDs for FeedbackRequest objects. | 85 * Used to generate unique IDs for FeedbackRequest objects. |
85 * @type {number} | 86 * @type {number} |
86 */ | 87 */ |
87 var lastUsedId = 0; | 88 var lastUsedId = 0; |
88 | 89 |
89 /** | 90 /** |
90 * A FeedbackRequest object represents a unique feedback report, requested by an | 91 * A FeedbackRequest object represents a unique feedback report, requested by an |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 * sent. | 171 * sent. |
171 */ | 172 */ |
172 sendReportNow() { | 173 sendReportNow() { |
173 if (!this.useSystemInfo_) { | 174 if (!this.useSystemInfo_) { |
174 // Clear the system information if the user doesn't want it to be sent. | 175 // Clear the system information if the user doesn't want it to be sent. |
175 this.feedbackInfo_.systemInformation = null; | 176 this.feedbackInfo_.systemInformation = null; |
176 } | 177 } |
177 | 178 |
178 /** @const */ var ID = this.id_; | 179 /** @const */ var ID = this.id_; |
179 /** @const */ var FLOW = this.feedbackInfo_.flow; | 180 /** @const */ var FLOW = this.feedbackInfo_.flow; |
180 chrome.feedbackPrivate.sendFeedback(this.feedbackInfo_, | 181 chrome.feedbackPrivate.sendFeedback(this.feedbackInfo_, function(result) { |
181 function(result) { | 182 if (result == ReportStatus.SUCCESS) { |
182 if (result == ReportStatus.SUCCESS) { | 183 console.log('Feedback: Report sent for request with ID ' + ID); |
183 console.log('Feedback: Report sent for request with ID ' + ID); | 184 if (FLOW != chrome.feedbackPrivate.FeedbackFlow.LOGIN) |
184 if (FLOW != chrome.feedbackPrivate.FeedbackFlow.LOGIN) | 185 window.open(FEEDBACK_LANDING_PAGE, '_blank'); |
185 window.open(FEEDBACK_LANDING_PAGE, '_blank'); | 186 } else { |
186 } else { | 187 console.log( |
187 console.log('Feedback: Report for request with ID ' + ID + | 188 'Feedback: Report for request with ID ' + ID + |
188 ' will be sent later.'); | 189 ' will be sent later.'); |
189 } | 190 } |
190 }); | 191 }); |
191 } | 192 } |
192 | 193 |
193 /** | 194 /** |
194 * Handles the event when the feedback UI window corresponding to this | 195 * Handles the event when the feedback UI window corresponding to this |
195 * FeedbackRequest instance is closed. | 196 * FeedbackRequest instance is closed. |
196 */ | 197 */ |
197 onWindowClosed() { | 198 onWindowClosed() { |
198 if (!this.reportIsBeingSent_) | 199 if (!this.reportIsBeingSent_) |
199 this.isRequestCanceled_ = true; | 200 this.isRequestCanceled_ = true; |
200 } | 201 } |
201 } | 202 } |
202 | 203 |
203 /** | 204 /** |
204 * Function to determine whether or not a given extension id is whitelisted to | 205 * Function to determine whether or not a given extension id is whitelisted to |
205 * invoke the feedback UI. If the extension is whitelisted, the callback to | 206 * invoke the feedback UI. If the extension is whitelisted, the callback to |
206 * start the Feedback UI will be called. | 207 * start the Feedback UI will be called. |
207 * @param {string} id the id of the sender extension. | 208 * @param {string} id the id of the sender extension. |
208 * @param {Function} startFeedbackCallback The callback function that will | 209 * @param {Function} startFeedbackCallback The callback function that will |
209 * will start the feedback UI. | 210 * will start the feedback UI. |
210 * @param {Object} feedbackInfo The feedback info object to pass to the | 211 * @param {Object} feedbackInfo The feedback info object to pass to the |
211 * start feedback UI callback. | 212 * start feedback UI callback. |
212 */ | 213 */ |
213 function senderWhitelisted(id, startFeedbackCallback, feedbackInfo) { | 214 function senderWhitelisted(id, startFeedbackCallback, feedbackInfo) { |
214 crypto.subtle.digest('SHA-1', new TextEncoder().encode(id)).then( | 215 crypto.subtle.digest('SHA-1', new TextEncoder().encode(id)) |
215 function(hashBuffer) { | 216 .then(function(hashBuffer) { |
216 var hashString = ''; | 217 var hashString = ''; |
217 var hashView = new Uint8Array(hashBuffer); | 218 var hashView = new Uint8Array(hashBuffer); |
218 for (var i = 0; i < hashView.length; ++i) { | 219 for (var i = 0; i < hashView.length; ++i) { |
219 var n = hashView[i]; | 220 var n = hashView[i]; |
220 hashString += n < 0x10 ? '0' : ''; | 221 hashString += n < 0x10 ? '0' : ''; |
221 hashString += n.toString(16); | 222 hashString += n.toString(16); |
222 } | 223 } |
223 if (whitelistedExtensionIds.indexOf(hashString.toUpperCase()) != -1) | 224 if (whitelistedExtensionIds.indexOf(hashString.toUpperCase()) != -1) |
224 startFeedbackCallback(feedbackInfo); | 225 startFeedbackCallback(feedbackInfo); |
225 }); | 226 }); |
226 } | 227 } |
227 | 228 |
228 /** | 229 /** |
229 * Callback which gets notified once our feedback UI has loaded and is ready to | 230 * Callback which gets notified once our feedback UI has loaded and is ready to |
230 * receive its initial feedback info object. | 231 * receive its initial feedback info object. |
231 * @param {Object} request The message request object. | 232 * @param {Object} request The message request object. |
232 * @param {Object} sender The sender of the message. | 233 * @param {Object} sender The sender of the message. |
233 * @param {function(Object)} sendResponse Callback for sending a response. | 234 * @param {function(Object)} sendResponse Callback for sending a response. |
234 */ | 235 */ |
235 function feedbackReadyHandler(request, sender, sendResponse) { | 236 function feedbackReadyHandler(request, sender, sendResponse) { |
(...skipping 15 matching lines...) Expand all Loading... |
251 /** | 252 /** |
252 * Callback which starts up the feedback UI. | 253 * Callback which starts up the feedback UI. |
253 * @param {Object} feedbackInfo Object containing any initial feedback info. | 254 * @param {Object} feedbackInfo Object containing any initial feedback info. |
254 */ | 255 */ |
255 function startFeedbackUI(feedbackInfo) { | 256 function startFeedbackUI(feedbackInfo) { |
256 var win = chrome.app.window.get(FEEDBACK_DEFAULT_WINDOW_ID); | 257 var win = chrome.app.window.get(FEEDBACK_DEFAULT_WINDOW_ID); |
257 if (win) { | 258 if (win) { |
258 win.show(); | 259 win.show(); |
259 return; | 260 return; |
260 } | 261 } |
261 chrome.app.window.create('html/default.html', { | 262 chrome.app.window.create( |
262 frame: feedbackInfo.useSystemWindowFrame ? 'chrome' : 'none', | 263 'html/default.html', { |
263 id: FEEDBACK_DEFAULT_WINDOW_ID, | 264 frame: feedbackInfo.useSystemWindowFrame ? 'chrome' : 'none', |
264 innerBounds: { | 265 id: FEEDBACK_DEFAULT_WINDOW_ID, |
265 minWidth: FEEDBACK_WIDTH, | 266 innerBounds: { |
266 minHeight: FEEDBACK_HEIGHT, | 267 minWidth: FEEDBACK_WIDTH, |
| 268 minHeight: FEEDBACK_HEIGHT, |
| 269 }, |
| 270 hidden: true, |
| 271 resizable: false |
267 }, | 272 }, |
268 hidden: true, | |
269 resizable: false }, | |
270 function(appWindow) { | 273 function(appWindow) { |
271 var request = new FeedbackRequest(feedbackInfo); | 274 var request = new FeedbackRequest(feedbackInfo); |
272 | 275 |
273 // The feedbackInfo member of the new window should refer to the one in | 276 // The feedbackInfo member of the new window should refer to the one in |
274 // its corresponding FeedbackRequest object to avoid copying and | 277 // its corresponding FeedbackRequest object to avoid copying and |
275 // duplicatations. | 278 // duplicatations. |
276 appWindow.contentWindow.feedbackInfo = request.feedbackInfo_; | 279 appWindow.contentWindow.feedbackInfo = request.feedbackInfo_; |
277 | 280 |
278 // Define some functions for the new window so that it can call back | 281 // Define some functions for the new window so that it can call back |
279 // into here. | 282 // into here. |
(...skipping 11 matching lines...) Expand all Loading... |
291 // Observe when the window is closed. | 294 // Observe when the window is closed. |
292 appWindow.onClosed.addListener(function() { | 295 appWindow.onClosed.addListener(function() { |
293 request.onWindowClosed(); | 296 request.onWindowClosed(); |
294 }); | 297 }); |
295 }); | 298 }); |
296 } | 299 } |
297 | 300 |
298 chrome.runtime.onMessage.addListener(feedbackReadyHandler); | 301 chrome.runtime.onMessage.addListener(feedbackReadyHandler); |
299 chrome.runtime.onMessageExternal.addListener(requestFeedbackHandler); | 302 chrome.runtime.onMessageExternal.addListener(requestFeedbackHandler); |
300 chrome.feedbackPrivate.onFeedbackRequested.addListener(startFeedbackUI); | 303 chrome.feedbackPrivate.onFeedbackRequested.addListener(startFeedbackUI); |
OLD | NEW |