OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 'use strict'; | 5 'use strict'; |
6 | 6 |
7 var remoting = remoting || {}; | 7 var remoting = remoting || {}; |
8 | 8 |
9 /** | 9 /** |
10 * Show or hide the feedback button based on whether or not the current version | 10 * Attach appropriate event handlers and show or hide the feedback button based |
11 * of Chrome recognizes Chrome Remote Desktop as an authorized feedback source. | 11 * on whether or not the current version of Chrome recognizes Chrome Remote |
| 12 * Desktop as an authorized feedback source. |
12 * | 13 * |
13 * @param {HTMLElement} helpIcon The parent <span> for the help icon and the | 14 * @param {HTMLElement} container The menu containing the help and feedback |
14 * <ul> containing the help and feedback entries. | 15 * items. |
15 * @param {HTMLElement} helpButton The Help <li> associated with the help icon. | |
16 * @param {HTMLElement} feedbackButton The Feedback <li> associated with the | |
17 * help icon. | |
18 * @constructor | |
19 */ | 16 */ |
20 remoting.Feedback = function(helpIcon, helpButton, feedbackButton) { | 17 remoting.manageHelpAndFeedback = function(container) { |
21 var menuButton = new remoting.MenuButton(helpIcon); | |
22 var showHelp = function() { | 18 var showHelp = function() { |
23 window.open('https://www.google.com/support/chrome/bin/answer.py?' + | 19 window.open('https://www.google.com/support/chrome/bin/answer.py?' + |
24 'answer=1649523'); | 20 'answer=1649523'); |
25 } | 21 } |
| 22 var helpButton = container.querySelector('.menu-help'); |
| 23 base.debug.assert(helpButton != null); |
26 helpButton.addEventListener('click', showHelp, false); | 24 helpButton.addEventListener('click', showHelp, false); |
| 25 var feedbackButton = container.querySelector('.menu-feedback'); |
| 26 base.debug.assert(feedbackButton != null); |
27 var chromeVersion = parseInt( | 27 var chromeVersion = parseInt( |
28 window.navigator.appVersion.match(/Chrome\/(\d+)\./)[1], 10); | 28 window.navigator.appVersion.match(/Chrome\/(\d+)\./)[1], 10); |
29 if (chromeVersion >= 35) { | 29 if (chromeVersion >= 35) { |
30 feedbackButton.addEventListener('click', | 30 feedbackButton.addEventListener('click', |
31 this.sendFeedback_.bind(this), | 31 remoting.sendFeedback_, |
32 false); | 32 false); |
33 } else { | 33 } else { |
34 feedbackButton.hidden = true; | 34 feedbackButton.hidden = true; |
35 } | 35 } |
36 }; | 36 }; |
37 | 37 |
38 /** | 38 /** |
39 * Pass the current version of Chrome Remote Desktop to the Google Feedback | 39 * Pass the current version of Chrome Remote Desktop to the Google Feedback |
40 * extension and instruct it to show the feedback dialog. | 40 * extension and instruct it to show the feedback dialog. |
41 */ | 41 */ |
42 remoting.Feedback.prototype.sendFeedback_ = function() { | 42 remoting.sendFeedback_ = function() { |
43 var message = { | 43 var message = { |
44 requestFeedback: true, | 44 requestFeedback: true, |
45 feedbackInfo: { | 45 feedbackInfo: { |
46 description: '', | 46 description: '', |
47 systemInformation: [ | 47 systemInformation: [ |
48 { key: 'version', value: remoting.getExtensionInfo() } | 48 { key: 'version', value: remoting.getExtensionInfo() } |
49 ] | 49 ] |
50 } | 50 } |
51 }; | 51 }; |
52 var kFeedbackExtensionId = 'gfdkimpbcpahaombhbimeihdjnejgicl'; | 52 var kFeedbackExtensionId = 'gfdkimpbcpahaombhbimeihdjnejgicl'; |
53 chrome.runtime.sendMessage(kFeedbackExtensionId, message, function() {}); | 53 chrome.runtime.sendMessage(kFeedbackExtensionId, message, function() {}); |
54 }; | 54 }; |
OLD | NEW |