| Index: trunk/src/chrome/browser/sync/profile_sync_service.cc
|
| ===================================================================
|
| --- trunk/src/chrome/browser/sync/profile_sync_service.cc (revision 251113)
|
| +++ trunk/src/chrome/browser/sync/profile_sync_service.cc (working copy)
|
| @@ -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 @@
|
| 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 @@
|
| 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 @@
|
| 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 @@
|
|
|
| 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 @@
|
|
|
| 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::OnRefreshTokenAvailable(
|
| const std::string& account_id) {
|
| - if (account_id == GetAccountIdToUse())
|
| + if (account_id == signin_->GetAccountIdToUse())
|
| OnRefreshTokensLoaded();
|
| }
|
|
|
| @@ -1973,7 +1975,7 @@
|
|
|
| // 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_);
|
| @@ -2159,13 +2161,19 @@
|
| 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();
|
| }
|
| @@ -2215,32 +2223,6 @@
|
| 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());
|
| }
|
|
|