| 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/jni_android.h" | 7 #include "base/android/jni_android.h" |
| 8 #include "base/android/jni_array.h" | 8 #include "base/android/jni_array.h" |
| 9 #include "base/android/jni_string.h" | 9 #include "base/android/jni_string.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 JNIEnv* env = AttachCurrentThread(); | 143 JNIEnv* env = AttachCurrentThread(); |
| 144 base::android::ScopedJavaLocalRef<jobject> local_java_ref = | 144 base::android::ScopedJavaLocalRef<jobject> local_java_ref = |
| 145 Java_OAuth2TokenService_create(env, reinterpret_cast<intptr_t>(this)); | 145 Java_OAuth2TokenService_create(env, reinterpret_cast<intptr_t>(this)); |
| 146 java_ref_.Reset(env, local_java_ref.obj()); | 146 java_ref_.Reset(env, local_java_ref.obj()); |
| 147 } | 147 } |
| 148 | 148 |
| 149 OAuth2TokenServiceDelegateAndroid::~OAuth2TokenServiceDelegateAndroid() { | 149 OAuth2TokenServiceDelegateAndroid::~OAuth2TokenServiceDelegateAndroid() { |
| 150 } | 150 } |
| 151 | 151 |
| 152 // static | 152 // static |
| 153 jobject OAuth2TokenServiceDelegateAndroid::GetForProfile( | 153 ScopedJavaLocalRef<jobject> OAuth2TokenServiceDelegateAndroid::GetForProfile( |
| 154 JNIEnv* env, | 154 JNIEnv* env, |
| 155 jclass clazz, | 155 jclass clazz, |
| 156 jobject j_profile_android) { | 156 jobject j_profile_android) { |
| 157 Profile* profile = ProfileAndroid::FromProfileAndroid(j_profile_android); | 157 Profile* profile = ProfileAndroid::FromProfileAndroid(j_profile_android); |
| 158 ProfileOAuth2TokenService* service = | 158 ProfileOAuth2TokenService* service = |
| 159 ProfileOAuth2TokenServiceFactory::GetForProfile(profile); | 159 ProfileOAuth2TokenServiceFactory::GetForProfile(profile); |
| 160 OAuth2TokenServiceDelegate* delegate = service->GetDelegate(); | 160 OAuth2TokenServiceDelegate* delegate = service->GetDelegate(); |
| 161 return static_cast<OAuth2TokenServiceDelegateAndroid*>(delegate) | 161 return ScopedJavaLocalRef<jobject>( |
| 162 ->java_ref_.obj(); | 162 static_cast<OAuth2TokenServiceDelegateAndroid*>(delegate)->java_ref_); |
| 163 } | 163 } |
| 164 | 164 |
| 165 static jobject GetForProfile(JNIEnv* env, | 165 static ScopedJavaLocalRef<jobject> GetForProfile(JNIEnv* env, |
| 166 jclass clazz, | 166 jclass clazz, |
| 167 jobject j_profile_android) { | 167 jobject j_profile_android) { |
| 168 return OAuth2TokenServiceDelegateAndroid::GetForProfile(env, clazz, | 168 return OAuth2TokenServiceDelegateAndroid::GetForProfile(env, clazz, |
| 169 j_profile_android); | 169 j_profile_android); |
| 170 } | 170 } |
| 171 | 171 |
| 172 void OAuth2TokenServiceDelegateAndroid::Initialize() { | 172 void OAuth2TokenServiceDelegateAndroid::Initialize() { |
| 173 DVLOG(1) << "OAuth2TokenServiceDelegateAndroid::Initialize"; | 173 DVLOG(1) << "OAuth2TokenServiceDelegateAndroid::Initialize"; |
| 174 if (!is_testing_profile_) { | 174 if (!is_testing_profile_) { |
| 175 Java_OAuth2TokenService_validateAccounts( | 175 Java_OAuth2TokenService_validateAccounts( |
| 176 AttachCurrentThread(), java_ref_.obj(), | 176 AttachCurrentThread(), java_ref_.obj(), |
| 177 base::android::GetApplicationContext(), JNI_TRUE); | 177 base::android::GetApplicationContext(), JNI_TRUE); |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 467 GoogleServiceAuthError err(authToken | 467 GoogleServiceAuthError err(authToken |
| 468 ? GoogleServiceAuthError::NONE | 468 ? GoogleServiceAuthError::NONE |
| 469 : GoogleServiceAuthError::CONNECTION_FAILED); | 469 : GoogleServiceAuthError::CONNECTION_FAILED); |
| 470 heap_callback->Run(err, token, base::Time()); | 470 heap_callback->Run(err, token, base::Time()); |
| 471 } | 471 } |
| 472 | 472 |
| 473 // static | 473 // static |
| 474 bool OAuth2TokenServiceDelegateAndroid::Register(JNIEnv* env) { | 474 bool OAuth2TokenServiceDelegateAndroid::Register(JNIEnv* env) { |
| 475 return RegisterNativesImpl(env); | 475 return RegisterNativesImpl(env); |
| 476 } | 476 } |
| OLD | NEW |