Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(286)

Side by Side Diff: chrome/browser/signin/android_profile_oauth2_token_service.cc

Issue 401693003: Notify Java O2TS when revoking all tokens. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 } 364 }
365 365
366 void AndroidProfileOAuth2TokenService::RevokeAllCredentials() { 366 void AndroidProfileOAuth2TokenService::RevokeAllCredentials() {
367 VLOG(1) << "AndroidProfileOAuth2TokenService::RevokeAllCredentials"; 367 VLOG(1) << "AndroidProfileOAuth2TokenService::RevokeAllCredentials";
368 ScopedBacthChange batch(this); 368 ScopedBacthChange batch(this);
369 std::vector<std::string> accounts = GetAccounts(); 369 std::vector<std::string> accounts = GetAccounts();
370 for (std::vector<std::string>::iterator it = accounts.begin(); 370 for (std::vector<std::string>::iterator it = accounts.begin();
371 it != accounts.end(); it++) { 371 it != accounts.end(); it++) {
372 FireRefreshTokenRevoked(*it); 372 FireRefreshTokenRevoked(*it);
373 } 373 }
374
375 // Clear everything on the Java side as well.
376 std::vector<std::string> empty;
377 JNIEnv* env = AttachCurrentThread();
378 ScopedJavaLocalRef<jobjectArray> java_accounts(
379 base::android::ToJavaArrayOfStrings(env, empty));
380 Java_OAuth2TokenService_saveStoredAccounts(
381 env, base::android::GetApplicationContext(), java_accounts.obj());
374 } 382 }
375 383
376 // Called from Java when fetching of an OAuth2 token is finished. The 384 // Called from Java when fetching of an OAuth2 token is finished. The
377 // |authToken| param is only valid when |result| is true. 385 // |authToken| param is only valid when |result| is true.
378 void OAuth2TokenFetched(JNIEnv* env, jclass clazz, 386 void OAuth2TokenFetched(JNIEnv* env, jclass clazz,
379 jstring authToken, 387 jstring authToken,
380 jboolean result, 388 jboolean result,
381 jlong nativeCallback) { 389 jlong nativeCallback) {
382 std::string token = ConvertJavaStringToUTF8(env, authToken); 390 std::string token = ConvertJavaStringToUTF8(env, authToken);
383 scoped_ptr<FetchOAuth2TokenCallback> heap_callback( 391 scoped_ptr<FetchOAuth2TokenCallback> heap_callback(
384 reinterpret_cast<FetchOAuth2TokenCallback*>(nativeCallback)); 392 reinterpret_cast<FetchOAuth2TokenCallback*>(nativeCallback));
385 // Android does not provide enough information to know if the credentials are 393 // Android does not provide enough information to know if the credentials are
386 // wrong, so assume any error is transient by using CONNECTION_FAILED. 394 // wrong, so assume any error is transient by using CONNECTION_FAILED.
387 GoogleServiceAuthError err(result ? 395 GoogleServiceAuthError err(result ?
388 GoogleServiceAuthError::NONE : 396 GoogleServiceAuthError::NONE :
389 GoogleServiceAuthError::CONNECTION_FAILED); 397 GoogleServiceAuthError::CONNECTION_FAILED);
390 heap_callback->Run(err, token, base::Time()); 398 heap_callback->Run(err, token, base::Time());
391 } 399 }
392 400
393 // static 401 // static
394 bool AndroidProfileOAuth2TokenService::Register(JNIEnv* env) { 402 bool AndroidProfileOAuth2TokenService::Register(JNIEnv* env) {
395 return RegisterNativesImpl(env); 403 return RegisterNativesImpl(env);
396 } 404 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698