Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(247)

Side by Side Diff: remoting/webapp/crd/js/mock_client_plugin.js

Issue 1397463003: Report the Auth method for me2me connections. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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 /** 5 /**
6 * @fileoverview 6 * @fileoverview
7 * Mock implementation of ClientPlugin for testing. 7 * Mock implementation of ClientPlugin for testing.
8 */ 8 */
9 9
10 /** @suppress {duplicate} */ 10 /** @suppress {duplicate} */
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 '|connectionEventHandler_| is null.'); 189 '|connectionEventHandler_| is null.');
190 var PluginError = remoting.ClientSession.ConnectionError; 190 var PluginError = remoting.ClientSession.ConnectionError;
191 var error = opt_error ? opt_error : PluginError.NONE; 191 var error = opt_error ? opt_error : PluginError.NONE;
192 this.connectionEventHandler_.onConnectionStatusUpdate(status, error); 192 this.connectionEventHandler_.onConnectionStatusUpdate(status, error);
193 if (this.mock$onPluginStatusChanged_) { 193 if (this.mock$onPluginStatusChanged_) {
194 this.mock$onPluginStatusChanged_(this, status); 194 this.mock$onPluginStatusChanged_(this, status);
195 } 195 }
196 }; 196 };
197 197
198 /** 198 /**
199 * @param {remoting.MockClientPlugin.AuthMethod} authMethod 199 * @param {remoting.ChromotingEvent.AuthMethod} authMethod
200 * @return {Promise} 200 * @return {Promise}
201 */ 201 */
202 remoting.MockClientPlugin.prototype.mock$authenticate = function(authMethod) { 202 remoting.MockClientPlugin.prototype.mock$authenticate = function(authMethod) {
203 var AuthMethod = remoting.MockClientPlugin.AuthMethod; 203 var AuthMethod = remoting.ChromotingEvent.AuthMethod;
204 var deferred = new base.Deferred(); 204 var deferred = new base.Deferred();
205 205
206 var that = this; 206 var that = this;
207 switch(authMethod) { 207 switch(authMethod) {
208 case AuthMethod.PIN: 208 case AuthMethod.PIN:
209 case AuthMethod.ACCESS_CODE: 209 case AuthMethod.ACCESS_CODE:
210 this.credentials_.getPIN(true).then(function() { 210 this.credentials_.getPIN(true).then(function() {
211 deferred.resolve(); 211 deferred.resolve();
212 }); 212 });
213 break; 213 break;
214 case AuthMethod.THIRD_PARTY: 214 case AuthMethod.THIRD_PARTY:
215 this.credentials_.getThirdPartyToken( 215 this.credentials_.getThirdPartyToken(
216 'fake_token_url', 'fake_host_publicKey', 'fake_scope' 216 'fake_token_url', 'fake_host_publicKey', 'fake_scope'
217 ).then(function() { 217 ).then(function() {
218 deferred.resolve(); 218 deferred.resolve();
219 }); 219 });
220 break; 220 break;
221 case AuthMethod.PAIRING: 221 case AuthMethod.PINLESS:
222 this.credentials_.getPairingInfo();
222 deferred.resolve(); 223 deferred.resolve();
223 } 224 }
224 return deferred.promise(); 225 return deferred.promise();
225 }; 226 };
226 227
227 /** 228 /**
228 * @param {?function(remoting.MockClientPlugin, remoting.ClientSession.State)} 229 * @param {?function(remoting.MockClientPlugin, remoting.ClientSession.State)}
229 * callback 230 * callback
230 */ 231 */
231 remoting.MockClientPlugin.prototype.mock$setPluginStatusChanged = 232 remoting.MockClientPlugin.prototype.mock$setPluginStatusChanged =
232 function(callback) { 233 function(callback) {
233 this.mock$onPluginStatusChanged_ = callback; 234 this.mock$onPluginStatusChanged_ = callback;
234 }; 235 };
235 236
236 /** 237 /**
237 * @param {remoting.MockClientPlugin.AuthMethod} authMethod 238 * @param {remoting.ChromotingEvent.AuthMethod} authMethod
238 */ 239 */
239 remoting.MockClientPlugin.prototype.mock$useDefaultBehavior = 240 remoting.MockClientPlugin.prototype.mock$useDefaultBehavior =
240 function(authMethod) { 241 function(authMethod) {
241 var that = this; 242 var that = this;
242 var State = remoting.ClientSession.State; 243 var State = remoting.ClientSession.State;
243 this.mock$onConnect().then(function() { 244 this.mock$onConnect().then(function() {
244 that.mock$setConnectionStatus(State.CONNECTING); 245 that.mock$setConnectionStatus(State.CONNECTING);
245 return that.mock$authenticate(authMethod); 246 return that.mock$authenticate(authMethod);
246 }).then(function() { 247 }).then(function() {
247 that.mock$setConnectionStatus(State.AUTHENTICATED); 248 that.mock$setConnectionStatus(State.AUTHENTICATED);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 function(container, capabilities) { 288 function(container, capabilities) {
288 this.plugin_ = new remoting.MockClientPlugin(); 289 this.plugin_ = new remoting.MockClientPlugin();
289 this.plugin_.mock$setContainer(container); 290 this.plugin_.mock$setContainer(container);
290 this.plugin_.mock$capabilities = capabilities; 291 this.plugin_.mock$capabilities = capabilities;
291 292
292 // Notify the listeners on plugin creation. 293 // Notify the listeners on plugin creation.
293 if (Boolean(this.onPluginCreated_)) { 294 if (Boolean(this.onPluginCreated_)) {
294 this.onPluginCreated_(this.plugin_); 295 this.onPluginCreated_(this.plugin_);
295 } else { 296 } else {
296 this.plugin_.mock$useDefaultBehavior( 297 this.plugin_.mock$useDefaultBehavior(
297 remoting.MockClientPlugin.AuthMethod.PIN); 298 remoting.ChromotingEvent.AuthMethod.PIN);
298 } 299 }
299 300
300 // Listens for plugin status changed. 301 // Listens for plugin status changed.
301 if (this.onPluginStatusChanged_) { 302 if (this.onPluginStatusChanged_) {
302 this.plugin_.mock$setPluginStatusChanged(this.onPluginStatusChanged_); 303 this.plugin_.mock$setPluginStatusChanged(this.onPluginStatusChanged_);
303 } 304 }
304 return this.plugin_; 305 return this.plugin_;
305 }; 306 };
306 307
307 /** 308 /**
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 }; 382 };
382 383
383 remoting.MockConnection.prototype.restore = function() { 384 remoting.MockConnection.prototype.restore = function() {
384 remoting.settings = this.originalSettings_; 385 remoting.settings = this.originalSettings_;
385 remoting.identity = this.originalIdentity_; 386 remoting.identity = this.originalIdentity_;
386 remoting.ClientPlugin.factory = this.originalPluginFactory_; 387 remoting.ClientPlugin.factory = this.originalPluginFactory_;
387 this.createSignalStrategyStub_.restore(); 388 this.createSignalStrategyStub_.restore();
388 }; 389 };
389 390
390 })(); 391 })();
391
392 /** @enum {string} */
393 remoting.MockClientPlugin.AuthMethod = {
394 ACCESS_CODE: 'accessCode',
395 PIN: 'pin',
396 THIRD_PARTY: 'thirdParty',
397 PAIRING: 'pairing'
398 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698