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
52 * Function to determine whether or not a given extension id is whitelisted to
53 * invoke the feedback UI.
54 * @param {string} id the id of the sender extension.
55 * @return {boolean} Whether or not this sender is whitelisted.
57 function senderWhitelisted(id) {
58 return id && whitelistedExtensionIds.indexOf(id) != -1;
62 * Callback which gets notified once our feedback UI has loaded and is ready to
63 * receive its initial feedback info object.
64 * @param {Object} request The message request object.
65 * @param {Object} sender The sender of the message.
66 * @param {function(Object)} sendResponse Callback for sending a response.
68 function feedbackReadyHandler(request, sender, sendResponse) {
70 // TODO(rkc): Remove logging once crbug.com/284662 is closed.
71 console.log('FEEDBACK_DEBUG: FeedbackUI Ready. Sending feedbackInfo.');
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 // TODO(rkc): Remove logging once crbug.com/284662 is closed.
96 console.log('FEEDBACK_DEBUG: Received onFeedbackRequested. Creating Window.');
97 chrome.app.window.create('html/default.html', {
100 width: FEEDBACK_WIDTH,
101 height: FEEDBACK_HEIGHT,
104 function(appWindow) {});
107 chrome.runtime.onMessage.addListener(feedbackReadyHandler);
108 chrome.runtime.onMessageExternal.addListener(requestFeedbackHandler);
109 chrome.feedbackPrivate.onFeedbackRequested.addListener(startFeedbackUI);