Chromium Code Reviews| Index: remoting/android/java/src/org/chromium/chromoting/Chromoting.java |
| diff --git a/remoting/android/java/src/org/chromium/chromoting/Chromoting.java b/remoting/android/java/src/org/chromium/chromoting/Chromoting.java |
| index 29aec73ad2138033e74434c650e7ad4d44400a1f..156e908033971d37048e489dec13a1c4c5e1d213 100644 |
| --- a/remoting/android/java/src/org/chromium/chromoting/Chromoting.java |
| +++ b/remoting/android/java/src/org/chromium/chromoting/Chromoting.java |
| @@ -86,6 +86,9 @@ public class Chromoting extends Activity implements JniInterface.ConnectionListe |
| /** Dialog for reporting connection progress. */ |
| private ProgressDialog mProgressIndicator; |
| + /** Object for fetching OAuth2 access tokens from third party authorization servers. */ |
| + private ThirdPartyTokenFetcher mTokenFetcher; |
| + |
| /** |
| * This is set when receiving an authentication error from the HostListLoader. If that occurs, |
| * this flag is set and a fresh authentication token is fetched from the AccountsService, and |
| @@ -162,6 +165,15 @@ public class Chromoting extends Activity implements JniInterface.ConnectionListe |
| JniInterface.loadLibrary(this); |
| } |
| + @Override |
| + protected void onNewIntent(Intent intent) { |
| + super.onNewIntent(intent); |
| + if (mTokenFetcher != null) { |
| + if (mTokenFetcher.handleTokenFetched(intent)) { |
| + mTokenFetcher = null; |
| + } |
| + } |
| + } |
| /** |
| * Called when the activity becomes visible. This happens on initial launch and whenever the |
| * user switches to the activity, for example, by using the window-switcher or when coming from |
| @@ -446,4 +458,27 @@ public class Chromoting extends Activity implements JniInterface.ConnectionListe |
| mProgressIndicator = null; |
| } |
| } |
| + |
| + public void fetchThirdPartyToken(String tokenUrl, String clientId, String scope) { |
| + assert mTokenFetcher == null; |
| + |
| + ThirdPartyTokenFetcher.Callback callback = new ThirdPartyTokenFetcher.Callback() { |
| + public void onTokenFetched(String code, String accessToken) { |
| + // The native client sends the OAuth authorization code to the host as the token so |
| + // that the host can obtains the shared secret from the third party authorization |
|
Lambros
2014/06/17 02:01:39
s/obtains/obtain
kelvinp
2014/06/17 03:33:40
Done.
|
| + // server. |
| + String token = code; |
|
Lambros
2014/06/17 02:01:39
nit: Blank line before comment.
kelvinp
2014/06/17 03:33:40
Done.
|
| + // The native client uses the OAuth access token as the shared secret to |
| + // authenticate itself with the host using spake. |
| + String sharedSecret = accessToken; |
| + |
| + JniInterface.nativeOnThirdPartyTokenFetched(token, sharedSecret); |
| + } |
| + }; |
| + |
| + mTokenFetcher = new ThirdPartyTokenFetcher(this, tokenUrl, clientId, scope, callback); |
| + mTokenFetcher.fetchToken(); |
| + } |
| + |
| + |
| } |