summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrogerta@chromium.org <rogerta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-28 13:48:18 +0000
committerrogerta@chromium.org <rogerta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-28 13:48:18 +0000
commit633b1ea1cd6e46531f45cc087cd6e280f322daaa (patch)
tree866f1beb134e6d935bfa0e14a12d0693dc9a60d2
parentb986850a1764a300b18caebb80db1b8bc12557d5 (diff)
downloadchromium_src-633b1ea1cd6e46531f45cc087cd6e280f322daaa.zip
chromium_src-633b1ea1cd6e46531f45cc087cd6e280f322daaa.tar.gz
chromium_src-633b1ea1cd6e46531f45cc087cd6e280f322daaa.tar.bz2
Revert 225847 "Make the SigninGlobalError multi-login aware."
> Make the SigninGlobalError multi-login aware. > > BUG=277149 > R=asvitkine@chromium.org, atwilson@chromium.org, courage@chromium.org, fgorski@chromium.org > TBR=asvitkine@chromium.org > > Review URL: https://codereview.chromium.org/23875028 TBR=rogerta@chromium.org Review URL: https://codereview.chromium.org/25157002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@225848 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/extensions/api/identity/identity_api.cc5
-rw-r--r--chrome/browser/extensions/api/identity/identity_api.h1
-rw-r--r--chrome/browser/signin/fake_auth_status_provider.cc8
-rw-r--r--chrome/browser/signin/fake_auth_status_provider.h9
-rw-r--r--chrome/browser/signin/profile_oauth2_token_service.cc96
-rw-r--r--chrome/browser/signin/profile_oauth2_token_service.h41
-rw-r--r--chrome/browser/signin/profile_oauth2_token_service_unittest.cc25
-rw-r--r--chrome/browser/signin/signin_global_error.cc25
-rw-r--r--chrome/browser/signin/signin_global_error.h10
-rw-r--r--chrome/browser/signin/signin_global_error_unittest.cc57
-rw-r--r--chrome/browser/signin/signin_manager_unittest.cc83
-rw-r--r--chrome/browser/signin/token_service_unittest.cc25
-rw-r--r--chrome/browser/signin/token_service_unittest.h5
-rw-r--r--chrome/browser/signin/ubertoken_fetcher_unittest.cc3
-rw-r--r--chrome/browser/sync/profile_sync_service.cc8
-rw-r--r--chrome/browser/sync/profile_sync_service.h7
-rw-r--r--chrome/browser/sync/sync_ui_util_unittest.cc11
-rw-r--r--chrome/browser/ui/cocoa/browser_window_controller_unittest.mm2
-rw-r--r--chrome/browser/ui/webui/sync_setup_handler_unittest.cc2
19 files changed, 87 insertions, 336 deletions
diff --git a/chrome/browser/extensions/api/identity/identity_api.cc b/chrome/browser/extensions/api/identity/identity_api.cc
index 206c91f..5726c65 100644
--- a/chrome/browser/extensions/api/identity/identity_api.cc
+++ b/chrome/browser/extensions/api/identity/identity_api.cc
@@ -749,11 +749,6 @@ ProfileKeyedAPIFactory<IdentityAPI>* IdentityAPI::GetFactoryInstance() {
return &g_factory.Get();
}
-std::string IdentityAPI::GetAccountId() const {
- return ProfileOAuth2TokenServiceFactory::GetForProfile(profile_)->
- GetPrimaryAccountId();
-}
-
GoogleServiceAuthError IdentityAPI::GetAuthStatus() const {
return error_;
}
diff --git a/chrome/browser/extensions/api/identity/identity_api.h b/chrome/browser/extensions/api/identity/identity_api.h
index 57fa8fa..96bbc19 100644
--- a/chrome/browser/extensions/api/identity/identity_api.h
+++ b/chrome/browser/extensions/api/identity/identity_api.h
@@ -274,7 +274,6 @@ class IdentityAPI : public ProfileKeyedAPI,
static ProfileKeyedAPIFactory<IdentityAPI>* GetFactoryInstance();
// AuthStatusProvider implementation.
- virtual std::string GetAccountId() const OVERRIDE;
virtual GoogleServiceAuthError GetAuthStatus() const OVERRIDE;
// OAuth2TokenService::Observer implementation:
diff --git a/chrome/browser/signin/fake_auth_status_provider.cc b/chrome/browser/signin/fake_auth_status_provider.cc
index 830a028..439231ff 100644
--- a/chrome/browser/signin/fake_auth_status_provider.cc
+++ b/chrome/browser/signin/fake_auth_status_provider.cc
@@ -14,17 +14,11 @@ FakeAuthStatusProvider::~FakeAuthStatusProvider() {
global_error_->RemoveProvider(this);
}
-std::string FakeAuthStatusProvider::GetAccountId() const {
- return account_id_;
-}
-
GoogleServiceAuthError FakeAuthStatusProvider::GetAuthStatus() const {
return auth_error_;
}
-void FakeAuthStatusProvider::SetAuthError(const std::string& account_id,
- const GoogleServiceAuthError& error) {
- account_id_ = account_id;
+void FakeAuthStatusProvider::SetAuthError(const GoogleServiceAuthError& error) {
auth_error_ = error;
global_error_->AuthStatusChanged();
}
diff --git a/chrome/browser/signin/fake_auth_status_provider.h b/chrome/browser/signin/fake_auth_status_provider.h
index 756922c..9d937d5 100644
--- a/chrome/browser/signin/fake_auth_status_provider.h
+++ b/chrome/browser/signin/fake_auth_status_provider.h
@@ -17,20 +17,13 @@ class FakeAuthStatusProvider : public SigninGlobalError::AuthStatusProvider {
// Sets the auth error that this provider reports to SigninGlobalError. Also
// notifies SigninGlobalError via AuthStatusChanged().
- void SetAuthError(const std::string& account_id,
- const GoogleServiceAuthError& error);
-
- void set_error_without_status_change(const GoogleServiceAuthError& error) {
- auth_error_ = error;
- }
+ void SetAuthError(const GoogleServiceAuthError& error);
// AuthStatusProvider implementation.
- virtual std::string GetAccountId() const OVERRIDE;
virtual GoogleServiceAuthError GetAuthStatus() const OVERRIDE;
private:
SigninGlobalError* global_error_;
- std::string account_id_;
GoogleServiceAuthError auth_error_;
};
diff --git a/chrome/browser/signin/profile_oauth2_token_service.cc b/chrome/browser/signin/profile_oauth2_token_service.cc
index 12ee76d..cc89a9d 100644
--- a/chrome/browser/signin/profile_oauth2_token_service.cc
+++ b/chrome/browser/signin/profile_oauth2_token_service.cc
@@ -48,44 +48,10 @@ std::string RemoveAccountIdPrefix(const std::string& prefixed_account_id) {
} // namespace
-
-ProfileOAuth2TokenService::AccountInfo::AccountInfo(
- ProfileOAuth2TokenService* token_service,
- const std::string& account_id,
- const std::string& refresh_token)
- : token_service_(token_service),
- account_id_(account_id),
- refresh_token_(refresh_token),
- last_auth_error_(GoogleServiceAuthError::NONE) {
- DCHECK(token_service_);
- DCHECK(!account_id_.empty());
- token_service_->signin_global_error()->AddProvider(this);
-}
-
-ProfileOAuth2TokenService::AccountInfo::~AccountInfo() {
- token_service_->signin_global_error()->RemoveProvider(this);
-}
-
-void ProfileOAuth2TokenService::AccountInfo::SetLastAuthError(
- const GoogleServiceAuthError& error) {
- if (error.state() != last_auth_error_.state()) {
- last_auth_error_ = error;
- token_service_->signin_global_error()->AuthStatusChanged();
- }
-}
-
-std::string ProfileOAuth2TokenService::AccountInfo::GetAccountId() const {
- return account_id_;
-}
-
-GoogleServiceAuthError
-ProfileOAuth2TokenService::AccountInfo::GetAuthStatus() const {
- return last_auth_error_;
-}
-
ProfileOAuth2TokenService::ProfileOAuth2TokenService()
: profile_(NULL),
- web_data_service_request_(0) {
+ web_data_service_request_(0),
+ last_auth_error_(GoogleServiceAuthError::NONE) {
}
ProfileOAuth2TokenService::~ProfileOAuth2TokenService() {
@@ -102,6 +68,7 @@ void ProfileOAuth2TokenService::Initialize(Profile* profile) {
signin_global_error_.reset(new SigninGlobalError(profile));
GlobalErrorServiceFactory::GetForProfile(profile_)->AddGlobalError(
signin_global_error_.get());
+ signin_global_error_->AddProvider(this);
content::Source<TokenService> token_service_source(
TokenServiceFactory::GetForProfile(profile));
@@ -119,7 +86,7 @@ void ProfileOAuth2TokenService::Initialize(Profile* profile) {
void ProfileOAuth2TokenService::Shutdown() {
DCHECK(profile_) << "Shutdown() called without matching call to Initialize()";
CancelAllRequests();
- refresh_tokens_.clear();
+ signin_global_error_->RemoveProvider(this);
GlobalErrorServiceFactory::GetForProfile(profile_)->RemoveGlobalError(
signin_global_error_.get());
signin_global_error_.reset();
@@ -127,9 +94,10 @@ void ProfileOAuth2TokenService::Shutdown() {
std::string ProfileOAuth2TokenService::GetRefreshToken(
const std::string& account_id) {
- AccountInfoMap::const_iterator iter = refresh_tokens_.find(account_id);
+ std::map<std::string, std::string>::const_iterator iter =
+ refresh_tokens_.find(account_id);
if (iter != refresh_tokens_.end())
- return iter->second->refresh_token();
+ return iter->second;
return std::string();
}
@@ -140,14 +108,17 @@ net::URLRequestContextGetter* ProfileOAuth2TokenService::GetRequestContext() {
void ProfileOAuth2TokenService::UpdateAuthError(
const std::string& account_id,
const GoogleServiceAuthError& error) {
+ // TODO(fgorski): SigninGlobalError needs to be made multi-login aware.
// Do not report connection errors as these are not actually auth errors.
// We also want to avoid masking a "real" auth error just because we
// subsequently get a transient network error.
if (error.state() == GoogleServiceAuthError::CONNECTION_FAILED)
return;
- DCHECK_GT(refresh_tokens_.count(account_id), 0u);
- refresh_tokens_[account_id]->SetLastAuthError(error);
+ if (error.state() != last_auth_error_.state()) {
+ last_auth_error_ = error;
+ signin_global_error_->AuthStatusChanged();
+ }
}
void ProfileOAuth2TokenService::Observe(
@@ -167,8 +138,7 @@ void ProfileOAuth2TokenService::Observe(
// the token DB.
CancelRequestsForAccount(account_id);
ClearCacheForAccount(account_id);
- refresh_tokens_[account_id].reset(
- new AccountInfo(this, account_id, tok_details->token()));
+ refresh_tokens_[account_id] = tok_details->token();
UpdateAuthError(account_id, GoogleServiceAuthError::AuthErrorNone());
FireRefreshTokenAvailable(account_id);
}
@@ -177,8 +147,7 @@ void ProfileOAuth2TokenService::Observe(
case chrome::NOTIFICATION_TOKENS_CLEARED: {
CancelAllRequests();
ClearCache();
- if (!account_id.empty())
- UpdateAuthError(account_id, GoogleServiceAuthError::AuthErrorNone());
+ UpdateAuthError(account_id, GoogleServiceAuthError::AuthErrorNone());
break;
}
case chrome::NOTIFICATION_TOKEN_LOADING_FINISHED:
@@ -187,17 +156,7 @@ void ProfileOAuth2TokenService::Observe(
// user goes on to set up sync, they will have to make two attempts:
// One to surface the OAuth2 error, and a second one after signing in.
// See crbug.com/276650.
-
- // If |account_id| is not empty, make sure that we have an entry in the
- // map for it. The entry could be missing if there is a corruption in
- // the token DB while this profile is connected to an account.
- if (!account_id.empty() && refresh_tokens_.count(account_id) == 0) {
- refresh_tokens_[account_id].reset(new AccountInfo(
- this, account_id, std::string()));
- }
-
- if (!account_id.empty() &&
- refresh_tokens_[account_id]->refresh_token().empty()) {
+ if (!account_id.empty() && GetRefreshToken(account_id).empty()) {
UpdateAuthError(account_id, GoogleServiceAuthError(
GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS));
}
@@ -209,6 +168,10 @@ void ProfileOAuth2TokenService::Observe(
}
}
+GoogleServiceAuthError ProfileOAuth2TokenService::GetAuthStatus() const {
+ return last_auth_error_;
+}
+
std::string ProfileOAuth2TokenService::GetPrimaryAccountId() {
SigninManagerBase* signin_manager =
SigninManagerFactory::GetForProfileIfExists(profile_);
@@ -220,8 +183,8 @@ std::string ProfileOAuth2TokenService::GetPrimaryAccountId() {
std::vector<std::string> ProfileOAuth2TokenService::GetAccounts() {
std::vector<std::string> account_ids;
- for (AccountInfoMap::const_iterator iter = refresh_tokens_.begin();
- iter != refresh_tokens_.end(); ++iter) {
+ for (std::map<std::string, std::string>::const_iterator iter =
+ refresh_tokens_.begin(); iter != refresh_tokens_.end(); ++iter) {
account_ids.push_back(iter->first);
}
return account_ids;
@@ -231,24 +194,20 @@ void ProfileOAuth2TokenService::UpdateCredentials(
const std::string& account_id,
const std::string& refresh_token) {
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
- DCHECK(!account_id.empty());
DCHECK(!refresh_token.empty());
bool refresh_token_present = refresh_tokens_.count(account_id) > 0;
if (!refresh_token_present ||
- refresh_tokens_[account_id]->refresh_token() != refresh_token) {
+ refresh_tokens_[account_id] != refresh_token) {
// If token present, and different from the new one, cancel its requests,
// and clear the entries in cache related to that account.
if (refresh_token_present) {
CancelRequestsForAccount(account_id);
ClearCacheForAccount(account_id);
- refresh_tokens_[account_id]->set_refresh_token(refresh_token);
- } else {
- refresh_tokens_[account_id].reset(
- new AccountInfo(this, account_id, refresh_token));
}
// Save the token in memory and in persistent store.
+ refresh_tokens_[account_id] = refresh_token;
PersistCredentials(account_id, refresh_token);
UpdateAuthError(account_id, GoogleServiceAuthError::AuthErrorNone());
@@ -295,8 +254,10 @@ void ProfileOAuth2TokenService::RevokeAllCredentials() {
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
CancelAllRequests();
- for (AccountInfoMap::const_iterator iter = refresh_tokens_.begin();
- iter != refresh_tokens_.end(); ++iter) {
+ for (std::map<std::string, std::string>::const_iterator iter =
+ refresh_tokens_.begin();
+ iter != refresh_tokens_.end();
+ ++iter) {
FireRefreshTokenRevoked(iter->first);
}
refresh_tokens_.clear();
@@ -359,8 +320,7 @@ void ProfileOAuth2TokenService::LoadAllCredentialsIntoMemory(
} else {
DCHECK(!refresh_token.empty());
std::string account_id = RemoveAccountIdPrefix(prefixed_account_id);
- refresh_tokens_[account_id].reset(
- new AccountInfo(this, account_id, refresh_token));
+ refresh_tokens_[account_id] = refresh_token;
FireRefreshTokenAvailable(account_id);
// TODO(fgorski): Notify diagnostic observers.
}
diff --git a/chrome/browser/signin/profile_oauth2_token_service.h b/chrome/browser/signin/profile_oauth2_token_service.h
index 670adb6..62d14ab 100644
--- a/chrome/browser/signin/profile_oauth2_token_service.h
+++ b/chrome/browser/signin/profile_oauth2_token_service.h
@@ -8,7 +8,6 @@
#include <string>
#include "base/gtest_prod_util.h"
-#include "base/memory/linked_ptr.h"
#include "chrome/browser/signin/signin_global_error.h"
#include "components/browser_context_keyed_service/browser_context_keyed_service.h"
#include "components/webdata/common/web_data_service_consumer.h"
@@ -41,6 +40,7 @@ class SigninGlobalError;
// request from other thread, please use ProfileOAuth2TokenServiceRequest.
class ProfileOAuth2TokenService : public OAuth2TokenService,
public content::NotificationObserver,
+ public SigninGlobalError::AuthStatusProvider,
public BrowserContextKeyedService,
public WebDataServiceConsumer {
public:
@@ -55,6 +55,9 @@ class ProfileOAuth2TokenService : public OAuth2TokenService,
// BrowserContextKeyedService implementation.
virtual void Shutdown() OVERRIDE;
+ // SigninGlobalError::AuthStatusProvider implementation.
+ virtual GoogleServiceAuthError GetAuthStatus() const OVERRIDE;
+
// Gets an account id of the primary account related to the profile.
std::string GetPrimaryAccountId();
@@ -109,37 +112,6 @@ class ProfileOAuth2TokenService : public OAuth2TokenService,
virtual void ClearPersistedCredentials(const std::string& account_id);
private:
- class AccountInfo : public SigninGlobalError::AuthStatusProvider {
- public:
- AccountInfo(ProfileOAuth2TokenService* token_service,
- const std::string& account_id,
- const std::string& refresh_token);
- virtual ~AccountInfo();
-
- const std::string& refresh_token() const { return refresh_token_; }
- void set_refresh_token(const std::string& token) {
- refresh_token_ = token;
- }
-
- void SetLastAuthError(const GoogleServiceAuthError& error);
-
- // SigninGlobalError::AuthStatusProvider implementation.
- virtual std::string GetAccountId() const OVERRIDE;
- virtual GoogleServiceAuthError GetAuthStatus() const OVERRIDE;
-
- private:
- ProfileOAuth2TokenService* token_service_;
- std::string account_id_;
- std::string refresh_token_;
- GoogleServiceAuthError last_auth_error_;
-
- DISALLOW_COPY_AND_ASSIGN(AccountInfo);
- };
-
- // Maps the |account_id| of accounts known to ProfileOAuth2TokenService
- // to information about the account.
- typedef std::map<std::string, linked_ptr<AccountInfo> > AccountInfoMap;
-
FRIEND_TEST_ALL_PREFIXES(ProfileOAuth2TokenServiceTest,
TokenServiceUpdateClearsCache);
FRIEND_TEST_ALL_PREFIXES(ProfileOAuth2TokenServiceTest,
@@ -171,7 +143,7 @@ class ProfileOAuth2TokenService : public OAuth2TokenService,
WebDataServiceBase::Handle web_data_service_request_;
// In memory refresh token store mapping account_id to refresh_token.
- AccountInfoMap refresh_tokens_;
+ std::map<std::string, std::string> refresh_tokens_;
// Used to show auth errors in the wrench menu. The SigninGlobalError is
// different than most GlobalErrors in that its lifetime is controlled by
@@ -179,6 +151,9 @@ class ProfileOAuth2TokenService : public OAuth2TokenService,
// wrench menu).
scoped_ptr<SigninGlobalError> signin_global_error_;
+ // The auth status from the most-recently-completed request.
+ GoogleServiceAuthError last_auth_error_;
+
// Registrar for notifications from the TokenService.
content::NotificationRegistrar registrar_;
diff --git a/chrome/browser/signin/profile_oauth2_token_service_unittest.cc b/chrome/browser/signin/profile_oauth2_token_service_unittest.cc
index 09c9d66..ee2cfc8 100644
--- a/chrome/browser/signin/profile_oauth2_token_service_unittest.cc
+++ b/chrome/browser/signin/profile_oauth2_token_service_unittest.cc
@@ -3,10 +3,8 @@
// found in the LICENSE file.
#include "base/run_loop.h"
-#include "chrome/browser/signin/fake_signin_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_factory.h"
#include "chrome/browser/signin/token_service_unittest.h"
#include "content/public/browser/browser_thread.h"
#include "google_apis/gaia/gaia_constants.h"
@@ -21,14 +19,12 @@ using content::BrowserThread;
// Defining constant here to handle backward compatiblity tests, but this
// constant is no longer used in current versions of chrome.
static const char kLSOService[] = "lso";
-static const char kEmail[] = "user@gmail.com";
class ProfileOAuth2TokenServiceTest : public TokenServiceTestHarness,
public OAuth2TokenService::Observer {
public:
ProfileOAuth2TokenServiceTest()
- : oauth2_service_(NULL),
- token_available_count_(0),
+ : token_available_count_(0),
token_revoked_count_(0),
tokens_loaded_count_(0) {
}
@@ -38,6 +34,7 @@ class ProfileOAuth2TokenServiceTest : public TokenServiceTestHarness,
UpdateCredentialsOnService();
oauth2_service_ = ProfileOAuth2TokenServiceFactory::GetForProfile(
profile());
+
oauth2_service_->AddObserver(this);
}
@@ -102,7 +99,6 @@ class ProfileOAuth2TokenServiceTest : public TokenServiceTestHarness,
TEST_F(ProfileOAuth2TokenServiceTest, Notifications) {
EXPECT_EQ(0, oauth2_service_->cache_size_for_testing());
- CreateSigninManager(kEmail);
service()->IssueAuthTokenForTest(GaiaConstants::kGaiaOAuth2LoginRefreshToken,
"refreshToken");
ExpectOneTokenAvailableNotification();
@@ -112,9 +108,8 @@ TEST_F(ProfileOAuth2TokenServiceTest, Notifications) {
}
TEST_F(ProfileOAuth2TokenServiceTest, PersistenceDBUpgrade) {
- CreateSigninManager(kEmail);
-
- std::string main_account_id(kEmail);
+ // No username for profile in unit tests, defaulting to empty string.
+ std::string main_account_id;
std::string main_refresh_token("old_refresh_token");
// Populate DB with legacy tokens.
@@ -137,7 +132,7 @@ TEST_F(ProfileOAuth2TokenServiceTest, PersistenceDBUpgrade) {
EXPECT_TRUE(oauth2_service_->RefreshTokenIsAvailable(main_account_id));
EXPECT_EQ(1U, oauth2_service_->refresh_tokens_.size());
EXPECT_EQ(main_refresh_token,
- oauth2_service_->refresh_tokens_[main_account_id]->refresh_token());
+ oauth2_service_->refresh_tokens_[main_account_id]);
// Add an old legacy token to the DB, to ensure it will not overwrite existing
// credentials for main account.
@@ -166,10 +161,9 @@ TEST_F(ProfileOAuth2TokenServiceTest, PersistenceDBUpgrade) {
// tokens using GetRefreshToken()
EXPECT_EQ(2U, oauth2_service_->refresh_tokens_.size());
EXPECT_EQ(main_refresh_token,
- oauth2_service_->refresh_tokens_[main_account_id]->refresh_token());
- EXPECT_EQ(
- other_refresh_token,
- oauth2_service_->refresh_tokens_[other_account_id]->refresh_token());
+ oauth2_service_->refresh_tokens_[main_account_id]);
+ EXPECT_EQ(other_refresh_token,
+ oauth2_service_->refresh_tokens_[other_account_id]);
oauth2_service_->RevokeAllCredentials();
}
@@ -285,7 +279,6 @@ TEST_F(ProfileOAuth2TokenServiceTest, TokensLoaded) {
TEST_F(ProfileOAuth2TokenServiceTest, UnknownNotificationsAreNoops) {
EXPECT_EQ(0, oauth2_service_->cache_size_for_testing());
- CreateSigninManager(kEmail);
service()->IssueAuthTokenForTest("foo", "toto");
ExpectNoNotifications();
@@ -300,7 +293,6 @@ TEST_F(ProfileOAuth2TokenServiceTest, UnknownNotificationsAreNoops) {
TEST_F(ProfileOAuth2TokenServiceTest, TokenServiceUpdateClearsCache) {
EXPECT_EQ(0, oauth2_service_->cache_size_for_testing());
- CreateSigninManager(kEmail);
std::set<std::string> scope_list;
scope_list.insert("scope");
oauth2_service_->UpdateCredentials(oauth2_service_->GetPrimaryAccountId(),
@@ -340,4 +332,3 @@ TEST_F(ProfileOAuth2TokenServiceTest, TokenServiceUpdateClearsCache) {
EXPECT_EQ("another token", consumer_.last_token_);
EXPECT_EQ(1, oauth2_service_->cache_size_for_testing());
}
-
diff --git a/chrome/browser/signin/signin_global_error.cc b/chrome/browser/signin/signin_global_error.cc
index 3b31038..4281626 100644
--- a/chrome/browser/signin/signin_global_error.cc
+++ b/chrome/browser/signin/signin_global_error.cc
@@ -59,12 +59,9 @@ SigninGlobalError::AuthStatusProvider::~AuthStatusProvider() {
void SigninGlobalError::AuthStatusChanged() {
// Walk all of the status providers and collect any error.
GoogleServiceAuthError current_error(GoogleServiceAuthError::AuthErrorNone());
- std::string current_account_id;
for (std::set<const AuthStatusProvider*>::const_iterator it =
provider_set_.begin(); it != provider_set_.end(); ++it) {
- current_account_id = (*it)->GetAccountId();
current_error = (*it)->GetAuthStatus();
-
// Break out if any provider reports an error (ignoring ordinary network
// errors, which are not surfaced to the user). This logic may eventually
// need to be extended to prioritize different auth errors, but for now
@@ -74,15 +71,8 @@ void SigninGlobalError::AuthStatusChanged() {
break;
}
}
- if (current_error.state() != auth_error_.state() ||
- account_id_ != current_account_id) {
+ if (current_error.state() != auth_error_.state()) {
auth_error_ = current_error;
- if (auth_error_.state() == GoogleServiceAuthError::NONE) {
- account_id_.clear();
- } else {
- account_id_ = current_account_id;
- }
-
GlobalErrorServiceFactory::GetForProfile(profile_)->NotifyErrorsChanged(
this);
}
@@ -97,7 +87,12 @@ int SigninGlobalError::MenuItemCommandID() {
}
string16 SigninGlobalError::MenuItemLabel() {
- if (account_id_.empty() ||
+ std::string username;
+ SigninManagerBase* signin_manager =
+ SigninManagerFactory::GetForProfileIfExists(profile_);
+ if (signin_manager)
+ username = signin_manager->GetAuthenticatedUsername();
+ if (username.empty() ||
auth_error_.state() == GoogleServiceAuthError::NONE ||
auth_error_.state() == GoogleServiceAuthError::CONNECTION_FAILED) {
// If the user isn't signed in, or there's no auth error worth elevating to
@@ -119,10 +114,6 @@ void SigninGlobalError::ExecuteMenuItem(Browser* browser) {
}
#endif
- // TODO(rogerta): what we do depends on which account is reporting an error.
- // This will be needed once the account reconcilor is implemented. The
- // LoginUIService will support multi-login as well.
-
// Global errors don't show up in the wrench menu on android.
#if !defined(OS_ANDROID)
LoginUIService* login_ui = LoginUIServiceFactory::GetForProfile(profile_);
@@ -162,8 +153,6 @@ std::vector<string16> SigninGlobalError::GetBubbleViewMessages() {
case GoogleServiceAuthError::NONE:
return messages;
- // TODO(rogerta): use account id in error messages.
-
// User credentials are invalid (bad acct, etc).
case GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS:
case GoogleServiceAuthError::ACCOUNT_DELETED:
diff --git a/chrome/browser/signin/signin_global_error.h b/chrome/browser/signin/signin_global_error.h
index d8852a7..1667031 100644
--- a/chrome/browser/signin/signin_global_error.h
+++ b/chrome/browser/signin/signin_global_error.h
@@ -25,15 +25,12 @@ class SigninGlobalError : public GlobalError {
AuthStatusProvider();
virtual ~AuthStatusProvider();
- // Returns the account id with the status specified by GetAuthStatus().
- virtual std::string GetAccountId() const = 0;
-
// API invoked by SigninGlobalError to get the current auth status of
// the various signed in services.
virtual GoogleServiceAuthError GetAuthStatus() const = 0;
};
- explicit SigninGlobalError(Profile* profile);
+ SigninGlobalError(Profile* profile);
virtual ~SigninGlobalError();
// Adds a provider which the SigninGlobalError object will start querying for
@@ -47,8 +44,6 @@ class SigninGlobalError : public GlobalError {
// Invoked when the auth status of an AuthStatusProvider has changed.
void AuthStatusChanged();
- std::string GetAccountIdOfLastAuthError() const { return account_id_; }
-
GoogleServiceAuthError GetLastAuthError() const { return auth_error_; }
// GlobalError implementation.
@@ -71,9 +66,6 @@ class SigninGlobalError : public GlobalError {
private:
std::set<const AuthStatusProvider*> provider_set_;
- // The account that generated the last auth error.
- std::string account_id_;
-
// The auth error detected the last time AuthStatusChanged() was invoked (or
// NONE if AuthStatusChanged() has never been invoked).
GoogleServiceAuthError auth_error_;
diff --git a/chrome/browser/signin/signin_global_error_unittest.cc b/chrome/browser/signin/signin_global_error_unittest.cc
index 1d91972..ade065e 100644
--- a/chrome/browser/signin/signin_global_error_unittest.cc
+++ b/chrome/browser/signin/signin_global_error_unittest.cc
@@ -17,9 +17,6 @@
#include "content/public/test/test_browser_thread_bundle.h"
#include "testing/gtest/include/gtest/gtest.h"
-static const char kTestAccountId[] = "testuser@test.com";
-static const char kOtherTestAccountId[] = "otheruser@test.com";
-
class SigninGlobalErrorTest : public testing::Test {
public:
virtual void SetUp() OVERRIDE {
@@ -30,7 +27,7 @@ class SigninGlobalErrorTest : public testing::Test {
SigninManagerFactory::GetInstance()->SetTestingFactoryAndUse(
profile_.get(), FakeSigninManagerBase::Build));
profile_->GetPrefs()->SetString(
- prefs::kGoogleServicesUsername, kTestAccountId);
+ prefs::kGoogleServicesUsername, "testuser@test.com");
manager->Initialize(profile_.get(), NULL);
global_error_ = SigninGlobalError::GetForProfile(profile_.get());
}
@@ -59,7 +56,7 @@ TEST_F(SigninGlobalErrorTest, ErrorAuthStatusProvider) {
ASSERT_FALSE(global_error_->HasMenuItem());
{
FakeAuthStatusProvider error_provider(global_error_);
- error_provider.SetAuthError(kTestAccountId, GoogleServiceAuthError(
+ error_provider.SetAuthError(GoogleServiceAuthError(
GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS));
ASSERT_TRUE(global_error_->HasMenuItem());
}
@@ -76,60 +73,17 @@ TEST_F(SigninGlobalErrorTest, AuthStatusProviderErrorTransition) {
FakeAuthStatusProvider provider1(global_error_);
ASSERT_FALSE(global_error_->HasMenuItem());
provider0.SetAuthError(
- kTestAccountId,
GoogleServiceAuthError(
GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS));
ASSERT_TRUE(global_error_->HasMenuItem());
provider1.SetAuthError(
- kTestAccountId,
GoogleServiceAuthError(GoogleServiceAuthError::ACCOUNT_DISABLED));
ASSERT_TRUE(global_error_->HasMenuItem());
// Now resolve the auth errors - the menu item should go away.
- provider0.SetAuthError(kTestAccountId,
- GoogleServiceAuthError::AuthErrorNone());
- ASSERT_TRUE(global_error_->HasMenuItem());
- provider1.SetAuthError(kTestAccountId,
- GoogleServiceAuthError::AuthErrorNone());
- ASSERT_FALSE(global_error_->HasMenuItem());
- }
- ASSERT_FALSE(global_error_->HasMenuItem());
-}
-
-TEST_F(SigninGlobalErrorTest, AuthStatusProviderAccountTransition) {
- {
- FakeAuthStatusProvider provider0(global_error_);
- FakeAuthStatusProvider provider1(global_error_);
- ASSERT_FALSE(global_error_->HasMenuItem());
-
- provider0.SetAuthError(
- kTestAccountId,
- GoogleServiceAuthError(
- GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS));
- provider1.SetAuthError(
- kOtherTestAccountId,
- GoogleServiceAuthError(GoogleServiceAuthError::NONE));
+ provider0.SetAuthError(GoogleServiceAuthError::AuthErrorNone());
ASSERT_TRUE(global_error_->HasMenuItem());
- ASSERT_STREQ(kTestAccountId,
- global_error_->GetAccountIdOfLastAuthError().c_str());
-
- // Swap providers reporting errors.
- provider1.set_error_without_status_change(
- GoogleServiceAuthError(
- GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS));
- provider0.set_error_without_status_change(
- GoogleServiceAuthError(GoogleServiceAuthError::NONE));
- global_error_->AuthStatusChanged();
- ASSERT_TRUE(global_error_->HasMenuItem());
- ASSERT_STREQ(kOtherTestAccountId,
- global_error_->GetAccountIdOfLastAuthError().c_str());
-
- // Now resolve the auth errors - the menu item should go away.
- provider0.set_error_without_status_change(
- GoogleServiceAuthError::AuthErrorNone());
- provider1.set_error_without_status_change(
- GoogleServiceAuthError::AuthErrorNone());
- global_error_->AuthStatusChanged();
+ provider1.SetAuthError(GoogleServiceAuthError::AuthErrorNone());
ASSERT_FALSE(global_error_->HasMenuItem());
}
ASSERT_FALSE(global_error_->HasMenuItem());
@@ -162,8 +116,7 @@ TEST_F(SigninGlobalErrorTest, AuthStatusEnumerateAllErrors) {
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(table); ++i) {
FakeAuthStatusProvider provider(global_error_);
- provider.SetAuthError(kTestAccountId,
- GoogleServiceAuthError(table[i].error_state));
+ provider.SetAuthError(GoogleServiceAuthError(table[i].error_state));
EXPECT_EQ(global_error_->HasMenuItem(), table[i].is_error);
// Only on chromeos do we have a separate menu item - on other platforms
// there's code in WrenchMenuModel to re-use the "sign in to chrome"
diff --git a/chrome/browser/signin/signin_manager_unittest.cc b/chrome/browser/signin/signin_manager_unittest.cc
index 60e0520..adcd4e5 100644
--- a/chrome/browser/signin/signin_manager_unittest.cc
+++ b/chrome/browser/signin/signin_manager_unittest.cc
@@ -15,7 +15,6 @@
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/prefs/browser_prefs.h"
#include "chrome/browser/signin/chrome_signin_manager_delegate.h"
-#include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/browser/signin/token_service.h"
#include "chrome/browser/signin/token_service_unittest.h"
#include "chrome/common/pref_names.h"
@@ -48,31 +47,20 @@ const char kGetTokenPairValidResponse[] =
const char kUberAuthTokenURLFormat[] = "?source=%s&issueuberauth=1";
-BrowserContextKeyedService* SigninManagerBuild(
- content::BrowserContext* context) {
- SigninManager* service = NULL;
- Profile* profile = static_cast<Profile*>(context);
- service = new SigninManager(
- scoped_ptr<SigninManagerDelegate>(
- new ChromeSigninManagerDelegate(profile)));
- return service;
-}
-
} // namespace
class SigninManagerTest : public TokenServiceTestHarness {
public:
- SigninManagerTest() : manager_(NULL) {}
- virtual ~SigninManagerTest() {}
-
virtual void SetUp() OVERRIDE {
- manager_ = NULL;
prefs_.reset(new TestingPrefServiceSimple);
chrome::RegisterLocalState(prefs_->registry());
TestingBrowserProcess::GetGlobal()->SetLocalState(
prefs_.get());
TokenServiceTestHarness::SetUp();
+ manager_.reset(new SigninManager(
+ scoped_ptr<SigninManagerDelegate>(
+ new ChromeSigninManagerDelegate(profile()))));
google_login_success_.ListenFor(
chrome::NOTIFICATION_GOOGLE_SIGNIN_SUCCESSFUL,
content::Source<Profile>(profile()));
@@ -83,35 +71,13 @@ class SigninManagerTest : public TokenServiceTestHarness {
virtual void TearDown() OVERRIDE {
// Destroy the SigninManager here, because it relies on profile() which is
// freed in the base class.
- if (naked_manager_) {
- naked_manager_->Shutdown();
- naked_manager_.reset(NULL);
- }
+ manager_->Shutdown();
+ manager_.reset(NULL);
TestingBrowserProcess::GetGlobal()->SetLocalState(NULL);
prefs_.reset(NULL);
TokenServiceTestHarness::TearDown();
}
- // Create a signin manager as a service if other code will try to get it as
- // a PKS.
- void CreateSigninManagerAsService() {
- DCHECK(!manager_);
- DCHECK(!naked_manager_);
- manager_ = static_cast<SigninManager*>(
- SigninManagerFactory::GetInstance()->SetTestingFactoryAndUse(
- profile(), SigninManagerBuild));
- }
-
- // Create a naked signin manager if integration with PKSs is not needed.
- void CreateNakedSigninManager() {
- DCHECK(!manager_);
- naked_manager_.reset(new SigninManager(
- scoped_ptr<SigninManagerDelegate>(
- new ChromeSigninManagerDelegate(profile()))));
-
- manager_ = naked_manager_.get();
- }
-
void SetupFetcherAndComplete(const GURL& url,
int response_code,
const net::ResponseCookies& cookies,
@@ -194,6 +160,14 @@ class SigninManagerTest : public TokenServiceTestHarness {
// Should go into token service and stop.
EXPECT_EQ(1U, google_login_success_.size());
EXPECT_EQ(0U, google_login_failure_.size());
+
+ // Should persist across resets.
+ manager_->Shutdown();
+ manager_.reset(new SigninManager(
+ scoped_ptr<SigninManagerDelegate>(
+ new ChromeSigninManagerDelegate(profile()))));
+ manager_->Initialize(profile(), NULL);
+ EXPECT_EQ("user@gmail.com", manager_->GetAuthenticatedUsername());
}
// Helper method that wraps the logic when signin with credentials
@@ -226,8 +200,7 @@ class SigninManagerTest : public TokenServiceTestHarness {
}
net::TestURLFetcherFactory factory_;
- scoped_ptr<SigninManager> naked_manager_;
- SigninManager* manager_;
+ scoped_ptr<SigninManager> manager_;
content::TestNotificationTracker google_login_success_;
content::TestNotificationTracker google_login_failure_;
std::vector<std::string> oauth_tokens_fetched_;
@@ -236,7 +209,6 @@ class SigninManagerTest : public TokenServiceTestHarness {
};
TEST_F(SigninManagerTest, SignInWithCredentials) {
- CreateSigninManagerAsService();
manager_->Initialize(profile(), NULL);
EXPECT_TRUE(manager_->GetAuthenticatedUsername().empty());
@@ -247,17 +219,9 @@ TEST_F(SigninManagerTest, SignInWithCredentials) {
SigninManager::OAuthTokenFetchedCallback());
ExpectSignInWithCredentialsSuccess();
-
- // Should persist across resets.
- manager_->Shutdown();
- manager_ = NULL;
- CreateNakedSigninManager();
- manager_->Initialize(profile(), NULL);
- EXPECT_EQ("user@gmail.com", manager_->GetAuthenticatedUsername());
}
TEST_F(SigninManagerTest, SignInWithCredentialsNonCanonicalEmail) {
- CreateSigninManagerAsService();
manager_->Initialize(profile(), NULL);
EXPECT_TRUE(manager_->GetAuthenticatedUsername().empty());
@@ -271,7 +235,6 @@ TEST_F(SigninManagerTest, SignInWithCredentialsNonCanonicalEmail) {
}
TEST_F(SigninManagerTest, SignInWithCredentialsWrongEmail) {
- CreateSigninManagerAsService();
manager_->Initialize(profile(), NULL);
EXPECT_TRUE(manager_->GetAuthenticatedUsername().empty());
@@ -287,7 +250,6 @@ TEST_F(SigninManagerTest, SignInWithCredentialsWrongEmail) {
}
TEST_F(SigninManagerTest, SignInWithCredentialsEmptyPasswordValidCookie) {
- CreateSigninManagerAsService();
manager_->Initialize(profile(), NULL);
EXPECT_TRUE(manager_->GetAuthenticatedUsername().empty());
@@ -315,7 +277,6 @@ TEST_F(SigninManagerTest, SignInWithCredentialsEmptyPasswordValidCookie) {
}
TEST_F(SigninManagerTest, SignInWithCredentialsEmptyPasswordNoValidCookie) {
- CreateSigninManagerAsService();
manager_->Initialize(profile(), NULL);
EXPECT_TRUE(manager_->GetAuthenticatedUsername().empty());
@@ -334,7 +295,6 @@ TEST_F(SigninManagerTest, SignInWithCredentialsEmptyPasswordNoValidCookie) {
}
TEST_F(SigninManagerTest, SignInWithCredentialsEmptyPasswordInValidCookie) {
- CreateSigninManagerAsService();
manager_->Initialize(profile(), NULL);
EXPECT_TRUE(manager_->GetAuthenticatedUsername().empty());
@@ -363,7 +323,6 @@ TEST_F(SigninManagerTest, SignInWithCredentialsEmptyPasswordInValidCookie) {
}
TEST_F(SigninManagerTest, SignInWithCredentialsCallbackComplete) {
- CreateSigninManagerAsService();
manager_->Initialize(profile(), NULL);
EXPECT_TRUE(manager_->GetAuthenticatedUsername().empty());
@@ -383,7 +342,6 @@ TEST_F(SigninManagerTest, SignInWithCredentialsCallbackComplete) {
}
TEST_F(SigninManagerTest, SignInWithCredentialsCallbackCancel) {
- CreateSigninManagerAsService();
manager_->Initialize(profile(), NULL);
EXPECT_TRUE(manager_->GetAuthenticatedUsername().empty());
@@ -404,7 +362,6 @@ TEST_F(SigninManagerTest, SignInWithCredentialsCallbackCancel) {
}
TEST_F(SigninManagerTest, SignOut) {
- CreateSigninManagerAsService();
manager_->Initialize(profile(), NULL);
SigninManager::OAuthTokenFetchedCallback dummy;
manager_->StartSignInWithCredentials("0", "user@gmail.com", "password",
@@ -415,14 +372,14 @@ TEST_F(SigninManagerTest, SignOut) {
EXPECT_TRUE(manager_->GetAuthenticatedUsername().empty());
// Should not be persisted anymore
manager_->Shutdown();
- manager_ = NULL;
- CreateNakedSigninManager();
+ manager_.reset(new SigninManager(
+ scoped_ptr<SigninManagerDelegate>(
+ new ChromeSigninManagerDelegate(profile()))));
manager_->Initialize(profile(), NULL);
EXPECT_TRUE(manager_->GetAuthenticatedUsername().empty());
}
TEST_F(SigninManagerTest, SignOutMidConnect) {
- CreateSigninManagerAsService();
manager_->Initialize(profile(), NULL);
SigninManager::OAuthTokenFetchedCallback dummy;
manager_->StartSignInWithCredentials("0", "user@gmail.com", "password",
@@ -437,7 +394,6 @@ TEST_F(SigninManagerTest, SignOutMidConnect) {
}
TEST_F(SigninManagerTest, SignOutWhileProhibited) {
- CreateSigninManagerAsService();
manager_->Initialize(profile(), NULL);
EXPECT_TRUE(manager_->GetAuthenticatedUsername().empty());
@@ -470,7 +426,6 @@ TEST_F(SigninManagerTest, TestIsWebBasedSigninFlowURL) {
TEST_F(SigninManagerTest, Prohibited) {
g_browser_process->local_state()->SetString(
prefs::kGoogleServicesUsernamePattern, ".*@google.com");
- CreateNakedSigninManager();
manager_->Initialize(profile(), g_browser_process->local_state());
EXPECT_TRUE(manager_->IsAllowedUsername("test@google.com"));
EXPECT_TRUE(manager_->IsAllowedUsername("happy@google.com"));
@@ -484,7 +439,6 @@ TEST_F(SigninManagerTest, TestAlternateWildcard) {
// the admin entered ".*@google.com").
g_browser_process->local_state()->SetString(
prefs::kGoogleServicesUsernamePattern, "*@google.com");
- CreateNakedSigninManager();
manager_->Initialize(profile(), g_browser_process->local_state());
EXPECT_TRUE(manager_->IsAllowedUsername("test@google.com"));
EXPECT_TRUE(manager_->IsAllowedUsername("happy@google.com"));
@@ -498,7 +452,6 @@ TEST_F(SigninManagerTest, ProhibitedAtStartup) {
"monkey@invalid.com");
g_browser_process->local_state()->SetString(
prefs::kGoogleServicesUsernamePattern, ".*@google.com");
- CreateNakedSigninManager();
manager_->Initialize(profile(), g_browser_process->local_state());
// Currently signed in user is prohibited by policy, so should be signed out.
EXPECT_EQ("", manager_->GetAuthenticatedUsername());
@@ -507,7 +460,6 @@ TEST_F(SigninManagerTest, ProhibitedAtStartup) {
TEST_F(SigninManagerTest, ProhibitedAfterStartup) {
std::string user("monkey@invalid.com");
profile()->GetPrefs()->SetString(prefs::kGoogleServicesUsername, user);
- CreateNakedSigninManager();
manager_->Initialize(profile(), g_browser_process->local_state());
EXPECT_EQ(user, manager_->GetAuthenticatedUsername());
// Update the profile - user should be signed out.
@@ -517,7 +469,6 @@ TEST_F(SigninManagerTest, ProhibitedAfterStartup) {
}
TEST_F(SigninManagerTest, ExternalSignIn) {
- CreateNakedSigninManager();
manager_->Initialize(profile(), g_browser_process->local_state());
EXPECT_EQ("",
profile()->GetPrefs()->GetString(prefs::kGoogleServicesUsername));
diff --git a/chrome/browser/signin/token_service_unittest.cc b/chrome/browser/signin/token_service_unittest.cc
index d6e871c..f934764 100644
--- a/chrome/browser/signin/token_service_unittest.cc
+++ b/chrome/browser/signin/token_service_unittest.cc
@@ -11,8 +11,6 @@
#include "base/command_line.h"
#include "base/run_loop.h"
#include "chrome/browser/chrome_notification_types.h"
-#include "chrome/browser/signin/fake_signin_manager.h"
-#include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/browser/signin/token_service_factory.h"
#include "chrome/browser/webdata/token_web_data.h"
#include "chrome/common/chrome_switches.h"
@@ -51,9 +49,7 @@ void TokenFailedTracker::Observe(int type,
}
}
-TokenServiceTestHarness::TokenServiceTestHarness()
- : signin_manager_(NULL), service_(NULL) {
-}
+TokenServiceTestHarness::TokenServiceTestHarness() {}
TokenServiceTestHarness::~TokenServiceTestHarness() {}
@@ -90,15 +86,6 @@ scoped_ptr<TestingProfile> TokenServiceTestHarness::CreateProfile() {
return make_scoped_ptr(new TestingProfile());
}
-void TokenServiceTestHarness::CreateSigninManager(const std::string& username) {
- signin_manager_ =
- static_cast<FakeSigninManagerBase*>(
- SigninManagerFactory::GetInstance()->SetTestingFactoryAndUse(
- profile(), FakeSigninManagerBase::Build));
- signin_manager_->Initialize(profile(), NULL);
- signin_manager_->SetAuthenticatedUsername(username);
-}
-
void TokenServiceTestHarness::TearDown() {
// You have to destroy the profile before the threads are shut down.
profile_.reset();
@@ -162,7 +149,6 @@ TEST_F(TokenServiceTest, NotificationSuccess) {
TEST_F(TokenServiceTest, NotificationOAuthLoginTokenSuccess) {
EXPECT_EQ(0U, success_tracker()->size());
EXPECT_EQ(0U, failure_tracker()->size());
- CreateSigninManager("test@gmail.com");
service()->OnClientOAuthSuccess(
GaiaAuthConsumer::ClientOAuthResult("rt1", "at1", 3600));
EXPECT_EQ(1U, success_tracker()->size());
@@ -178,7 +164,6 @@ TEST_F(TokenServiceTest, NotificationOAuthLoginTokenSuccess) {
TEST_F(TokenServiceTest, NotificationFailed) {
EXPECT_EQ(0U, success_tracker()->size());
EXPECT_EQ(0U, failure_tracker()->size());
- CreateSigninManager("test@gmail.com");
GoogleServiceAuthError error(GoogleServiceAuthError::REQUEST_CANCELED);
service()->OnIssueAuthTokenFailure(GaiaConstants::kSyncService, error);
EXPECT_EQ(0U, success_tracker()->size());
@@ -194,7 +179,6 @@ TEST_F(TokenServiceTest, NotificationFailed) {
TEST_F(TokenServiceTest, NotificationOAuthLoginTokenFailed) {
EXPECT_EQ(0U, success_tracker()->size());
EXPECT_EQ(0U, failure_tracker()->size());
- CreateSigninManager("test@gmail.com");
GoogleServiceAuthError error(GoogleServiceAuthError::REQUEST_CANCELED);
service()->OnClientOAuthFailure(error);
EXPECT_EQ(0U, success_tracker()->size());
@@ -227,7 +211,6 @@ TEST_F(TokenServiceTest, OnTokenSuccessUpdate) {
}
TEST_F(TokenServiceTest, OnOAuth2LoginTokenSuccessUpdate) {
- CreateSigninManager("test@gmail.com");
EXPECT_FALSE(service()->HasOAuthLoginToken());
service()->OnClientOAuthSuccess(
@@ -247,7 +230,6 @@ TEST_F(TokenServiceTest, OnOAuth2LoginTokenSuccessUpdate) {
}
TEST_F(TokenServiceTest, OnTokenSuccess) {
- CreateSigninManager("test@gmail.com");
// Don't "start fetching", just go ahead and issue the callback.
service()->OnIssueAuthTokenSuccess(GaiaConstants::kSyncService, "token");
EXPECT_TRUE(service()->HasTokenForService(GaiaConstants::kSyncService));
@@ -258,7 +240,6 @@ TEST_F(TokenServiceTest, OnTokenSuccess) {
}
TEST_F(TokenServiceTest, Reset) {
- CreateSigninManager("test@gmail.com");
net::TestURLFetcherFactory factory;
service()->StartFetchingTokens();
// You have to call delegates by hand with the test fetcher,
@@ -302,7 +283,6 @@ TEST_F(TokenServiceTest, FullIntegration) {
}
TEST_F(TokenServiceTest, LoadTokensIntoMemoryBasic) {
- CreateSigninManager("test@gmail.com");
// Validate that the method sets proper data in notifications and map.
std::map<std::string, std::string> db_tokens;
std::map<std::string, std::string> memory_tokens;
@@ -325,7 +305,6 @@ TEST_F(TokenServiceTest, LoadTokensIntoMemoryBasic) {
}
TEST_F(TokenServiceTest, LoadTokensIntoMemoryAdvanced) {
- CreateSigninManager("test@gmail.com");
// LoadTokensIntoMemory should avoid setting tokens already in the
// token map.
std::map<std::string, std::string> db_tokens;
@@ -355,7 +334,6 @@ TEST_F(TokenServiceTest, LoadTokensIntoMemoryAdvanced) {
}
TEST_F(TokenServiceTest, WebDBLoadIntegration) {
- CreateSigninManager("test@gmail.com");
service()->LoadTokensFromDB();
base::RunLoop().RunUntilIdle();
EXPECT_TRUE(service()->TokensLoadedFromDB());
@@ -379,7 +357,6 @@ TEST_F(TokenServiceTest, WebDBLoadIntegration) {
}
TEST_F(TokenServiceTest, MultipleLoadResetIntegration) {
- CreateSigninManager("test@gmail.com");
// Should result in DB write.
service()->OnIssueAuthTokenSuccess(GaiaConstants::kSyncService, "token");
service()->ResetCredentialsInMemory();
diff --git a/chrome/browser/signin/token_service_unittest.h b/chrome/browser/signin/token_service_unittest.h
index 8e89292..3039be3 100644
--- a/chrome/browser/signin/token_service_unittest.h
+++ b/chrome/browser/signin/token_service_unittest.h
@@ -18,8 +18,6 @@
#include "google_apis/gaia/gaia_auth_consumer.h"
#include "testing/gtest/include/gtest/gtest.h"
-class FakeSigninManagerBase;
-
// TestNotificationTracker doesn't do a deep copy on the notification details.
// We have to in order to read it out, or we have a bad ptr, since the details
// are a reference on the stack.
@@ -75,12 +73,9 @@ class TokenServiceTestHarness : public testing::Test {
TokenAvailableTracker* success_tracker() { return &success_tracker_; }
TokenFailedTracker* failure_tracker() { return &failure_tracker_; }
- void CreateSigninManager(const std::string& username);
-
private:
content::TestBrowserThreadBundle thread_bundle_;
- FakeSigninManagerBase* signin_manager_;
TokenService* service_;
TokenAvailableTracker success_tracker_;
TokenFailedTracker failure_tracker_;
diff --git a/chrome/browser/signin/ubertoken_fetcher_unittest.cc b/chrome/browser/signin/ubertoken_fetcher_unittest.cc
index fb68517..58464d8 100644
--- a/chrome/browser/signin/ubertoken_fetcher_unittest.cc
+++ b/chrome/browser/signin/ubertoken_fetcher_unittest.cc
@@ -6,9 +6,7 @@
#include "base/memory/scoped_ptr.h"
#include "chrome/browser/signin/fake_profile_oauth2_token_service.h"
-#include "chrome/browser/signin/fake_signin_manager.h"
#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
-#include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/browser/signin/token_service_unittest.h"
#include "google_apis/gaia/gaia_constants.h"
#include "net/url_request/test_url_fetcher_factory.h"
@@ -50,7 +48,6 @@ class UbertokenFetcherTest : public TokenServiceTestHarness {
TokenServiceTestHarness::SetUp();
UpdateCredentialsOnService();
fetcher_.reset(new UbertokenFetcher(profile(), &consumer_));
- CreateSigninManager("test@gmail.com");
}
virtual scoped_ptr<TestingProfile> CreateProfile() OVERRIDE {
diff --git a/chrome/browser/sync/profile_sync_service.cc b/chrome/browser/sync/profile_sync_service.cc
index 8c613b0..cdcb655 100644
--- a/chrome/browser/sync/profile_sync_service.cc
+++ b/chrome/browser/sync/profile_sync_service.cc
@@ -31,7 +31,6 @@
#include "chrome/browser/signin/about_signin_internals.h"
#include "chrome/browser/signin/about_signin_internals_factory.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/signin/token_service.h"
@@ -1097,7 +1096,7 @@ void ProfileSyncService::UpdateAuthErrorState(const AuthError& error) {
// Fan the notification out to interested UI-thread components. Notify the
// SigninGlobalError first so it reflects the latest auth state before we
// notify observers.
- if (profile_ && !use_oauth2_token_)
+ if (profile_)
SigninGlobalError::GetForProfile(profile_)->AuthStatusChanged();
NotifyObservers();
@@ -1449,11 +1448,6 @@ const AuthError& ProfileSyncService::GetAuthError() const {
return last_auth_error_;
}
-std::string ProfileSyncService::GetAccountId() const {
- return ProfileOAuth2TokenServiceFactory::GetForProfile(profile_)->
- GetPrimaryAccountId();
-}
-
GoogleServiceAuthError ProfileSyncService::GetAuthStatus() const {
// If waiting_for_auth() returns true, it means that ProfileSyncService has
// detected that the user has just successfully completed gaia signin, but the
diff --git a/chrome/browser/sync/profile_sync_service.h b/chrome/browser/sync/profile_sync_service.h
index a0a126b..0810178 100644
--- a/chrome/browser/sync/profile_sync_service.h
+++ b/chrome/browser/sync/profile_sync_service.h
@@ -351,6 +351,9 @@ class ProfileSyncService : public ProfileSyncServiceBase,
virtual bool IsPassphraseRequired() const OVERRIDE;
virtual syncer::ModelTypeSet GetEncryptedDataTypes() const OVERRIDE;
+ // Update the last auth error and notify observers of error state.
+ void UpdateAuthErrorState(const GoogleServiceAuthError& error);
+
// Called when a user chooses which data types to sync as part of the sync
// setup wizard. |sync_everything| represents whether they chose the
// "keep everything synced" option; if true, |chosen_types| will be ignored
@@ -449,7 +452,6 @@ class ProfileSyncService : public ProfileSyncServiceBase,
virtual bool IsManaged() const;
// SigninGlobalError::AuthStatusProvider implementation.
- virtual std::string GetAccountId() const OVERRIDE;
virtual GoogleServiceAuthError GetAuthStatus() const OVERRIDE;
// syncer::UnrecoverableErrorHandler implementation.
@@ -718,9 +720,6 @@ class ProfileSyncService : public ProfileSyncServiceBase,
friend class TestProfileSyncService;
FRIEND_TEST_ALL_PREFIXES(ProfileSyncServiceTest, InitialState);
- // Update the last auth error and notify observers of error state.
- void UpdateAuthErrorState(const GoogleServiceAuthError& error);
-
// Detects and attempts to recover from a previous improper datatype
// configuration where Keep Everything Synced and the preferred types were
// not correctly set.
diff --git a/chrome/browser/sync/sync_ui_util_unittest.cc b/chrome/browser/sync/sync_ui_util_unittest.cc
index 8b44988..7246f8f 100644
--- a/chrome/browser/sync/sync_ui_util_unittest.cc
+++ b/chrome/browser/sync/sync_ui_util_unittest.cc
@@ -43,8 +43,6 @@ enum DistinctState {
namespace {
-const char kTestUser[] = "test_user@test.com";
-
// Utility function to test that GetStatusLabelsForSyncGlobalError returns
// the correct results for the given states.
void VerifySyncGlobalErrorResult(NiceMock<ProfileSyncServiceMock>* service,
@@ -243,9 +241,8 @@ void GetDistinctCase(ProfileSyncServiceMock& service,
EXPECT_CALL(service, QueryDetailedSyncStatus(_))
.WillRepeatedly(DoAll(SetArgPointee<0>(status),
Return(false)));
- provider->SetAuthError(
- kTestUser,
- GoogleServiceAuthError(GoogleServiceAuthError::SERVICE_UNAVAILABLE));
+ provider->SetAuthError(GoogleServiceAuthError(
+ GoogleServiceAuthError::SERVICE_UNAVAILABLE));
EXPECT_CALL(service, HasUnrecoverableError())
.WillRepeatedly(Return(false));
return;
@@ -330,7 +327,7 @@ TEST_F(SyncUIUtilTest, DistinctCasesReportUniqueMessageSets) {
GoogleServiceAuthError error = GoogleServiceAuthError::AuthErrorNone();
EXPECT_CALL(service, GetAuthError()).WillRepeatedly(ReturnRef(error));
FakeSigninManagerForSyncUIUtilTest signin(profile.get());
- signin.SetAuthenticatedUsername(kTestUser);
+ signin.SetAuthenticatedUsername("test_user@test.com");
scoped_ptr<FakeAuthStatusProvider> provider(
new FakeAuthStatusProvider(
SigninGlobalError::GetForProfile(profile.get())));
@@ -370,7 +367,7 @@ TEST_F(SyncUIUtilTest, HtmlNotIncludedInStatusIfNotRequested) {
GoogleServiceAuthError error = GoogleServiceAuthError::AuthErrorNone();
EXPECT_CALL(service, GetAuthError()).WillRepeatedly(ReturnRef(error));
FakeSigninManagerForSyncUIUtilTest signin(profile.get());
- signin.SetAuthenticatedUsername(kTestUser);
+ signin.SetAuthenticatedUsername("test_user@test.com");
scoped_ptr<FakeAuthStatusProvider> provider(
new FakeAuthStatusProvider(
SigninGlobalError::GetForProfile(profile.get())));
diff --git a/chrome/browser/ui/cocoa/browser_window_controller_unittest.mm b/chrome/browser/ui/cocoa/browser_window_controller_unittest.mm
index 22576b4..470961b 100644
--- a/chrome/browser/ui/cocoa/browser_window_controller_unittest.mm
+++ b/chrome/browser/ui/cocoa/browser_window_controller_unittest.mm
@@ -713,7 +713,7 @@ TEST_F(BrowserWindowControllerTest, TestSigninMenuItemAuthError) {
FakeAuthStatusProvider provider(SigninGlobalError::GetForProfile(profile()));
GoogleServiceAuthError error(
GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS);
- provider.SetAuthError("user@gmail.com", error);
+ provider.SetAuthError(error);
[BrowserWindowController updateSigninItem:syncMenuItem
shouldShow:YES
currentProfile:profile()];
diff --git a/chrome/browser/ui/webui/sync_setup_handler_unittest.cc b/chrome/browser/ui/webui/sync_setup_handler_unittest.cc
index a3372f0..5a973e8 100644
--- a/chrome/browser/ui/webui/sync_setup_handler_unittest.cc
+++ b/chrome/browser/ui/webui/sync_setup_handler_unittest.cc
@@ -899,7 +899,7 @@ TEST_F(SyncSetupHandlerTest, ShowSigninOnAuthError) {
mock_signin_->SetAuthenticatedUsername(kTestUser);
FakeAuthStatusProvider provider(
SigninGlobalError::GetForProfile(profile_.get()));
- provider.SetAuthError(kTestUser, error_);
+ provider.SetAuthError(error_);
EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn())
.WillRepeatedly(Return(true));
EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable())