diff options
author | akalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-24 00:15:52 +0000 |
---|---|---|
committer | akalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-24 00:15:52 +0000 |
commit | 5a566b911e935a5cae25da0f2809e9635c07b1d8 (patch) | |
tree | 3c444c9d54f40055af411427e14f763d8cfe7029 | |
parent | 111bea77d0114189d18c732ef3bb975766461b22 (diff) | |
download | chromium_src-5a566b911e935a5cae25da0f2809e9635c07b1d8.zip chromium_src-5a566b911e935a5cae25da0f2809e9635c07b1d8.tar.gz chromium_src-5a566b911e935a5cae25da0f2809e9635c07b1d8.tar.bz2 |
[Sync] Remove sync/util/oauth.{h,cc} and dependencies
Remove --enable-sync-oauth switch.
Clean up some headers.
BUG=113723
TEST=
Review URL: http://codereview.chromium.org/9455005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@123378 0039d316-1c4b-4281-b951-d872f2087c98
25 files changed, 23 insertions, 645 deletions
diff --git a/chrome/browser/chromeos/login/online_attempt.cc b/chrome/browser/chromeos/login/online_attempt.cc index 4569f17..955cee2 100644 --- a/chrome/browser/chromeos/login/online_attempt.cc +++ b/chrome/browser/chromeos/login/online_attempt.cc @@ -29,7 +29,8 @@ namespace { // The service scope of the OAuth v2 token that ChromeOS login will be // requesting. -const char* kServiceScopeChromeOS = GaiaConstants::kSyncServiceOAuth; +const char kServiceScopeChromeOS[] = + "https://www.googleapis.com/auth/chromesync"; } diff --git a/chrome/browser/signin/signin_manager.cc b/chrome/browser/signin/signin_manager.cc index 5f6c987..491007a 100644 --- a/chrome/browser/signin/signin_manager.cc +++ b/chrome/browser/signin/signin_manager.cc @@ -14,7 +14,6 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/browser/signin/token_service.h" #include "chrome/browser/sync/profile_sync_service.h" -#include "chrome/browser/sync/util/oauth.h" #include "chrome/common/chrome_notification_types.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/net/gaia/gaia_constants.h" @@ -87,7 +86,6 @@ void SigninManager::SetAuthenticatedUsername(const std::string& username) { } void SigninManager::PrepareForSignin() { - DCHECK(!browser_sync::IsUsingOAuth()); DCHECK(possibly_invalid_username_.empty()); // This attempt is either 1) the user trying to establish initial sync, or // 2) trying to refresh credentials for an existing username. If it is 2, we @@ -97,34 +95,11 @@ void SigninManager::PrepareForSignin() { ClearTransientSigninData(); } -void SigninManager::PrepareForOAuthSignin() { - DCHECK(browser_sync::IsUsingOAuth()); -#if !defined(OS_CHROMEOS) - // The Sign out should clear the token service credentials. - // Note: In CHROMEOS we might have valid credentials but still need to - // set up 2-factor authentication. - DCHECK(!profile_->GetTokenService()->HasOAuthCredentials()); -#endif - ClearTransientSigninData(); -} - -// Users must always sign out before they sign in again. -void SigninManager::StartOAuthSignIn(const std::string& oauth1_request_token, - GaiaOAuthFetcher* fetcher) { - DCHECK(browser_sync::IsUsingOAuth()); - PrepareForOAuthSignin(); - oauth1_request_token_.assign(oauth1_request_token); - oauth_login_.reset(fetcher); - oauth_login_->StartOAuthGetAccessToken(oauth1_request_token_); - // TODO(rogerta?): Bug 92325: Expand Autologin to include OAuth signin -} - // Users must always sign out before they sign in again. void SigninManager::StartSignIn(const std::string& username, const std::string& password, const std::string& login_token, const std::string& login_captcha) { - DCHECK(!browser_sync::IsUsingOAuth()); DCHECK(authenticated_username_.empty() || username == authenticated_username_); PrepareForSignin(); @@ -153,7 +128,6 @@ void SigninManager::StartSignIn(const std::string& username, void SigninManager::ProvideSecondFactorAccessCode( const std::string& access_code) { - DCHECK(!browser_sync::IsUsingOAuth()); DCHECK(!possibly_invalid_username_.empty() && !password_.empty() && last_result_.data.empty()); @@ -181,9 +155,7 @@ void SigninManager::ClearTransientSigninData() { void SigninManager::SignOut() { DCHECK(IsInitialized()); - if (authenticated_username_.empty() && - !client_login_.get() && - !oauth_login_.get()) { + if (authenticated_username_.empty() && !client_login_.get()) { // Just exit if we aren't signed in (or in the process of signing in). // This avoids a perf regression because SignOut() is invoked on startup to // clean up any incomplete previous signin attempts. @@ -193,7 +165,6 @@ void SigninManager::SignOut() { ClearTransientSigninData(); authenticated_username_.clear(); profile_->GetPrefs()->ClearPref(prefs::kGoogleServicesUsername); - profile_->GetPrefs()->ClearPref(prefs::kSyncUsingOAuth); profile_->GetPrefs()->ClearPref(prefs::kIsGooglePlusUser); profile_->GetTokenService()->ResetCredentialsInMemory(); profile_->GetTokenService()->EraseTokensFromDB(); @@ -208,15 +179,12 @@ bool SigninManager::AuthInProgress() const { } void SigninManager::OnClientLoginSuccess(const ClientLoginResult& result) { - DCHECK(!browser_sync::IsUsingOAuth()); last_result_ = result; // Make a request for the canonical email address and services. client_login_->StartGetUserInfo(result.lsid); } -// NOTE: GetUserInfo is a ClientLogin request similar to OAuth's userinfo void SigninManager::OnGetUserInfoSuccess(const UserInfoMap& data) { - DCHECK(!browser_sync::IsUsingOAuth()); UserInfoMap::const_iterator email_iter = data.find(kGetInfoEmailKey); if (email_iter == data.end()) { OnGetUserInfoKeyNotFound(kGetInfoEmailKey); @@ -228,7 +196,6 @@ void SigninManager::OnGetUserInfoSuccess(const UserInfoMap& data) { possibly_invalid_username_.clear(); profile_->GetPrefs()->SetString(prefs::kGoogleServicesUsername, authenticated_username_); - profile_->GetPrefs()->SetBoolean(prefs::kSyncUsingOAuth, false); } UserInfoMap::const_iterator service_iter = data.find(kGetInfoServicesKey); @@ -259,7 +226,6 @@ void SigninManager::OnGetUserInfoSuccess(const UserInfoMap& data) { } void SigninManager::OnGetUserInfoKeyNotFound(const std::string& key) { - DCHECK(!browser_sync::IsUsingOAuth()); DCHECK(key == kGetInfoEmailKey); LOG(ERROR) << "Account is not associated with a valid email address. " << "Login failed."; @@ -268,13 +234,11 @@ void SigninManager::OnGetUserInfoKeyNotFound(const std::string& key) { } void SigninManager::OnGetUserInfoFailure(const GoogleServiceAuthError& error) { - DCHECK(!browser_sync::IsUsingOAuth()); LOG(ERROR) << "Unable to retreive the canonical email address. Login failed."; OnClientLoginFailure(error); } void SigninManager::OnTokenAuthFailure(const GoogleServiceAuthError& error) { - DCHECK(!browser_sync::IsUsingOAuth()); #if !defined(OS_CHROMEOS) DVLOG(1) << "Unable to retrieve the token auth."; CleanupNotificationRegistration(); @@ -282,7 +246,6 @@ void SigninManager::OnTokenAuthFailure(const GoogleServiceAuthError& error) { } void SigninManager::OnClientLoginFailure(const GoogleServiceAuthError& error) { - DCHECK(!browser_sync::IsUsingOAuth()); // If we got a bad ASP, prompt for an ASP again by forcing another TWO_FACTOR // error. bool invalid_gaia = error.state() == @@ -305,69 +268,6 @@ void SigninManager::OnClientLoginFailure(const GoogleServiceAuthError& error) { ClearTransientSigninData(); } -void SigninManager::OnOAuthGetAccessTokenSuccess(const std::string& token, - const std::string& secret) { - DCHECK(browser_sync::IsUsingOAuth()); - DVLOG(1) << "SigninManager::OnOAuthGetAccessTokenSuccess"; - profile_->GetTokenService()->UpdateOAuthCredentials(token, secret); -} - -void SigninManager::OnOAuthGetAccessTokenFailure( - const GoogleServiceAuthError& error) { - DCHECK(browser_sync::IsUsingOAuth()); - LOG(WARNING) << "SigninManager::OnOAuthGetAccessTokenFailure"; -} - -void SigninManager::OnOAuthWrapBridgeSuccess(const std::string& service_name, - const std::string& token, - const std::string& expires_in) { - DCHECK(browser_sync::IsUsingOAuth()); - DVLOG(1) << "SigninManager::OnOAuthWrapBridgeSuccess"; -} - -void SigninManager::OnOAuthWrapBridgeFailure( - const std::string& service_scope, - const GoogleServiceAuthError& error) { - DCHECK(browser_sync::IsUsingOAuth()); - LOG(WARNING) << "SigninManager::OnOAuthWrapBridgeFailure"; -} - -// NOTE: userinfo is an OAuth request similar to ClientLogin's GetUserInfo -void SigninManager::OnUserInfoSuccess(const std::string& email) { - DCHECK(browser_sync::IsUsingOAuth()); - - TokenService* token_service = profile_->GetTokenService(); - CHECK(token_service); - - // If |SignOut()| was called between the login start and |OnUserInfoSucess()|, - // then the OAuth credentials would have been cleared. - if (!token_service->HasOAuthCredentials()) - return; - - DVLOG(1) << "Sync signin for " << email << " is complete."; - last_login_auth_error_ = GoogleServiceAuthError::None(); - - authenticated_username_ = email; - profile_->GetPrefs()->SetString( - prefs::kGoogleServicesUsername, authenticated_username_); - profile_->GetPrefs()->SetBoolean(prefs::kSyncUsingOAuth, true); - - DCHECK(password_.empty()); - GoogleServiceSigninSuccessDetails details(authenticated_username_, ""); - content::NotificationService::current()->Notify( - chrome::NOTIFICATION_GOOGLE_SIGNIN_SUCCESSFUL, - content::Source<Profile>(profile_), - content::Details<const GoogleServiceSigninSuccessDetails>(&details)); - - DCHECK(token_service->HasOAuthCredentials()); - token_service->StartFetchingOAuthTokens(); -} - -void SigninManager::OnUserInfoFailure(const GoogleServiceAuthError& error) { - DCHECK(browser_sync::IsUsingOAuth()); - LOG(WARNING) << "SigninManager::OnUserInfoFailure"; -} - void SigninManager::Observe(int type, const content::NotificationSource& source, const content::NotificationDetails& details) { @@ -379,7 +279,6 @@ void SigninManager::Observe(int type, // If a GAIA service token has become available, use it to pre-login the // user to other services that depend on GAIA credentials. if (tok_details->service() == GaiaConstants::kGaiaService) { - DCHECK(!browser_sync::IsUsingOAuth()); if (client_login_.get() == NULL) { client_login_.reset(new GaiaAuthFetcher(this, GaiaConstants::kChromeSource, diff --git a/chrome/browser/signin/signin_manager.h b/chrome/browser/signin/signin_manager.h index 6224463..b840b3b 100644 --- a/chrome/browser/signin/signin_manager.h +++ b/chrome/browser/signin/signin_manager.h @@ -21,9 +21,9 @@ #include <string> #include "base/compiler_specific.h" +#include "base/gtest_prod_util.h" #include "base/logging.h" #include "base/memory/scoped_ptr.h" -#include "chrome/browser/net/gaia/gaia_oauth_fetcher.h" #include "chrome/browser/profiles/profile_keyed_service.h" #include "chrome/common/net/gaia/gaia_auth_consumer.h" #include "chrome/common/net/gaia/google_service_auth_error.h" @@ -47,7 +47,6 @@ struct GoogleServiceSigninSuccessDetails { }; class SigninManager : public GaiaAuthConsumer, - public GaiaOAuthConsumer, public content::NotificationObserver, public ProfileKeyedService { public: @@ -69,12 +68,6 @@ class SigninManager : public GaiaAuthConsumer, // (by platform / depending on StartBehavior). Bug 88109. void SetAuthenticatedUsername(const std::string& username); - // Attempt to sign in this user with OAuth. If successful, set a preference - // indicating the signed in user and send out a notification, then start - // fetching tokens for the user. SigninManager takes ownership of |fetcher|. - virtual void StartOAuthSignIn(const std::string& oauth1_request_token, - GaiaOAuthFetcher* fetcher); - // Attempt to sign in this user with ClientLogin. If successful, set a // preference indicating the signed in user and send out a notification, // then start fetching tokens for the user. @@ -113,20 +106,6 @@ class SigninManager : public GaiaAuthConsumer, const GoogleServiceAuthError& error) OVERRIDE; virtual void OnTokenAuthFailure(const GoogleServiceAuthError& error) OVERRIDE; - // GaiaOAuthConsumer - virtual void OnOAuthGetAccessTokenSuccess(const std::string& token, - const std::string& secret) OVERRIDE; - virtual void OnOAuthGetAccessTokenFailure( - const GoogleServiceAuthError& error) OVERRIDE; - virtual void OnOAuthWrapBridgeSuccess(const std::string& service_name, - const std::string& token, - const std::string& expires_in) OVERRIDE; - virtual void OnOAuthWrapBridgeFailure( - const std::string& service_name, - const GoogleServiceAuthError& error) OVERRIDE; - virtual void OnUserInfoSuccess(const std::string& email) OVERRIDE; - virtual void OnUserInfoFailure(const GoogleServiceAuthError& error) OVERRIDE; - // content::NotificationObserver virtual void Observe(int type, const content::NotificationSource& source, @@ -138,7 +117,6 @@ class SigninManager : public GaiaAuthConsumer, FRIEND_TEST_ALL_PREFIXES(SigninManagerTest, ProvideSecondFactorSuccess); FRIEND_TEST_ALL_PREFIXES(SigninManagerTest, ProvideSecondFactorFailure); void PrepareForSignin(); - void PrepareForOAuthSignin(); // Called when a new request to re-authenticate a user is in progress. // Will clear in memory data but leaves the db as such so when the browser @@ -152,9 +130,6 @@ class SigninManager : public GaiaAuthConsumer, std::string password_; // This is kept empty whenever possible. bool had_two_factor_error_; - // OAuth identity. - std::string oauth1_request_token_; - void CleanupNotificationRegistration(); // Result of the last client login, kept pending the lookup of the @@ -164,9 +139,6 @@ class SigninManager : public GaiaAuthConsumer, // Actual client login handler. scoped_ptr<GaiaAuthFetcher> client_login_; - // Actual OAuth login handler. - scoped_ptr<GaiaOAuthFetcher> oauth_login_; - // Register for notifications from the TokenService. content::NotificationRegistrar registrar_; diff --git a/chrome/browser/signin/signin_manager_factory.cc b/chrome/browser/signin/signin_manager_factory.cc index 659eee4..1406669 100644 --- a/chrome/browser/signin/signin_manager_factory.cc +++ b/chrome/browser/signin/signin_manager_factory.cc @@ -31,8 +31,6 @@ SigninManagerFactory* SigninManagerFactory::GetInstance() { } void SigninManagerFactory::RegisterUserPrefs(PrefService* user_prefs) { - user_prefs->RegisterBooleanPref(prefs::kSyncUsingOAuth, true, - PrefService::UNSYNCABLE_PREF); user_prefs->RegisterStringPref(prefs::kGoogleServicesUsername, "", PrefService::UNSYNCABLE_PREF); user_prefs->RegisterBooleanPref(prefs::kAutologinEnabled, true, diff --git a/chrome/browser/signin/signin_manager_unittest.cc b/chrome/browser/signin/signin_manager_unittest.cc index e5626dc..7445ba6 100644 --- a/chrome/browser/signin/signin_manager_unittest.cc +++ b/chrome/browser/signin/signin_manager_unittest.cc @@ -11,7 +11,6 @@ #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/signin/token_service.h" #include "chrome/browser/signin/token_service_unittest.h" -#include "chrome/browser/sync/util/oauth.h" #include "chrome/browser/webdata/web_data_service.h" #include "chrome/common/chrome_notification_types.h" #include "chrome/common/net/gaia/gaia_urls.h" @@ -24,29 +23,6 @@ #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" -class MockGaiaOAuthFetcher : public GaiaOAuthFetcher { - public: - MockGaiaOAuthFetcher(GaiaOAuthConsumer* consumer, - net::URLRequestContextGetter* getter, - Profile* profile, - const std::string& service_scope) - : GaiaOAuthFetcher( - consumer, getter, profile, service_scope) {} - - ~MockGaiaOAuthFetcher() {} - - MOCK_METHOD1(StartOAuthGetAccessToken, - void(const std::string& oauth1_request_token)); - - MOCK_METHOD4(StartOAuthWrapBridge, - void(const std::string& oauth1_access_token, - const std::string& oauth1_access_token_secret, - const std::string& wrap_token_duration, - const std::string& oauth2_scope)); - - MOCK_METHOD1(StartUserInfo, void(const std::string& oauth2_access_token)); -}; - class SigninManagerTest : public TokenServiceTestHarness { public: virtual void SetUp() OVERRIDE { @@ -57,16 +33,9 @@ class SigninManagerTest : public TokenServiceTestHarness { content::Source<Profile>(profile_.get())); google_login_failure_.ListenFor(chrome::NOTIFICATION_GOOGLE_SIGNIN_FAILED, content::Source<Profile>(profile_.get())); - originally_using_oauth_ = browser_sync::IsUsingOAuth(); - } - - virtual void TearDown() OVERRIDE { - TokenServiceTestHarness::TearDown(); - browser_sync::SetIsUsingOAuthForTest(originally_using_oauth_); } void SimulateValidResponseClientLogin(bool isGPlusUser) { - DCHECK(!browser_sync::IsUsingOAuth()); // Simulate the correct ClientLogin response. std::string respons_string = isGPlusUser ? "email=user@gmail.com\nallServices=googleme" : @@ -93,46 +62,15 @@ class SigninManagerTest : public TokenServiceTestHarness { fetcher->delegate()->OnURLFetchComplete(fetcher); } - void SimulateSigninStartOAuth() { - DCHECK(browser_sync::IsUsingOAuth()); - // Simulate a valid OAuth-based signin - MockGaiaOAuthFetcher* fetcher = new MockGaiaOAuthFetcher( - manager_.get(), - profile_->GetRequestContext(), - profile_.get(), - std::string()); - std::string request_token ="oauth1_request_token"; - EXPECT_CALL(*fetcher, StartOAuthGetAccessToken(request_token)).Times(1); - manager_->StartOAuthSignIn(request_token, fetcher); - manager_->OnGetOAuthTokenSuccess("oauth_token-Ev1Vu1hv"); - manager_->OnOAuthGetAccessTokenSuccess("oauth1_access_token-qOAmlrSM", - "secret-NKKn1DuR"); - manager_->OnOAuthWrapBridgeSuccess(browser_sync::SyncServiceName(), - "oauth2_wrap_access_token-R0Z3nRtw", - "3600"); - } - - void SimulateOAuthUserInfoSuccess() { - manager_->OnUserInfoSuccess("user-xZIuqTKu@gmail.com"); - } - - void SimulateValidSigninOAuth() { - SimulateSigninStartOAuth(); - SimulateOAuthUserInfoSuccess(); - } - - TestURLFetcherFactory factory_; scoped_ptr<SigninManager> manager_; TestNotificationTracker google_login_success_; TestNotificationTracker google_login_failure_; - bool originally_using_oauth_; }; // NOTE: ClientLogin's "StartSignin" is called after collecting credentials -// from the user. See also SigninManagerTest::SignInOAuth. +// from the user. TEST_F(SigninManagerTest, SignInClientLogin) { - browser_sync::SetIsUsingOAuthForTest(false); manager_->Initialize(profile_.get()); EXPECT_TRUE(manager_->GetAuthenticatedUsername().empty()); @@ -154,7 +92,6 @@ TEST_F(SigninManagerTest, SignInClientLogin) { } TEST_F(SigninManagerTest, SignInClientLoginNoGPlus) { - browser_sync::SetIsUsingOAuthForTest(false); manager_->Initialize(profile_.get()); EXPECT_TRUE(manager_->GetAuthenticatedUsername().empty()); @@ -167,7 +104,6 @@ TEST_F(SigninManagerTest, SignInClientLoginNoGPlus) { } TEST_F(SigninManagerTest, ClearTransientSigninData) { - browser_sync::SetIsUsingOAuthForTest(false); manager_->Initialize(profile_.get()); EXPECT_TRUE(manager_->GetAuthenticatedUsername().empty()); @@ -199,28 +135,7 @@ TEST_F(SigninManagerTest, ClearTransientSigninData) { EXPECT_EQ("user@gmail.com", manager_->GetAuthenticatedUsername()); } -// NOTE: OAuth's "StartOAuthSignIn" is called before collecting credentials -// from the user. See also SigninManagerTest::SignInClientLogin. -TEST_F(SigninManagerTest, SignInOAuth) { - browser_sync::SetIsUsingOAuthForTest(true); - manager_->Initialize(profile_.get()); - EXPECT_TRUE(manager_->GetAuthenticatedUsername().empty()); - - SimulateValidSigninOAuth(); - EXPECT_FALSE(manager_->GetAuthenticatedUsername().empty()); - - // 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_.reset(new SigninManager()); - manager_->Initialize(profile_.get()); - EXPECT_EQ("user-xZIuqTKu@gmail.com", manager_->GetAuthenticatedUsername()); -} - TEST_F(SigninManagerTest, SignOutClientLogin) { - browser_sync::SetIsUsingOAuthForTest(false); manager_->Initialize(profile_.get()); manager_->StartSignIn("username", "password", "", ""); SimulateValidResponseClientLogin(false); @@ -236,25 +151,7 @@ TEST_F(SigninManagerTest, SignOutClientLogin) { EXPECT_TRUE(manager_->GetAuthenticatedUsername().empty()); } -TEST_F(SigninManagerTest, SignOutOAuth) { - browser_sync::SetIsUsingOAuthForTest(true); - manager_->Initialize(profile_.get()); - - SimulateValidSigninOAuth(); - EXPECT_FALSE(manager_->GetAuthenticatedUsername().empty()); - - EXPECT_EQ("user-xZIuqTKu@gmail.com", manager_->GetAuthenticatedUsername()); - manager_->SignOut(); - EXPECT_TRUE(manager_->GetAuthenticatedUsername().empty()); - - // Should not be persisted anymore - manager_.reset(new SigninManager()); - manager_->Initialize(profile_.get()); - EXPECT_TRUE(manager_->GetAuthenticatedUsername().empty()); -} - TEST_F(SigninManagerTest, SignInFailureClientLogin) { - browser_sync::SetIsUsingOAuthForTest(false); manager_->Initialize(profile_.get()); manager_->StartSignIn("username", "password", "", ""); GoogleServiceAuthError error(GoogleServiceAuthError::REQUEST_CANCELED); @@ -272,7 +169,6 @@ TEST_F(SigninManagerTest, SignInFailureClientLogin) { } TEST_F(SigninManagerTest, ProvideSecondFactorSuccess) { - browser_sync::SetIsUsingOAuthForTest(false); manager_->Initialize(profile_.get()); manager_->StartSignIn("username", "password", "", ""); GoogleServiceAuthError error(GoogleServiceAuthError::TWO_FACTOR); @@ -292,7 +188,6 @@ TEST_F(SigninManagerTest, ProvideSecondFactorSuccess) { } TEST_F(SigninManagerTest, ProvideSecondFactorFailure) { - browser_sync::SetIsUsingOAuthForTest(false); manager_->Initialize(profile_.get()); manager_->StartSignIn("username", "password", "", ""); GoogleServiceAuthError error1(GoogleServiceAuthError::TWO_FACTOR); @@ -323,7 +218,6 @@ TEST_F(SigninManagerTest, ProvideSecondFactorFailure) { } TEST_F(SigninManagerTest, SignOutMidConnect) { - browser_sync::SetIsUsingOAuthForTest(false); manager_->Initialize(profile_.get()); manager_->StartSignIn("username", "password", "", ""); manager_->SignOut(); @@ -332,13 +226,3 @@ TEST_F(SigninManagerTest, SignOutMidConnect) { EXPECT_TRUE(manager_->GetAuthenticatedUsername().empty()); } - -TEST_F(SigninManagerTest, SignOutOnUserInfoSucessRaceTest) { - browser_sync::SetIsUsingOAuthForTest(true); - manager_->Initialize(profile_.get()); - EXPECT_TRUE(manager_->GetAuthenticatedUsername().empty()); - SimulateSigninStartOAuth(); - manager_->SignOut(); - SimulateOAuthUserInfoSuccess(); - EXPECT_TRUE(manager_->GetAuthenticatedUsername().empty()); -} diff --git a/chrome/browser/signin/token_service.cc b/chrome/browser/signin/token_service.cc index 78e4a24..5e7f017 100644 --- a/chrome/browser/signin/token_service.cc +++ b/chrome/browser/signin/token_service.cc @@ -31,12 +31,6 @@ const char* TokenService::kServices[] = { const char* kUnusedServiceScope = "unused-service-scope"; -// Unfortunately kNumOAuthServices must be defined in the .h. -// For OAuth, Chrome uses the OAuth2 service scope as the service name. -const char* TokenService::kOAuthServices[] = { - GaiaConstants::kSyncServiceOAuth, -}; - TokenService::TokenService() : profile_(NULL), token_loading_query_(0), @@ -92,9 +86,6 @@ void TokenService::ResetCredentialsInMemory() { for (int i = 0; i < kNumServices; ++i) { fetchers_[i].reset(); } - for (int i = 0; i < kNumOAuthServices; ++i) { - oauth_fetchers_[i].reset(); - } // Cancel pending loads. Callbacks will not return. if (token_loading_query_) { @@ -105,8 +96,6 @@ void TokenService::ResetCredentialsInMemory() { tokens_loaded_ = false; token_map_.clear(); credentials_ = GaiaAuthConsumer::ClientLoginResult(); - oauth_token_.clear(); - oauth_secret_.clear(); } void TokenService::UpdateCredentials( @@ -123,22 +112,6 @@ void TokenService::UpdateCredentials( } } -void TokenService::UpdateOAuthCredentials( - const std::string& oauth_token, - const std::string& oauth_secret) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - oauth_token_ = oauth_token; - oauth_secret_ = oauth_secret; - - SaveAuthTokenToDB(GaiaConstants::kGaiaOAuthToken, oauth_token); - SaveAuthTokenToDB(GaiaConstants::kGaiaOAuthSecret, oauth_secret); - - // Cancel any currently running requests. - for (int i = 0; i < kNumOAuthServices; i++) { - oauth_fetchers_[i].reset(); - } -} - void TokenService::LoadTokensFromDB() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); if (web_data_service_.get()) @@ -183,18 +156,6 @@ const std::string& TokenService::GetLsid() const { return credentials_.lsid; } -bool TokenService::HasOAuthCredentials() const { - return !oauth_token_.empty() && !oauth_secret_.empty(); -} - -const std::string& TokenService::GetOAuthToken() const { - return oauth_token_; -} - -const std::string& TokenService::GetOAuthSecret() const { - return oauth_secret_; -} - void TokenService::StartFetchingTokens() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(AreCredentialsValid()); @@ -206,19 +167,6 @@ void TokenService::StartFetchingTokens() { } } -void TokenService::StartFetchingOAuthTokens() { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - DCHECK(HasOAuthCredentials()); - for (int i = 0; i < kNumOAuthServices; i++) { - oauth_fetchers_[i].reset( - new GaiaOAuthFetcher(this, getter_, profile_, kUnusedServiceScope)); - oauth_fetchers_[i]->StartOAuthWrapBridge(oauth_token_, - oauth_secret_, - GaiaConstants::kGaiaOAuthDuration, - kOAuthServices[i]); - } -} - // Services dependent on a token will check if a token is available. // If it isn't, they'll go to sleep until they get a token event. bool TokenService::HasTokenForService(const char* service) const { @@ -328,38 +276,6 @@ void TokenService::OnOAuthLoginTokenFailure( GaiaConstants::kGaiaOAuth2LoginRefreshToken, error); } -void TokenService::OnOAuthGetAccessTokenSuccess(const std::string& token, - const std::string& secret) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - VLOG(1) << "TokenService::OnOAuthGetAccessTokenSuccess"; - SaveAuthTokenToDB(GaiaConstants::kGaiaOAuthToken, token); - SaveAuthTokenToDB(GaiaConstants::kGaiaOAuthSecret, secret); - UpdateOAuthCredentials(token, secret); -} - -void TokenService::OnOAuthGetAccessTokenFailure( - const GoogleServiceAuthError& error) { - VLOG(1) << "TokenService::OnOAuthGetAccessTokenFailure"; -} - -void TokenService::OnOAuthWrapBridgeSuccess(const std::string& service_scope, - const std::string& token, - const std::string& expires_in) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - VLOG(1) << "Got an access token for " << service_scope; - token_map_[service_scope] = token; - FireTokenAvailableNotification(service_scope, token); - SaveAuthTokenToDB(service_scope, token); -} - -void TokenService::OnOAuthWrapBridgeFailure( - const std::string& service_scope, - const GoogleServiceAuthError& error) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - LOG(WARNING) << "Auth token issuing failed for service:" << service_scope; - FireTokenRequestFailedNotification(service_scope, error); -} - void TokenService::OnWebDataServiceRequestDone(WebDataService::Handle h, const WDTypedResult* result) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); @@ -415,27 +331,6 @@ void TokenService::LoadTokensIntoMemory( std::string())); } } - - for (int i = 0; i < kNumOAuthServices; i++) { - LoadSingleTokenIntoMemory(db_tokens, in_memory_tokens, kOAuthServices[i]); - } - - if (oauth_token_.empty() && oauth_secret_.empty()) { - // Look for GAIA OAuth1 access token and secret. If we have both, and the - // current crendentials are empty, update the credentials. - std::string oauth_token; - std::string oauth_secret; - - if (db_tokens.count(GaiaConstants::kGaiaOAuthToken) > 0) - oauth_token = db_tokens.find(GaiaConstants::kGaiaOAuthToken)->second; - - if (db_tokens.count(GaiaConstants::kGaiaOAuthSecret) > 0) - oauth_secret = db_tokens.find(GaiaConstants::kGaiaOAuthSecret)->second; - - if (!oauth_token.empty() && !oauth_secret.empty()) { - UpdateOAuthCredentials(oauth_token, oauth_secret); - } - } } void TokenService::LoadSingleTokenIntoMemory( diff --git a/chrome/browser/signin/token_service.h b/chrome/browser/signin/token_service.h index e775c8c..fc7a08b 100644 --- a/chrome/browser/signin/token_service.h +++ b/chrome/browser/signin/token_service.h @@ -41,8 +41,6 @@ #include "base/gtest_prod_util.h" #include "base/memory/scoped_ptr.h" -#include "chrome/browser/net/gaia/gaia_oauth_consumer.h" -#include "chrome/browser/net/gaia/gaia_oauth_fetcher.h" #include "chrome/browser/webdata/web_data_service.h" #include "chrome/common/net/gaia/gaia_auth_consumer.h" #include "chrome/common/net/gaia/gaia_auth_fetcher.h" @@ -60,7 +58,6 @@ class URLRequestContextGetter; // The TokenService is a Profile member, so all calls are expected // from the UI thread. class TokenService : public GaiaAuthConsumer, - public GaiaOAuthConsumer, public WebDataServiceConsumer, public content::NotificationObserver { public: @@ -108,18 +105,11 @@ class TokenService : public GaiaAuthConsumer, void UpdateCredentials( const GaiaAuthConsumer::ClientLoginResult& credentials); - // Update OAuth credentials in the token service. - // Afterwards you can StartFetchingOAuthTokens. - void UpdateOAuthCredentials( - const std::string& oauth_token, - const std::string& oauth_secret); - // Terminate any running requests and reset the TokenService to a clean // slate. Resets in memory structures. Does not modify the DB. // When this is done, no tokens will be left in memory and no // user credentials will be left. Useful if a user is logging out. - // Initialize doesn't need to be called again but UpdateCredentials and - // UpdateOAuthCredentials do. + // Initialize doesn't need to be called again but UpdateCredentials does. void ResetCredentialsInMemory(); // Async load all tokens for services we know of from the DB. @@ -143,17 +133,10 @@ class TokenService : public GaiaAuthConsumer, // Did we get a proper LSID? virtual bool AreCredentialsValid() const; - // For services with their own auth routines, they can read the OAuth token - // and secret directly. Deprecated (in the sense of discouraged). - bool HasOAuthCredentials() const; - const std::string& GetOAuthToken() const; - const std::string& GetOAuthSecret() const; - // Tokens will be fetched for all services(sync, talk) in the background. // Results come back via event channel. Services can also poll before events // are issued. void StartFetchingTokens(); - void StartFetchingOAuthTokens(); virtual bool HasTokenForService(const char* service) const; const std::string& GetTokenForService(const char* const service) const; @@ -181,19 +164,6 @@ class TokenService : public GaiaAuthConsumer, virtual void OnOAuthLoginTokenFailure(const GoogleServiceAuthError& error) OVERRIDE; - // GaiaOAuthConsumer implementation. - virtual void OnOAuthGetAccessTokenSuccess(const std::string& token, - const std::string& secret) OVERRIDE; - virtual void OnOAuthGetAccessTokenFailure( - const GoogleServiceAuthError& error) OVERRIDE; - - virtual void OnOAuthWrapBridgeSuccess(const std::string& service_scope, - const std::string& token, - const std::string& expires_in) OVERRIDE; - virtual void OnOAuthWrapBridgeFailure( - const std::string& service_name, - const GoogleServiceAuthError& error) OVERRIDE; - // WebDataServiceConsumer implementation. virtual void OnWebDataServiceRequestDone( WebDataService::Handle h, @@ -242,16 +212,9 @@ class TokenService : public GaiaAuthConsumer, std::string source_; // Credentials from ClientLogin for Issuing auth tokens. GaiaAuthConsumer::ClientLoginResult credentials_; - // Credentials from Gaia OAuth (uber/login token) - std::string oauth_token_; - std::string oauth_secret_; // Size of array of services capable of ClientLogin-based authentication. // This value must be defined here. - // NOTE: The use of --enable-sync-oauth does not affect this count. The - // TokenService can continue to do some degree of ClientLogin token - // management, mostly related to persistence while Sync and possibly other - // services are using OAuth-based authentication. static const int kNumServices = 5; // List of services that are capable of ClientLogin-based authentication. static const char* kServices[kNumServices]; @@ -259,19 +222,6 @@ class TokenService : public GaiaAuthConsumer, // about the ordering, nor do we care which is for which service. scoped_ptr<GaiaAuthFetcher> fetchers_[kNumServices]; - // Size of array of services capable of OAuth-based authentication. This - // value must be defined here. - // NOTE: The use of --enable-sync-oauth does not affect this count. The - // TokenService can continue to do some degree of OAuth token - // management, mostly related to persistence while Sync and possibly other - // services are using ClientLogin-based authentication. - static const int kNumOAuthServices = 1; - // List of services that are capable of OAuth-based authentication. - static const char* kOAuthServices[kNumOAuthServices]; - // A bunch of fetchers suitable for OAuth token issuing. We don't care about - // the ordering, nor do we care which is for which service. - scoped_ptr<GaiaOAuthFetcher> oauth_fetchers_[kNumOAuthServices]; - // Map from service to token. std::map<std::string, std::string> token_map_; diff --git a/chrome/browser/signin/token_service_unittest.cc b/chrome/browser/signin/token_service_unittest.cc index c8d401d..2437a61 100644 --- a/chrome/browser/signin/token_service_unittest.cc +++ b/chrome/browser/signin/token_service_unittest.cc @@ -114,7 +114,6 @@ class TokenServiceTest : public TokenServiceTestHarness { virtual void SetUp() { TokenServiceTestHarness::SetUp(); service_->UpdateCredentials(credentials_); - service_->UpdateOAuthCredentials(oauth_token_, oauth_secret_); } protected: void TestLoadSingleToken( @@ -141,9 +140,6 @@ TEST_F(TokenServiceTest, SanityCheck) { EXPECT_TRUE(service_->HasLsid()); EXPECT_EQ(service_->GetLsid(), "lsid"); EXPECT_FALSE(service_->HasTokenForService("nonexistent service")); - EXPECT_TRUE(service_->HasOAuthCredentials()); - EXPECT_EQ(service_->GetOAuthToken(), "oauth"); - EXPECT_EQ(service_->GetOAuthSecret(), "secret"); EXPECT_FALSE(service_->TokensLoadedFromDB()); } @@ -179,20 +175,6 @@ TEST_F(TokenServiceTest, NotificationOAuthLoginTokenSuccess) { EXPECT_EQ(details.token(), "rt1"); } -TEST_F(TokenServiceTest, NotificationSuccessOAuth) { - EXPECT_EQ(0U, success_tracker_.size()); - EXPECT_EQ(0U, failure_tracker_.size()); - service_->OnOAuthWrapBridgeSuccess( - GaiaConstants::kSyncServiceOAuth, "token", "3600"); - EXPECT_EQ(1U, success_tracker_.size()); - EXPECT_EQ(0U, failure_tracker_.size()); - - TokenService::TokenAvailableDetails details = success_tracker_.details(); - // MSVC doesn't like this comparison as EQ. - EXPECT_TRUE(details.service() == GaiaConstants::kSyncServiceOAuth); - EXPECT_EQ(details.token(), "token"); -} - TEST_F(TokenServiceTest, NotificationFailed) { EXPECT_EQ(0U, success_tracker_.size()); EXPECT_EQ(0U, failure_tracker_.size()); @@ -202,7 +184,6 @@ TEST_F(TokenServiceTest, NotificationFailed) { EXPECT_EQ(1U, failure_tracker_.size()); TokenService::TokenRequestFailedDetails details = failure_tracker_.details(); - // MSVC doesn't like this comparison as EQ. EXPECT_TRUE(details.service() == GaiaConstants::kSyncService); EXPECT_TRUE(details.error() == error); // Struct has no print function. @@ -224,21 +205,6 @@ TEST_F(TokenServiceTest, NotificationOAuthLoginTokenFailed) { EXPECT_TRUE(details.error() == error); // Struct has no print function. } -TEST_F(TokenServiceTest, NotificationFailedOAuth) { - EXPECT_EQ(0U, success_tracker_.size()); - EXPECT_EQ(0U, failure_tracker_.size()); - GoogleServiceAuthError error(GoogleServiceAuthError::REQUEST_CANCELED); - service_->OnOAuthWrapBridgeFailure(GaiaConstants::kSyncServiceOAuth, error); - EXPECT_EQ(0U, success_tracker_.size()); - EXPECT_EQ(1U, failure_tracker_.size()); - - TokenService::TokenRequestFailedDetails details = failure_tracker_.details(); - - // MSVC doesn't like this comparison as EQ. - EXPECT_TRUE(details.service() == GaiaConstants::kSyncServiceOAuth); - EXPECT_TRUE(details.error() == error); // Struct has no print function. -} - TEST_F(TokenServiceTest, OnTokenSuccessUpdate) { service_->OnIssueAuthTokenSuccess(GaiaConstants::kSyncService, "token"); EXPECT_TRUE(service_->HasTokenForService(GaiaConstants::kSyncService)); @@ -273,42 +239,13 @@ TEST_F(TokenServiceTest, OnTokenSuccess) { // Don't "start fetching", just go ahead and issue the callback. service_->OnIssueAuthTokenSuccess(GaiaConstants::kSyncService, "token"); EXPECT_TRUE(service_->HasTokenForService(GaiaConstants::kSyncService)); - EXPECT_FALSE(service_->HasTokenForService(GaiaConstants::kSyncServiceOAuth)); EXPECT_FALSE(service_->HasTokenForService(GaiaConstants::kTalkService)); // Gaia returns the entire result as the token so while this is a shared // result with ClientLogin, it doesn't matter, we should still get it back. EXPECT_EQ(service_->GetTokenForService(GaiaConstants::kSyncService), "token"); - - // Try the OAuth service. - service_->OnOAuthWrapBridgeSuccess( - GaiaConstants::kSyncServiceOAuth, "token2", "3600"); - EXPECT_TRUE(service_->HasTokenForService(GaiaConstants::kSyncServiceOAuth)); - EXPECT_EQ(service_->GetTokenForService(GaiaConstants::kSyncServiceOAuth), - "token2"); - - // First didn't change. - EXPECT_EQ(service_->GetTokenForService(GaiaConstants::kSyncService), "token"); } -TEST_F(TokenServiceTest, ResetSimple) { - service_->OnIssueAuthTokenSuccess(GaiaConstants::kSyncService, "token"); - EXPECT_TRUE(service_->HasTokenForService(GaiaConstants::kSyncService)); - EXPECT_TRUE(service_->HasLsid()); - service_->OnOAuthGetAccessTokenSuccess("token2", "secret"); - service_->OnOAuthWrapBridgeSuccess( - GaiaConstants::kSyncServiceOAuth, "token3", "4321"); - EXPECT_TRUE(service_->HasTokenForService(GaiaConstants::kSyncServiceOAuth)); - EXPECT_TRUE(service_->HasOAuthCredentials()); - - service_->ResetCredentialsInMemory(); - - EXPECT_FALSE(service_->HasTokenForService(GaiaConstants::kSyncService)); - EXPECT_FALSE(service_->HasLsid()); - EXPECT_FALSE(service_->HasTokenForService(GaiaConstants::kSyncServiceOAuth)); - EXPECT_FALSE(service_->HasOAuthCredentials()); -} - -TEST_F(TokenServiceTest, ResetComplex) { +TEST_F(TokenServiceTest, Reset) { TestURLFetcherFactory factory; service_->StartFetchingTokens(); // You have to call delegates by hand with the test fetcher, @@ -318,42 +255,22 @@ TEST_F(TokenServiceTest, ResetComplex) { EXPECT_TRUE(service_->HasTokenForService(GaiaConstants::kSyncService)); EXPECT_EQ(service_->GetTokenForService(GaiaConstants::kSyncService), "eraseme"); - EXPECT_FALSE(service_->HasTokenForService(GaiaConstants::kSyncServiceOAuth)); - EXPECT_FALSE(service_->HasTokenForService(GaiaConstants::kTalkService)); - - service_->OnOAuthWrapBridgeSuccess( - GaiaConstants::kSyncServiceOAuth, "erasemetoo", "1234"); - EXPECT_TRUE(service_->HasTokenForService(GaiaConstants::kSyncService)); - EXPECT_EQ(service_->GetTokenForService(GaiaConstants::kSyncService), - "eraseme"); - EXPECT_TRUE(service_->HasTokenForService(GaiaConstants::kSyncServiceOAuth)); - EXPECT_EQ(service_->GetTokenForService(GaiaConstants::kSyncServiceOAuth), - "erasemetoo"); EXPECT_FALSE(service_->HasTokenForService(GaiaConstants::kTalkService)); service_->ResetCredentialsInMemory(); EXPECT_FALSE(service_->HasTokenForService(GaiaConstants::kSyncService)); - EXPECT_FALSE(service_->HasTokenForService(GaiaConstants::kSyncServiceOAuth)); EXPECT_FALSE(service_->HasTokenForService(GaiaConstants::kTalkService)); EXPECT_FALSE(service_->HasLsid()); - EXPECT_FALSE(service_->HasOAuthCredentials()); // Now start using it again. service_->UpdateCredentials(credentials_); EXPECT_TRUE(service_->HasLsid()); service_->StartFetchingTokens(); - service_->UpdateOAuthCredentials(oauth_token_, oauth_secret_); - EXPECT_TRUE(service_->HasOAuthCredentials()); - service_->StartFetchingOAuthTokens(); service_->OnIssueAuthTokenSuccess(GaiaConstants::kSyncService, "token"); - service_->OnOAuthWrapBridgeSuccess( - GaiaConstants::kSyncServiceOAuth, "token2", "3600"); service_->OnIssueAuthTokenSuccess(GaiaConstants::kTalkService, "token3"); EXPECT_EQ(service_->GetTokenForService(GaiaConstants::kSyncService), "token"); - EXPECT_EQ(service_->GetTokenForService(GaiaConstants::kSyncServiceOAuth), - "token2"); EXPECT_EQ(service_->GetTokenForService(GaiaConstants::kTalkService), "token3"); } @@ -365,8 +282,6 @@ TEST_F(TokenServiceTest, FullIntegration) { MockFactory<MockFetcher> factory; factory.set_results(result); EXPECT_FALSE(service_->HasTokenForService(GaiaConstants::kSyncService)); - EXPECT_FALSE(service_->HasTokenForService( - GaiaConstants::kSyncServiceOAuth)); EXPECT_FALSE(service_->HasTokenForService(GaiaConstants::kTalkService)); service_->StartFetchingTokens(); } @@ -400,10 +315,6 @@ TEST_F(TokenServiceTest, LoadTokensIntoMemoryBasic) { service = TokenService::kServices[i]; TestLoadSingleToken(&db_tokens, &memory_tokens, service); } - for (int i = 0; i < TokenService::kNumOAuthServices; ++i) { - service = TokenService::kOAuthServices[i]; - TestLoadSingleToken(&db_tokens, &memory_tokens, service); - } service = GaiaConstants::kGaiaOAuth2LoginRefreshToken; TestLoadSingleToken(&db_tokens, &memory_tokens, service); service = GaiaConstants::kGaiaOAuth2LoginAccessToken; @@ -431,13 +342,10 @@ TEST_F(TokenServiceTest, LoadTokensIntoMemoryAdvanced) { // SyncService token is already in memory. Pretend we got it off // the disk as well, but an older token. db_tokens[GaiaConstants::kSyncService] = "ignoreme"; - db_tokens[GaiaConstants::kSyncServiceOAuth] = "tomato"; service_->LoadTokensIntoMemory(db_tokens, &memory_tokens); - EXPECT_EQ(2U, memory_tokens.size()); - EXPECT_EQ(1U, memory_tokens.count(GaiaConstants::kSyncServiceOAuth)); - EXPECT_EQ(memory_tokens[GaiaConstants::kSyncServiceOAuth], "tomato"); - EXPECT_EQ(1U, success_tracker_.size()); + EXPECT_EQ(1U, memory_tokens.size()); + EXPECT_EQ(0U, success_tracker_.size()); EXPECT_EQ(1U, memory_tokens.count(GaiaConstants::kSyncService)); EXPECT_EQ(memory_tokens[GaiaConstants::kSyncService], "pepper"); } @@ -451,28 +359,20 @@ TEST_F(TokenServiceTest, WebDBLoadIntegration) { // Should result in DB write. service_->OnIssueAuthTokenSuccess(GaiaConstants::kSyncService, "token"); EXPECT_EQ(1U, success_tracker_.size()); - service_->OnOAuthGetAccessTokenSuccess("token1", "secret"); - service_->OnOAuthWrapBridgeSuccess( - GaiaConstants::kSyncServiceOAuth, "token2", "3600"); - EXPECT_EQ(2U, success_tracker_.size()); EXPECT_TRUE(service_->HasTokenForService(GaiaConstants::kSyncService)); - EXPECT_TRUE(service_->HasTokenForService(GaiaConstants::kSyncServiceOAuth)); // Clean slate. service_->ResetCredentialsInMemory(); success_tracker_.Reset(); EXPECT_FALSE(service_->HasTokenForService(GaiaConstants::kSyncService)); - EXPECT_FALSE(service_->HasTokenForService(GaiaConstants::kSyncServiceOAuth)); service_->LoadTokensFromDB(); WaitForDBLoadCompletion(); - EXPECT_EQ(2U, success_tracker_.size()); + EXPECT_EQ(1U, success_tracker_.size()); EXPECT_TRUE(service_->HasTokenForService(GaiaConstants::kSyncService)); - EXPECT_TRUE(service_->HasTokenForService(GaiaConstants::kSyncServiceOAuth)); EXPECT_FALSE(service_->HasTokenForService(GaiaConstants::kTalkService)); EXPECT_TRUE(service_->HasLsid()); - EXPECT_TRUE(service_->HasOAuthCredentials()); } TEST_F(TokenServiceTest, MultipleLoadResetIntegration) { @@ -483,14 +383,6 @@ TEST_F(TokenServiceTest, MultipleLoadResetIntegration) { EXPECT_FALSE(service_->HasTokenForService(GaiaConstants::kSyncService)); EXPECT_FALSE(service_->HasLsid()); - service_->OnOAuthGetAccessTokenSuccess("token2", "secret"); - service_->OnOAuthWrapBridgeSuccess( - GaiaConstants::kSyncServiceOAuth, "token3", "3600"); - service_->ResetCredentialsInMemory(); - success_tracker_.Reset(); - EXPECT_FALSE(service_->HasTokenForService(GaiaConstants::kSyncServiceOAuth)); - EXPECT_FALSE(service_->HasOAuthCredentials()); - EXPECT_FALSE(service_->TokensLoadedFromDB()); service_->LoadTokensFromDB(); WaitForDBLoadCompletion(); @@ -500,12 +392,10 @@ TEST_F(TokenServiceTest, MultipleLoadResetIntegration) { WaitForDBLoadCompletion(); EXPECT_TRUE(service_->TokensLoadedFromDB()); - EXPECT_EQ(2U, success_tracker_.size()); + EXPECT_EQ(1U, success_tracker_.size()); EXPECT_TRUE(service_->HasTokenForService(GaiaConstants::kSyncService)); - EXPECT_TRUE(service_->HasTokenForService(GaiaConstants::kSyncServiceOAuth)); EXPECT_FALSE(service_->HasTokenForService(GaiaConstants::kTalkService)); EXPECT_TRUE(service_->HasLsid()); - EXPECT_TRUE(service_->HasOAuthCredentials()); // Reset it one more time so there's no surprises. service_->ResetCredentialsInMemory(); @@ -516,11 +406,9 @@ TEST_F(TokenServiceTest, MultipleLoadResetIntegration) { WaitForDBLoadCompletion(); EXPECT_TRUE(service_->TokensLoadedFromDB()); - EXPECT_EQ(2U, success_tracker_.size()); + EXPECT_EQ(1U, success_tracker_.size()); EXPECT_TRUE(service_->HasTokenForService(GaiaConstants::kSyncService)); - EXPECT_TRUE(service_->HasTokenForService(GaiaConstants::kSyncServiceOAuth)); EXPECT_TRUE(service_->HasLsid()); - EXPECT_TRUE(service_->HasOAuthCredentials()); } #ifndef NDEBUG @@ -532,7 +420,6 @@ class TokenServiceCommandLineTest : public TokenServiceTestHarness { switches::kSetToken, "my_service:my_value"); TokenServiceTestHarness::SetUp(); service_->UpdateCredentials(credentials_); - service_->UpdateOAuthCredentials(oauth_token_, oauth_secret_); *CommandLine::ForCurrentProcess() = original_cl; } diff --git a/chrome/browser/sync/internal_api/syncapi_server_connection_manager.cc b/chrome/browser/sync/internal_api/syncapi_server_connection_manager.cc index fa11ec9..84a5d01 100644 --- a/chrome/browser/sync/internal_api/syncapi_server_connection_manager.cc +++ b/chrome/browser/sync/internal_api/syncapi_server_connection_manager.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -6,7 +6,6 @@ #include "chrome/browser/sync/internal_api/http_post_provider_factory.h" #include "chrome/browser/sync/internal_api/http_post_provider_interface.h" -#include "chrome/browser/sync/util/oauth.h" #include "chrome/common/net/http_return.h" #include "net/base/net_errors.h" @@ -42,12 +41,8 @@ bool SyncAPIBridgedConnection::Init(const char* path, http->SetURL(connection_url.c_str(), sync_server_port); if (!auth_token.empty()) { - std::string headers; - if (browser_sync::IsUsingOAuth()) { - headers = "Authorization: OAuth " + auth_token; - } else { - headers = "Authorization: GoogleLogin auth=" + auth_token; - } + const std::string& headers = + "Authorization: GoogleLogin auth=" + auth_token; http->SetExtraRequestHeaders(headers.c_str()); } diff --git a/chrome/browser/sync/profile_sync_service.cc b/chrome/browser/sync/profile_sync_service.cc index 71d3881..3327492 100644 --- a/chrome/browser/sync/profile_sync_service.cc +++ b/chrome/browser/sync/profile_sync_service.cc @@ -24,7 +24,6 @@ #include "chrome/browser/about_flags.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/net/chrome_cookie_notification_details.h" - #include "chrome/browser/profiles/profile.h" #include "chrome/browser/signin/signin_manager.h" #include "chrome/browser/signin/token_service.h" @@ -43,7 +42,6 @@ #include "chrome/browser/sync/profile_sync_components_factory_impl.h" #include "chrome/browser/sync/sync_global_error.h" #include "chrome/browser/sync/util/cryptographer.h" -#include "chrome/browser/sync/util/oauth.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_list.h" #include "chrome/browser/ui/browser_window.h" @@ -176,7 +174,7 @@ bool ProfileSyncService::AreCredentialsAvailable( return false; // TODO(chron): Verify CrOS unit test behavior. - if (!token_service->HasTokenForService(browser_sync::SyncServiceName())) + if (!token_service->HasTokenForService(GaiaConstants::kSyncService)) return false; return !check_oauth_login_token || token_service->HasOAuthLoginToken(); } @@ -309,7 +307,7 @@ SyncCredentials ProfileSyncService::GetCredentials() { DCHECK(!credentials.email.empty()); TokenService* service = profile_->GetTokenService(); credentials.sync_token = service->GetTokenForService( - browser_sync::SyncServiceName()); + GaiaConstants::kSyncService); return credentials; } diff --git a/chrome/browser/sync/sync_setup_flow.cc b/chrome/browser/sync/sync_setup_flow.cc index 3b11c1a..40356bc 100644 --- a/chrome/browser/sync/sync_setup_flow.cc +++ b/chrome/browser/sync/sync_setup_flow.cc @@ -20,7 +20,6 @@ #include "chrome/browser/sync/sync_setup_flow_handler.h" #include "chrome/browser/sync/syncable/model_type.h" #include "chrome/browser/sync/user_selectable_sync_type.h" -#include "chrome/browser/sync/util/oauth.h" #include "chrome/browser/ui/browser_list.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/net/gaia/gaia_constants.h" diff --git a/chrome/browser/sync/sync_setup_flow_handler.h b/chrome/browser/sync/sync_setup_flow_handler.h index 6a8ef2c..8c92311 100644 --- a/chrome/browser/sync/sync_setup_flow_handler.h +++ b/chrome/browser/sync/sync_setup_flow_handler.h @@ -8,6 +8,8 @@ #include <string> +#include "base/string16.h" + class SyncSetupFlow; namespace base { diff --git a/chrome/browser/sync/sync_setup_wizard.cc b/chrome/browser/sync/sync_setup_wizard.cc index 97b501a..02ddd75 100644 --- a/chrome/browser/sync/sync_setup_wizard.cc +++ b/chrome/browser/sync/sync_setup_wizard.cc @@ -12,7 +12,6 @@ #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/sync/sync_setup_flow.h" -#include "chrome/browser/sync/util/oauth.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/pref_names.h" diff --git a/chrome/browser/sync/util/DEPS b/chrome/browser/sync/util/DEPS index b8f365f..cb1b125 100644 --- a/chrome/browser/sync/util/DEPS +++ b/chrome/browser/sync/util/DEPS @@ -11,9 +11,4 @@ include_rules = [ # unittests need this for mac osx keychain overriding "+chrome/browser/password_manager/encryptor.h", - - "+chrome/common/chrome_switches.h", - "+chrome/common/net/gaia/gaia_constants.h", - "+chrome/common/random.h", ] - diff --git a/chrome/browser/sync/util/oauth.cc b/chrome/browser/sync/util/oauth.cc deleted file mode 100644 index ddd3dec..0000000 --- a/chrome/browser/sync/util/oauth.cc +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/sync/util/oauth.h" - -#include "base/command_line.h" -#include "chrome/common/chrome_switches.h" -#include "chrome/common/net/gaia/gaia_constants.h" - -namespace browser_sync { - -static bool has_local_override = false; -static bool local_override = false; - -// TODO(rickcam): Bug(92948): Remove IsUsingOAuth post-ClientLogin -bool IsUsingOAuth() { - if (has_local_override) - return local_override; - return CommandLine::ForCurrentProcess()->HasSwitch( - switches::kEnableSyncOAuth); -} - -// TODO(rickcam): Bug(92948): Remove SyncServiceName post-ClientLogin -const char* SyncServiceName() { - return IsUsingOAuth() ? - GaiaConstants::kSyncServiceOAuth : - GaiaConstants::kSyncService; -} - -// TODO(rickcam): Bug(92948): Remove SetIsUsingOAuthForTest post-ClientLogin -void SetIsUsingOAuthForTest(bool is_using_oauth) { - has_local_override = true; - local_override = is_using_oauth; -} - -} // namespace browser_sync diff --git a/chrome/browser/sync/util/oauth.h b/chrome/browser/sync/util/oauth.h deleted file mode 100644 index 43e2613..0000000 --- a/chrome/browser/sync/util/oauth.h +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_SYNC_UTIL_OAUTH_H_ -#define CHROME_BROWSER_SYNC_UTIL_OAUTH_H_ -#pragma once - -namespace browser_sync { - -// TODO(rickcam): Bug(92948): Remove IsUsingOAuth after ClientLogin is gone -bool IsUsingOAuth(); - -// TODO(rickcam): Bug(92948): Remove SyncServiceName post-ClientLogin -const char* SyncServiceName(); - -// TODO(rickcam): Bug(92948): Remove SetIsUsingOAuthForTest post-ClientLogin -void SetIsUsingOAuthForTest(bool is_using_oauth); - -} // namespace browser_sync - -#endif // CHROME_BROWSER_SYNC_UTIL_OAUTH_H_ diff --git a/chrome/browser/ui/webui/sync_setup_handler.cc b/chrome/browser/ui/webui/sync_setup_handler.cc index 1f5722e..76313c8 100644 --- a/chrome/browser/ui/webui/sync_setup_handler.cc +++ b/chrome/browser/ui/webui/sync_setup_handler.cc @@ -22,7 +22,6 @@ #include "chrome/browser/sync/profile_sync_service_factory.h" #include "chrome/browser/sync/protocol/service_constants.h" #include "chrome/browser/sync/sync_setup_flow.h" -#include "chrome/browser/sync/util/oauth.h" #include "chrome/browser/ui/browser_list.h" #include "chrome/browser/ui/webui/signin/login_ui_service.h" #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" @@ -379,22 +378,6 @@ bool SyncSetupHandler::IsActiveLogin() const { return service && (service->current_login_ui() == web_ui()); } -void SyncSetupHandler::OnGetOAuthTokenSuccess(const std::string& oauth_token) { - Profile* profile = GetProfile(); - SigninManager* signin = GetSignin(); - GaiaOAuthFetcher* fetcher = new GaiaOAuthFetcher( - signin, - profile->GetRequestContext(), - profile, - GaiaConstants::kSyncServiceOAuth); - signin->StartOAuthSignIn(oauth_token, fetcher); -} - -void SyncSetupHandler::OnGetOAuthTokenFailure( - const GoogleServiceAuthError& error) { - CloseOverlay(); -} - void SyncSetupHandler::RegisterMessages() { web_ui()->RegisterMessageCallback("SyncSetupDidClosePage", base::Bind(&SyncSetupHandler::OnDidClosePage, @@ -432,7 +415,6 @@ void SyncSetupHandler::DisplayGaiaLogin(bool fatal_error) { void SyncSetupHandler::DisplayGaiaLoginWithErrorMessage( const string16& error_message, bool fatal_error) { - DCHECK(!browser_sync::IsUsingOAuth()); // If we're exiting from sync config (due to some kind of error), notify // SyncSetupFlow. if (flow_) { diff --git a/chrome/browser/ui/webui/sync_setup_handler.h b/chrome/browser/ui/webui/sync_setup_handler.h index d7bbda0..ab63330 100644 --- a/chrome/browser/ui/webui/sync_setup_handler.h +++ b/chrome/browser/ui/webui/sync_setup_handler.h @@ -5,9 +5,8 @@ #ifndef CHROME_BROWSER_UI_WEBUI_SYNC_SETUP_HANDLER_H_ #define CHROME_BROWSER_UI_WEBUI_SYNC_SETUP_HANDLER_H_ +#include "base/gtest_prod_util.h" #include "base/memory/scoped_ptr.h" -#include "chrome/browser/net/gaia/gaia_oauth_consumer.h" -#include "chrome/browser/net/gaia/gaia_oauth_fetcher.h" #include "chrome/browser/sync/sync_setup_flow_handler.h" #include "chrome/browser/ui/webui/options/options_ui.h" #include "chrome/browser/ui/webui/signin/signin_tracker.h" @@ -18,8 +17,7 @@ class ProfileSyncService; class SigninManager; class SyncSetupFlow; -class SyncSetupHandler : public GaiaOAuthConsumer, - public OptionsPageUIHandler, +class SyncSetupHandler : public OptionsPageUIHandler, public SyncSetupFlowHandler, public SigninTracker::Observer { public: @@ -41,11 +39,6 @@ class SyncSetupHandler : public GaiaOAuthConsumer, virtual void SetFlow(SyncSetupFlow* flow) OVERRIDE; virtual void Focus() OVERRIDE; - // GaiaOAuthConsumer implementation. - virtual void OnGetOAuthTokenSuccess(const std::string& oauth_token) OVERRIDE; - virtual void OnGetOAuthTokenFailure( - const GoogleServiceAuthError& error) OVERRIDE; - // SigninTracker::Observer implementation virtual void GaiaCredentialsValid() OVERRIDE; virtual void SigninFailed() OVERRIDE; diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp index 5b2adfb..59ae1b9 100644 --- a/chrome/chrome.gyp +++ b/chrome/chrome.gyp @@ -490,8 +490,6 @@ 'browser/sync/util/logging.h', 'browser/sync/util/nigori.cc', 'browser/sync/util/nigori.h', - 'browser/sync/util/oauth.cc', - 'browser/sync/util/oauth.h', 'browser/sync/util/time.cc', 'browser/sync/util/time.h', 'browser/sync/util/unrecoverable_error_info.h', diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc index a837e8a..ba69a38 100644 --- a/chrome/common/chrome_switches.cc +++ b/chrome/common/chrome_switches.cc @@ -558,9 +558,6 @@ const char kEnableSdch[] = "enable-sdch"; // Enables syncing extension settings. const char kEnableSyncExtensionSettings[] = "enable-sync-extension-settings"; -// Enables OAuth sign-in for sync. -const char kEnableSyncOAuth[] = "enable-sync-oauth"; - // Enables syncing browser sessions. const char kEnableSyncTabs[] = "enable-sync-tabs"; diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h index 846a918..4351ba6 100644 --- a/chrome/common/chrome_switches.h +++ b/chrome/common/chrome_switches.h @@ -159,7 +159,6 @@ extern const char kEnableSdch[]; // TODO(kalman): Add to about:flags when UI for syncing extension settings has // been figured out. extern const char kEnableSyncExtensionSettings[]; -extern const char kEnableSyncOAuth[]; extern const char kEnableSyncTabs[]; extern const char kEnableSyncTabsForOtherClients[]; extern const char kEnableTabGroupsContextMenu[]; diff --git a/chrome/common/net/gaia/gaia_constants.cc b/chrome/common/net/gaia/gaia_constants.cc index 8c84578..1b7d12d 100644 --- a/chrome/common/net/gaia/gaia_constants.cc +++ b/chrome/common/net/gaia/gaia_constants.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // @@ -19,7 +19,6 @@ const char kPicasaService[] = "lh2"; // Service/scope names for sync. const char kSyncService[] = "chromiumsync"; -const char kSyncServiceOAuth[] = "https://www.googleapis.com/auth/chromesync"; // Service name for XMPP Google Talk. const char kTalkService[] = "talk"; diff --git a/chrome/common/net/gaia/gaia_constants.h b/chrome/common/net/gaia/gaia_constants.h index c079059..491b04c 100644 --- a/chrome/common/net/gaia/gaia_constants.h +++ b/chrome/common/net/gaia/gaia_constants.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // @@ -18,7 +18,6 @@ extern const char kGaiaService[]; // uber token extern const char kPicasaService[]; extern const char kTalkService[]; extern const char kSyncService[]; -extern const char kSyncServiceOAuth[]; extern const char kRemotingService[]; extern const char kCloudPrintService[]; extern const char kDeviceManagementService[]; diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc index a134d11..4777240 100644 --- a/chrome/common/pref_names.cc +++ b/chrome/common/pref_names.cc @@ -1478,9 +1478,6 @@ const char kSyncMaxInvalidationVersions[] = "sync.max_invalidation_versions"; const char kSyncEncryptionBootstrapToken[] = "sync.encryption_bootstrap_token"; -// Boolean tracking whether the user authenticated with OAuth. -const char kSyncUsingOAuth[] = "sync.using_oauth"; - // Boolean tracking whether the user chose to specify a secondary encryption // passphrase. const char kSyncUsingSecondaryPassphrase[] = "sync.using_secondary_passphrase"; diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h index c66fb0e..889a9e6 100644 --- a/chrome/common/pref_names.h +++ b/chrome/common/pref_names.h @@ -537,7 +537,6 @@ extern const char kSyncSearchEngines[]; extern const char kSyncSessions[]; extern const char kSyncSuppressStart[]; extern const char kGoogleServicesUsername[]; -extern const char kSyncUsingOAuth[]; extern const char kSyncUsingSecondaryPassphrase[]; extern const char kSyncEncryptionBootstrapToken[]; extern const char kSyncAcknowledgedSyncTypes[]; |