summaryrefslogtreecommitdiffstats
path: root/google_apis
diff options
context:
space:
mode:
authorgogerald <gogerald@chromium.org>2015-09-23 19:52:59 -0700
committerCommit bot <commit-bot@chromium.org>2015-09-24 02:54:12 +0000
commitf3bccd6b7d15f3585bdfe924a6d3b33bcf90ea26 (patch)
tree6b79c312eefdb7ebcb97e565afbf621ae8760e4d /google_apis
parentcb19f775e847043bdc6b9ed2159feb6cc792e0e2 (diff)
downloadchromium_src-f3bccd6b7d15f3585bdfe924a6d3b33bcf90ea26.zip
chromium_src-f3bccd6b7d15f3585bdfe924a6d3b33bcf90ea26.tar.gz
chromium_src-f3bccd6b7d15f3585bdfe924a6d3b33bcf90ea26.tar.bz2
Do not crash in case of messed or missed information.
This is a first step fix of below bug. It filters out invalid persistent accounts in OAuth2TokenService and avoids sending out refresh token revoked notification if its information in ATS is missing for some reason. Next step, we should understand how the user data been corrupted. BUG=535211 Review URL: https://codereview.chromium.org/1362043007 Cr-Commit-Position: refs/heads/master@{#350451}
Diffstat (limited to 'google_apis')
-rw-r--r--google_apis/gaia/oauth2_token_service_delegate.cc13
-rw-r--r--google_apis/gaia/oauth2_token_service_delegate.h2
2 files changed, 10 insertions, 5 deletions
diff --git a/google_apis/gaia/oauth2_token_service_delegate.cc b/google_apis/gaia/oauth2_token_service_delegate.cc
index aed5db8..3c5f75b 100644
--- a/google_apis/gaia/oauth2_token_service_delegate.cc
+++ b/google_apis/gaia/oauth2_token_service_delegate.cc
@@ -24,16 +24,21 @@ OAuth2TokenServiceDelegate::OAuth2TokenServiceDelegate()
OAuth2TokenServiceDelegate::~OAuth2TokenServiceDelegate() {
}
-void OAuth2TokenServiceDelegate::ValidateAccountId(
+bool OAuth2TokenServiceDelegate::ValidateAccountId(
const std::string& account_id) const {
- DCHECK(!account_id.empty());
+ bool valid = !account_id.empty();
// If the account is given as an email, make sure its a canonical email.
// Note that some tests don't use email strings as account id, and after
// the gaia id migration it won't be an email. So only check for
// canonicalization if the account_id is suspected to be an email.
- if (account_id.find('@') != std::string::npos)
- DCHECK_EQ(gaia::CanonicalizeEmail(account_id), account_id);
+ if (account_id.find('@') != std::string::npos &&
+ gaia::CanonicalizeEmail(account_id) != account_id) {
+ valid = false;
+ }
+
+ DCHECK(valid);
+ return valid;
}
void OAuth2TokenServiceDelegate::AddObserver(
diff --git a/google_apis/gaia/oauth2_token_service_delegate.h b/google_apis/gaia/oauth2_token_service_delegate.h
index 3a2d39f..24bf063 100644
--- a/google_apis/gaia/oauth2_token_service_delegate.h
+++ b/google_apis/gaia/oauth2_token_service_delegate.h
@@ -48,7 +48,7 @@ class OAuth2TokenServiceDelegate {
virtual void RevokeCredentials(const std::string& account_id) {}
virtual net::URLRequestContextGetter* GetRequestContext() const;
- void ValidateAccountId(const std::string& account_id) const;
+ bool ValidateAccountId(const std::string& account_id) const;
// Add or remove observers of this token service.
void AddObserver(OAuth2TokenService::Observer* observer);