Index: remoting/webapp/client_plugin_async.js |
diff --git a/remoting/webapp/client_plugin_async.js b/remoting/webapp/client_plugin_async.js |
index 71ec21f6dc6523074902d68a6bd8a5cc7043093e..788b49afb83a589f2901275876f5f2711867796f 100644 |
--- a/remoting/webapp/client_plugin_async.js |
+++ b/remoting/webapp/client_plugin_async.js |
@@ -40,6 +40,13 @@ remoting.ClientPluginAsync = function(plugin) { |
this.onConnectionStatusUpdateHandler = function(state, error) {}; |
/** @param {boolean} ready Connection ready state. */ |
this.onConnectionReadyHandler = function(ready) {}; |
+ /** |
+ * @param {string} tokenUrl Token-request URL, received from the host. |
+ * @param {string} hostPublicKey Public key for the host. |
+ * @param {string} scope OAuth scope to request the token for. |
+ */ |
+ this.fetchThirdPartyTokenHandler = function( |
+ tokenUrl, hostPublicKey, scope) {}; |
this.onDesktopSizeUpdateHandler = function () {}; |
/** @param {!Array.<string>} capabilities The negotiated capabilities. */ |
this.onSetCapabilitiesHandler = function (capabilities) {}; |
@@ -266,6 +273,18 @@ remoting.ClientPluginAsync.prototype.handleMessage_ = function(messageStr) { |
/** @type {!Array.<string>} */ |
var capabilities = tokenize(message.data['capabilities']); |
this.onSetCapabilitiesHandler(capabilities); |
+ } else if (message.method == 'fetchThirdPartyToken') { |
+ if (typeof message.data['tokenUrl'] != 'string' || |
+ typeof message.data['hostPublicKey'] != 'string' || |
+ typeof message.data['scope'] != 'string') { |
+ console.error('Received incorrect fetchThirdPartyToken message.'); |
+ return; |
+ } |
+ var tokenUrl = /** @type {string} */ message.data['tokenUrl']; |
+ var hostPublicKey = |
+ /** @type {string} */ message.data['hostPublicKey']; |
+ var scope = /** @type {string} */ message.data['scope']; |
+ this.fetchThirdPartyTokenHandler(tokenUrl, hostPublicKey, scope); |
} |
}; |
@@ -523,6 +542,19 @@ remoting.ClientPluginAsync.prototype.useAsyncPinDialog = |
}; |
/** |
+ * Sets the third party authentication token and shared secret. |
+ * |
+ * @param {string} token The token received from the token URL. |
+ * @param {string} sharedSecret Shared secret received from the token URL. |
+ */ |
+remoting.ClientPluginAsync.prototype.onThirdPartyTokenFetched = function( |
+ token, sharedSecret) { |
+ this.plugin.postMessage(JSON.stringify( |
+ { method: 'onThirdPartyTokenFetched', |
+ data: { token: token, sharedSecret: sharedSecret}})); |
+}; |
+ |
+/** |
* If we haven't yet received a "hello" message from the plugin, change its |
* size so that the user can confirm it if click-to-play is enabled, or can |
* see the "this plugin is disabled" message if it is actually disabled. |