Roll src/third_party/WebKit d9c6159:8139f33 (svn 201974:201975)
[chromium-blink-merge.git] / remoting / webapp / crd / js / feedback.js
bloba0ef42679ad8f0d7b2e62f90520ee4ae449971f3
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
3 // found in the LICENSE file.
5 'use strict';
7 var remoting = remoting || {};
9 (function(){
11 /**
12 * Attach appropriate event handlers and show or hide the feedback button based
13 * on whether or not the current version of Chrome recognizes Chrome Remote
14 * Desktop as an authorized feedback source.
16 * @param {HTMLElement} container The menu containing the help and feedback
17 * items.
19 remoting.manageHelpAndFeedback = function(container) {
20 var helpButton = container.querySelector('.menu-help');
21 console.assert(helpButton != null, 'Missing help button.');
22 helpButton.addEventListener('click', showHelp, false);
24 var creditsButton = container.querySelector('.menu-credits');
25 console.assert(creditsButton != null, 'Missing credits button.');
26 creditsButton.addEventListener('click', showCredits, false);
28 var feedbackButton = container.querySelector('.menu-feedback');
29 console.assert(feedbackButton != null, 'Missing feedback button.');
30 var chromeVersion = parseInt(
31 window.navigator.appVersion.match(/Chrome\/(\d+)\./)[1], 10);
32 if (chromeVersion >= 35) {
33 feedbackButton.addEventListener('click', sendFeedback, false);
34 } else {
35 feedbackButton.hidden = true;
39 function showHelp() {
40 window.open('https://support.google.com/chrome/answer/1649523');
43 function showCredits() {
44 chrome.app.window.create(
45 'credits.html',
47 'width': 800,
48 'height': 600,
49 'id' : 'remoting-credits'
50 });
53 /**
54 * Pass the current version of Chrome Remote Desktop to the Google Feedback
55 * extension and instruct it to show the feedback dialog.
57 function sendFeedback() {
58 var message = {
59 requestFeedback: true,
60 feedbackInfo: {
61 description: '',
62 systemInformation: [
64 key: 'version',
65 value: remoting.app.getExtensionInfo()
68 key: 'consoleErrors',
69 value: JSON.stringify(
70 remoting.ConsoleWrapper.getInstance().getHistory())
75 var kFeedbackExtensionId = 'gfdkimpbcpahaombhbimeihdjnejgicl';
76 chrome.runtime.sendMessage(kFeedbackExtensionId, message, function() {});
79 })();