| Index: trunk/src/chrome/android/java/src/org/chromium/chrome/browser/sync/ProfileSyncService.java
|
| ===================================================================
|
| --- trunk/src/chrome/android/java/src/org/chromium/chrome/browser/sync/ProfileSyncService.java (revision 190557)
|
| +++ trunk/src/chrome/android/java/src/org/chromium/chrome/browser/sync/ProfileSyncService.java (working copy)
|
| @@ -89,11 +89,6 @@
|
| mNativeProfileSyncServiceAndroid = nativeInit();
|
| }
|
|
|
| - @CalledByNative
|
| - private static int getProfileSyncServiceAndroid(Context context) {
|
| - return get(context).mNativeProfileSyncServiceAndroid;
|
| - }
|
| -
|
| /**
|
| * If we are currently in the process of setting up sync, this method clears the
|
| * sync setup in progress flag.
|
| @@ -168,37 +163,30 @@
|
| }
|
| }
|
|
|
| - private Account getAccountOrNullFromUsername(String username) {
|
| + /**
|
| + * Requests a new auth token from the AccountManager. Invalidates the old token
|
| + * if |invalidAuthToken| is not empty.
|
| + */
|
| + @CalledByNative
|
| + public void getNewAuthToken(final String username, final String invalidAuthToken) {
|
| if (username == null) {
|
| Log.e(TAG, "username is null");
|
| - return null;
|
| + return;
|
| }
|
|
|
| final AccountManagerHelper accountManagerHelper = AccountManagerHelper.get(mContext);
|
| final Account account = accountManagerHelper.getAccountFromName(username);
|
| if (account == null) {
|
| Log.e(TAG, "Account not found for provided username.");
|
| - return null;
|
| + return;
|
| }
|
| - return account;
|
| - }
|
|
|
| - /**
|
| - * Requests a new auth token from the AccountManager. Invalidates the old token
|
| - * if |invalidAuthToken| is not empty.
|
| - */
|
| - @CalledByNative
|
| - public void getNewAuthToken(final String username, final String invalidAuthToken) {
|
| - final Account account = getAccountOrNullFromUsername(username);
|
| - if (account == null) return;
|
| -
|
| // Since this is blocking, do it in the background.
|
| new AsyncTask<Void, Void, String>() {
|
|
|
| @Override
|
| public String doInBackground(Void... params) {
|
| // Invalidate our old auth token and fetch a new one.
|
| - AccountManagerHelper accountManagerHelper = AccountManagerHelper.get(mContext);
|
| return accountManagerHelper.getNewAuthToken(
|
| account, invalidAuthToken, SyncStatusHelper.AUTH_TOKEN_TYPE_SYNC);
|
| }
|
| @@ -206,6 +194,8 @@
|
| @Override
|
| public void onPostExecute(String authToken) {
|
| if (authToken == null) {
|
| + // DO NOT COMMIT do we really need this TODO? We trigger a call to
|
| + // requestSyncFromNativeChrome() when an account changes and sync is setup.
|
| // TODO(sync): Need to hook LOGIN_ACCOUNTS_CHANGED_ACTION (http://b/5354713).
|
| Log.d(TAG, "Auth token for sync was null.");
|
| } else {
|
| @@ -216,48 +206,7 @@
|
| }.execute();
|
| }
|
|
|
| - /**
|
| - * Called by native to invalidate an OAuth2 token.
|
| - */
|
| - @CalledByNative
|
| - public void invalidateOAuth2AuthToken(String scope, String accessToken) {
|
| - AccountManagerHelper.get(mContext).invalidateAuthToken(scope, accessToken);
|
| - }
|
| -
|
| /**
|
| - * Called by native to retrieve OAuth2 tokens.
|
| - *
|
| - * @param username the native username (full address)
|
| - * @param scope the scope to get an auth token for (without Android-style 'oauth2:' prefix).
|
| - * @param oldAuthToken if provided, the token will be invalidated before getting a new token.
|
| - * @param nativeCallback the pointer to the native callback that should be run upon completion.
|
| - */
|
| - @CalledByNative
|
| - public void getOAuth2AuthToken(String username, String scope, final int nativeCallback) {
|
| - final Account account = getAccountOrNullFromUsername(username);
|
| - if (account == null) {
|
| - nativeOAuth2TokenFetched(
|
| - mNativeProfileSyncServiceAndroid, nativeCallback, null, false);
|
| - return;
|
| - }
|
| - final String oauth2Scope = "oauth2:" + scope;
|
| -
|
| - new AsyncTask<Void, Void, String>() {
|
| - @Override
|
| - public String doInBackground(Void... params) {
|
| - AccountManagerHelper accountManagerHelper = AccountManagerHelper.get(mContext);
|
| - return accountManagerHelper.getAuthTokenFromBackground(account, oauth2Scope);
|
| - }
|
| -
|
| - @Override
|
| - public void onPostExecute(String authToken) {
|
| - nativeOAuth2TokenFetched(
|
| - mNativeProfileSyncServiceAndroid, nativeCallback, authToken, authToken != null);
|
| - }
|
| - }.execute();
|
| - }
|
| -
|
| - /**
|
| * Checks if a password or a passphrase is required for decryption of sync data.
|
| * <p/>
|
| * Returns NONE if the state is unavailable, or decryption passphrase/password is not required.
|
| @@ -585,7 +534,4 @@
|
| private native boolean nativeIsSessionSyncEnabled(int nativeProfileSyncServiceAndroid);
|
| private native boolean nativeHasUnrecoverableError(int nativeProfileSyncServiceAndroid);
|
| private native String nativeGetAboutInfoForTest(int nativeProfileSyncServiceAndroid);
|
| - private native void nativeOAuth2TokenFetched(
|
| - int nativeProfileSyncServiceAndroid, int nativeCallback, String authToken,
|
| - boolean result);
|
| }
|
|
|