Chromium Code Reviews| Index: components/autofill/content/browser/wallet/wallet_signin_helper.cc |
| diff --git a/components/autofill/content/browser/wallet/wallet_signin_helper.cc b/components/autofill/content/browser/wallet/wallet_signin_helper.cc |
| index 1474a93393c9f70c9e0fe37393d31217f4211792..0fd95ebea28f0e5fc721bd7bf5a16279234432ec 100644 |
| --- a/components/autofill/content/browser/wallet/wallet_signin_helper.cc |
| +++ b/components/autofill/content/browser/wallet/wallet_signin_helper.cc |
| @@ -214,15 +214,11 @@ void WalletSigninHelper::OnURLFetchComplete( |
| break; |
| case PASSIVE_EXECUTING_SIGNIN: |
| - url_fetcher_.reset(); |
| - state_ = PASSIVE_FETCHING_USERINFO; |
| - StartFetchingUserNameFromSession(); |
| + ProcessPassiveSignInResponseAndFetchUserName(); |
| break; |
| case AUTOMATIC_EXECUTING_SIGNIN: |
| - state_ = IDLE; |
| - url_fetcher_.reset(); |
| - delegate_->OnAutomaticSigninSuccess(username_); |
| + ProcessAutomaticSignInResponseAndFinish(); |
| break; |
| default: |
| @@ -243,6 +239,30 @@ void WalletSigninHelper::StartFetchingUserNameFromSession() { |
| url_fetcher_->Start(); // This will result in OnURLFetchComplete callback. |
| } |
| +void WalletSigninHelper::ProcessPassiveSignInResponseAndFetchUserName() { |
| + GoogleServiceAuthError error(GoogleServiceAuthError::AuthErrorNone()); |
| + if (!ParsePassiveSignInResponse(&error)) { |
| + OnServiceError(error); |
| + return; |
| + } |
| + |
| + url_fetcher_.reset(); |
| + state_ = PASSIVE_FETCHING_USERINFO; |
| + StartFetchingUserNameFromSession(); |
| +} |
| + |
| +void WalletSigninHelper::ProcessAutomaticSignInResponseAndFinish() { |
| + GoogleServiceAuthError error(GoogleServiceAuthError::AuthErrorNone()); |
| + if (!ParsePassiveSignInResponse(&error)) { |
| + OnServiceError(error); |
| + return; |
| + } |
| + |
| + url_fetcher_.reset(); |
| + state_ = IDLE; |
| + delegate_->OnAutomaticSigninSuccess(username_); |
| +} |
| + |
| void WalletSigninHelper::ProcessGetAccountInfoResponseAndFinish() { |
| std::string email; |
| if (!ParseGetAccountInfoResponse(url_fetcher_.get(), &email)) { |
| @@ -294,5 +314,23 @@ bool WalletSigninHelper::ParseGetAccountInfoResponse( |
| return !email->empty(); |
| } |
| +bool WalletSigninHelper::ParsePassiveSignInResponse( |
| + GoogleServiceAuthError* error) { |
|
ahutter
2013/06/13 23:52:10
Should you DCHECK(error)?
aruslan
2013/06/18 21:21:47
Done.
|
| + std::string data; |
| + if (!url_fetcher_->GetResponseAsString(&data)) { |
| + LOG(ERROR) << "failed to GetResponseAsString"; |
| + *error = GoogleServiceAuthError::AuthErrorNone(); |
| + return false; |
| + } |
| + |
| + if (data != "YES") { |
| + *error = |
| + GoogleServiceAuthError(GoogleServiceAuthError::USER_NOT_SIGNED_UP); |
| + return false; |
| + } |
| + |
| + return true; |
| +} |
| + |
| } // namespace wallet |
| } // namespace autofill |