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 var whitelistedExtensionIds = [
19 'bpmcpldpdmajfigpchkicefoigmkfalc', // QuickOffice
20 'ehibbfinohgbchlgdbfpikodjaojhccn', // QuickOffice
21 'gbkeegbaiigmenfmjfclcdgdpimamgkj', // QuickOffice
22 'efjnaogkjbogokcnohkmnjdojkikgobo', // G+ Photos
23 'ebpbnabdhheoknfklmpddcdijjkmklkp', // G+ Photos
24 'endkpmfloggdajndjpoekmkjnkolfdbf', // Feedback Extension
25 'mlocfejafidcakdddnndjdngfmncfbeg', // Connectivity Diagnostics
26 'ganomidahfnpdchomfgdoppjmmedlhia', // Connectivity Diagnostics
27 'eemlkeanncmjljgehlbplemhmdmalhdc', // Connectivity Diagnostics
28 'kodldpbjkkmmnilagfdheibampofhaom', // Connectivity Diagnostics
29 'kkebgepbbgbcmghedmmdfcbdcodlkngh', // Chrome OS Recovery Tool
30 'jndclpdbaamdhonoechobihbbiimdgai', // Chrome OS Recovery Tool
31 'ljoammodoonkhnehlncldjelhidljdpi', // GetHelp app.
32 'ljacajndfccfgnfohlgkdphmbnpkjflk', // Chrome Remote Desktop Dev
33 'gbchcmhmhahfdphkhkmpfmihenigjmpp', // Chrome Remote Desktop Stable
37 * Function to determine whether or not a given extension id is whitelisted to
38 * invoke the feedback UI.
39 * @param {string} id the id of the sender extension.
40 * @return {boolean} Whether or not this sender is whitelisted.
42 function senderWhitelisted(id) {
43 return id && whitelistedExtensionIds.indexOf(id) != -1;
47 * Callback which gets notified once our feedback UI has loaded and is ready to
48 * receive its initial feedback info object.
49 * @param {Object} request The message request object.
50 * @param {Object} sender The sender of the message.
51 * @param {function(Object)} sendResponse Callback for sending a response.
53 function feedbackReadyHandler(request, sender, sendResponse) {
55 // TODO(rkc): Remove logging once crbug.com/284662 is closed.
56 console.log('FEEDBACK_DEBUG: FeedbackUI Ready. Sending feedbackInfo.');
57 chrome.runtime.sendMessage(
58 {sentFromEventPage: true, data: initialFeedbackInfo});
64 * Callback which gets notified if another extension is requesting feedback.
65 * @param {Object} request The message request object.
66 * @param {Object} sender The sender of the message.
67 * @param {function(Object)} sendResponse Callback for sending a response.
69 function requestFeedbackHandler(request, sender, sendResponse) {
70 if (request.requestFeedback && senderWhitelisted(sender.id))
71 startFeedbackUI(request.feedbackInfo);
75 * Callback which starts up the feedback UI.
76 * @param {Object} feedbackInfo Object containing any initial feedback info.
78 function startFeedbackUI(feedbackInfo) {
79 initialFeedbackInfo = feedbackInfo;
80 // TODO(rkc): Remove logging once crbug.com/284662 is closed.
81 console.log('FEEDBACK_DEBUG: Received onFeedbackRequested. Creating Window.');
82 chrome.app.window.create('html/default.html', {
85 width: FEEDBACK_WIDTH,
86 height: FEEDBACK_HEIGHT,
89 function(appWindow) {});
92 chrome.runtime.onMessage.addListener(feedbackReadyHandler);
93 chrome.runtime.onMessageExternal.addListener(requestFeedbackHandler);
94 chrome.feedbackPrivate.onFeedbackRequested.addListener(startFeedbackUI);