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

Unified Diff: chrome/browser/signin/android_profile_oauth2_token_service.cc

Issue 617183003: Make sure GetAuthenticatedAccountId() returns a canonicalized id. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address review comments Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/signin/android_profile_oauth2_token_service.cc
diff --git a/chrome/browser/signin/android_profile_oauth2_token_service.cc b/chrome/browser/signin/android_profile_oauth2_token_service.cc
index 722d5d7e7c253f4e159b05883c54e3a1ec86eadd..39bbb9f4a88e56dc2c81c1a537070087938cc3c0 100644
--- a/chrome/browser/signin/android_profile_oauth2_token_service.cc
+++ b/chrome/browser/signin/android_profile_oauth2_token_service.cc
@@ -13,6 +13,7 @@
#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
#include "chrome/browser/sync/profile_sync_service_android.h"
#include "content/public/browser/browser_thread.h"
+#include "google_apis/gaia/gaia_auth_util.h"
#include "google_apis/gaia/oauth2_access_token_fetcher.h"
#include "jni/OAuth2TokenService_jni.h"
@@ -171,6 +172,7 @@ void AndroidProfileOAuth2TokenService::Initialize(SigninClient* client) {
bool AndroidProfileOAuth2TokenService::RefreshTokenIsAvailable(
const std::string& account_id) const {
+ ValidateAccountId(account_id);
JNIEnv* env = AttachCurrentThread();
ScopedJavaLocalRef<jstring> j_account_id =
ConvertUTF8ToJavaString(env, account_id);
@@ -217,7 +219,7 @@ AndroidProfileOAuth2TokenService::CreateAccessTokenFetcher(
const std::string& account_id,
net::URLRequestContextGetter* getter,
OAuth2AccessTokenConsumer* consumer) {
- DCHECK(!account_id.empty());
+ ValidateAccountId(account_id);
return new AndroidAccessTokenFetcher(consumer, account_id);
}
@@ -226,6 +228,7 @@ void AndroidProfileOAuth2TokenService::InvalidateOAuth2Token(
const std::string& client_id,
const ScopeSet& scopes,
const std::string& access_token) {
+ ValidateAccountId(account_id);
OAuth2TokenService::InvalidateOAuth2Token(account_id,
client_id,
scopes,
@@ -246,6 +249,8 @@ void AndroidProfileOAuth2TokenService::ValidateAccounts(
jboolean j_force_notifications) {
VLOG(1) << "AndroidProfileOAuth2TokenService::ValidateAccounts from java";
std::string signed_in_account = ConvertJavaStringToUTF8(env, j_current_acc);
+ if (!signed_in_account.empty())
+ signed_in_account = gaia::CanonicalizeEmail(signed_in_account);
ValidateAccounts(signed_in_account, j_force_notifications != JNI_FALSE);
}
@@ -257,6 +262,12 @@ void AndroidProfileOAuth2TokenService::ValidateAccounts(
std::vector<std::string> refreshed_ids;
std::vector<std::string> revoked_ids;
+ // Canonicalize system accounts. |prev_ids| is already done.
+ for (size_t i = 0; i < curr_ids.size(); ++i)
+ curr_ids[i] = gaia::CanonicalizeEmail(curr_ids[i]);
+ for (size_t i = 0; i < prev_ids.size(); ++i)
+ ValidateAccountId(prev_ids[i]);
+
VLOG(1) << "AndroidProfileOAuth2TokenService::ValidateAccounts:"
<< " sigined_in_account=" << signed_in_account
<< " prev_ids=" << prev_ids.size()

Powered by Google App Engine
This is Rietveld 408576698