Commit e1b56df2 authored by Pâris MEULEMAN's avatar Pâris MEULEMAN Committed by Commit Bot

Do not FireRefreshTokenAvailable on empty robot account

This CL enforces the constraint that the account_id is not empty in
OAuth2TokenServiceDelegate FireRefreshTokenAvailable,
FireRefreshTokenRevoked and FireAuthErrorChanged. This is in the
interest of adding this semantic constraint to the oauth2_token_service
APIs which is already respected by most callsites.

There is one case that failed on ChromeOS tests (impacting multiple
tests, see first patchset here), in
DeviceOAuth2TokenServiceDelegate::DidGetSystemSalt, where the Robot
account Id might be empty. This is changed to call
FireRefreshTokenAvailable only if the robot account is set.


Bug: 960281
Change-Id: I8cc55cdc0f4c9c15c004c7fb20ed9e221ca1030b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1619811Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Reviewed-by: default avatarBoris Sazonov <bsazonov@chromium.org>
Commit-Queue: Xiyuan Xia <xiyuan@chromium.org>
Auto-Submit: Pâris Meuleman <pmeuleman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#664989}
parent 430e21fb
......@@ -214,7 +214,9 @@ void DeviceOAuth2TokenServiceDelegate::DidGetSystemSalt(
StartValidation();
// Announce the token.
FireRefreshTokenAvailable(GetRobotAccountId());
if (!GetRobotAccountId().empty()) {
FireRefreshTokenAvailable(GetRobotAccountId());
}
FireRefreshTokensLoaded();
}
......
......@@ -71,12 +71,14 @@ void OAuth2TokenServiceDelegate::EndBatchChanges() {
void OAuth2TokenServiceDelegate::FireRefreshTokenAvailable(
const std::string& account_id) {
DCHECK(!account_id.empty());
for (auto& observer : observer_list_)
observer.OnRefreshTokenAvailable(account_id);
}
void OAuth2TokenServiceDelegate::FireRefreshTokenRevoked(
const std::string& account_id) {
DCHECK(!account_id.empty());
for (auto& observer : observer_list_)
observer.OnRefreshTokenRevoked(account_id);
}
......@@ -89,6 +91,7 @@ void OAuth2TokenServiceDelegate::FireRefreshTokensLoaded() {
void OAuth2TokenServiceDelegate::FireAuthErrorChanged(
const std::string& account_id,
const GoogleServiceAuthError& error) {
DCHECK(!account_id.empty());
for (auto& observer : observer_list_)
observer.OnAuthErrorChanged(account_id, error);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment