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 * This class provides an interface between the HostSession and either the | 7 * This class provides an interface between the HostSession and either the |
8 * NativeMessaging Host or the Host NPAPI plugin, depending on whether or not | 8 * NativeMessaging Host or the Host NPAPI plugin, depending on whether or not |
9 * NativeMessaging is supported. Since the test for NativeMessaging support is | 9 * NativeMessaging is supported. Since the test for NativeMessaging support is |
10 * asynchronous, the connection is attemped on either the the NativeMessaging | 10 * asynchronous, the connection is attemped on either the the NativeMessaging |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 * plugin works. | 49 * plugin works. |
50 */ | 50 */ |
51 remoting.HostIt2MeDispatcher.prototype.initialize = | 51 remoting.HostIt2MeDispatcher.prototype.initialize = |
52 function(createPluginCallback, onDispatcherInitialized, | 52 function(createPluginCallback, onDispatcherInitialized, |
53 onDispatcherInitializationFailed) { | 53 onDispatcherInitializationFailed) { |
54 /** @type {remoting.HostIt2MeDispatcher} */ | 54 /** @type {remoting.HostIt2MeDispatcher} */ |
55 var that = this; | 55 var that = this; |
56 | 56 |
57 function onNativeMessagingStarted() { | 57 function onNativeMessagingStarted() { |
58 console.log('Native Messaging supported.'); | 58 console.log('Native Messaging supported.'); |
| 59 |
| 60 that.npapiHost_ = null; |
59 onDispatcherInitialized(); | 61 onDispatcherInitialized(); |
60 } | 62 } |
61 | 63 |
62 function onNativeMessagingInitFailed() { | 64 function onNativeMessagingInitFailed() { |
63 console.log('Native Messaging unsupported, falling back to NPAPI.'); | 65 console.log('Native Messaging unsupported, falling back to NPAPI.'); |
64 | 66 |
65 that.nativeMessagingHost_ = null; | 67 that.nativeMessagingHost_ = null; |
66 that.npapiHost_ = createPluginCallback(); | 68 that.npapiHost_ = createPluginCallback(); |
67 | 69 |
68 // TODO(weitaosu): is there a better way to check whether NPAPI plugin is | 70 // TODO(weitaosu): is there a better way to check whether NPAPI plugin is |
(...skipping 14 matching lines...) Expand all Loading... |
83 /** | 85 /** |
84 * @param {remoting.Error} error | 86 * @param {remoting.Error} error |
85 */ | 87 */ |
86 remoting.HostIt2MeDispatcher.prototype.onNativeMessagingError_ = | 88 remoting.HostIt2MeDispatcher.prototype.onNativeMessagingError_ = |
87 function(error) { | 89 function(error) { |
88 this.nativeMessagingHost_ = null; | 90 this.nativeMessagingHost_ = null; |
89 this.onErrorHandler_(error); | 91 this.onErrorHandler_(error); |
90 } | 92 } |
91 | 93 |
92 /** | 94 /** |
| 95 * @return {boolean} |
| 96 */ |
| 97 remoting.HostIt2MeDispatcher.prototype.usingNpapi = function() { |
| 98 return this.npapiHost_ != null; |
| 99 } |
| 100 |
| 101 /** |
| 102 * @return {remoting.HostPlugin} |
| 103 */ |
| 104 remoting.HostIt2MeDispatcher.prototype.getNpapiHost = function() { |
| 105 return this.npapiHost_; |
| 106 } |
| 107 |
| 108 /** |
93 * @param {string} email The user's email address. | 109 * @param {string} email The user's email address. |
94 * @param {string} authServiceWithToken Concatenation of the auth service | 110 * @param {string} authServiceWithToken Concatenation of the auth service |
95 * (e.g. oauth2) and the access token. | 111 * (e.g. oauth2) and the access token. |
96 * @param {function(remoting.HostSession.State):void} onStateChanged Callback to | 112 * @param {function(remoting.HostSession.State):void} onStateChanged Callback to |
97 * invoke when the host state changes. | 113 * invoke when the host state changes. |
98 * @param {function(boolean):void} onNatPolicyChanged Callback to invoke when | 114 * @param {function(boolean):void} onNatPolicyChanged Callback to invoke when |
99 * the nat traversal policy changes. | 115 * the nat traversal policy changes. |
100 * @param {function(string):void} logDebugInfo Callback allowing the plugin | 116 * @param {function(string):void} logDebugInfo Callback allowing the plugin |
101 * to log messages to the debug log. | 117 * to log messages to the debug log. |
102 * @param {string} xmppServerAddress XMPP server host name (or IP address) and | 118 * @param {string} xmppServerAddress XMPP server host name (or IP address) and |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 }; | 194 }; |
179 | 195 |
180 /** | 196 /** |
181 * @return {void} | 197 * @return {void} |
182 */ | 198 */ |
183 remoting.HostIt2MeDispatcher.prototype.cleanup = function() { | 199 remoting.HostIt2MeDispatcher.prototype.cleanup = function() { |
184 if (this.npapiHost_) { | 200 if (this.npapiHost_) { |
185 this.npapiHost_.parentNode.removeChild(this.npapiHost_); | 201 this.npapiHost_.parentNode.removeChild(this.npapiHost_); |
186 } | 202 } |
187 }; | 203 }; |
OLD | NEW |