| 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 #include "chrome/browser/signin/oauth2_token_service_delegate_android.h" | 5 #include "chrome/browser/signin/oauth2_token_service_delegate_android.h" |
| 6 | 6 |
| 7 #include "base/android/context_utils.h" | 7 #include "base/android/context_utils.h" |
| 8 #include "base/android/jni_android.h" | 8 #include "base/android/jni_android.h" |
| 9 #include "base/android/jni_array.h" | 9 #include "base/android/jni_array.h" |
| 10 #include "base/android/jni_string.h" | 10 #include "base/android/jni_string.h" |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/metrics/histogram_macros.h" | 14 #include "base/metrics/histogram_macros.h" |
| 15 #include "base/stl_util.h" | 15 #include "base/stl_util.h" |
| 16 #include "chrome/browser/profiles/profile_android.h" | 16 #include "chrome/browser/profiles/profile_android.h" |
| 17 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 17 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
| 18 #include "chrome/browser/sync/profile_sync_service_android.h" | 18 #include "chrome/browser/sync/profile_sync_service_android.h" |
| 19 #include "components/signin/core/browser/account_info.h" | 19 #include "components/signin/core/browser/account_info.h" |
| 20 #include "content/public/browser/browser_thread.h" | 20 #include "content/public/browser/browser_thread.h" |
| 21 #include "google_apis/gaia/gaia_auth_util.h" | 21 #include "google_apis/gaia/gaia_auth_util.h" |
| 22 #include "google_apis/gaia/oauth2_access_token_fetcher.h" | 22 #include "google_apis/gaia/oauth2_access_token_fetcher.h" |
| 23 #include "jni/OAuth2TokenService_jni.h" | 23 #include "jni/OAuth2TokenService_jni.h" |
| 24 | 24 |
| 25 using base::android::AttachCurrentThread; | 25 using base::android::AttachCurrentThread; |
| 26 using base::android::ConvertJavaStringToUTF8; | 26 using base::android::ConvertJavaStringToUTF8; |
| 27 using base::android::ConvertUTF8ToJavaString; | 27 using base::android::ConvertUTF8ToJavaString; |
| 28 using base::android::JavaParamRef; |
| 28 using base::android::ScopedJavaLocalRef; | 29 using base::android::ScopedJavaLocalRef; |
| 29 using content::BrowserThread; | 30 using content::BrowserThread; |
| 30 | 31 |
| 31 namespace { | 32 namespace { |
| 32 | 33 |
| 33 // Callback from FetchOAuth2TokenWithUsername(). | 34 // Callback from FetchOAuth2TokenWithUsername(). |
| 34 // Arguments: | 35 // Arguments: |
| 35 // - the error, or NONE if the token fetch was successful. | 36 // - the error, or NONE if the token fetch was successful. |
| 36 // - the OAuth2 access token. | 37 // - the OAuth2 access token. |
| 37 // - the expiry time of the token (may be null, indicating that the expiry | 38 // - the expiry time of the token (may be null, indicating that the expiry |
| (...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 568 : isTransientError | 569 : isTransientError |
| 569 ? GoogleServiceAuthError::CONNECTION_FAILED | 570 ? GoogleServiceAuthError::CONNECTION_FAILED |
| 570 : GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS); | 571 : GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS); |
| 571 heap_callback->Run(err, token, base::Time()); | 572 heap_callback->Run(err, token, base::Time()); |
| 572 } | 573 } |
| 573 | 574 |
| 574 // static | 575 // static |
| 575 bool OAuth2TokenServiceDelegateAndroid::Register(JNIEnv* env) { | 576 bool OAuth2TokenServiceDelegateAndroid::Register(JNIEnv* env) { |
| 576 return RegisterNativesImpl(env); | 577 return RegisterNativesImpl(env); |
| 577 } | 578 } |
| OLD | NEW |