| 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/android_profile_oauth2_token_service.h" | 5 #include "chrome/browser/signin/android_profile_oauth2_token_service.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 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 << " sigined_in_account=" << signed_in_account | 271 << " sigined_in_account=" << signed_in_account |
| 272 << " prev_ids=" << prev_ids.size() | 272 << " prev_ids=" << prev_ids.size() |
| 273 << " curr_ids=" << curr_ids.size() | 273 << " curr_ids=" << curr_ids.size() |
| 274 << " force=" << (force_notifications ? "true" : "false"); | 274 << " force=" << (force_notifications ? "true" : "false"); |
| 275 | 275 |
| 276 if (!ValidateAccounts(signed_in_account, prev_ids, curr_ids, refreshed_ids, | 276 if (!ValidateAccounts(signed_in_account, prev_ids, curr_ids, refreshed_ids, |
| 277 revoked_ids, force_notifications)) { | 277 revoked_ids, force_notifications)) { |
| 278 curr_ids.clear(); | 278 curr_ids.clear(); |
| 279 } | 279 } |
| 280 | 280 |
| 281 ScopedBacthChange batch(this); | 281 ScopedBatchChange batch(this); |
| 282 | 282 |
| 283 JNIEnv* env = AttachCurrentThread(); | 283 JNIEnv* env = AttachCurrentThread(); |
| 284 ScopedJavaLocalRef<jobjectArray> java_accounts( | 284 ScopedJavaLocalRef<jobjectArray> java_accounts( |
| 285 base::android::ToJavaArrayOfStrings(env, curr_ids)); | 285 base::android::ToJavaArrayOfStrings(env, curr_ids)); |
| 286 Java_OAuth2TokenService_saveStoredAccounts( | 286 Java_OAuth2TokenService_saveStoredAccounts( |
| 287 env, base::android::GetApplicationContext(), java_accounts.obj()); | 287 env, base::android::GetApplicationContext(), java_accounts.obj()); |
| 288 | 288 |
| 289 for (std::vector<std::string>::iterator it = refreshed_ids.begin(); | 289 for (std::vector<std::string>::iterator it = refreshed_ids.begin(); |
| 290 it != refreshed_ids.end(); it++) { | 290 it != refreshed_ids.end(); it++) { |
| 291 FireRefreshTokenAvailable(*it); | 291 FireRefreshTokenAvailable(*it); |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 // Notify native observers. | 424 // Notify native observers. |
| 425 OAuth2TokenService::FireRefreshTokensLoaded(); | 425 OAuth2TokenService::FireRefreshTokensLoaded(); |
| 426 // Notify Java observers. | 426 // Notify Java observers. |
| 427 JNIEnv* env = AttachCurrentThread(); | 427 JNIEnv* env = AttachCurrentThread(); |
| 428 Java_OAuth2TokenService_notifyRefreshTokensLoaded( | 428 Java_OAuth2TokenService_notifyRefreshTokensLoaded( |
| 429 env, java_ref_.obj()); | 429 env, java_ref_.obj()); |
| 430 } | 430 } |
| 431 | 431 |
| 432 void AndroidProfileOAuth2TokenService::RevokeAllCredentials() { | 432 void AndroidProfileOAuth2TokenService::RevokeAllCredentials() { |
| 433 VLOG(1) << "AndroidProfileOAuth2TokenService::RevokeAllCredentials"; | 433 VLOG(1) << "AndroidProfileOAuth2TokenService::RevokeAllCredentials"; |
| 434 ScopedBacthChange batch(this); | 434 ScopedBatchChange batch(this); |
| 435 std::vector<std::string> accounts = GetAccounts(); | 435 std::vector<std::string> accounts = GetAccounts(); |
| 436 for (std::vector<std::string>::iterator it = accounts.begin(); | 436 for (std::vector<std::string>::iterator it = accounts.begin(); |
| 437 it != accounts.end(); it++) { | 437 it != accounts.end(); it++) { |
| 438 FireRefreshTokenRevoked(*it); | 438 FireRefreshTokenRevoked(*it); |
| 439 } | 439 } |
| 440 | 440 |
| 441 // Clear everything on the Java side as well. | 441 // Clear everything on the Java side as well. |
| 442 std::vector<std::string> empty; | 442 std::vector<std::string> empty; |
| 443 JNIEnv* env = AttachCurrentThread(); | 443 JNIEnv* env = AttachCurrentThread(); |
| 444 ScopedJavaLocalRef<jobjectArray> java_accounts( | 444 ScopedJavaLocalRef<jobjectArray> java_accounts( |
| (...skipping 18 matching lines...) Expand all Loading... |
| 463 GoogleServiceAuthError err(result ? | 463 GoogleServiceAuthError err(result ? |
| 464 GoogleServiceAuthError::NONE : | 464 GoogleServiceAuthError::NONE : |
| 465 GoogleServiceAuthError::CONNECTION_FAILED); | 465 GoogleServiceAuthError::CONNECTION_FAILED); |
| 466 heap_callback->Run(err, token, base::Time()); | 466 heap_callback->Run(err, token, base::Time()); |
| 467 } | 467 } |
| 468 | 468 |
| 469 // static | 469 // static |
| 470 bool AndroidProfileOAuth2TokenService::Register(JNIEnv* env) { | 470 bool AndroidProfileOAuth2TokenService::Register(JNIEnv* env) { |
| 471 return RegisterNativesImpl(env); | 471 return RegisterNativesImpl(env); |
| 472 } | 472 } |
| OLD | NEW |