| Index: remoting/webapp/crd/js/client_screen.js
|
| diff --git a/remoting/webapp/crd/js/client_screen.js b/remoting/webapp/crd/js/client_screen.js
|
| index 3b06083e9fd00a874c633a1a7eee5b9b8fcc3687..523dd32352e164a7616981682f48c302190ce316 100644
|
| --- a/remoting/webapp/crd/js/client_screen.js
|
| +++ b/remoting/webapp/crd/js/client_screen.js
|
| @@ -13,12 +13,6 @@
|
| var remoting = remoting || {};
|
|
|
| /**
|
| - * @type {remoting.SessionConnector} The connector object, set when a
|
| - * connection is initiated.
|
| - */
|
| -remoting.connector = null;
|
| -
|
| -/**
|
| * @type {remoting.ClientSession} The client session object, set once the
|
| * connector has invoked its onOk callback.
|
| */
|
| @@ -28,10 +22,10 @@ remoting.clientSession = null;
|
| * Initiate an IT2Me connection.
|
| */
|
| remoting.connectIT2Me = function() {
|
| - remoting.ensureSessionConnector_();
|
| + var connector = remoting.app.getSessionConnector();
|
| var accessCode = document.getElementById('access-code-entry').value;
|
| remoting.setMode(remoting.AppMode.CLIENT_CONNECTING);
|
| - remoting.connector.connectIT2Me(accessCode);
|
| + connector.connectIT2Me(accessCode);
|
| };
|
|
|
| /**
|
| @@ -103,14 +97,14 @@ function onClientStateChange_(state) {
|
| if (error == null) {
|
| error = remoting.Error.UNEXPECTED;
|
| }
|
| - showConnectError_(error);
|
| + remoting.app.onError(error);
|
| break;
|
|
|
| default:
|
| console.error('Unexpected client plugin state: ' + state.current);
|
| // This should only happen if the web-app and client plugin get out of
|
| // sync, so MISSING_PLUGIN is a suitable error.
|
| - showConnectError_(remoting.Error.MISSING_PLUGIN);
|
| + remoting.app.onError(remoting.Error.MISSING_PLUGIN);
|
| break;
|
| }
|
|
|
| @@ -121,45 +115,6 @@ function onClientStateChange_(state) {
|
| }
|
|
|
| /**
|
| - * Show a client-side error message.
|
| - *
|
| - * @param {remoting.Error} errorTag The error to be localized and
|
| - * displayed.
|
| - * @return {void} Nothing.
|
| - */
|
| -function showConnectError_(errorTag) {
|
| - console.error('Connection failed: ' + errorTag);
|
| - var errorDiv = document.getElementById('connect-error-message');
|
| - l10n.localizeElementFromTag(errorDiv, /** @type {string} */ (errorTag));
|
| - remoting.accessCode = '';
|
| - var mode = remoting.clientSession ? remoting.clientSession.getMode()
|
| - : remoting.connector.getConnectionMode();
|
| - if (mode == remoting.ClientSession.Mode.IT2ME) {
|
| - remoting.setMode(remoting.AppMode.CLIENT_CONNECT_FAILED_IT2ME);
|
| - remoting.hangoutSessionEvents.raiseEvent(
|
| - remoting.hangoutSessionEvents.sessionStateChanged,
|
| - remoting.ClientSession.State.FAILED
|
| - );
|
| - } else {
|
| - remoting.setMode(remoting.AppMode.CLIENT_CONNECT_FAILED_ME2ME);
|
| - }
|
| -}
|
| -
|
| -/**
|
| - * Set the text on the buttons shown under the error message so that they are
|
| - * easy to understand in the case where a successful connection failed, as
|
| - * opposed to the case where a connection never succeeded.
|
| - */
|
| -function setConnectionInterruptedButtonsText_() {
|
| - var button1 = document.getElementById('client-reconnect-button');
|
| - l10n.localizeElementFromTag(button1, /*i18n-content*/'RECONNECT');
|
| - button1.removeAttribute('autofocus');
|
| - var button2 = document.getElementById('client-finished-me2me-button');
|
| - l10n.localizeElementFromTag(button2, /*i18n-content*/'OK');
|
| - button2.setAttribute('autofocus', 'autofocus');
|
| -}
|
| -
|
| -/**
|
| * Timer callback to update the statistics panel.
|
| */
|
| function updateStatistics_() {
|
| @@ -185,7 +140,7 @@ function updateStatistics_() {
|
| remoting.connectMe2Me = function(hostId) {
|
| var host = remoting.hostList.getHostForId(hostId);
|
| if (!host) {
|
| - showConnectError_(remoting.Error.HOST_IS_OFFLINE);
|
| + remoting.app.onError(remoting.Error.HOST_IS_OFFLINE);
|
| return;
|
| }
|
| var webappVersion = chrome.runtime.getManifest().version;
|
| @@ -225,7 +180,8 @@ remoting.connectMe2Me = function(hostId) {
|
| * @return {void} Nothing.
|
| */
|
| remoting.connectMe2MeHostVersionAcknowledged_ = function(host) {
|
| - remoting.ensureSessionConnector_();
|
| + /** @type {remoting.SessionConnector} */
|
| + var connector = remoting.app.getSessionConnector();
|
| remoting.setMode(remoting.AppMode.CLIENT_CONNECTING);
|
|
|
| /**
|
| @@ -307,87 +263,9 @@ remoting.connectMe2MeHostVersionAcknowledged_ = function(host) {
|
| clientId = /** @type {string} */ (pairingInfo['clientId']);
|
| sharedSecret = /** @type {string} */ (pairingInfo['sharedSecret']);
|
| }
|
| - remoting.connector.connectMe2Me(host, requestPin, fetchThirdPartyToken,
|
| + connector.connectMe2Me(host, requestPin, fetchThirdPartyToken,
|
| clientId, sharedSecret);
|
| }
|
|
|
| remoting.HostSettings.load(host.hostId, connectMe2MeHostSettingsRetrieved);
|
| };
|
| -
|
| -/** @param {remoting.ClientSession} clientSession */
|
| -remoting.onConnected = function(clientSession) {
|
| - remoting.clientSession = clientSession;
|
| - remoting.clientSession.addEventListener('stateChanged', onClientStateChange_);
|
| - setConnectionInterruptedButtonsText_();
|
| - document.getElementById('access-code-entry').value = '';
|
| - remoting.setMode(remoting.AppMode.IN_SESSION);
|
| - if (!base.isAppsV2()) {
|
| - remoting.toolbar.center();
|
| - remoting.toolbar.preview();
|
| - }
|
| - remoting.clipboard.startSession();
|
| - updateStatistics_();
|
| - remoting.hangoutSessionEvents.raiseEvent(
|
| - remoting.hangoutSessionEvents.sessionStateChanged,
|
| - remoting.ClientSession.State.CONNECTED
|
| - );
|
| - if (remoting.pairingRequested) {
|
| - /**
|
| - * @param {string} clientId
|
| - * @param {string} sharedSecret
|
| - */
|
| - var onPairingComplete = function(clientId, sharedSecret) {
|
| - var pairingInfo = {
|
| - pairingInfo: {
|
| - clientId: clientId,
|
| - sharedSecret: sharedSecret
|
| - }
|
| - };
|
| - remoting.HostSettings.save(remoting.connector.getHostId(), pairingInfo);
|
| - remoting.connector.updatePairingInfo(clientId, sharedSecret);
|
| - };
|
| - // Use the platform name as a proxy for the local computer name.
|
| - // TODO(jamiewalch): Use a descriptive name for the local computer, for
|
| - // example, its Chrome Sync name.
|
| - var clientName = '';
|
| - if (remoting.platformIsMac()) {
|
| - clientName = 'Mac';
|
| - } else if (remoting.platformIsWindows()) {
|
| - clientName = 'Windows';
|
| - } else if (remoting.platformIsChromeOS()) {
|
| - clientName = 'ChromeOS';
|
| - } else if (remoting.platformIsLinux()) {
|
| - clientName = 'Linux';
|
| - } else {
|
| - console.log('Unrecognized client platform. Using navigator.platform.');
|
| - clientName = navigator.platform;
|
| - }
|
| - clientSession.requestPairing(clientName, onPairingComplete);
|
| - }
|
| -};
|
| -
|
| -/**
|
| - * Extension message handler.
|
| - *
|
| - * @param {string} type The type of the extension message.
|
| - * @param {string} data The payload of the extension message.
|
| - * @return {boolean} Return true if the extension message was recognized.
|
| - */
|
| -remoting.onExtensionMessage = function(type, data) {
|
| - if (remoting.clientSession) {
|
| - return remoting.clientSession.handleExtensionMessage(type, data);
|
| - }
|
| - return false;
|
| -};
|
| -
|
| -/**
|
| - * Create a session connector if one doesn't already exist.
|
| - */
|
| -remoting.ensureSessionConnector_ = function() {
|
| - if (!remoting.connector) {
|
| - remoting.connector = remoting.SessionConnector.factory.createConnector(
|
| - document.getElementById('video-container'),
|
| - remoting.onConnected,
|
| - showConnectError_, remoting.onExtensionMessage);
|
| - }
|
| -};
|
|
|