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

Unified Diff: remoting/webapp/crd/js/host_controller.js

Issue 1111603002: Added ability to register new hosts using GCD. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@host-list-delete
Patch Set: for review Created 5 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: remoting/webapp/crd/js/host_controller.js
diff --git a/remoting/webapp/crd/js/host_controller.js b/remoting/webapp/crd/js/host_controller.js
index b8015721ee913f309cb5b1e1e262af9e75e518f6..7be18f7065f930fb645aded1179a7f19bf96a15f 100644
--- a/remoting/webapp/crd/js/host_controller.js
+++ b/remoting/webapp/crd/js/host_controller.js
@@ -172,8 +172,8 @@ remoting.HostController.prototype.start = function(hostPin, consent) {
// Register the host and extract an optional auth code from the host
// response. The absence of an auth code is represented by an empty
// string.
Jamie 2015/04/27 23:24:24 Is this comment still correct?
John Williams 2015/04/28 20:27:40 Fixed.
- /** @type {!Promise<string>} */
- var authCodePromise = Promise.all([
+ /** @type {!Promise<remoting.HostListApi.RegisterResult>} */
+ var regResultPromise = Promise.all([
hostClientIdPromise,
hostNamePromise,
keyPairPromise
@@ -184,16 +184,26 @@ remoting.HostController.prototype.start = function(hostPin, consent) {
return remoting.HostListApi.getInstance().register(
newHostId, hostName, keyPair.publicKey, hostClientId);
- }).then(function(/** string */ result) {
+ }).then(function(/** remoting.HostListApi.RegisterResult */ result) {
hostRegistered = true;
return result;
});
// Get XMPP creditials.
- var xmppCredsPromise = authCodePromise.then(function(authCode) {
- if (authCode) {
+ var xmppCredsPromise = regResultPromise.then(function(regResult) {
+ if (regResult.authCode && regResult.email) {
+ // Use auth code and email supplied by GCD.
+ return that.hostDaemonFacade_.getRefreshTokenFromAuthCode(
+ regResult.authCode).then(function(token) {
+ return {
+ userEmail: regResult.email,
+ refreshToken: token
+ };
+ });
+ } else if (regResult.authCode) {
// Use auth code supplied by Chromoting registry.
- return that.hostDaemonFacade_.getCredentialsFromAuthCode(authCode);
+ return that.hostDaemonFacade_.getCredentialsFromAuthCode(
+ regResult.authCode);
} else {
// No authorization code returned, use regular Chrome
// identity credential flow.
@@ -207,8 +217,8 @@ remoting.HostController.prototype.start = function(hostPin, consent) {
});
// Get as JID to use as the host owner.
- var hostOwnerPromise = authCodePromise.then(function(authCode) {
- if (authCode) {
+ var hostOwnerPromise = regResultPromise.then(function(regResult) {
+ if (regResult.authCode && !regResult.email) {
Jamie 2015/04/27 23:24:24 This doesn't look right. You're never using regRes
John Williams 2015/04/28 20:27:40 Done.
return that.getClientBaseJid_();
} else {
return remoting.identity.getEmail();
« no previous file with comments | « no previous file | remoting/webapp/crd/js/host_controller_unittest.js » ('j') | remoting/webapp/crd/js/host_list_api_impl.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698