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.
9 var FEEDBACK_WIDTH = 500;
14 var FEEDBACK_HEIGHT = 585;
16 var initialFeedbackInfo = null;
18 // To generate a hashed extension ID, use a sha-256 hash, all in lower case.
20 // echo -n 'abcdefghijklmnopqrstuvwxyzabcdef' | sha1sum | \
21 // awk '{print toupper($1)}'
22 var whitelistedExtensionIds = [
23 '12E618C3C6E97495AAECF2AC12DEB082353241C6', // QuickOffice
24 '3727DD3E564B6055387425027AD74C58784ACC15', // QuickOffice
25 '2FC374607C2DF285634B67C64A2E356C607091C3', // QuickOffice
26 '2843C1E82A9B6C6FB49308FDDF4E157B6B44BC2B', // G+ Photos
27 '5B5DA6D054D10DB917AF7D9EAE3C56044D1B0B03', // G+ Photos
28 '986913085E3E3C3AFDE9B7A943149C4D3F4C937B', // Feedback Extension
29 '7AE714FFD394E073F0294CFA134C9F91DB5FBAA4', // Connectivity Diagnostics
30 'C7DA3A55C2355F994D3FDDAD120B426A0DF63843', // Connectivity Diagnostics
31 '75E3CFFFC530582C583E4690EF97C70B9C8423B7', // Connectivity Diagnostics
32 '32A1BA997F8AB8DE29ED1BA94AAF00CF2A3FEFA7', // Connectivity Diagnostics
33 'A291B26E088FA6BA53FFD72F0916F06EBA7C585A', // Chrome OS Recovery Tool
34 'D7986543275120831B39EF28D1327552FC343960', // Chrome OS Recovery Tool
35 '8EBDF73405D0B84CEABB8C7513C9B9FA9F1DC2CE', // GetHelp app.
36 '97B23E01B2AA064E8332EE43A7A85C628AADC3F2', // Chrome Remote Desktop Dev
37 '9E527CDA9D7C50844E8A5DB964A54A640AE48F98', // Chrome Remote Desktop Stable
38 'DF52618D0B040D8A054D8348D2E84DDEEE5974E7', // Chrome Remote Desktop QA
39 '269D721F163E587BC53C6F83553BF9CE2BB143CD', // Chrome Remote Desktop QA backup
40 'C449A798C495E6CF7D6AF10162113D564E67AD12', // Chrome Remote Desktop Apps V2
41 '981974CD1832B87BE6B21BE78F7249BB501E0DE6', // Play Movies Dev
42 '32FD7A816E47392C92D447707A89EB07EEDE6FF7', // Play Movies Nightly
43 '3F3CEC4B9B2B5DC2F820CE917AABDF97DB2F5B49', // Play Movies Beta
44 'F92FAC70AB68E1778BF62D9194C25979596AA0E6', // Play Movies Stable
45 '0F585FB1D0FDFBEBCE1FEB5E9DFFB6DA476B8C9B', // Hangouts Extension
46 '2D22CDB6583FD0A13758AEBE8B15E45208B4E9A7', // Hangouts Extension
47 '49DA0B9CCEEA299186C6E7226FD66922D57543DC', // Hangouts Extension
48 'E7E2461CE072DF036CF9592740196159E2D7C089', // Hangouts Extension
49 'A74A4D44C7CFCD8844830E6140C8D763E12DD8F3', // Hangouts Extension
50 '312745D9BF916161191143F6490085EEA0434997', // Hangouts Extension
51 '53041A2FA309EECED01FFC751E7399186E860B2C', // Hangouts Extension
52 '0F42756099D914A026DADFA182871C015735DD95', // Hangouts Extension
53 '1B7734733E207CCE5C33BFAA544CA89634BF881F', // GLS nightly
54 'E2ACA3D943A3C96310523BCDFD8C3AF68387E6B7', // GLS stable
55 '11B478CEC461C766A2DC1E5BEEB7970AE06DC9C2', // http://crbug.com/463552
56 '0EFB879311E9EFBB7C45251F89EC655711B1F6ED', // http://crbug.com/463552
57 '9193D3A51E2FE33B496CDA53EA330423166E7F02', // http://crbug.com/463552
58 'F9119B8B18C7C82B51E7BC6FF816B694F2EC3E89', // http://crbug.com/463552
59 'BA007D8D52CC0E2632EFCA03ACD003B0F613FD71', // http://crbug.com/470411
60 '5260FA31DE2007A837B7F7B0EB4A47CE477018C8', // http://crbug.com/470411
61 '4F4A25F31413D9B9F80E61D096DEB09082515267', // http://crbug.com/470411
62 'FBA0DE4D3EFB5485FC03760F01F821466907A743', // http://crbug.com/470411
63 'E216473E4D15C5FB14522D32C5F8DEAAB2CECDC6', // http://crbug.com/470411
64 '676A08383D875E51CE4C2308D875AE77199F1413', // http://crbug.com/473845
65 '869A23E11B308AF45A68CC386C36AADA4BE44A01', // http://crbug.com/473845
66 'E9CE07C7EDEFE70B9857B312E88F94EC49FCC30F', // http://crbug.com/473845
67 'A4577D8C2AF4CF26F40CBCA83FFA4251D6F6C8F8', // http://crbug.com/478929
68 'A8208CCC87F8261AFAEB6B85D5E8D47372DDEA6B', // http://crbug.com/478929
69 'B620CF4203315F9F2E046EDED22C7571A935958D', // http://crbug.com/510270
70 'B206D8716769728278D2D300349C6CB7D7DE2EF9', // http://crbug.com/510270
75 * Function to determine whether or not a given extension id is whitelisted to
76 * invoke the feedback UI. If the extension is whitelisted, the callback to
77 * start the Feedback UI will be called.
78 * @param {string} id the id of the sender extension.
79 * @param {Function} startFeedbackCallback The callback function that will
80 * will start the feedback UI.
81 * @param {Object} feedbackInfo The feedback info object to pass to the
82 * start feedback UI callback.
84 function senderWhitelisted(id, startFeedbackCallback, feedbackInfo) {
85 crypto.subtle.digest('SHA-1', new TextEncoder().encode(id)).then(
86 function(hashBuffer) {
88 var hashView = new Uint8Array(hashBuffer);
89 for (var i = 0; i < hashView.length; ++i) {
91 hashString += n < 0x10 ? '0' : '';
92 hashString += n.toString(16);
94 if (whitelistedExtensionIds.indexOf(hashString.toUpperCase()) != -1)
95 startFeedbackCallback(feedbackInfo);
100 * Callback which gets notified once our feedback UI has loaded and is ready to
101 * receive its initial feedback info object.
102 * @param {Object} request The message request object.
103 * @param {Object} sender The sender of the message.
104 * @param {function(Object)} sendResponse Callback for sending a response.
106 function feedbackReadyHandler(request, sender, sendResponse) {
108 chrome.runtime.sendMessage(
109 {sentFromEventPage: true, data: initialFeedbackInfo});
115 * Callback which gets notified if another extension is requesting feedback.
116 * @param {Object} request The message request object.
117 * @param {Object} sender The sender of the message.
118 * @param {function(Object)} sendResponse Callback for sending a response.
120 function requestFeedbackHandler(request, sender, sendResponse) {
121 if (request.requestFeedback)
122 senderWhitelisted(sender.id, startFeedbackUI, request.feedbackInfo);
126 * Callback which starts up the feedback UI.
127 * @param {Object} feedbackInfo Object containing any initial feedback info.
129 function startFeedbackUI(feedbackInfo) {
130 initialFeedbackInfo = feedbackInfo;
131 var win = chrome.app.window.get('default_window');
136 chrome.app.window.create('html/default.html', {
138 id: 'default_window',
139 width: FEEDBACK_WIDTH,
140 height: FEEDBACK_HEIGHT,
143 function(appWindow) {});
146 chrome.runtime.onMessage.addListener(feedbackReadyHandler);
147 chrome.runtime.onMessageExternal.addListener(requestFeedbackHandler);
148 chrome.feedbackPrivate.onFeedbackRequested.addListener(startFeedbackUI);