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

Side by Side Diff: remoting/android/java/src/org/chromium/chromoting/Chromoting.java

Issue 981783003: Pull authentication UX code out of JniInterface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@fix-jni-initialization
Patch Set: Address Sergey's comments Created 5 years, 9 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 unified diff | Download patch
« no previous file with comments | « no previous file | remoting/android/java/src/org/chromium/chromoting/SessionAuthenticator.java » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 package org.chromium.chromoting; 5 package org.chromium.chromoting;
6 6
7 import android.accounts.Account; 7 import android.accounts.Account;
8 import android.accounts.AccountManager; 8 import android.accounts.AccountManager;
9 import android.accounts.AccountManagerCallback; 9 import android.accounts.AccountManagerCallback;
10 import android.accounts.AccountManagerFuture; 10 import android.accounts.AccountManagerFuture;
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 83
84 /** Host list as it appears to the user. */ 84 /** Host list as it appears to the user. */
85 private ListView mHostListView; 85 private ListView mHostListView;
86 86
87 /** Progress view shown instead of the host list when the host list is loadi ng. */ 87 /** Progress view shown instead of the host list when the host list is loadi ng. */
88 private View mProgressView; 88 private View mProgressView;
89 89
90 /** Dialog for reporting connection progress. */ 90 /** Dialog for reporting connection progress. */
91 private ProgressDialog mProgressIndicator; 91 private ProgressDialog mProgressIndicator;
92 92
93 /** Object for fetching OAuth2 access tokens from third party authorization servers. */ 93 /** Object for handling the Intent received when using third-party session a uthentication. */
Sergey Ulanov 2015/03/18 17:55:03 I don't think this is a good description. Handling
Lambros 2015/03/18 18:45:19 Done.
94 private ThirdPartyTokenFetcher mTokenFetcher; 94 private SessionAuthenticator mAuthenticator;
95 95
96 /** 96 /**
97 * This is set when receiving an authentication error from the HostListLoade r. If that occurs, 97 * This is set when receiving an authentication error from the HostListLoade r. If that occurs,
98 * this flag is set and a fresh authentication token is fetched from the Acc ountsService, and 98 * this flag is set and a fresh authentication token is fetched from the Acc ountsService, and
99 * used to request the host list a second time. 99 * used to request the host list a second time.
100 */ 100 */
101 boolean mTriedNewAuthToken; 101 boolean mTriedNewAuthToken;
102 102
103 /** 103 /**
104 * Flag to track whether a call to AccountManager.getAuthToken() is currentl y pending. 104 * Flag to track whether a call to AccountManager.getAuthToken() is currentl y pending.
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 207
208 @Override 208 @Override
209 protected void onPostCreate(Bundle savedInstanceState) { 209 protected void onPostCreate(Bundle savedInstanceState) {
210 super.onPostCreate(savedInstanceState); 210 super.onPostCreate(savedInstanceState);
211 mDrawerToggle.syncState(); 211 mDrawerToggle.syncState();
212 } 212 }
213 213
214 @Override 214 @Override
215 protected void onNewIntent(Intent intent) { 215 protected void onNewIntent(Intent intent) {
216 super.onNewIntent(intent); 216 super.onNewIntent(intent);
217 if (mTokenFetcher != null) { 217
218 if (mTokenFetcher.handleTokenFetched(intent)) { 218 if (mAuthenticator != null) {
219 mTokenFetcher = null; 219 mAuthenticator.onNewIntent(intent);
220 }
221 } 220 }
222 } 221 }
223 222
224 /** 223 /**
225 * Called when the activity becomes visible. This happens on initial launch and whenever the 224 * Called when the activity becomes visible. This happens on initial launch and whenever the
226 * user switches to the activity, for example, by using the window-switcher or when coming from 225 * user switches to the activity, for example, by using the window-switcher or when coming from
227 * the device's lock screen. 226 * the device's lock screen.
228 */ 227 */
229 @Override 228 @Override
230 public void onStart() { 229 public void onStart() {
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 mProgressIndicator = ProgressDialog.show( 315 mProgressIndicator = ProgressDialog.show(
317 this, 316 this,
318 host.name, 317 host.name,
319 getString(R.string.footer_connecting), 318 getString(R.string.footer_connecting),
320 true, 319 true,
321 true, 320 true,
322 new DialogInterface.OnCancelListener() { 321 new DialogInterface.OnCancelListener() {
323 @Override 322 @Override
324 public void onCancel(DialogInterface dialog) { 323 public void onCancel(DialogInterface dialog) {
325 JniInterface.disconnectFromHost(); 324 JniInterface.disconnectFromHost();
326 mTokenFetcher = null;
327 } 325 }
328 }); 326 });
329 SessionConnector connector = new SessionConnector(this, this, mHostListL oader); 327 SessionConnector connector = new SessionConnector(this, this, mHostListL oader);
330 assert mTokenFetcher == null; 328 mAuthenticator = new SessionAuthenticator(this, host);
331 mTokenFetcher = createTokenFetcher(host); 329 connector.connectToHost(mAccount.name, mToken, host, mAuthenticator);
332 connector.connectToHost(mAccount.name, mToken, host);
333 } 330 }
334 331
335 private void refreshHostList() { 332 private void refreshHostList() {
336 if (mWaitingForAuthToken) { 333 if (mWaitingForAuthToken) {
337 return; 334 return;
338 } 335 }
339 336
340 mTriedNewAuthToken = false; 337 mTriedNewAuthToken = false;
341 setHostListProgressVisible(true); 338 setHostListProgressVisible(true);
342 339
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 default: 500 default:
504 // Unreachable, but required by Google Java style and findbugs. 501 // Unreachable, but required by Google Java style and findbugs.
505 assert false : "Unreached"; 502 assert false : "Unreached";
506 } 503 }
507 504
508 if (dismissProgress && mProgressIndicator != null) { 505 if (dismissProgress && mProgressIndicator != null) {
509 mProgressIndicator.dismiss(); 506 mProgressIndicator.dismiss();
510 mProgressIndicator = null; 507 mProgressIndicator = null;
511 } 508 }
512 } 509 }
513
514 private ThirdPartyTokenFetcher createTokenFetcher(HostInfo host) {
515 ThirdPartyTokenFetcher.Callback callback = new ThirdPartyTokenFetcher.Ca llback() {
516 @Override
517 public void onTokenFetched(String code, String accessToken) {
518 // The native client sends the OAuth authorization code to the h ost as the token so
519 // that the host can obtain the shared secret from the third par ty authorization
520 // server.
521 String token = code;
522
523 // The native client uses the OAuth access token as the shared s ecret to
524 // authenticate itself with the host using spake.
525 String sharedSecret = accessToken;
526
527 JniInterface.onThirdPartyTokenFetched(token, sharedSecret);
528 }
529 };
530 return new ThirdPartyTokenFetcher(this, host.getTokenUrlPatterns(), call back);
531 }
532
533 public void fetchThirdPartyToken(String tokenUrl, String clientId, String sc ope) {
534 assert mTokenFetcher != null;
535 mTokenFetcher.fetchToken(tokenUrl, clientId, scope);
536 }
537 } 510 }
OLDNEW
« no previous file with comments | « no previous file | remoting/android/java/src/org/chromium/chromoting/SessionAuthenticator.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698