Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | |
|
Sergey Ulanov
2014/09/24 01:26:59
year
Jamie
2014/09/24 17:03:45
Done.
| |
| 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 * @suppress {checkTypes} | |
| 8 */ | |
| 9 | |
| 10 'use strict'; | |
| 11 | |
| 12 /** @suppress {duplicate} */ | |
| 13 var remoting = remoting || {}; | |
| 14 | |
| 15 /** | |
| 16 * @constructor | |
| 17 * @implements {remoting.SessionConnector} | |
| 18 */ | |
| 19 remoting.MockSessionConnector = function(clientContainer, onConnected, onError, | |
| 20 onExtensionMessage) { | |
| 21 this.clientContainer_ = clientContainer; | |
| 22 this.onConnected_ = onConnected; | |
| 23 this.onError = onError; | |
| 24 this.onExtensionMessage_ = onExtensionMessage; | |
| 25 this.reset(); | |
| 26 }; | |
| 27 | |
| 28 remoting.MockSessionConnector.prototype.reset = function() { | |
| 29 this.pairingRequested_ = false; | |
| 30 }; | |
| 31 | |
| 32 remoting.MockSessionConnector.prototype.connectMe2Me = | |
| 33 function(host, fetchPin, fetchThirdPartyToken, | |
| 34 clientPairingId, clientPairedSecret) { | |
| 35 this.mode_ = remoting.ClientSession.Mode.ME2ME; | |
| 36 this.connect_(); | |
| 37 }; | |
| 38 | |
| 39 remoting.MockSessionConnector.prototype.updatePairingInfo = | |
| 40 function(clientId, sharedSecret) { | |
| 41 }; | |
| 42 | |
| 43 remoting.MockSessionConnector.prototype.connectIT2Me = | |
| 44 function(accessCode) { | |
| 45 this.mode_ = remoting.ClientSession.Mode.ME2ME; | |
| 46 this.connect_(); | |
| 47 }; | |
| 48 | |
| 49 remoting.MockSessionConnector.prototype.reconnect = function() { | |
| 50 base.debug.assert(this.mode_ == remoting.ClientSession.Mode.ME2ME); | |
| 51 this.connect_(); | |
| 52 }; | |
| 53 | |
| 54 remoting.MockSessionConnector.prototype.cancel = function() { | |
| 55 }; | |
| 56 | |
| 57 remoting.MockSessionConnector.prototype.getConnectionMode = function() { | |
| 58 return this.mode_; | |
| 59 }; | |
| 60 | |
| 61 remoting.MockSessionConnector.prototype.getHostId = function() { | |
| 62 return this.hostId_; | |
| 63 }; | |
| 64 | |
| 65 remoting.MockSessionConnector.prototype.requestPairing = function() { | |
| 66 this.pairingRequested_ = true; | |
| 67 }; | |
| 68 | |
| 69 remoting.MockSessionConnector.prototype.pairingRequested = function() { | |
| 70 return this.pairingRequested_; | |
| 71 }; | |
| 72 | |
| 73 remoting.MockSessionConnector.prototype.connect_ = function() { | |
| 74 var signalling = new remoting.MockSignalStrategy(); | |
| 75 var hostName = 'Mock host'; | |
| 76 var accessCode = ''; | |
| 77 var authenticationMethods = ''; | |
| 78 var hostId = ''; | |
| 79 var hostJid = ''; | |
| 80 var hostPublicKey = ''; | |
| 81 var clientPairingId = ''; | |
| 82 var clientPairedSecret = ''; | |
| 83 var fetchPin = function(offerPairing, callback) { | |
| 84 window.setTimeout(function() { callback('') }, 0); | |
| 85 }; | |
| 86 var fetchThirdPartyToken = function(tokenUrl, scope, callback) { | |
| 87 window.setTimeout(function() { callback('', '') }, 0); | |
| 88 }; | |
| 89 | |
| 90 var clientSession = new remoting.ClientSession( | |
|
Sergey Ulanov
2014/09/24 01:26:59
Why do you need to create real ClientSession here
Jamie
2014/09/24 17:03:45
ClientSession contains most of the application log
| |
| 91 signalling, this.clientContainer_, hostName, | |
| 92 accessCode, fetchPin, fetchThirdPartyToken, | |
| 93 authenticationMethods, hostId, hostJid, hostPublicKey, | |
| 94 this.mode_, clientPairingId, clientPairedSecret); | |
| 95 | |
| 96 var onStateChange = function(event) { | |
| 97 if (event.current == remoting.ClientSession.State.CONNECTED) { | |
| 98 this.onConnected_(clientSession); | |
|
Jamie
2014/09/23 23:53:55
Part of the API contract for SessionConnector is t
| |
| 99 } | |
| 100 }.bind(this); | |
| 101 | |
| 102 clientSession.addEventListener( | |
| 103 remoting.ClientSession.Events.stateChanged, | |
| 104 onStateChange); | |
| 105 clientSession.createPluginAndConnect(this.onExtensionMessage_); | |
| 106 }; | |
| 107 | |
| 108 | |
|
Sergey Ulanov
2014/09/24 01:26:59
nit:remove extra empty lines
Jamie
2014/09/24 17:03:45
I've removed one of them. I prefer to leave two bl
| |
| 109 | |
| 110 /** | |
| 111 * @constructor | |
| 112 * @extends {remoting.SessionConnectorFactory} | |
| 113 */ | |
| 114 remoting.MockSessionConnectorFactory = function() {}; | |
| 115 | |
| 116 remoting.MockSessionConnectorFactory.prototype.createConnector = | |
| 117 function(clientContainer, onConnected, onError, onExtensionMessage) { | |
| 118 return new remoting.MockSessionConnector( | |
| 119 clientContainer, onConnected, onError, onExtensionMessage); | |
| 120 }; | |
| OLD | NEW |