OLD | NEW |
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 * Class to communicate with the It2me Host component via Native Messaging. | 7 * Class to communicate with the It2me Host component via Native Messaging. |
8 */ | 8 */ |
9 | 9 |
10 /** @suppress {duplicate} */ | 10 /** @suppress {duplicate} */ |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 * an error. | 125 * an error. |
126 * @return {void} | 126 * @return {void} |
127 */ | 127 */ |
128 remoting.It2MeHostFacade.prototype.connect = | 128 remoting.It2MeHostFacade.prototype.connect = |
129 function(email, authServiceWithToken, onStateChanged, onNatPolicyChanged, | 129 function(email, authServiceWithToken, onStateChanged, onNatPolicyChanged, |
130 logDebugInfo, xmppServerAddress, xmppServerUseTls, directoryBotJid, | 130 logDebugInfo, xmppServerAddress, xmppServerUseTls, directoryBotJid, |
131 onError) { | 131 onError) { |
132 if (!this.port_) { | 132 if (!this.port_) { |
133 console.error( | 133 console.error( |
134 'remoting.It2MeHostFacade.connect() without initialization.'); | 134 'remoting.It2MeHostFacade.connect() without initialization.'); |
135 onError(remoting.Error.UNEXPECTED); | 135 onError(remoting.Error.unexpected()); |
136 return; | 136 return; |
137 } | 137 } |
138 | 138 |
139 this.onStateChanged_ = onStateChanged; | 139 this.onStateChanged_ = onStateChanged; |
140 this.onNatPolicyChanged_ = onNatPolicyChanged; | 140 this.onNatPolicyChanged_ = onNatPolicyChanged; |
141 this.onError_ = onError; | 141 this.onError_ = onError; |
142 this.port_.postMessage({ | 142 this.port_.postMessage({ |
143 type: 'connect', | 143 type: 'connect', |
144 userName: email, | 144 userName: email, |
145 authServiceWithToken: authServiceWithToken, | 145 authServiceWithToken: authServiceWithToken, |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 if (this.onNatPolicyChanged_) { | 261 if (this.onNatPolicyChanged_) { |
262 var natTraversalEnabled = | 262 var natTraversalEnabled = |
263 getBooleanAttr(message, 'natTraversalEnabled'); | 263 getBooleanAttr(message, 'natTraversalEnabled'); |
264 this.onNatPolicyChanged_(natTraversalEnabled); | 264 this.onNatPolicyChanged_(natTraversalEnabled); |
265 } | 265 } |
266 break; | 266 break; |
267 | 267 |
268 case 'error': | 268 case 'error': |
269 console.error(getStringAttr(message, 'description')); | 269 console.error(getStringAttr(message, 'description')); |
270 if (this.onError_) { | 270 if (this.onError_) { |
271 this.onError_(remoting.Error.UNEXPECTED); | 271 this.onError_(remoting.Error.unexpected()); |
272 } | 272 } |
273 break; | 273 break; |
274 | 274 |
275 default: | 275 default: |
276 throw 'Unexpected native message: ' + message; | 276 throw 'Unexpected native message: ' + message; |
277 } | 277 } |
278 }; | 278 }; |
279 | 279 |
280 /** | 280 /** |
281 * @param {string} accessCode | 281 * @param {string} accessCode |
(...skipping 27 matching lines...) Expand all Loading... |
309 // E.g., if the host manifest is not present we get "Specified native | 309 // E.g., if the host manifest is not present we get "Specified native |
310 // messaging host not found" error. If the host manifest is present but | 310 // messaging host not found" error. If the host manifest is present but |
311 // the host binary cannot be found we get the "Native host has exited" | 311 // the host binary cannot be found we get the "Native host has exited" |
312 // error. | 312 // error. |
313 console.log('Native Messaging initialization failed: ' + | 313 console.log('Native Messaging initialization failed: ' + |
314 chrome.runtime.lastError.message); | 314 chrome.runtime.lastError.message); |
315 this.onInitializationFailed_(); | 315 this.onInitializationFailed_(); |
316 } else { | 316 } else { |
317 console.error('Native Messaging port disconnected.'); | 317 console.error('Native Messaging port disconnected.'); |
318 this.port_ = null; | 318 this.port_ = null; |
319 this.onError_(remoting.Error.UNEXPECTED); | 319 this.onError_(remoting.Error.unexpected()); |
320 } | 320 } |
321 }; | 321 }; |
322 | 322 |
323 })(); | 323 })(); |
OLD | NEW |