From e733310db58160074f574c429d48f8308c0afe17 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Wed, 8 Mar 2017 10:28:10 +0100 Subject: BASELINE: Update Chromium to 56.0.2924.122 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I4e04de8f47e47e501c46ed934c76a431c6337ced Reviewed-by: Michael BrĂ¼ning --- .../signin/core/account_id/account_id.cc | 6 +-- .../components/signin/core/account_id/account_id.h | 8 ++- .../signin/core/browser/about_signin_internals.cc | 62 +++++++++------------- .../signin/core/browser/about_signin_internals.h | 13 ++--- .../signin/core/browser/account_fetcher_service.cc | 4 +- .../signin/core/browser/account_tracker_service.cc | 12 ++--- .../core/browser/child_account_info_fetcher.cc | 13 +++-- .../core/browser/child_account_info_fetcher.h | 6 +-- .../browser/child_account_info_fetcher_android.cc | 27 ++++++++-- .../browser/child_account_info_fetcher_android.h | 23 ++++++-- .../signin/core/browser/fake_signin_manager.cc | 15 +++--- .../core/browser/gaia_cookie_manager_service.cc | 28 ++++++---- .../core/browser/gaia_cookie_manager_service.h | 7 ++- .../signin/core/browser/signin_client.cc | 4 ++ .../components/signin/core/browser/signin_client.h | 9 +++- .../signin/core/browser/signin_error_controller.cc | 3 +- .../signin/core/browser/signin_manager.cc | 28 ++++++---- .../signin/core/browser/signin_manager.h | 4 ++ .../signin/core/browser/signin_manager_base.cc | 5 +- .../core/common/profile_management_switches.cc | 4 -- .../core/common/profile_management_switches.h | 3 -- .../signin/core/common/signin_switches.cc | 4 -- .../signin/core/common/signin_switches.h | 1 - 23 files changed, 166 insertions(+), 123 deletions(-) (limited to 'chromium/components/signin') diff --git a/chromium/components/signin/core/account_id/account_id.cc b/chromium/components/signin/core/account_id/account_id.cc index 17d0ffd70ec..00ceb2e2f52 100644 --- a/chromium/components/signin/core/account_id/account_id.cc +++ b/chromium/components/signin/core/account_id/account_id.cc @@ -23,7 +23,7 @@ const char kGoogle[] = "google"; const char kGaiaIdKey[] = "gaia_id"; const char kEmailKey[] = "email"; -// Prefix for GetGaiaIdKey(). +// Prefix for GetAccountIdKey(). const char kKeyGaiaIdPrefix[] = "g-"; struct GoogleStringSingleton { @@ -105,10 +105,10 @@ const std::string& AccountId::GetUserEmail() const { return user_email_; } -const std::string AccountId::GetGaiaIdKey() const { +const std::string AccountId::GetAccountIdKey() const { #ifdef NDEBUG if (gaia_id_.empty()) - LOG(FATAL) << "GetGaiaIdKey(): no gaia id for " << Serialize(); + LOG(FATAL) << "GetAccountIdKey(): no gaia id for " << Serialize(); #else CHECK(!gaia_id_.empty()); diff --git a/chromium/components/signin/core/account_id/account_id.h b/chromium/components/signin/core/account_id/account_id.h index fe567d4ff62..7cba697805d 100644 --- a/chromium/components/signin/core/account_id/account_id.h +++ b/chromium/components/signin/core/account_id/account_id.h @@ -33,10 +33,14 @@ class AccountId { const std::string& GetAccountType() const; const std::string& GetGaiaId() const; + // Users of AccountId should make no assumptions on the format of email. + // I.e. it cannot be used as account identifier, because it is (in general) + // non-comparable. const std::string& GetUserEmail() const; - // This returns prefixed GaiaId string to be used as a storage key. - const std::string GetGaiaIdKey() const; + // This returns prefixed some string that can be used as a storage key. + // You should make no assumptions on the format of this string. + const std::string GetAccountIdKey() const; void SetGaiaId(const std::string& gaia_id); void SetUserEmail(const std::string& email); diff --git a/chromium/components/signin/core/browser/about_signin_internals.cc b/chromium/components/signin/core/browser/about_signin_internals.cc index b6b897b6325..ec21740ccb8 100644 --- a/chromium/components/signin/core/browser/about_signin_internals.cc +++ b/chromium/components/signin/core/browser/about_signin_internals.cc @@ -6,12 +6,14 @@ #include +#include #include #include "base/command_line.h" #include "base/hash.h" #include "base/i18n/time_formatting.h" #include "base/logging.h" +#include "base/memory/ptr_util.h" #include "base/profiler/scoped_tracker.h" #include "base/strings/stringprintf.h" #include "base/strings/utf_string_conversions.h" @@ -282,9 +284,8 @@ void AboutSigninInternals::NotifyObservers() { FROM_HERE_WITH_EXPLICIT_FUNCTION( "422460 AboutSigninInternals::NotifyObservers1")); - FOR_EACH_OBSERVER(AboutSigninInternals::Observer, - signin_observers_, - OnSigninStateChanged(signin_status_value.get())); + for (auto& observer : signin_observers_) + observer.OnSigninStateChanged(signin_status_value.get()); } std::unique_ptr AboutSigninInternals::GetSigninStatus() { @@ -307,8 +308,8 @@ void AboutSigninInternals::OnAccessTokenRequested( if (token) { *token = TokenInfo(consumer_id, scopes); } else { - token = new TokenInfo(consumer_id, scopes); - signin_status_.token_info_map[account_id].push_back(token); + signin_status_.token_info_map[account_id].push_back( + base::MakeUnique(consumer_id, scopes)); } NotifyObservers(); @@ -336,9 +337,8 @@ void AboutSigninInternals::OnFetchAccessTokenComplete( void AboutSigninInternals::OnTokenRemoved( const std::string& account_id, const OAuth2TokenService::ScopeSet& scopes) { - for (size_t i = 0; i < signin_status_.token_info_map[account_id].size(); - ++i) { - TokenInfo* token = signin_status_.token_info_map[account_id][i]; + for (const std::unique_ptr& token : + signin_status_.token_info_map[account_id]) { if (token->scopes == scopes) token->Invalidate(); } @@ -400,9 +400,8 @@ void AboutSigninInternals::OnGaiaAccountsInCookieUpdated( } // Update the observers that the cookie's accounts are updated. - FOR_EACH_OBSERVER(AboutSigninInternals::Observer, - signin_observers_, - OnCookieAccountsFetched(&cookie_status)); + for (auto& observer : signin_observers_) + observer.OnCookieAccountsFetched(&cookie_status); } AboutSigninInternals::TokenInfo::TokenInfo( @@ -416,15 +415,11 @@ AboutSigninInternals::TokenInfo::TokenInfo( AboutSigninInternals::TokenInfo::~TokenInfo() {} -bool AboutSigninInternals::TokenInfo::LessThan(const TokenInfo* a, - const TokenInfo* b) { - if (a->request_time == b->request_time) { - if (a->consumer_id == b->consumer_id) { - return a->scopes < b->scopes; - } - return a->consumer_id < b->consumer_id; - } - return a->request_time < b->request_time; +bool AboutSigninInternals::TokenInfo::LessThan( + const std::unique_ptr& a, + const std::unique_ptr& b) { + return std::tie(a->request_time, a->consumer_id, a->scopes) < + std::tie(b->request_time, b->consumer_id, b->scopes); } void AboutSigninInternals::TokenInfo::Invalidate() { removed_ = true; } @@ -478,24 +473,17 @@ AboutSigninInternals::TokenInfo::ToValue() const { AboutSigninInternals::SigninStatus::SigninStatus() : timed_signin_fields(TIMED_FIELDS_COUNT) {} -AboutSigninInternals::SigninStatus::~SigninStatus() { - for (TokenInfoMap::iterator it = token_info_map.begin(); - it != token_info_map.end(); - ++it) { - base::STLDeleteElements(&it->second); - } -} +AboutSigninInternals::SigninStatus::~SigninStatus() {} AboutSigninInternals::TokenInfo* AboutSigninInternals::SigninStatus::FindToken( const std::string& account_id, const std::string& consumer_id, const OAuth2TokenService::ScopeSet& scopes) { - for (size_t i = 0; i < token_info_map[account_id].size(); ++i) { - TokenInfo* tmp = token_info_map[account_id][i]; - if (tmp->consumer_id == consumer_id && tmp->scopes == scopes) - return tmp; + for (const std::unique_ptr& token : token_info_map[account_id]) { + if (token->consumer_id == consumer_id && token->scopes == scopes) + return token.get(); } - return NULL; + return nullptr; } std::unique_ptr @@ -627,9 +615,7 @@ AboutSigninInternals::SigninStatus::ToValue( // Token information for all services. base::ListValue* token_info = new base::ListValue(); signin_status->Set("token_info", token_info); - for (TokenInfoMap::iterator it = token_info_map.begin(); - it != token_info_map.end(); - ++it) { + for (auto it = token_info_map.begin(); it != token_info_map.end(); ++it) { // TODO(robliao): Remove ScopedTracker below once https://crbug.com/422460 // is fixed. tracked_objects::ScopedTracker tracking_profile41( @@ -645,7 +631,7 @@ AboutSigninInternals::SigninStatus::ToValue( "422460 AboutSigninInternals::SigninStatus::ToValue42")); std::sort(it->second.begin(), it->second.end(), TokenInfo::LessThan); - const std::vector& tokens = it->second; + const auto& tokens = it->second; // TODO(robliao): Remove ScopedTracker below once https://crbug.com/422460 // is fixed. @@ -653,8 +639,8 @@ AboutSigninInternals::SigninStatus::ToValue( FROM_HERE_WITH_EXPLICIT_FUNCTION( "422460 AboutSigninInternals::SigninStatus::ToValue43")); - for (size_t i = 0; i < tokens.size(); ++i) { - token_details->Append(tokens[i]->ToValue()); + for (const std::unique_ptr& token : tokens) { + token_details->Append(token->ToValue()); } } diff --git a/chromium/components/signin/core/browser/about_signin_internals.h b/chromium/components/signin/core/browser/about_signin_internals.h index 7af382bfc8e..0e32b0eb345 100644 --- a/chromium/components/signin/core/browser/about_signin_internals.h +++ b/chromium/components/signin/core/browser/about_signin_internals.h @@ -32,7 +32,7 @@ class SigninClient; // Many values in SigninStatus are also associated with a timestamp. // This makes it easier to keep values and their associated times together. -typedef std::pair TimedSigninStatusValue; +using TimedSigninStatusValue = std::pair; // This class collects authentication, signin and token information // to propagate to about:signin-internals via SigninInternalsUI. @@ -110,7 +110,8 @@ class AboutSigninInternals ~TokenInfo(); std::unique_ptr ToValue() const; - static bool LessThan(const TokenInfo* a, const TokenInfo* b); + static bool LessThan(const std::unique_ptr& a, + const std::unique_ptr& b); // Called when the token is invalidated. void Invalidate(); @@ -124,15 +125,15 @@ class AboutSigninInternals bool removed_; }; - // Map account id to tokens associated to the account. - typedef std::map > TokenInfoMap; - // Encapsulates both authentication and token related information. Used // by SigninInternals to maintain information that needs to be shown in // the about:signin-internals page. struct SigninStatus { std::vector timed_signin_fields; - TokenInfoMap token_info_map; + + // Map account id to tokens associated to the account. + std::map>> + token_info_map; SigninStatus(); ~SigninStatus(); diff --git a/chromium/components/signin/core/browser/account_fetcher_service.cc b/chromium/components/signin/core/browser/account_fetcher_service.cc index caade390d7d..2cd588b94d3 100644 --- a/chromium/components/signin/core/browser/account_fetcher_service.cc +++ b/chromium/components/signin/core/browser/account_fetcher_service.cc @@ -214,9 +214,9 @@ void AccountFetcherService::StartFetchingUserInfo( // Starts fetching whether this is a child account. Handles refresh internally. void AccountFetcherService::StartFetchingChildInfo( const std::string& account_id) { - child_info_request_.reset(ChildAccountInfoFetcher::CreateFrom( + child_info_request_ = ChildAccountInfoFetcher::CreateFrom( child_request_account_id_, this, token_service_, - signin_client_->GetURLRequestContext(), invalidation_service_)); + signin_client_->GetURLRequestContext(), invalidation_service_); } void AccountFetcherService::ResetChildInfo() { diff --git a/chromium/components/signin/core/browser/account_tracker_service.cc b/chromium/components/signin/core/browser/account_tracker_service.cc index 84f522a7eba..efe9e6e36c7 100644 --- a/chromium/components/signin/core/browser/account_tracker_service.cc +++ b/chromium/components/signin/core/browser/account_tracker_service.cc @@ -168,20 +168,20 @@ AccountTrackerService::GetMigrationState(const PrefService* pref_service) { void AccountTrackerService::NotifyAccountUpdated(const AccountState& state) { DCHECK(!state.info.gaia.empty()); - FOR_EACH_OBSERVER( - Observer, observer_list_, OnAccountUpdated(state.info)); + for (auto& observer : observer_list_) + observer.OnAccountUpdated(state.info); } void AccountTrackerService::NotifyAccountUpdateFailed( const std::string& account_id) { - FOR_EACH_OBSERVER( - Observer, observer_list_, OnAccountUpdateFailed(account_id)); + for (auto& observer : observer_list_) + observer.OnAccountUpdateFailed(account_id); } void AccountTrackerService::NotifyAccountRemoved(const AccountState& state) { DCHECK(!state.info.gaia.empty()); - FOR_EACH_OBSERVER( - Observer, observer_list_, OnAccountRemoved(state.info)); + for (auto& observer : observer_list_) + observer.OnAccountRemoved(state.info); } void AccountTrackerService::StartTrackingAccount( diff --git a/chromium/components/signin/core/browser/child_account_info_fetcher.cc b/chromium/components/signin/core/browser/child_account_info_fetcher.cc index 3ee32037c03..15bc0538f6e 100644 --- a/chromium/components/signin/core/browser/child_account_info_fetcher.cc +++ b/chromium/components/signin/core/browser/child_account_info_fetcher.cc @@ -4,6 +4,7 @@ #include "components/signin/core/browser/child_account_info_fetcher.h" +#include "base/memory/ptr_util.h" #include "build/build_config.h" #if defined(OS_ANDROID) @@ -13,20 +14,18 @@ #endif // static -ChildAccountInfoFetcher* ChildAccountInfoFetcher::CreateFrom( +std::unique_ptr ChildAccountInfoFetcher::CreateFrom( const std::string& account_id, AccountFetcherService* fetcher_service, OAuth2TokenService* token_service, net::URLRequestContextGetter* request_context_getter, invalidation::InvalidationService* invalidation_service) { #if defined(OS_ANDROID) - ChildAccountInfoFetcherAndroid::StartFetchingChildAccountInfo(fetcher_service, - account_id); - return nullptr; + return ChildAccountInfoFetcherAndroid::Create(fetcher_service, account_id); #else - return new ChildAccountInfoFetcherImpl(account_id, fetcher_service, - token_service, request_context_getter, - invalidation_service); + return base::MakeUnique( + account_id, fetcher_service, token_service, request_context_getter, + invalidation_service); #endif } diff --git a/chromium/components/signin/core/browser/child_account_info_fetcher.h b/chromium/components/signin/core/browser/child_account_info_fetcher.h index bf69dd83133..1c35c48d332 100644 --- a/chromium/components/signin/core/browser/child_account_info_fetcher.h +++ b/chromium/components/signin/core/browser/child_account_info_fetcher.h @@ -5,6 +5,7 @@ #ifndef COMPONENTS_SIGNIN_CORE_BROWSER_CHILD_ACCOUNT_INFO_FETCHER_H_ #define COMPONENTS_SIGNIN_CORE_BROWSER_CHILD_ACCOUNT_INFO_FETCHER_H_ +#include #include #include "build/build_config.h" @@ -25,9 +26,8 @@ class OAuth2TokenService; class ChildAccountInfoFetcher { public: // Caller takes ownership of the fetcher and keeps it alive in order to - // receive updates except on Android where the return value is a nullptr - // and there are no updates due to a stale OS cache. - static ChildAccountInfoFetcher* CreateFrom( + // receive updates. + static std::unique_ptr CreateFrom( const std::string& account_id, AccountFetcherService* fetcher_service, OAuth2TokenService* token_service, diff --git a/chromium/components/signin/core/browser/child_account_info_fetcher_android.cc b/chromium/components/signin/core/browser/child_account_info_fetcher_android.cc index 2697018b72a..654a8154e3e 100644 --- a/chromium/components/signin/core/browser/child_account_info_fetcher_android.cc +++ b/chromium/components/signin/core/browser/child_account_info_fetcher_android.cc @@ -13,19 +13,36 @@ using base::android::JavaParamRef; // static -void ChildAccountInfoFetcherAndroid::StartFetchingChildAccountInfo( +std::unique_ptr ChildAccountInfoFetcherAndroid::Create( AccountFetcherService* service, const std::string& account_id) { - JNIEnv* env = base::android::AttachCurrentThread(); std::string account_name = service->account_tracker_service()->GetAccountInfo(account_id).email; // The AccountTrackerService may not be populated correctly in tests. if (account_name.empty()) - return; - Java_ChildAccountInfoFetcher_fetch( + return nullptr; + + // Call the constructor directly instead of using base::MakeUnique because the + // constructor is private. Also, use the std::unique_ptr<> constructor instead + // of base::WrapUnique because the _destructor_ of the subclass is private. + return std::unique_ptr( + new ChildAccountInfoFetcherAndroid(service, account_id, account_name)); +} + +ChildAccountInfoFetcherAndroid::ChildAccountInfoFetcherAndroid( + AccountFetcherService* service, + const std::string& account_id, + const std::string& account_name) { + JNIEnv* env = base::android::AttachCurrentThread(); + j_child_account_info_fetcher_.Reset(Java_ChildAccountInfoFetcher_create( env, reinterpret_cast(service), base::android::ConvertUTF8ToJavaString(env, account_id), - base::android::ConvertUTF8ToJavaString(env, account_name)); + base::android::ConvertUTF8ToJavaString(env, account_name))); +} + +ChildAccountInfoFetcherAndroid::~ChildAccountInfoFetcherAndroid() { + Java_ChildAccountInfoFetcher_destroy(base::android::AttachCurrentThread(), + j_child_account_info_fetcher_.obj()); } // static diff --git a/chromium/components/signin/core/browser/child_account_info_fetcher_android.h b/chromium/components/signin/core/browser/child_account_info_fetcher_android.h index db8b0f4342e..cb06fedbc05 100644 --- a/chromium/components/signin/core/browser/child_account_info_fetcher_android.h +++ b/chromium/components/signin/core/browser/child_account_info_fetcher_android.h @@ -8,18 +8,31 @@ #include #include -#include "base/macros.h" +#include "base/android/scoped_java_ref.h" +#include "base/memory/ptr_util.h" +#include "components/signin/core/browser/child_account_info_fetcher.h" class AccountFetcherService; -class ChildAccountInfoFetcherAndroid { +class ChildAccountInfoFetcherAndroid : public ChildAccountInfoFetcher { public: - static void StartFetchingChildAccountInfo(AccountFetcherService* service, - const std::string& account_id); + static std::unique_ptr Create( + AccountFetcherService* service, + const std::string& account_id); + // Register JNI methods. static bool Register(JNIEnv* env); - DISALLOW_IMPLICIT_CONSTRUCTORS(ChildAccountInfoFetcherAndroid); + private: + ChildAccountInfoFetcherAndroid(AccountFetcherService* service, + const std::string& account_id, + const std::string& account_name); + ~ChildAccountInfoFetcherAndroid() override; + + private: + base::android::ScopedJavaGlobalRef j_child_account_info_fetcher_; + + DISALLOW_COPY_AND_ASSIGN(ChildAccountInfoFetcherAndroid); }; #endif // COMPONENTS_SIGNIN_CORE_BROWSER_CHILD_ACCOUNT_INFO_FETCHER_ANDROID_H_ diff --git a/chromium/components/signin/core/browser/fake_signin_manager.cc b/chromium/components/signin/core/browser/fake_signin_manager.cc index a4912d5fd22..32caba99d7b 100644 --- a/chromium/components/signin/core/browser/fake_signin_manager.cc +++ b/chromium/components/signin/core/browser/fake_signin_manager.cc @@ -56,9 +56,10 @@ void FakeSigninManager::StartSignInWithRefreshToken( void FakeSigninManager::CompletePendingSignin() { SetAuthenticatedAccountId(GetAccountIdForAuthInProgress()); set_auth_in_progress(std::string()); - FOR_EACH_OBSERVER( - SigninManagerBase::Observer, observer_list_, - GoogleSigninSucceeded(authenticated_account_id_, username_, password_)); + for (auto& observer : observer_list_) { + observer.GoogleSigninSucceeded(authenticated_account_id_, username_, + password_); + } } void FakeSigninManager::SignIn(const std::string& gaia_id, @@ -76,8 +77,8 @@ void FakeSigninManager::ForceSignOut() { } void FakeSigninManager::FailSignin(const GoogleServiceAuthError& error) { - FOR_EACH_OBSERVER(SigninManagerBase::Observer, observer_list_, - GoogleSigninFailed(error)); + for (auto& observer : observer_list_) + observer.GoogleSigninFailed(error); } void FakeSigninManager::SignOut( @@ -91,8 +92,8 @@ void FakeSigninManager::SignOut( const std::string username = GetAuthenticatedAccountInfo().email; authenticated_account_id_.clear(); - FOR_EACH_OBSERVER(SigninManagerBase::Observer, observer_list_, - GoogleSignedOut(account_id, username)); + for (auto& observer : observer_list_) + observer.GoogleSignedOut(account_id, username); } #endif // !defined (OS_CHROMEOS) diff --git a/chromium/components/signin/core/browser/gaia_cookie_manager_service.cc b/chromium/components/signin/core/browser/gaia_cookie_manager_service.cc index cb807f69f37..9cfd9c9ae0f 100644 --- a/chromium/components/signin/core/browser/gaia_cookie_manager_service.cc +++ b/chromium/components/signin/core/browser/gaia_cookie_manager_service.cc @@ -519,8 +519,8 @@ void GaiaCookieManagerService::SignalComplete( // Its possible for the observer to delete |this| object. Don't access // access any members after this calling the observer. This method should // be the last call in any other method. - FOR_EACH_OBSERVER(Observer, observer_list_, - OnAddAccountToCookieCompleted(account_id, error)); + for (auto& observer : observer_list_) + observer.OnAddAccountToCookieCompleted(account_id, error); } void GaiaCookieManagerService::OnUbertokenSuccess( @@ -627,11 +627,11 @@ void GaiaCookieManagerService::OnListAccountsSuccess(const std::string& data) { // services, in response to OnGaiaAccountsInCookieUpdated, may try in return // to call ListAccounts, which would immediately return false if the // ListAccounts request is still sitting in queue. - FOR_EACH_OBSERVER(Observer, observer_list_, - OnGaiaAccountsInCookieUpdated( - listed_accounts_, - signed_out_accounts_, - GoogleServiceAuthError(GoogleServiceAuthError::NONE))); + for (auto& observer : observer_list_) { + observer.OnGaiaAccountsInCookieUpdated( + listed_accounts_, signed_out_accounts_, + GoogleServiceAuthError(GoogleServiceAuthError::NONE)); + } } void GaiaCookieManagerService::OnListAccountsFailure( @@ -655,9 +655,10 @@ void GaiaCookieManagerService::OnListAccountsFailure( UMA_HISTOGRAM_ENUMERATION("Signin.ListAccountsFailure", error.state(), GoogleServiceAuthError::NUM_STATES); - FOR_EACH_OBSERVER(Observer, observer_list_, - OnGaiaAccountsInCookieUpdated( - listed_accounts_, signed_out_accounts_, error)); + for (auto& observer : observer_list_) { + observer.OnGaiaAccountsInCookieUpdated(listed_accounts_, + signed_out_accounts_, error); + } HandleNextRequest(); } @@ -666,8 +667,11 @@ void GaiaCookieManagerService::OnLogOutSuccess() { VLOG(1) << "GaiaCookieManagerService::OnLogOutSuccess"; list_accounts_stale_ = true; - fetcher_backoff_.InformOfRequest(true); + for (auto& observer : observer_list_) { + observer.OnLogOutAccountsFromCookieCompleted( + GoogleServiceAuthError(GoogleServiceAuthError::NONE)); + } HandleNextRequest(); } @@ -687,6 +691,8 @@ void GaiaCookieManagerService::OnLogOutFailure( return; } + for (auto& observer : observer_list_) + observer.OnLogOutAccountsFromCookieCompleted(error); HandleNextRequest(); } diff --git a/chromium/components/signin/core/browser/gaia_cookie_manager_service.h b/chromium/components/signin/core/browser/gaia_cookie_manager_service.h index 47c673fc8b1..72f178d72bc 100644 --- a/chromium/components/signin/core/browser/gaia_cookie_manager_service.h +++ b/chromium/components/signin/core/browser/gaia_cookie_manager_service.h @@ -80,11 +80,16 @@ class GaiaCookieManagerService : public KeyedService, public: // Called whenever a merge session is completed. The account that was // merged is given by |account_id|. If |error| is equal to - // GoogleServiceAuthError::AuthErrorNone() then the merge succeeeded. + // GoogleServiceAuthError::AuthErrorNone() then the merge succeeded. virtual void OnAddAccountToCookieCompleted( const std::string& account_id, const GoogleServiceAuthError& error) {} + // Called whenever a logout is completed. If |error| is equal to + // GoogleServiceAuthError::AuthErrorNone() then the logout succeeded. + virtual void OnLogOutAccountsFromCookieCompleted( + const GoogleServiceAuthError& error) {} + // Called whenever the GaiaCookieManagerService's list of GAIA accounts is // updated. The GCMS monitors the APISID cookie and triggers a /ListAccounts // call on change. The GCMS will also call ListAccounts upon the first call diff --git a/chromium/components/signin/core/browser/signin_client.cc b/chromium/components/signin/core/browser/signin_client.cc index 2e70ebe977f..9473e0bb59c 100644 --- a/chromium/components/signin/core/browser/signin_client.cc +++ b/chromium/components/signin/core/browser/signin_client.cc @@ -32,6 +32,10 @@ std::string SigninClient::GetOrCreateScopedDeviceIdPref(PrefService* prefs) { return signin_scoped_device_id; } +void SigninClient::PreSignOut(const base::Callback& sign_out) { + sign_out.Run(); +} + void SigninClient::SignOut() { GetPrefs()->ClearPref(prefs::kGoogleServicesSigninScopedDeviceId); OnSignedOut(); diff --git a/chromium/components/signin/core/browser/signin_client.h b/chromium/components/signin/core/browser/signin_client.h index 99b37c49fbb..6c2c17dc323 100644 --- a/chromium/components/signin/core/browser/signin_client.h +++ b/chromium/components/signin/core/browser/signin_client.h @@ -34,7 +34,7 @@ class SigninClient : public KeyedService { // The subcription for cookie changed notifications. class CookieChangedSubscription { public: - virtual ~CookieChangedSubscription() {}; + virtual ~CookieChangedSubscription() {} }; ~SigninClient() override {} @@ -97,6 +97,10 @@ class SigninClient : public KeyedService { const std::string& username, const std::string& password) {} + // Called before Google signout started, call |sign_out| to start the sign out + // process. + virtual void PreSignOut(const base::Callback& sign_out); + virtual bool IsFirstRun() const = 0; virtual base::Time GetInstallDate() = 0; @@ -120,6 +124,9 @@ class SigninClient : public KeyedService { const std::string& source, net::URLRequestContextGetter* getter) = 0; + // Called once the credentials has been copied to another SigninManager. + virtual void AfterCredentialsCopied() {} + protected: // Returns device id that is scoped to single signin. // Stores the ID in the kGoogleServicesSigninScopedDeviceId pref. diff --git a/chromium/components/signin/core/browser/signin_error_controller.cc b/chromium/components/signin/core/browser/signin_error_controller.cc index 1fa6e9f9112..6dbaf23b151 100644 --- a/chromium/components/signin/core/browser/signin_error_controller.cc +++ b/chromium/components/signin/core/browser/signin_error_controller.cc @@ -91,7 +91,8 @@ void SigninErrorController::AuthStatusChanged() { if (error_changed) { signin_metrics::LogAuthError(auth_error_.state()); - FOR_EACH_OBSERVER(Observer, observer_list_, OnErrorChanged()); + for (auto& observer : observer_list_) + observer.OnErrorChanged(); } } diff --git a/chromium/components/signin/core/browser/signin_manager.cc b/chromium/components/signin/core/browser/signin_manager.cc index cb537ec9e6d..fc3a0c503a5 100644 --- a/chromium/components/signin/core/browser/signin_manager.cc +++ b/chromium/components/signin/core/browser/signin_manager.cc @@ -125,6 +125,7 @@ void SigninManager::CopyCredentialsFrom(const SigninManager& source) { possibly_invalid_email_ = source.possibly_invalid_email_; temp_refresh_token_ = source.temp_refresh_token_; password_ = source.password_; + source.client_->AfterCredentialsCopied(); } void SigninManager::ClearTransientSigninData() { @@ -141,14 +142,21 @@ void SigninManager::ClearTransientSigninData() { void SigninManager::HandleAuthError(const GoogleServiceAuthError& error) { ClearTransientSigninData(); - FOR_EACH_OBSERVER(SigninManagerBase::Observer, - observer_list_, - GoogleSigninFailed(error)); + for (auto& observer : observer_list_) + observer.GoogleSigninFailed(error); } void SigninManager::SignOut( signin_metrics::ProfileSignout signout_source_metric, signin_metrics::SignoutDelete signout_delete_metric) { + client_->PreSignOut(base::Bind(&SigninManager::DoSignOut, + base::Unretained(this), signout_source_metric, + signout_delete_metric)); +} + +void SigninManager::DoSignOut( + signin_metrics::ProfileSignout signout_source_metric, + signin_metrics::SignoutDelete signout_delete_metric) { DCHECK(IsInitialized()); signin_metrics::LogSignout(signout_source_metric, signout_delete_metric); @@ -201,9 +209,8 @@ void SigninManager::SignOut( << "IsSigninAllowed: " << IsSigninAllowed(); token_service_->RevokeAllCredentials(); - FOR_EACH_OBSERVER(SigninManagerBase::Observer, - observer_list_, - GoogleSignedOut(account_id, username)); + for (auto& observer : observer_list_) + observer.GoogleSignedOut(account_id, username); } void SigninManager::Initialize(PrefService* local_state) { @@ -375,10 +382,11 @@ void SigninManager::OnSignedIn() { possibly_invalid_email_.clear(); signin_manager_signed_in_ = true; - FOR_EACH_OBSERVER( - SigninManagerBase::Observer, observer_list_, - GoogleSigninSucceeded(GetAuthenticatedAccountId(), - GetAuthenticatedAccountInfo().email, password_)); + for (auto& observer : observer_list_) { + observer.GoogleSigninSucceeded(GetAuthenticatedAccountId(), + GetAuthenticatedAccountInfo().email, + password_); + } client_->OnSignedIn(GetAuthenticatedAccountId(), gaia_id, GetAuthenticatedAccountInfo().email, password_); diff --git a/chromium/components/signin/core/browser/signin_manager.h b/chromium/components/signin/core/browser/signin_manager.h index f9b6be7b2b2..92e9ff587ec 100644 --- a/chromium/components/signin/core/browser/signin_manager.h +++ b/chromium/components/signin/core/browser/signin_manager.h @@ -147,6 +147,10 @@ class SigninManager : public SigninManagerBase, // Flag saying whether signing out is allowed. bool prohibit_signout_; + // The sign out process which is started by SigninClient::PreSignOut() + virtual void DoSignOut(signin_metrics::ProfileSignout signout_source_metric, + signin_metrics::SignoutDelete signout_delete_metric); + private: enum SigninType { SIGNIN_TYPE_NONE, SIGNIN_TYPE_WITH_REFRESH_TOKEN }; diff --git a/chromium/components/signin/core/browser/signin_manager_base.cc b/chromium/components/signin/core/browser/signin_manager_base.cc index efbb7e4ad41..68d68b477b4 100644 --- a/chromium/components/signin/core/browser/signin_manager_base.cc +++ b/chromium/components/signin/core/browser/signin_manager_base.cc @@ -250,7 +250,6 @@ void SigninManagerBase::RemoveSigninDiagnosticsObserver( void SigninManagerBase::NotifyDiagnosticsObservers( const TimedSigninStatusField& field, const std::string& value) { - FOR_EACH_OBSERVER(SigninDiagnosticsObserver, - signin_diagnostics_observers_, - NotifySigninValueChanged(field, value)); + for (auto& observer : signin_diagnostics_observers_) + observer.NotifySigninValueChanged(field, value); } diff --git a/chromium/components/signin/core/common/profile_management_switches.cc b/chromium/components/signin/core/common/profile_management_switches.cc index e66596b2484..bf1cd842176 100644 --- a/chromium/components/signin/core/common/profile_management_switches.cc +++ b/chromium/components/signin/core/common/profile_management_switches.cc @@ -136,10 +136,6 @@ bool UsePasswordSeparatedSigninFlow() { switches::kUsePasswordSeparatedSigninFlow); } -bool IsMaterialDesignUserManager() { - return base::FeatureList::IsEnabled(switches::kMaterialDesignUserManager); -} - bool IsMaterialDesignUserMenu() { return base::FeatureList::IsEnabled(switches::kMaterialDesignUserMenu); } diff --git a/chromium/components/signin/core/common/profile_management_switches.h b/chromium/components/signin/core/common/profile_management_switches.h index 98f47093dbd..26cb06471d5 100644 --- a/chromium/components/signin/core/common/profile_management_switches.h +++ b/chromium/components/signin/core/common/profile_management_switches.h @@ -35,9 +35,6 @@ bool IsNewProfileManagementPreviewEnabled(); // Checks whether the new gaia password separated sign in flow is enabled. bool UsePasswordSeparatedSigninFlow(); -// Whether the new Material Design User Manager should be displayed. -bool IsMaterialDesignUserManager(); - // Whether the material design user menu should be displayed. bool IsMaterialDesignUserMenu(); diff --git a/chromium/components/signin/core/common/signin_switches.cc b/chromium/components/signin/core/common/signin_switches.cc index 9826d61228f..bf1d0ee8914 100644 --- a/chromium/components/signin/core/common/signin_switches.cc +++ b/chromium/components/signin/core/common/signin_switches.cc @@ -35,10 +35,6 @@ const char kExtensionsMultiAccount[] = "extensions-multi-account"; // Enables using GAIA information to populate profile name and icon. const char kGoogleProfileInfo[] = "google-profile-info"; -const base::Feature kMaterialDesignUserManager { - "MaterialDesignUserManager", base::FEATURE_ENABLED_BY_DEFAULT -}; - // Enables or disables the material design desktop user menu. const base::Feature kMaterialDesignUserMenu { "MaterialDesignUserMenu", base::FEATURE_ENABLED_BY_DEFAULT diff --git a/chromium/components/signin/core/common/signin_switches.h b/chromium/components/signin/core/common/signin_switches.h index 70e5ef66128..f7d1bb29be5 100644 --- a/chromium/components/signin/core/common/signin_switches.h +++ b/chromium/components/signin/core/common/signin_switches.h @@ -25,7 +25,6 @@ extern const char kEnableRefreshTokenAnnotationRequest[]; extern const char kExtensionsMultiAccount[]; extern const char kGoogleProfileInfo[]; -extern const base::Feature kMaterialDesignUserManager; extern const base::Feature kMaterialDesignUserMenu; extern const base::Feature kUsePasswordSeparatedSigninFlow; -- cgit v1.2.1