Commit 0ed0d294 authored by pavely@chromium.org's avatar pavely@chromium.org

Remove GaiaAuthFetcher::StartCookieForOAuthCodeExchange.

It is not used anywhere.

R=rogerta@chromium.org
BUG=

Review URL: https://codereview.chromium.org/301323003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@273968 0039d316-1c4b-4281-b951-d872f2087c98
parent 5a0e61be
...@@ -72,9 +72,6 @@ class GaiaAuthConsumer { ...@@ -72,9 +72,6 @@ class GaiaAuthConsumer {
virtual void OnClientOAuthSuccess(const ClientOAuthResult& result) {} virtual void OnClientOAuthSuccess(const ClientOAuthResult& result) {}
virtual void OnClientOAuthFailure(const GoogleServiceAuthError& error) {} virtual void OnClientOAuthFailure(const GoogleServiceAuthError& error) {}
virtual void OnClientOAuthCodeSuccess(const std::string& auth_code) {}
virtual void OnClientOAuthCodeFailure(const GoogleServiceAuthError& error) {}
virtual void OnOAuth2RevokeTokenCompleted() {} virtual void OnOAuth2RevokeTokenCompleted() {}
virtual void OnGetUserInfoSuccess(const UserInfoMap& data) {} virtual void OnGetUserInfoSuccess(const UserInfoMap& data) {}
......
...@@ -183,8 +183,7 @@ GaiaAuthFetcher::GaiaAuthFetcher(GaiaAuthConsumer* consumer, ...@@ -183,8 +183,7 @@ GaiaAuthFetcher::GaiaAuthFetcher(GaiaAuthConsumer* consumer,
list_accounts_gurl_(GaiaUrls::GetInstance()->list_accounts_url()), list_accounts_gurl_(GaiaUrls::GetInstance()->list_accounts_url()),
client_login_to_oauth2_gurl_( client_login_to_oauth2_gurl_(
GaiaUrls::GetInstance()->client_login_to_oauth2_url()), GaiaUrls::GetInstance()->client_login_to_oauth2_url()),
fetch_pending_(false), fetch_pending_(false) {}
fetch_code_only_(false) {}
GaiaAuthFetcher::~GaiaAuthFetcher() {} GaiaAuthFetcher::~GaiaAuthFetcher() {}
...@@ -544,13 +543,6 @@ void GaiaAuthFetcher::StartRevokeOAuth2Token(const std::string& auth_token) { ...@@ -544,13 +543,6 @@ void GaiaAuthFetcher::StartRevokeOAuth2Token(const std::string& auth_token) {
fetcher_->Start(); fetcher_->Start();
} }
void GaiaAuthFetcher::StartCookieForOAuthCodeExchange(
const std::string& session_index) {
// Same as the first step of StartCookieForOAuthLoginTokenExchange;
StartCookieForOAuthLoginTokenExchange(session_index);
fetch_code_only_ = true;
}
void GaiaAuthFetcher::StartCookieForOAuthLoginTokenExchange( void GaiaAuthFetcher::StartCookieForOAuthLoginTokenExchange(
const std::string& session_index) { const std::string& session_index) {
DCHECK(!fetch_pending_) << "Tried to fetch two things at once!"; DCHECK(!fetch_pending_) << "Tried to fetch two things at once!";
...@@ -572,7 +564,6 @@ void GaiaAuthFetcher::StartCookieForOAuthLoginTokenExchange( ...@@ -572,7 +564,6 @@ void GaiaAuthFetcher::StartCookieForOAuthLoginTokenExchange(
net::LOAD_NORMAL, net::LOAD_NORMAL,
this)); this));
fetch_pending_ = true; fetch_pending_ = true;
fetch_code_only_ = false;
fetcher_->Start(); fetcher_->Start();
} }
...@@ -764,15 +755,9 @@ void GaiaAuthFetcher::OnClientLoginToOAuth2Fetched( ...@@ -764,15 +755,9 @@ void GaiaAuthFetcher::OnClientLoginToOAuth2Fetched(
if (status.is_success() && response_code == net::HTTP_OK) { if (status.is_success() && response_code == net::HTTP_OK) {
std::string auth_code; std::string auth_code;
ParseClientLoginToOAuth2Response(cookies, &auth_code); ParseClientLoginToOAuth2Response(cookies, &auth_code);
if (fetch_code_only_)
consumer_->OnClientOAuthCodeSuccess(auth_code);
else
StartAuthCodeForOAuth2TokenExchange(auth_code); StartAuthCodeForOAuth2TokenExchange(auth_code);
} else { } else {
GoogleServiceAuthError auth_error(GenerateAuthError(data, status)); GoogleServiceAuthError auth_error(GenerateAuthError(data, status));
if (fetch_code_only_)
consumer_->OnClientOAuthCodeFailure(auth_error);
else
consumer_->OnClientOAuthFailure(auth_error); consumer_->OnClientOAuthFailure(auth_error);
} }
} }
......
...@@ -106,15 +106,6 @@ class GaiaAuthFetcher : public net::URLFetcherDelegate { ...@@ -106,15 +106,6 @@ class GaiaAuthFetcher : public net::URLFetcherDelegate {
// thread. // thread.
void StartRevokeOAuth2Token(const std::string& auth_token); void StartRevokeOAuth2Token(const std::string& auth_token);
// Start a request to exchange the cookies of a signed-in user session
// for an OAuth2 authorization code. In the case of a session with
// multiple accounts signed in, |session_index| indicate the which of accounts
// within the session.
//
// Either OnClientOAuthCodeSuccess or OnClientOAuthCodeFailure will be
// called on the consumer on the original thread.
void StartCookieForOAuthCodeExchange(const std::string& session_index);
// Start a request to exchange the cookies of a signed-in user session // Start a request to exchange the cookies of a signed-in user session
// for an OAuthLogin-scoped oauth2 token. In the case of a session with // for an OAuthLogin-scoped oauth2 token. In the case of a session with
// multiple accounts signed in, |session_index| indicate the which of accounts // multiple accounts signed in, |session_index| indicate the which of accounts
...@@ -383,9 +374,6 @@ class GaiaAuthFetcher : public net::URLFetcherDelegate { ...@@ -383,9 +374,6 @@ class GaiaAuthFetcher : public net::URLFetcherDelegate {
std::string request_body_; std::string request_body_;
std::string requested_service_; // Currently tracked for IssueAuthToken only. std::string requested_service_; // Currently tracked for IssueAuthToken only.
bool fetch_pending_; bool fetch_pending_;
// This is to distinguish between the fetch for oauth login token and that for
// oauth code.
bool fetch_code_only_;
friend class GaiaAuthFetcherTest; friend class GaiaAuthFetcherTest;
FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, CaptchaParse); FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, CaptchaParse);
......
...@@ -175,8 +175,6 @@ class MockGaiaConsumer : public GaiaAuthConsumer { ...@@ -175,8 +175,6 @@ class MockGaiaConsumer : public GaiaAuthConsumer {
const std::string& token)); const std::string& token));
MOCK_METHOD1(OnClientOAuthSuccess, MOCK_METHOD1(OnClientOAuthSuccess,
void(const GaiaAuthConsumer::ClientOAuthResult& result)); void(const GaiaAuthConsumer::ClientOAuthResult& result));
MOCK_METHOD1(OnClientOAuthCodeSuccess,
void(const std::string& result));
MOCK_METHOD1(OnMergeSessionSuccess, void(const std::string& data)); MOCK_METHOD1(OnMergeSessionSuccess, void(const std::string& data));
MOCK_METHOD1(OnUberAuthTokenSuccess, void(const std::string& data)); MOCK_METHOD1(OnUberAuthTokenSuccess, void(const std::string& data));
MOCK_METHOD1(OnClientLoginFailure, MOCK_METHOD1(OnClientLoginFailure,
...@@ -185,8 +183,6 @@ class MockGaiaConsumer : public GaiaAuthConsumer { ...@@ -185,8 +183,6 @@ class MockGaiaConsumer : public GaiaAuthConsumer {
const GoogleServiceAuthError& error)); const GoogleServiceAuthError& error));
MOCK_METHOD1(OnClientOAuthFailure, MOCK_METHOD1(OnClientOAuthFailure,
void(const GoogleServiceAuthError& error)); void(const GoogleServiceAuthError& error));
MOCK_METHOD1(OnClientOAuthCodeFailure,
void(const GoogleServiceAuthError& error));
MOCK_METHOD1(OnMergeSessionFailure, void( MOCK_METHOD1(OnMergeSessionFailure, void(
const GoogleServiceAuthError& error)); const GoogleServiceAuthError& error));
MOCK_METHOD1(OnUberAuthTokenFailure, void( MOCK_METHOD1(OnUberAuthTokenFailure, void(
...@@ -632,54 +628,6 @@ TEST_F(GaiaAuthFetcherTest, OAuthLoginTokenOAuth2TokenPairFailure) { ...@@ -632,54 +628,6 @@ TEST_F(GaiaAuthFetcherTest, OAuthLoginTokenOAuth2TokenPairFailure) {
EXPECT_FALSE(auth.HasPendingFetch()); EXPECT_FALSE(auth.HasPendingFetch());
} }
TEST_F(GaiaAuthFetcherTest, OAuthCodeWithCookiesSuccess) {
MockGaiaConsumer consumer;
EXPECT_CALL(consumer, OnClientOAuthCodeSuccess("test-code")).Times(1);
net::TestURLFetcherFactory factory;
GaiaAuthFetcher auth(&consumer, std::string(), GetRequestContext());
auth.StartCookieForOAuthCodeExchange("");
net::TestURLFetcher* fetcher = factory.GetFetcherByID(0);
EXPECT_TRUE(NULL != fetcher);
EXPECT_EQ(net::LOAD_NORMAL, fetcher->GetLoadFlags());
EXPECT_TRUE(auth.HasPendingFetch());
net::ResponseCookies cookies;
cookies.push_back(kGetAuthCodeValidCookie);
MockFetcher mock_fetcher(
client_login_to_oauth2_source_,
net::URLRequestStatus(net::URLRequestStatus::SUCCESS, 0),
net::HTTP_OK,
cookies,
std::string(),
net::URLFetcher::POST,
&auth);
auth.OnURLFetchComplete(&mock_fetcher);
EXPECT_FALSE(auth.HasPendingFetch());
}
TEST_F(GaiaAuthFetcherTest, OAuthCodeWithCookiesFailure) {
MockGaiaConsumer consumer;
EXPECT_CALL(consumer, OnClientOAuthCodeFailure(_)).Times(1);
GaiaAuthFetcher auth(&consumer, std::string(), GetRequestContext());
auth.StartCookieForOAuthCodeExchange("");
EXPECT_TRUE(auth.HasPendingFetch());
net::ResponseCookies cookies;
MockFetcher mock_fetcher(
client_login_to_oauth2_source_,
net::URLRequestStatus(net::URLRequestStatus::SUCCESS, 0),
net::HTTP_FORBIDDEN,
cookies,
std::string(),
net::URLFetcher::POST,
&auth);
auth.OnURLFetchComplete(&mock_fetcher);
EXPECT_FALSE(auth.HasPendingFetch());
}
TEST_F(GaiaAuthFetcherTest, MergeSessionSuccess) { TEST_F(GaiaAuthFetcherTest, MergeSessionSuccess) {
MockGaiaConsumer consumer; MockGaiaConsumer consumer;
EXPECT_CALL(consumer, OnMergeSessionSuccess("<html></html>")) EXPECT_CALL(consumer, OnMergeSessionSuccess("<html></html>"))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment