OLD | NEW |
---|---|
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 27 matching lines...) Expand all Loading... | |
38 * The user interface for querying and displaying a user's host list from the di rectory server. It | 38 * The user interface for querying and displaying a user's host list from the di rectory server. It |
39 * also requests and renews authentication tokens using the system account manag er. | 39 * also requests and renews authentication tokens using the system account manag er. |
40 */ | 40 */ |
41 public class Chromoting extends Activity implements JniInterface.ConnectionListe ner, | 41 public class Chromoting extends Activity implements JniInterface.ConnectionListe ner, |
42 AccountManagerCallback<Bundle>, ActionBar.OnNavigationListener, HostList Loader.Callback, | 42 AccountManagerCallback<Bundle>, ActionBar.OnNavigationListener, HostList Loader.Callback, |
43 View.OnClickListener { | 43 View.OnClickListener { |
44 /** Only accounts of this type will be selectable for authentication. */ | 44 /** Only accounts of this type will be selectable for authentication. */ |
45 private static final String ACCOUNT_TYPE = "com.google"; | 45 private static final String ACCOUNT_TYPE = "com.google"; |
46 | 46 |
47 /** Scopes at which the authentication token we request will be valid. */ | 47 /** Scopes at which the authentication token we request will be valid. */ |
48 private static final String TOKEN_SCOPE = "oauth2:https://www.googleapis.com /auth/chromoting " + | 48 private static final String TOKEN_SCOPE = "oauth2:https://www.googleapis.com /auth/chromoting " |
49 "https://www.googleapis.com/auth/googletalk"; | 49 + "https://www.googleapis.com/auth/googletalk"; |
50 | 50 |
51 /** Web page to be displayed in the Help screen when launched from this acti vity. */ | 51 /** Web page to be displayed in the Help screen when launched from this acti vity. */ |
52 private static final String HELP_URL = | 52 private static final String HELP_URL = |
53 "http://support.google.com/chrome/?p=mobile_crd_hostslist"; | 53 "http://support.google.com/chrome/?p=mobile_crd_hostslist"; |
54 | 54 |
55 /** Web page to be displayed when user triggers the hyperlink for setting up hosts. */ | 55 /** Web page to be displayed when user triggers the hyperlink for setting up hosts. */ |
56 private static final String HOST_SETUP_URL = | 56 private static final String HOST_SETUP_URL = |
57 "https://support.google.com/chrome/answer/1649523"; | 57 "https://support.google.com/chrome/answer/1649523"; |
58 | 58 |
59 /** User's account details. */ | 59 /** User's account details. */ |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
348 mToken = result.getString(AccountManager.KEY_AUTHTOKEN); | 348 mToken = result.getString(AccountManager.KEY_AUTHTOKEN); |
349 Log.i("auth", "Received an auth token from system"); | 349 Log.i("auth", "Received an auth token from system"); |
350 | 350 |
351 mHostListLoader.retrieveHostList(mToken, this); | 351 mHostListLoader.retrieveHostList(mToken, this); |
352 } | 352 } |
353 | 353 |
354 @Override | 354 @Override |
355 public boolean onNavigationItemSelected(int itemPosition, long itemId) { | 355 public boolean onNavigationItemSelected(int itemPosition, long itemId) { |
356 mAccount = mAccounts[itemPosition]; | 356 mAccount = mAccounts[itemPosition]; |
357 | 357 |
358 getPreferences(MODE_PRIVATE).edit().putString("account_name", mAccount.n ame). | 358 getPreferences(MODE_PRIVATE).edit().putString("account_name", mAccount.n ame) |
359 putString("account_type", mAccount.type).apply(); | 359 .putString("account_type", mAccount.type).apply(); |
Ted C
2014/10/22 17:18:05
-4 indent here
| |
360 | 360 |
361 // The current host list is no longer valid for the new account, so clea r the list. | 361 // The current host list is no longer valid for the new account, so clea r the list. |
362 mHosts = new HostInfo[0]; | 362 mHosts = new HostInfo[0]; |
363 updateUi(); | 363 updateUi(); |
364 refreshHostList(); | 364 refreshHostList(); |
365 return true; | 365 return true; |
366 } | 366 } |
367 | 367 |
368 @Override | 368 @Override |
369 public void onHostListReceived(HostInfo[] hosts) { | 369 public void onHostListReceived(HostInfo[] hosts) { |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
495 } | 495 } |
496 }; | 496 }; |
497 return new ThirdPartyTokenFetcher(this, host.getTokenUrlPatterns(), call back); | 497 return new ThirdPartyTokenFetcher(this, host.getTokenUrlPatterns(), call back); |
498 } | 498 } |
499 | 499 |
500 public void fetchThirdPartyToken(String tokenUrl, String clientId, String sc ope) { | 500 public void fetchThirdPartyToken(String tokenUrl, String clientId, String sc ope) { |
501 assert mTokenFetcher != null; | 501 assert mTokenFetcher != null; |
502 mTokenFetcher.fetchToken(tokenUrl, clientId, scope); | 502 mTokenFetcher.fetchToken(tokenUrl, clientId, scope); |
503 } | 503 } |
504 } | 504 } |
OLD | NEW |