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
34 'odkaodonbgfohohmklejpjiejmcipmib', // Chrome Remote Desktop QA
35 'dokpleeekgeeiehdhmdkeimnkmoifgdd', // Chrome Remote Desktop QA backup
36 'ajoainacpilcemgiakehflpbkbfipojk', // Chrome Remote Desktop Apps V2
37 'llohocloplkbhgcfnplnoficdkiechcn', // Play Movies Dev
38 'icljpnebmoleodmchaaajbkpoipfoahp', // Play Movies Nightly
39 'mjekoljodoiapgkggnlmbecndfpbbcch', // Play Movies Beta
40 'gdijeikdkaembjbdobgfkoidjkpbmlkd', // Play Movies Stable
41 'andfmajejfpjojledngpdaibbhkffipo', // Hangouts Extension
42 'jfjjdfefebklmdbmenmlehlopoocnoeh', // Hangouts Extension
43 'dhcmpocobclokhifdkgcjbnfdaneoojd', // Hangouts Extension
44 'ppleadejekpmccmnpjdimmlfljlkdfej', // Hangouts Extension
45 'eggnbpckecmjlblplehfpjjdhhidfdoj', // Hangouts Extension
46 'ljclpkphhpbpinifbeabbhlfddcpfdde', // Hangouts Extension
47 'nckgahadagoaajjgafhacjanaoiihapd', // Hangouts Extension
48 'knipolnnllmklapflnccelgolnpehhpl', // Hangouts Extension
49 'dogkdgiahcdchbabhdmpbhlfoddjined', // GLS nightly
50 'khkjfddibboofomnlkndfedpoccieiee', // GLS stable
54 * Function to determine whether or not a given extension id is whitelisted to
55 * invoke the feedback UI.
56 * @param {string} id the id of the sender extension.
57 * @return {boolean} Whether or not this sender is whitelisted.
59 function senderWhitelisted(id
) {
60 return id
&& whitelistedExtensionIds
.indexOf(id
) != -1;
64 * Callback which gets notified once our feedback UI has loaded and is ready to
65 * receive its initial feedback info object.
66 * @param {Object} request The message request object.
67 * @param {Object} sender The sender of the message.
68 * @param {function(Object)} sendResponse Callback for sending a response.
70 function feedbackReadyHandler(request
, sender
, sendResponse
) {
72 chrome
.runtime
.sendMessage(
73 {sentFromEventPage
: true, data
: initialFeedbackInfo
});
79 * Callback which gets notified if another extension is requesting feedback.
80 * @param {Object} request The message request object.
81 * @param {Object} sender The sender of the message.
82 * @param {function(Object)} sendResponse Callback for sending a response.
84 function requestFeedbackHandler(request
, sender
, sendResponse
) {
85 if (request
.requestFeedback
&& senderWhitelisted(sender
.id
))
86 startFeedbackUI(request
.feedbackInfo
);
90 * Callback which starts up the feedback UI.
91 * @param {Object} feedbackInfo Object containing any initial feedback info.
93 function startFeedbackUI(feedbackInfo
) {
94 initialFeedbackInfo
= feedbackInfo
;
95 chrome
.app
.window
.create('html/default.html', {
98 width
: FEEDBACK_WIDTH
,
99 height
: FEEDBACK_HEIGHT
,
102 function(appWindow
) {});
105 chrome
.runtime
.onMessage
.addListener(feedbackReadyHandler
);
106 chrome
.runtime
.onMessageExternal
.addListener(requestFeedbackHandler
);
107 chrome
.feedbackPrivate
.onFeedbackRequested
.addListener(startFeedbackUI
);