OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 * Class to communicate with the Host components via Native Messaging. | 7 * Class to communicate with the Host components via Native Messaging. |
8 */ | 8 */ |
9 | 9 |
10 'use strict'; | 10 'use strict'; |
(...skipping 11 matching lines...) Expand all Loading... | |
22 */ | 22 */ |
23 this.nextId_ = 0; | 23 this.nextId_ = 0; |
24 | 24 |
25 /** | 25 /** |
26 * @type {Object.<number, remoting.HostNativeMessaging.PendingReply>} | 26 * @type {Object.<number, remoting.HostNativeMessaging.PendingReply>} |
27 * @private | 27 * @private |
28 */ | 28 */ |
29 this.pendingReplies_ = {}; | 29 this.pendingReplies_ = {}; |
30 | 30 |
31 /** @type {?chrome.extension.Port} @private */ | 31 /** @type {?chrome.extension.Port} @private */ |
32 this.port_ = null; | 32 this.me2mePort_ = null; |
Sergey Ulanov
2013/10/30 22:51:01
I don't think you really need this change. It's be
| |
33 | 33 |
34 /** @type {string} @private */ | 34 /** @type {string} @private */ |
35 this.version_ = ''; | 35 this.version_ = ''; |
36 | 36 |
37 /** @type {Array.<remoting.HostController.Feature>} @private */ | 37 /** @type {Array.<remoting.HostController.Feature>} @private */ |
38 this.supportedFeatures_ = []; | 38 this.supportedFeatures_ = []; |
39 }; | 39 }; |
40 | 40 |
41 /** | 41 /** |
42 * Type used for entries of |pendingReplies_| list. | 42 * Type used for entries of |pendingReplies_| list. |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
75 // onDisconnect in the case where the Host components are not installed. Need | 75 // onDisconnect in the case where the Host components are not installed. Need |
76 // to blacklist these versions of Chrome. | 76 // to blacklist these versions of Chrome. |
77 var majorVersion = navigator.appVersion.match('Chrome/(\\d+)\.')[1]; | 77 var majorVersion = navigator.appVersion.match('Chrome/(\\d+)\.')[1]; |
78 if (!majorVersion || majorVersion <= 26) { | 78 if (!majorVersion || majorVersion <= 26) { |
79 console.log('Native Messaging not supported on this version of Chrome'); | 79 console.log('Native Messaging not supported on this version of Chrome'); |
80 onError(remoting.Error.UNEXPECTED); | 80 onError(remoting.Error.UNEXPECTED); |
81 return; | 81 return; |
82 } | 82 } |
83 | 83 |
84 try { | 84 try { |
85 this.port_ = chrome.runtime.connectNative( | 85 this.me2mePort_ = chrome.runtime.connectNative( |
86 'com.google.chrome.remote_desktop'); | 86 'com.google.chrome.remote_desktop'); |
87 this.port_.onMessage.addListener(this.onIncomingMessage_.bind(this)); | 87 this.me2mePort_.onMessage.addListener(this.onIncomingMessage_.bind(this)); |
88 this.port_.onDisconnect.addListener(this.onDisconnect_.bind(this)); | 88 this.me2mePort_.onDisconnect.addListener(this.onDisconnect_.bind(this)); |
89 this.postMessage_({type: 'hello'}, onDone, | 89 this.postMessage_({type: 'hello'}, onDone, |
90 onError.bind(null, remoting.Error.UNEXPECTED)); | 90 onError.bind(null, remoting.Error.UNEXPECTED)); |
91 } catch (err) { | 91 } catch (err) { |
92 console.log('Native Messaging initialization failed: ', | 92 console.log('Native Messaging initialization failed: ', |
93 /** @type {*} */ (err)); | 93 /** @type {*} */ (err)); |
94 onError(remoting.Error.UNEXPECTED); | 94 onError(remoting.Error.UNEXPECTED); |
95 return; | 95 return; |
96 } | 96 } |
97 }; | 97 }; |
98 | 98 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
170 * on error. | 170 * on error. |
171 * @return {void} Nothing. | 171 * @return {void} Nothing. |
172 * @private | 172 * @private |
173 */ | 173 */ |
174 remoting.HostNativeMessaging.prototype.postMessage_ = | 174 remoting.HostNativeMessaging.prototype.postMessage_ = |
175 function(message, onDone, onError) { | 175 function(message, onDone, onError) { |
176 var id = this.nextId_++; | 176 var id = this.nextId_++; |
177 message['id'] = id; | 177 message['id'] = id; |
178 this.pendingReplies_[id] = new remoting.HostNativeMessaging.PendingReply( | 178 this.pendingReplies_[id] = new remoting.HostNativeMessaging.PendingReply( |
179 message.type + 'Response', onDone, onError); | 179 message.type + 'Response', onDone, onError); |
180 this.port_.postMessage(message); | 180 this.me2mePort_.postMessage(message); |
181 }; | 181 }; |
182 | 182 |
183 /** | 183 /** |
184 * Handler for incoming Native Messages. | 184 * Handler for incoming Native Messages. |
185 * | 185 * |
186 * @param {Object} message The received message. | 186 * @param {Object} message The received message. |
187 * @return {void} Nothing. | 187 * @return {void} Nothing. |
188 * @private | 188 * @private |
189 */ | 189 */ |
190 remoting.HostNativeMessaging.prototype.onIncomingMessage_ = function(message) { | 190 remoting.HostNativeMessaging.prototype.onIncomingMessage_ = function(message) { |
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
605 * on error. | 605 * on error. |
606 * @return {void} Nothing. | 606 * @return {void} Nothing. |
607 */ | 607 */ |
608 remoting.HostNativeMessaging.prototype.getCredentialsFromAuthCode = | 608 remoting.HostNativeMessaging.prototype.getCredentialsFromAuthCode = |
609 function(authorizationCode, onDone, onError) { | 609 function(authorizationCode, onDone, onError) { |
610 this.postMessage_({ | 610 this.postMessage_({ |
611 type: 'getCredentialsFromAuthCode', | 611 type: 'getCredentialsFromAuthCode', |
612 authorizationCode: authorizationCode | 612 authorizationCode: authorizationCode |
613 }, onDone, onError); | 613 }, onDone, onError); |
614 }; | 614 }; |
OLD | NEW |