diff options
author | rogerta@chromium.org <rogerta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-14 15:57:24 +0000 |
---|---|---|
committer | rogerta@chromium.org <rogerta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-14 15:57:24 +0000 |
commit | 3caf404d2477de520e5bbd61cab9991c0893e280 (patch) | |
tree | 7b46470523091fdbdc926b2376ba44aa5ee892c1 /chrome/browser | |
parent | 709deb2529e5be833889467efb2cc94ed5f85c1b (diff) | |
download | chromium_src-3caf404d2477de520e5bbd61cab9991c0893e280.zip chromium_src-3caf404d2477de520e5bbd61cab9991c0893e280.tar.gz chromium_src-3caf404d2477de520e5bbd61cab9991c0893e280.tar.bz2 |
Replace PO2TS::GetPrimaryAccountId() with SMB::GetAuthenticatedAccountId.
The functionality is the same, just moving the code to a new place.
NOTRY=True
BUG=333995
R=bauerb@chromium.org, brettw@chromium.org, joaodasilva@chromium.org, nhiroki@chromium.org, noms@chromium.org, rlarocque@chromium.org
Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=251221
Review URL: https://codereview.chromium.org/150003004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@251339 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
10 files changed, 51 insertions, 21 deletions
diff --git a/chrome/browser/history/DEPS b/chrome/browser/history/DEPS index ede6270..6585583 100644 --- a/chrome/browser/history/DEPS +++ b/chrome/browser/history/DEPS @@ -40,6 +40,8 @@ include_rules = [ "!chrome/browser/signin/oauth2_token_service.h", "!chrome/browser/signin/profile_oauth2_token_service.h", "!chrome/browser/signin/profile_oauth2_token_service_factory.h", + "!chrome/browser/signin/signin_manager.h", + "!chrome/browser/signin/signin_manager_factory.h", "!chrome/browser/signin/token_service_factory.h", "!chrome/browser/sync/profile_sync_service.h", "!chrome/browser/sync/profile_sync_service_factory.h", diff --git a/chrome/browser/history/web_history_service.cc b/chrome/browser/history/web_history_service.cc index 8dfe959..12d13e1 100644 --- a/chrome/browser/history/web_history_service.cc +++ b/chrome/browser/history/web_history_service.cc @@ -13,6 +13,8 @@ #include "base/values.h" #include "chrome/browser/signin/profile_oauth2_token_service.h" #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" +#include "chrome/browser/signin/signin_manager.h" +#include "chrome/browser/signin/signin_manager_factory.h" #include "google_apis/gaia/gaia_urls.h" #include "google_apis/gaia/google_service_auth_error.h" #include "google_apis/gaia/oauth2_token_service.h" @@ -82,8 +84,10 @@ class RequestImpl : public WebHistoryService::Request, ProfileOAuth2TokenService* token_service = ProfileOAuth2TokenServiceFactory::GetForProfile(profile_); + SigninManagerBase* signin_manager = + SigninManagerFactory::GetForProfile(profile_); token_request_ = token_service->StartRequest( - token_service->GetPrimaryAccountId(), oauth_scopes, this); + signin_manager->GetAuthenticatedAccountId(), oauth_scopes, this); is_pending_ = true; } @@ -103,9 +107,12 @@ class RequestImpl : public WebHistoryService::Request, oauth_scopes.insert(kHistoryOAuthScope); ProfileOAuth2TokenService* token_service = ProfileOAuth2TokenServiceFactory::GetForProfile(profile_); - token_service->InvalidateToken(token_service->GetPrimaryAccountId(), - oauth_scopes, - access_token_); + SigninManagerBase* signin_manager = + SigninManagerFactory::GetForProfile(profile_); + token_service->InvalidateToken( + signin_manager->GetAuthenticatedAccountId(), + oauth_scopes, + access_token_); access_token_.clear(); Start(); diff --git a/chrome/browser/invalidation/ticl_invalidation_service.cc b/chrome/browser/invalidation/ticl_invalidation_service.cc index c30e689..e83c843 100644 --- a/chrome/browser/invalidation/ticl_invalidation_service.cc +++ b/chrome/browser/invalidation/ticl_invalidation_service.cc @@ -179,7 +179,7 @@ void TiclInvalidationService::RequestAccessToken() { oauth2_scopes.insert(kOAuth2Scopes[i]); // 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 = signin_manager_->GetAuthenticatedAccountId(); oauth2_token_service_->InvalidateToken(account_id, oauth2_scopes, access_token_); @@ -237,7 +237,7 @@ void TiclInvalidationService::OnGetTokenFailure( void TiclInvalidationService::OnRefreshTokenAvailable( const std::string& account_id) { - if (oauth2_token_service_->GetPrimaryAccountId() == account_id) { + if (signin_manager_->GetAuthenticatedAccountId() == account_id) { if (!IsStarted() && IsReadyToStart()) { StartInvalidator(PUSH_CLIENT_CHANNEL); } @@ -246,7 +246,7 @@ void TiclInvalidationService::OnRefreshTokenAvailable( void TiclInvalidationService::OnRefreshTokenRevoked( const std::string& account_id) { - if (oauth2_token_service_->GetPrimaryAccountId() == account_id) { + if (signin_manager_->GetAuthenticatedAccountId() == account_id) { access_token_.clear(); if (IsStarted()) { UpdateInvalidatorCredentials(); @@ -312,7 +312,7 @@ bool TiclInvalidationService::IsReadyToStart() { } if (!oauth2_token_service_->RefreshTokenIsAvailable( - oauth2_token_service_->GetPrimaryAccountId())) { + signin_manager_->GetAuthenticatedAccountId())) { DVLOG(2) << "Not starting TiclInvalidationServce: Waiting for refresh token."; return false; diff --git a/chrome/browser/managed_mode/managed_user_registration_utility.cc b/chrome/browser/managed_mode/managed_user_registration_utility.cc index cf26a62..34b02f8 100644 --- a/chrome/browser/managed_mode/managed_user_registration_utility.cc +++ b/chrome/browser/managed_mode/managed_user_registration_utility.cc @@ -20,6 +20,8 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/browser/signin/profile_oauth2_token_service.h" #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" +#include "chrome/browser/signin/signin_manager.h" +#include "chrome/browser/signin/signin_manager_factory.h" #include "chrome/browser/sync/glue/device_info.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/pref_names.h" @@ -141,10 +143,12 @@ ManagedUserRegistrationUtility::Create(Profile* profile) { ProfileOAuth2TokenService* token_service = ProfileOAuth2TokenServiceFactory::GetForProfile(profile); + SigninManagerBase* signin_manager = + SigninManagerFactory::GetForProfile(profile); scoped_ptr<ManagedUserRefreshTokenFetcher> token_fetcher = ManagedUserRefreshTokenFetcher::Create( token_service, - token_service->GetPrimaryAccountId(), + signin_manager->GetAuthenticatedAccountId(), profile->GetRequestContext()); ManagedUserSyncService* managed_user_sync_service = ManagedUserSyncServiceFactory::GetForProfile(profile); diff --git a/chrome/browser/policy/cloud/user_policy_signin_service.cc b/chrome/browser/policy/cloud/user_policy_signin_service.cc index 4e36757..4277f45 100644 --- a/chrome/browser/policy/cloud/user_policy_signin_service.cc +++ b/chrome/browser/policy/cloud/user_policy_signin_service.cc @@ -43,7 +43,7 @@ UserPolicySigninService::UserPolicySigninService( // happens in the background after PKS initialization - so this service // should always be created before the oauth token is available. DCHECK(!oauth2_token_service_->RefreshTokenIsAvailable( - oauth2_token_service_->GetPrimaryAccountId())); + signin_manager->GetAuthenticatedAccountId())); // Listen for an OAuth token to become available so we can register a client // if for some reason the client is not already registered (for example, if @@ -116,7 +116,7 @@ void UserPolicySigninService::OnRefreshTokenAvailable( } // Ignore OAuth tokens for any account but the primary one. - if (account_id != oauth2_token_service_->GetPrimaryAccountId()) + if (account_id != signin_manager()->GetAuthenticatedAccountId()) return; // ProfileOAuth2TokenService now has a refresh token so initialize the @@ -153,7 +153,7 @@ void UserPolicySigninService::OnInitializationCompleted( << "Client already registered - not fetching DMToken"; if (!manager->IsClientRegistered()) { if (!oauth2_token_service_->RefreshTokenIsAvailable( - oauth2_token_service_->GetPrimaryAccountId())) { + signin_manager()->GetAuthenticatedAccountId())) { // No token yet - this class listens for OnRefreshTokenAvailable() // and will re-attempt registration once the token is available. DLOG(WARNING) << "No OAuth Refresh Token - delaying policy download"; @@ -180,7 +180,7 @@ void UserPolicySigninService::RegisterCloudPolicyService() { enterprise_management::DeviceRegisterRequest::BROWSER)); registration_helper_->StartRegistration( oauth2_token_service_, - oauth2_token_service_->GetPrimaryAccountId(), + signin_manager()->GetAuthenticatedAccountId(), base::Bind(&UserPolicySigninService::OnRegistrationComplete, base::Unretained(this))); } diff --git a/chrome/browser/policy/cloud/user_policy_signin_service.h b/chrome/browser/policy/cloud/user_policy_signin_service.h index 305b284..5e8865f 100644 --- a/chrome/browser/policy/cloud/user_policy_signin_service.h +++ b/chrome/browser/policy/cloud/user_policy_signin_service.h @@ -12,9 +12,10 @@ #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" #include "chrome/browser/policy/cloud/user_policy_signin_service_base.h" -#include "chrome/browser/signin/profile_oauth2_token_service.h" +#include "google_apis/gaia/oauth2_token_service.h" class Profile; +class ProfileOAuth2TokenService; namespace net { class URLRequestContextGetter; diff --git a/chrome/browser/profiles/profile_downloader.cc b/chrome/browser/profiles/profile_downloader.cc index 9a7a715..7248e53 100644 --- a/chrome/browser/profiles/profile_downloader.cc +++ b/chrome/browser/profiles/profile_downloader.cc @@ -19,6 +19,8 @@ #include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/signin/profile_oauth2_token_service.h" #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" +#include "chrome/browser/signin/signin_manager.h" +#include "chrome/browser/signin/signin_manager_factory.h" #include "content/public/browser/browser_thread.h" #include "google_apis/gaia/gaia_constants.h" #include "google_apis/gaia/gaia_urls.h" @@ -233,8 +235,11 @@ void ProfileDownloader::StartForAccount(const std::string& account_id) { return; } + SigninManagerBase* signin_manager = + SigninManagerFactory::GetForProfile(delegate_->GetBrowserProfile()); account_id_ = - account_id.empty() ? service->GetPrimaryAccountId() : account_id; + account_id.empty() ? + signin_manager->GetAuthenticatedAccountId() : account_id; if (service->RefreshTokenIsAvailable(account_id_)) { StartFetchingOAuth2AccessToken(); } else { diff --git a/chrome/browser/sync_file_system/drive_backend/sync_engine.cc b/chrome/browser/sync_file_system/drive_backend/sync_engine.cc index 0dccd59..7904692 100644 --- a/chrome/browser/sync_file_system/drive_backend/sync_engine.cc +++ b/chrome/browser/sync_file_system/drive_backend/sync_engine.cc @@ -17,6 +17,8 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/browser/signin/profile_oauth2_token_service.h" #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" +#include "chrome/browser/signin/signin_manager.h" +#include "chrome/browser/signin/signin_manager_factory.h" #include "chrome/browser/sync_file_system/drive_backend/conflict_resolver.h" #include "chrome/browser/sync_file_system/drive_backend/drive_backend_constants.h" #include "chrome/browser/sync_file_system/drive_backend/list_changes_task.h" @@ -65,9 +67,11 @@ scoped_ptr<SyncEngine> SyncEngine::CreateForBrowserContext( worker_pool->GetSequenceToken(), base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)); + Profile* profile = Profile::FromBrowserContext(context); ProfileOAuth2TokenService* token_service = - ProfileOAuth2TokenServiceFactory::GetForProfile( - Profile::FromBrowserContext(context)); + ProfileOAuth2TokenServiceFactory::GetForProfile(profile); + SigninManagerBase* signin_manager = + SigninManagerFactory::GetForProfile(profile); scoped_ptr<drive::DriveServiceInterface> drive_service( new drive::DriveAPIService( token_service, @@ -75,7 +79,7 @@ scoped_ptr<SyncEngine> SyncEngine::CreateForBrowserContext( drive_task_runner.get(), base_drive_url, base_download_url, wapi_base_url, std::string() /* custom_user_agent */)); - drive_service->Initialize(token_service->GetPrimaryAccountId()); + drive_service->Initialize(signin_manager->GetAuthenticatedAccountId()); scoped_ptr<drive::DriveUploaderInterface> drive_uploader( new drive::DriveUploader(drive_service.get(), drive_task_runner.get())); @@ -351,7 +355,9 @@ void SyncEngine::OnReadyToSendRequests() { UpdateServiceState(REMOTE_SERVICE_OK, "Authenticated"); if (!metadata_database_ && auth_token_service_) { - drive_service_->Initialize(auth_token_service_->GetPrimaryAccountId()); + SigninManagerBase* signin_manager = + SigninManagerFactory::GetForProfile(auth_token_service_->profile()); + drive_service_->Initialize(signin_manager->GetAuthenticatedAccountId()); PostInitializeTask(); return; } diff --git a/chrome/browser/sync_file_system/drive_backend_v1/api_util.cc b/chrome/browser/sync_file_system/drive_backend_v1/api_util.cc index ef2580b..6491146 100644 --- a/chrome/browser/sync_file_system/drive_backend_v1/api_util.cc +++ b/chrome/browser/sync_file_system/drive_backend_v1/api_util.cc @@ -22,6 +22,8 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/browser/signin/profile_oauth2_token_service.h" #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" +#include "chrome/browser/signin/signin_manager.h" +#include "chrome/browser/signin/signin_manager_factory.h" #include "chrome/browser/sync_file_system/drive_backend/drive_backend_constants.h" #include "chrome/browser/sync_file_system/drive_backend_v1/drive_file_sync_util.h" #include "chrome/browser/sync_file_system/logger.h" @@ -157,6 +159,7 @@ bool CreateTemporaryFile(const base::FilePath& dir_path, APIUtil::APIUtil(Profile* profile, const base::FilePath& temp_dir_path) : oauth_service_(ProfileOAuth2TokenServiceFactory::GetForProfile(profile)), + signin_manager_(SigninManagerFactory::GetForProfile(profile)), upload_next_key_(0), temp_dir_path_(temp_dir_path), has_initialized_token_(false) { @@ -183,7 +186,7 @@ APIUtil::APIUtil(Profile* profile, std::string() /* custom_user_agent */)); } - drive_service_->Initialize(oauth_service_->GetPrimaryAccountId()); + drive_service_->Initialize(signin_manager_->GetAuthenticatedAccountId()); drive_service_->AddObserver(this); has_initialized_token_ = drive_service_->HasRefreshToken(); @@ -663,7 +666,7 @@ GURL APIUtil::DirectoryTitleToOrigin(const std::string& title) { void APIUtil::OnReadyToSendRequests() { DCHECK(CalledOnValidThread()); if (!has_initialized_token_) { - drive_service_->Initialize(oauth_service_->GetPrimaryAccountId()); + drive_service_->Initialize(signin_manager_->GetAuthenticatedAccountId()); has_initialized_token_ = true; } FOR_EACH_OBSERVER(APIUtilObserver, observers_, OnAuthenticated()); diff --git a/chrome/browser/sync_file_system/drive_backend_v1/api_util.h b/chrome/browser/sync_file_system/drive_backend_v1/api_util.h index 474b4ea..42180ed 100644 --- a/chrome/browser/sync_file_system/drive_backend_v1/api_util.h +++ b/chrome/browser/sync_file_system/drive_backend_v1/api_util.h @@ -18,6 +18,7 @@ class GURL; class Profile; class ProfileOAuth2TokenService; +class SigninManagerBase; namespace drive { class DriveUploaderInterface; } @@ -242,6 +243,7 @@ class APIUtil : public APIUtilInterface, scoped_ptr<drive::DriveUploaderInterface> drive_uploader_; ProfileOAuth2TokenService* oauth_service_; + SigninManagerBase* signin_manager_; UploadCallbackMap upload_callback_map_; UploadKey upload_next_key_; |