diff options
author | rogerta@chromium.org <rogerta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-07 00:03:49 +0000 |
---|---|---|
committer | rogerta@chromium.org <rogerta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-07 00:03:49 +0000 |
commit | 03608d8b532c1eb1d9e8bf2b7f942068d1e322ce (patch) | |
tree | f2f7941d01c711405d8642ef6caad26696dab1a3 /google_apis | |
parent | 4ecd01b126c1f85f89ad03a587e9c2d12b088242 (diff) | |
download | chromium_src-03608d8b532c1eb1d9e8bf2b7f942068d1e322ce.zip chromium_src-03608d8b532c1eb1d9e8bf2b7f942068d1e322ce.tar.gz chromium_src-03608d8b532c1eb1d9e8bf2b7f942068d1e322ce.tar.bz2 |
Enable account reconcilor when --new-profile-management is used.
Move mergesession from SigninManager to reconcilor.
Implement ListAccounts.
Start implementing reconcile action, but still a noop for now.
This CL depends on https://codereview.chromium.org/57103002/
Alan: here is an implementation of the ListAccounts. I also added lots of
DVLOG() to the code. Let me know if you'd rather I took those out and put
in a separate CL.
Hui: please review. This CL adds more functionality to the reconcilor but
its still not complete. However, it enables AC behind the flag for merge
session so you don't need to do that manually.
BUG=305249
Review URL: https://codereview.chromium.org/57363003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@233424 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'google_apis')
-rw-r--r-- | google_apis/gaia/gaia_auth_consumer.h | 3 | ||||
-rw-r--r-- | google_apis/gaia/gaia_auth_fetcher.cc | 26 | ||||
-rw-r--r-- | google_apis/gaia/gaia_auth_fetcher.h | 8 | ||||
-rw-r--r-- | google_apis/gaia/gaia_auth_fetcher_unittest.cc | 15 | ||||
-rw-r--r-- | google_apis/gaia/gaia_urls.cc | 6 | ||||
-rw-r--r-- | google_apis/gaia/gaia_urls.h | 2 |
6 files changed, 60 insertions, 0 deletions
diff --git a/google_apis/gaia/gaia_auth_consumer.h b/google_apis/gaia/gaia_auth_consumer.h index 4030336..d5ab306 100644 --- a/google_apis/gaia/gaia_auth_consumer.h +++ b/google_apis/gaia/gaia_auth_consumer.h @@ -82,6 +82,9 @@ class GaiaAuthConsumer { virtual void OnMergeSessionSuccess(const std::string& data) {} virtual void OnMergeSessionFailure(const GoogleServiceAuthError& error) {} + + virtual void OnListAccountsSuccess(const std::string& data) {} + virtual void OnListAccountsFailure(const GoogleServiceAuthError& error) {} }; #endif // GOOGLE_APIS_GAIA_GAIA_AUTH_CONSUMER_H_ diff --git a/google_apis/gaia/gaia_auth_fetcher.cc b/google_apis/gaia/gaia_auth_fetcher.cc index f0e2644..8c0eb9a 100644 --- a/google_apis/gaia/gaia_auth_fetcher.cc +++ b/google_apis/gaia/gaia_auth_fetcher.cc @@ -182,6 +182,7 @@ GaiaAuthFetcher::GaiaAuthFetcher(GaiaAuthConsumer* consumer, uberauth_token_gurl_(GaiaUrls::GetInstance()->oauth1_login_url().Resolve( base::StringPrintf(kUberAuthTokenURLFormat, source.c_str()))), oauth_login_gurl_(GaiaUrls::GetInstance()->oauth1_login_url()), + list_accounts_gurl_(GaiaUrls::GetInstance()->list_accounts_url()), client_login_to_oauth2_gurl_( GaiaUrls::GetInstance()->client_login_to_oauth2_url()), fetch_pending_(false) {} @@ -659,6 +660,19 @@ void GaiaAuthFetcher::StartOAuthLogin(const std::string& access_token, fetcher_->Start(); } +void GaiaAuthFetcher::StartListAccounts() { + DCHECK(!fetch_pending_) << "Tried to fetch two things at once!"; + + fetcher_.reset(CreateGaiaFetcher(getter_, + " ", // To force an HTTP POST. + "Origin: https://www.google.com", + list_accounts_gurl_, + net::LOAD_NORMAL, + this)); + fetch_pending_ = true; + fetcher_->Start(); +} + // static GoogleServiceAuthError GaiaAuthFetcher::GenerateAuthError( const std::string& data, @@ -844,6 +858,16 @@ void GaiaAuthFetcher::OnOAuth2RevokeTokenFetched( consumer_->OnOAuth2RevokeTokenCompleted(); } +void GaiaAuthFetcher::OnListAccountsFetched(const std::string& data, + const net::URLRequestStatus& status, + int response_code) { + if (status.is_success() && response_code == net::HTTP_OK) { + consumer_->OnListAccountsSuccess(data); + } else { + consumer_->OnListAccountsFailure(GenerateAuthError(data, status)); + } +} + void GaiaAuthFetcher::OnGetUserInfoFetched( const std::string& data, const net::URLRequestStatus& status, @@ -937,6 +961,8 @@ void GaiaAuthFetcher::OnURLFetchComplete(const net::URLFetcher* source) { OnOAuthLoginFetched(data, status, response_code); } else if (url == oauth2_revoke_gurl_) { OnOAuth2RevokeTokenFetched(data, status, response_code); + } else if (url == list_accounts_gurl_) { + OnListAccountsFetched(data, status, response_code); } else { NOTREACHED(); } diff --git a/google_apis/gaia/gaia_auth_fetcher.h b/google_apis/gaia/gaia_auth_fetcher.h index 5021a53..0864f18 100644 --- a/google_apis/gaia/gaia_auth_fetcher.h +++ b/google_apis/gaia/gaia_auth_fetcher.h @@ -158,6 +158,9 @@ class GaiaAuthFetcher : public net::URLFetcherDelegate { void StartOAuthLogin(const std::string& access_token, const std::string& service); + // Starts a request to list the accounts in the GAIA cookie. + void StartListAccounts(); + // Implementation of net::URLFetcherDelegate virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; @@ -253,6 +256,10 @@ class GaiaAuthFetcher : public net::URLFetcherDelegate { const net::URLRequestStatus& status, int response_code); + void OnListAccountsFetched(const std::string& data, + const net::URLRequestStatus& status, + int response_code); + void OnGetUserInfoFetched(const std::string& data, const net::URLRequestStatus& status, int response_code); @@ -359,6 +366,7 @@ class GaiaAuthFetcher : public net::URLFetcherDelegate { const GURL merge_session_gurl_; const GURL uberauth_token_gurl_; const GURL oauth_login_gurl_; + const GURL list_accounts_gurl_; // While a fetch is going on: scoped_ptr<net::URLFetcher> fetcher_; diff --git a/google_apis/gaia/gaia_auth_fetcher_unittest.cc b/google_apis/gaia/gaia_auth_fetcher_unittest.cc index 8970691..a12fb97 100644 --- a/google_apis/gaia/gaia_auth_fetcher_unittest.cc +++ b/google_apis/gaia/gaia_auth_fetcher_unittest.cc @@ -187,6 +187,7 @@ class MockGaiaConsumer : public GaiaAuthConsumer { const GoogleServiceAuthError& error)); MOCK_METHOD1(OnUberAuthTokenFailure, void( const GoogleServiceAuthError& error)); + MOCK_METHOD1(OnListAccountsSuccess, void(const std::string& data)); }; #if defined(OS_WIN) @@ -789,3 +790,17 @@ TEST_F(GaiaAuthFetcherTest, StartOAuthLogin) { net::URLFetcher::GET, &auth); auth.OnURLFetchComplete(&mock_fetcher); } + +TEST_F(GaiaAuthFetcherTest, ListAccounts) { + std::string data("[\"gaia.l.a.r\", [" + "[\"gaia.l.a\", 1, \"First Last\", \"user@gmail.com\", " + "\"//googleusercontent.com/A/B/C/D/photo.jpg\", 1, 1, 0]]]"); + MockGaiaConsumer consumer; + EXPECT_CALL(consumer, OnListAccountsSuccess(data)).Times(1); + + GaiaAuthFetcher auth(&consumer, std::string(), GetRequestContext()); + net::URLRequestStatus status(net::URLRequestStatus::SUCCESS, 0); + MockFetcher mock_fetcher(GaiaUrls::GetInstance()->list_accounts_url(), + status, net::HTTP_OK, cookies_, data, net::URLFetcher::GET, &auth); + auth.OnURLFetchComplete(&mock_fetcher); +} diff --git a/google_apis/gaia/gaia_urls.cc b/google_apis/gaia/gaia_urls.cc index 43e4bf9..16bd9d6 100644 --- a/google_apis/gaia/gaia_urls.cc +++ b/google_apis/gaia/gaia_urls.cc @@ -28,6 +28,7 @@ const char kOAuthGetAccessTokenUrlSuffix[] = "OAuthGetAccessToken"; const char kOAuthWrapBridgeUrlSuffix[] = "OAuthWrapBridge"; const char kOAuth1LoginUrlSuffix[] = "OAuthLogin"; const char kOAuthRevokeTokenUrlSuffix[] = "AuthSubRevokeToken"; +const char kListAccountsSuffix[] = "ListAccounts"; // OAuth scopes const char kOAuth1LoginScope[] = "https://www.google.com/accounts/OAuthLogin"; @@ -103,6 +104,7 @@ GaiaUrls::GaiaUrls() { oauth_wrap_bridge_url_ = gaia_url_.Resolve(kOAuthWrapBridgeUrlSuffix); oauth_revoke_token_url_ = gaia_url_.Resolve(kOAuthRevokeTokenUrlSuffix); oauth1_login_url_ = gaia_url_.Resolve(kOAuth1LoginUrlSuffix); + list_accounts_url_ = gaia_url_.Resolve(kListAccountsSuffix); // URLs from accounts.google.com (LSO). get_oauth_token_url_ = lso_origin_url_.Resolve(kGetOAuthTokenUrlSuffix); @@ -198,6 +200,10 @@ const GURL& GaiaUrls::oauth1_login_url() const { return oauth1_login_url_; } +const GURL& GaiaUrls::list_accounts_url() const { + return list_accounts_url_; +} + const std::string& GaiaUrls::oauth1_login_scope() const { return oauth1_login_scope_; } diff --git a/google_apis/gaia/gaia_urls.h b/google_apis/gaia/gaia_urls.h index e06b95d..51addeb 100644 --- a/google_apis/gaia/gaia_urls.h +++ b/google_apis/gaia/gaia_urls.h @@ -32,6 +32,7 @@ class GaiaUrls { const GURL& oauth_user_info_url() const; const GURL& oauth_revoke_token_url() const; const GURL& oauth1_login_url() const; + const GURL& list_accounts_url() const; const std::string& oauth1_login_scope() const; const std::string& oauth_wrap_bridge_user_info_scope() const; @@ -73,6 +74,7 @@ class GaiaUrls { GURL oauth_user_info_url_; GURL oauth_revoke_token_url_; GURL oauth1_login_url_; + GURL list_accounts_url_; std::string oauth1_login_scope_; std::string oauth_wrap_bridge_user_info_scope_; |