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
= 625;
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 'kkebgepbbgbcmghedmmdfcbdcodlkngh', // Chrome OS Recovery Tool
29 'jndclpdbaamdhonoechobihbbiimdgai' // Chrome OS Recovery Tool
33 * Function to determine whether or not a given extension id is whitelisted to
34 * invoke the feedback UI.
35 * @param {string} id the id of the sender extension.
36 * @return {boolean} Whether or not this sender is whitelisted.
38 function senderWhitelisted(id
) {
39 return id
&& whitelistedExtensionIds
.indexOf(id
) != -1;
43 * Callback which gets notified once our feedback UI has loaded and is ready to
44 * receive its initial feedback info object.
45 * @param {Object} request The message request object.
46 * @param {Object} sender The sender of the message.
47 * @param {function(Object)} sendResponse Callback for sending a response.
49 function feedbackReadyHandler(request
, sender
, sendResponse
) {
51 // TODO(rkc): Remove logging once crbug.com/284662 is closed.
52 console
.log('FEEDBACK_DEBUG: FeedbackUI Ready. Sending feedbackInfo.');
53 chrome
.runtime
.sendMessage(
54 {sentFromEventPage
: true, data
: initialFeedbackInfo
});
60 * Callback which gets notified if another extension is requesting feedback.
61 * @param {Object} request The message request object.
62 * @param {Object} sender The sender of the message.
63 * @param {function(Object)} sendResponse Callback for sending a response.
65 function requestFeedbackHandler(request
, sender
, sendResponse
) {
66 if (request
.requestFeedback
&& senderWhitelisted(sender
.id
))
67 startFeedbackUI(request
.feedbackInfo
);
71 * Callback which starts up the feedback UI.
72 * @param {Object} feedbackInfo Object containing any initial feedback info.
74 function startFeedbackUI(feedbackInfo
) {
75 initialFeedbackInfo
= feedbackInfo
;
76 // TODO(rkc): Remove logging once crbug.com/284662 is closed.
77 console
.log('FEEDBACK_DEBUG: Received onFeedbackRequested. Creating Window.');
78 chrome
.app
.window
.create('html/default.html', {
81 width
: FEEDBACK_WIDTH
,
82 height
: FEEDBACK_HEIGHT
,
85 function(appWindow
) {});
88 chrome
.runtime
.onMessage
.addListener(feedbackReadyHandler
);
89 chrome
.runtime
.onMessageExternal
.addListener(requestFeedbackHandler
);
90 chrome
.feedbackPrivate
.onFeedbackRequested
.addListener(startFeedbackUI
);