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

Unified Diff: chrome/browser/sync/profile_sync_service.cc

Issue 33173005: Correctly deal with tokens for supervised users in ProfileOAuth2TokenService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 7 years, 1 month 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/sync/profile_sync_service.cc
diff --git a/chrome/browser/sync/profile_sync_service.cc b/chrome/browser/sync/profile_sync_service.cc
index ead0cf5aed34d91b3096d36b6c71d9d71e23f849..8c1f748ac3172b8ae2f8a02c73ce5b006bacfc1e 100644
--- a/chrome/browser/sync/profile_sync_service.cc
+++ b/chrome/browser/sync/profile_sync_service.cc
@@ -78,7 +78,7 @@
#include "ui/base/l10n/time_format.h"
#if defined(ENABLE_MANAGED_USERS)
-#include "chrome/browser/managed_mode/managed_user_service.h"
+#include "chrome/browser/managed_mode/managed_user_constants.h"
#endif
#if defined(OS_ANDROID)
@@ -209,8 +209,8 @@ bool ProfileSyncService::IsSyncEnabledAndLoggedIn() {
bool ProfileSyncService::IsOAuthRefreshTokenAvailable() {
if (!oauth2_token_service_)
return false;
- return oauth2_token_service_->RefreshTokenIsAvailable(
- oauth2_token_service_->GetPrimaryAccountId());
+
+ return oauth2_token_service_->RefreshTokenIsAvailable(GetAccountIdToUse());
}
void ProfileSyncService::Initialize() {
@@ -698,7 +698,7 @@ void ProfileSyncService::OnGetTokenFailure(
void ProfileSyncService::OnRefreshTokenAvailable(
const std::string& account_id) {
- if (oauth2_token_service_->GetPrimaryAccountId() == account_id)
+ if (account_id == GetAccountIdToUse())
OnRefreshTokensLoaded();
}
@@ -1887,7 +1887,7 @@ void ProfileSyncService::RequestAccessToken() {
// Invalidate previous token, otherwise token service will return the same
// token again.
- const std::string& account_id = oauth2_token_service_->GetPrimaryAccountId();
+ const std::string& account_id = GetAccountIdToUse();
if (!access_token_.empty()) {
oauth2_token_service_->InvalidateToken(
account_id, oauth2_scopes, access_token_);
@@ -2129,12 +2129,25 @@ std::string ProfileSyncService::GetEffectiveUsername() {
if (profile_->IsManaged()) {
#if defined(ENABLE_MANAGED_USERS)
DCHECK_EQ(std::string(), signin_->GetAuthenticatedUsername());
- return ManagedUserService::GetManagedUserPseudoEmail();
+ return managed_users::kManagedUserPseudoEmail;
+#else
+ NOTREACHED();
+#endif
+ }
+
+ return signin_->GetAuthenticatedUsername();
+}
+
+std::string ProfileSyncService::GetAccountIdToUse() {
+ if (profile_->IsManaged()) {
+#if defined(ENABLE_MANAGED_USERS)
+ return managed_users::kManagedUserPseudoEmail;
#else
NOTREACHED();
#endif
}
+ // TODO(fgorski): Use GetPrimaryAccountId() when it's available.
return signin_->GetAuthenticatedUsername();
}

Powered by Google App Engine
This is Rietveld 408576698