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

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

Issue 137753012: [sync]: add ManagedUserSigninManagerWrapper and pass to ProfileSyncService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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
« no previous file with comments | « chrome/browser/sync/profile_sync_service.h ('k') | chrome/browser/sync/profile_sync_service_factory.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 03a996aceedff9c24264a8a15c3624196b6ccb36..1b1ab3865773fbd8ce943c1745315548adca5b30 100644
--- a/chrome/browser/sync/profile_sync_service.cc
+++ b/chrome/browser/sync/profile_sync_service.cc
@@ -25,6 +25,7 @@
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/defaults.h"
+#include "chrome/browser/managed_mode/managed_user_signin_manager_wrapper.h"
#include "chrome/browser/net/chrome_cookie_notification_details.h"
#include "chrome/browser/prefs/pref_service_syncable.h"
#include "chrome/browser/profiles/profile.h"
@@ -158,7 +159,7 @@ bool ShouldShowActionOnUI(
ProfileSyncService::ProfileSyncService(
ProfileSyncComponentsFactory* factory,
Profile* profile,
- SigninManagerBase* signin_manager,
+ ManagedUserSigninManagerWrapper* signin_wrapper,
ProfileOAuth2TokenService* oauth2_token_service,
StartBehavior start_behavior)
: OAuth2TokenService::Consumer("sync"),
@@ -173,7 +174,7 @@ ProfileSyncService::ProfileSyncService(
backend_initialized_(false),
sync_disabled_by_admin_(false),
is_auth_in_progress_(false),
- signin_(signin_manager),
+ signin_(signin_wrapper),
unrecoverable_error_reason_(ERROR_REASON_UNSET),
expect_sync_configuration_aborted_(false),
encrypted_types_(syncer::SyncEncryptionHandler::SensitiveTypes()),
@@ -225,14 +226,15 @@ bool ProfileSyncService::IsSyncEnabledAndLoggedIn() {
return false;
// Sync is logged in if there is a non-empty effective username.
- return !GetEffectiveUsername().empty();
+ return !signin_->GetEffectiveUsername().empty();
}
bool ProfileSyncService::IsOAuthRefreshTokenAvailable() {
if (!oauth2_token_service_)
return false;
- return oauth2_token_service_->RefreshTokenIsAvailable(GetAccountIdToUse());
+ return oauth2_token_service_->RefreshTokenIsAvailable(
+ signin_->GetAccountIdToUse());
}
void ProfileSyncService::Initialize() {
@@ -253,7 +255,7 @@ void ProfileSyncService::Initialize() {
RegisterAuthNotifications();
- if (!HasSyncSetupCompleted() || GetEffectiveUsername().empty()) {
+ if (!HasSyncSetupCompleted() || signin_->GetEffectiveUsername().empty()) {
// Clean up in case of previous crash / setup abort / signout.
DisableForUser();
}
@@ -534,7 +536,7 @@ void ProfileSyncService::InitSettings() {
SyncCredentials ProfileSyncService::GetCredentials() {
SyncCredentials credentials;
- credentials.email = GetEffectiveUsername();
+ credentials.email = signin_->GetEffectiveUsername();
DCHECK(!credentials.email.empty());
credentials.sync_token = access_token_;
@@ -746,7 +748,7 @@ void ProfileSyncService::OnGetTokenFailure(
void ProfileSyncService::OnRefreshTokenAvailable(
const std::string& account_id) {
- if (account_id == GetAccountIdToUse())
+ if (account_id == signin_->GetAccountIdToUse())
OnRefreshTokensLoaded();
}
@@ -1966,7 +1968,7 @@ void ProfileSyncService::RequestAccessToken() {
// Invalidate previous token, otherwise token service will return the same
// token again.
- const std::string& account_id = GetAccountIdToUse();
+ const std::string& account_id = signin_->GetAccountIdToUse();
if (!access_token_.empty()) {
oauth2_token_service_->InvalidateToken(
account_id, oauth2_scopes, access_token_);
@@ -2152,13 +2154,19 @@ bool ProfileSyncService::IsStartSuppressed() const {
return sync_prefs_.IsStartSuppressed();
}
+SigninManagerBase* ProfileSyncService::signin() const {
+ return signin_->GetOriginal();
+}
+
void ProfileSyncService::UnsuppressAndStart() {
DCHECK(profile_);
sync_prefs_.SetStartSuppressed(false);
// Set username in SigninManager, as SigninManager::OnGetUserInfoSuccess
// is never called for some clients.
- if (signin_ && signin_->GetAuthenticatedUsername().empty()) {
- signin_->SetAuthenticatedUsername(sync_prefs_.GetGoogleServicesUsername());
+ if (signin_.get() &&
+ signin_->GetOriginal()->GetAuthenticatedUsername().empty()) {
+ signin_->GetOriginal()->SetAuthenticatedUsername(
+ sync_prefs_.GetGoogleServicesUsername());
}
TryStart();
}
@@ -2208,32 +2216,6 @@ std::string ProfileSyncService::GetAccessTokenForTest() const {
return access_token_;
}
-std::string ProfileSyncService::GetEffectiveUsername() {
- if (profile_->IsManaged()) {
-#if defined(ENABLE_MANAGED_USERS)
- DCHECK_EQ(std::string(), signin_->GetAuthenticatedUsername());
- 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();
-}
-
WeakHandle<syncer::JsEventHandler> ProfileSyncService::GetJsEventHandler() {
return MakeWeakHandle(sync_js_controller_.AsWeakPtr());
}
« no previous file with comments | « chrome/browser/sync/profile_sync_service.h ('k') | chrome/browser/sync/profile_sync_service_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698