Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2014 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. | |
| 4 | |
| 5 /** | |
| 6 * @fileoverview | |
| 7 * This class implements the functionality that is specific to Remote Desktop. | |
| 8 */ | |
| 9 | |
| 10 'use strict'; | |
| 11 | |
| 12 /** @suppress {duplicate} */ | |
| 13 var remoting = remoting || {}; | |
| 14 | |
| 15 /** | |
| 16 * @param {remoting.Application} app The main app that owns this delegate. | |
| 17 * @constructor | |
| 18 * @implements {remoting.ApplicationDelegate} | |
| 19 */ | |
| 20 remoting.DesktopRemoting = function(app) { | |
| 21 /** | |
| 22 * @type {remoting.Application} | |
| 23 * @private | |
| 24 */ | |
| 25 this.app_ = app; | |
|
Jamie
2014/12/06 00:09:23
The Application object is only needed to extract t
garykac
2014/12/06 01:39:33
We can't trivially pass in the mode because it's s
| |
| 26 app.setDelegate(this); | |
| 27 }; | |
| 28 | |
| 29 remoting.DesktopRemoting.prototype.init = function() { | |
| 30 remoting.initGlobalObjects(); | |
| 31 remoting.initIdentity(); | |
| 32 remoting.initIdentityEmail(remoting.onEmailAvailable); | |
| 33 | |
| 34 remoting.initEventHandlers(); | |
| 35 | |
| 36 if (base.isAppsV2()) { | |
| 37 remoting.fullscreen = new remoting.FullscreenAppsV2(); | |
| 38 remoting.windowFrame = new remoting.WindowFrame( | |
| 39 document.getElementById('title-bar')); | |
| 40 remoting.optionsMenu = remoting.windowFrame.createOptionsMenu(); | |
| 41 } else { | |
| 42 remoting.fullscreen = new remoting.FullscreenAppsV1(); | |
| 43 remoting.toolbar = new remoting.Toolbar( | |
| 44 document.getElementById('session-toolbar')); | |
| 45 remoting.optionsMenu = remoting.toolbar.createOptionsMenu(); | |
| 46 } | |
| 47 | |
| 48 remoting.initHostlist_(); | |
| 49 | |
| 50 var homeFeedback = new remoting.MenuButton( | |
| 51 document.getElementById('help-feedback-main')); | |
| 52 var toolbarFeedback = new remoting.MenuButton( | |
| 53 document.getElementById('help-feedback-toolbar')); | |
| 54 remoting.manageHelpAndFeedback( | |
| 55 document.getElementById('title-bar')); | |
| 56 remoting.manageHelpAndFeedback( | |
| 57 document.getElementById('help-feedback-toolbar')); | |
| 58 remoting.manageHelpAndFeedback( | |
| 59 document.getElementById('help-feedback-main')); | |
| 60 | |
| 61 remoting.windowShape.updateClientWindowShape(); | |
| 62 | |
| 63 remoting.showOrHideIT2MeUi(); | |
| 64 remoting.showOrHideMe2MeUi(); | |
| 65 | |
| 66 // For Apps v1, check the tab type to warn the user if they are not getting | |
| 67 // the best keyboard experience. | |
| 68 if (!base.isAppsV2() && !remoting.platformIsMac()) { | |
| 69 /** @param {boolean} isWindowed */ | |
| 70 var onIsWindowed = function(isWindowed) { | |
| 71 if (!isWindowed) { | |
| 72 document.getElementById('startup-mode-box-me2me').hidden = false; | |
| 73 document.getElementById('startup-mode-box-it2me').hidden = false; | |
| 74 } | |
| 75 }; | |
| 76 isWindowed_(onIsWindowed); | |
| 77 } | |
| 78 | |
| 79 remoting.ClientPlugin.factory.preloadPlugin(); | |
| 80 } | |
| 81 | |
| 82 /** | |
| 83 * @param {remoting.ClientSession} clientSession | |
| 84 */ | |
| 85 remoting.DesktopRemoting.prototype.onConnected = function(clientSession) { | |
| 86 // Set the text on the buttons shown under the error message so that they are | |
| 87 // easy to understand in the case where a successful connection failed, as | |
| 88 // opposed to the case where a connection never succeeded. | |
| 89 // TODO(garykac): Investigate to see if these need to be reverted to their | |
| 90 // original values in the onDisconnected method. | |
| 91 var button1 = document.getElementById('client-reconnect-button'); | |
| 92 l10n.localizeElementFromTag(button1, /*i18n-content*/'RECONNECT'); | |
| 93 button1.removeAttribute('autofocus'); | |
| 94 var button2 = document.getElementById('client-finished-me2me-button'); | |
| 95 l10n.localizeElementFromTag(button2, /*i18n-content*/'OK'); | |
| 96 button2.setAttribute('autofocus', 'autofocus'); | |
| 97 | |
| 98 document.getElementById('access-code-entry').value = ''; | |
| 99 remoting.setMode(remoting.AppMode.IN_SESSION); | |
| 100 if (!base.isAppsV2()) { | |
| 101 remoting.toolbar.center(); | |
| 102 remoting.toolbar.preview(); | |
| 103 } | |
| 104 | |
| 105 if (remoting.pairingRequested) { | |
| 106 /** | |
| 107 * @param {string} clientId | |
| 108 * @param {string} sharedSecret | |
| 109 */ | |
| 110 var onPairingComplete = function(clientId, sharedSecret) { | |
| 111 var pairingInfo = { | |
| 112 pairingInfo: { | |
| 113 clientId: clientId, | |
| 114 sharedSecret: sharedSecret | |
| 115 } | |
| 116 }; | |
| 117 var connector = remoting.app.getSessionConnector(); | |
| 118 remoting.HostSettings.save(connector.getHostId(), pairingInfo); | |
| 119 connector.updatePairingInfo(clientId, sharedSecret); | |
| 120 }; | |
| 121 // Use the platform name as a proxy for the local computer name. | |
| 122 // TODO(jamiewalch): Use a descriptive name for the local computer, for | |
| 123 // example, its Chrome Sync name. | |
| 124 var clientName = ''; | |
| 125 if (remoting.platformIsMac()) { | |
| 126 clientName = 'Mac'; | |
| 127 } else if (remoting.platformIsWindows()) { | |
| 128 clientName = 'Windows'; | |
| 129 } else if (remoting.platformIsChromeOS()) { | |
| 130 clientName = 'ChromeOS'; | |
| 131 } else if (remoting.platformIsLinux()) { | |
| 132 clientName = 'Linux'; | |
| 133 } else { | |
| 134 console.log('Unrecognized client platform. Using navigator.platform.'); | |
| 135 clientName = navigator.platform; | |
| 136 } | |
| 137 clientSession.requestPairing(clientName, onPairingComplete); | |
| 138 } | |
| 139 }; | |
| 140 | |
| 141 remoting.DesktopRemoting.prototype.onDisconnected = function() { | |
| 142 }; | |
| 143 | |
| 144 remoting.DesktopRemoting.prototype.onVideoStreamingStarted = function() { | |
| 145 }; | |
| 146 | |
| 147 /** | |
| 148 * @param {string} type The type of the extension message. | |
| 149 * @param {string} data The payload of the extension message. | |
| 150 * @return {boolean} Return true if the extension message was recognized. | |
| 151 */ | |
| 152 remoting.DesktopRemoting.prototype.onExtensionMessage = function(type, data) { | |
| 153 if (remoting.clientSession) { | |
| 154 return remoting.clientSession.handleExtensionMessage(type, data); | |
| 155 } | |
| 156 return false; | |
| 157 }; | |
| 158 | |
| 159 /** | |
| 160 * Show a client-side error message. | |
| 161 * | |
| 162 * @param {remoting.Error} errorTag The error to be localized and displayed. | |
| 163 * @return {void} Nothing. | |
| 164 */ | |
| 165 remoting.DesktopRemoting.prototype.onError = function(errorTag) { | |
| 166 console.error('Connection failed: ' + errorTag); | |
| 167 remoting.accessCode = ''; | |
| 168 | |
| 169 var errorDiv = document.getElementById('connect-error-message'); | |
| 170 l10n.localizeElementFromTag(errorDiv, /** @type {string} */ (errorTag)); | |
| 171 | |
| 172 var mode = remoting.clientSession ? remoting.clientSession.getMode() | |
| 173 : this.app_.getSessionConnector().getConnectionMode(); | |
| 174 if (mode == remoting.ClientSession.Mode.IT2ME) { | |
| 175 remoting.setMode(remoting.AppMode.CLIENT_CONNECT_FAILED_IT2ME); | |
| 176 remoting.hangoutSessionEvents.raiseEvent( | |
| 177 remoting.hangoutSessionEvents.sessionStateChanged, | |
| 178 remoting.ClientSession.State.FAILED | |
| 179 ); | |
| 180 } else { | |
| 181 remoting.setMode(remoting.AppMode.CLIENT_CONNECT_FAILED_ME2ME); | |
| 182 } | |
| 183 }; | |
| OLD | NEW |