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

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

Issue 1161813006: Updated handling of GCD devices. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: oops--ignore Created 5 years, 6 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
« no previous file with comments | « remoting/webapp/crd/js/legacy_host_list_api_unittest.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 remoting.HostList 7 * Mock implementation of remoting.HostList
8 */ 8 */
9 9
10 'use strict'; 10 'use strict';
(...skipping 13 matching lines...) Expand all
24 */ 24 */
25 this.authCodeFromRegister = null; 25 this.authCodeFromRegister = null;
26 26
27 /** 27 /**
28 * The email value for the |register| method to return, or null if 28 * The email value for the |register| method to return, or null if
29 * it should fail. 29 * it should fail.
30 * @type {?string} 30 * @type {?string}
31 */ 31 */
32 this.emailFromRegister = null; 32 this.emailFromRegister = null;
33 33
34 /**
35 * This host ID to return from register(), or null if it should fail.
36 * @type {?string}
37 */
38 this.hostIdFromRegister = null;
39
34 /** @type {Array<remoting.Host>} */ 40 /** @type {Array<remoting.Host>} */
35 this.hosts = [ 41 this.hosts = [
36 { 42 {
37 'hostName': 'Online host', 43 'hostName': 'Online host',
38 'hostId': 'online-host-id', 44 'hostId': 'online-host-id',
39 'status': 'ONLINE', 45 'status': 'ONLINE',
40 'jabberId': 'online-jid', 46 'jabberId': 'online-jid',
41 'publicKey': 'online-public-key', 47 'publicKey': 'online-public-key',
42 'tokenUrlPatterns': [], 48 'tokenUrlPatterns': [],
43 'updatedTime': new Date().toISOString() 49 'updatedTime': new Date().toISOString()
44 }, 50 },
45 { 51 {
46 'hostName': 'Offline host', 52 'hostName': 'Offline host',
47 'hostId': 'offline-host-id', 53 'hostId': 'offline-host-id',
48 'status': 'OFFLINE', 54 'status': 'OFFLINE',
49 'jabberId': 'offline-jid', 55 'jabberId': 'offline-jid',
50 'publicKey': 'offline-public-key', 56 'publicKey': 'offline-public-key',
51 'tokenUrlPatterns': [], 57 'tokenUrlPatterns': [],
52 'updatedTime': new Date(1970, 1, 1).toISOString() 58 'updatedTime': new Date(1970, 1, 1).toISOString()
53 } 59 }
54 ]; 60 ];
55 }; 61 };
56 62
57 /** @override */ 63 /** @override */
58 remoting.MockHostListApi.prototype.register = function( 64 remoting.MockHostListApi.prototype.register = function(
59 newHostId, hostName, publicKey, hostClientId) { 65 hostName, publicKey, hostClientId) {
60 if (this.authCodeFromRegister === null || this.emailFromRegister === null) { 66 if (this.authCodeFromRegister === null || this.emailFromRegister === null) {
61 return Promise.reject( 67 return Promise.reject(
62 new remoting.Error( 68 new remoting.Error(
63 remoting.Error.Tag.REGISTRATION_FAILED, 69 remoting.Error.Tag.REGISTRATION_FAILED,
64 'MockHostListApi.register')); 70 'MockHostListApi.register'));
65 } else { 71 } else {
66 return Promise.resolve({ 72 return Promise.resolve({
67 authCode: this.authCodeFromRegister, 73 authCode: this.authCodeFromRegister,
68 email: this.emailFromRegister 74 email: this.emailFromRegister,
75 hostId: this.hostIdFromRegister
69 }); 76 });
70 } 77 }
71 }; 78 };
72 79
73 /** @override */ 80 /** @override */
74 remoting.MockHostListApi.prototype.get = function() { 81 remoting.MockHostListApi.prototype.get = function() {
75 var that = this; 82 var that = this;
76 return new Promise(function(resolve, reject) { 83 return new Promise(function(resolve, reject) {
77 remoting.mockIdentity.validateTokenAndCall( 84 remoting.mockIdentity.validateTokenAndCall(
78 resolve, remoting.Error.handler(reject), [that.hosts]); 85 resolve, remoting.Error.handler(reject), [that.hosts]);
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 150
144 }; 151 };
145 152
146 /** 153 /**
147 * @param {boolean} active 154 * @param {boolean} active
148 */ 155 */
149 remoting.MockHostListApi.setActive = function(active) { 156 remoting.MockHostListApi.setActive = function(active) {
150 remoting.HostListApi.setInstance( 157 remoting.HostListApi.setInstance(
151 active ? new remoting.MockHostListApi() : null); 158 active ? new remoting.MockHostListApi() : null);
152 }; 159 };
OLDNEW
« no previous file with comments | « remoting/webapp/crd/js/legacy_host_list_api_unittest.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698