diff options
Diffstat (limited to 'components/autofill/content/browser/wallet')
9 files changed, 115 insertions, 308 deletions
diff --git a/components/autofill/content/browser/wallet/wallet_items.cc b/components/autofill/content/browser/wallet/wallet_items.cc index fbc49ef..a6d7de3 100644 --- a/components/autofill/content/browser/wallet/wallet_items.cc +++ b/components/autofill/content/browser/wallet/wallet_items.cc @@ -417,13 +417,15 @@ WalletItems::WalletItems(const std::vector<RequiredAction>& required_actions, const std::string& default_instrument_id, const std::string& default_address_id, const std::string& obfuscated_gaia_id, - AmexPermission amex_permission) + AmexPermission amex_permission, + const std::vector<std::string>& gaia_accounts) : required_actions_(required_actions), google_transaction_id_(google_transaction_id), default_instrument_id_(default_instrument_id), default_address_id_(default_address_id), obfuscated_gaia_id_(obfuscated_gaia_id), - amex_permission_(amex_permission) {} + amex_permission_(amex_permission), + gaia_accounts_(gaia_accounts) {} WalletItems::~WalletItems() {} @@ -473,12 +475,30 @@ scoped_ptr<WalletItems> AmexPermission amex_permission = amex_disallowed ? AMEX_DISALLOWED : AMEX_ALLOWED; + std::vector<std::string> gaia_accounts; + const base::ListValue* gaia_profiles; + if (dictionary.GetList("gaia_profile", &gaia_profiles)) { + for (size_t i = 0; i < gaia_profiles->GetSize(); ++i) { + const base::DictionaryValue* account_dict; + std::string email; + if (gaia_profiles->GetDictionary(i, &account_dict) && + account_dict->GetString("buyer_email", &email)) { + gaia_accounts.push_back(email); + } else { + DVLOG(1) << "Response from Google Wallet has malformed GAIA profile."; + } + } + } else { + DVLOG(1) << "Response from Google wallet missing GAIA profiles."; + } + scoped_ptr<WalletItems> wallet_items(new WalletItems(required_action, google_transaction_id, default_instrument_id, default_address_id, obfuscated_gaia_id, - amex_permission)); + amex_permission, + gaia_accounts)); const ListValue* legal_docs; if (dictionary.GetList("required_legal_document", &legal_docs)) { diff --git a/components/autofill/content/browser/wallet/wallet_items.h b/components/autofill/content/browser/wallet/wallet_items.h index 257bbad..32f1118 100644 --- a/components/autofill/content/browser/wallet/wallet_items.h +++ b/components/autofill/content/browser/wallet/wallet_items.h @@ -259,6 +259,9 @@ class WalletItems { const std::vector<Address*>& addresses() const { return addresses_.get(); } const std::string& default_address_id() const { return default_address_id_; } const std::string& obfuscated_gaia_id() const { return obfuscated_gaia_id_; } + const std::vector<std::string>& gaia_accounts() const { + return gaia_accounts_; + } const std::vector<LegalDocument*>& legal_documents() const { return legal_documents_.get(); } @@ -267,7 +270,10 @@ class WalletItems { friend class WalletItemsTest; friend scoped_ptr<WalletItems> GetTestWalletItems( const std::vector<RequiredAction>&, - const std::string&, const std::string&, AmexPermission); + const std::string&, + const std::string&, + AmexPermission, + const std::vector<std::string>&); friend scoped_ptr<WalletItems> GetTestWalletItemsWithDefaultIds( RequiredAction action); FRIEND_TEST_ALL_PREFIXES(WalletItemsTest, CreateWalletItems); @@ -279,7 +285,8 @@ class WalletItems { const std::string& default_instrument_id, const std::string& default_address_id, const std::string& obfuscated_gaia_id, - AmexPermission amex_permission); + AmexPermission amex_permission, + const std::vector<std::string>& gaia_accounts); // Actions that must be completed by the user before a FullWallet can be // issued to them by the Online Wallet service. @@ -309,6 +316,11 @@ class WalletItems { // Whether Google Wallet allows American Express card for this merchant. AmexPermission amex_permission_; + // The complete set of logged in GAIA accounts. This just stores email + // addresses. The actual response has more metadata which we currently + // ignore. + std::vector<std::string> gaia_accounts_; + DISALLOW_COPY_AND_ASSIGN(WalletItems); }; diff --git a/components/autofill/content/browser/wallet/wallet_items_unittest.cc b/components/autofill/content/browser/wallet/wallet_items_unittest.cc index a1b32f6..142c74a 100644 --- a/components/autofill/content/browser/wallet/wallet_items_unittest.cc +++ b/components/autofill/content/browser/wallet/wallet_items_unittest.cc @@ -346,7 +346,32 @@ const char kWalletItems[] = " ]," " \"default_address_id\":\"default_address_id\"," " \"obfuscated_gaia_id\":\"obfuscated_gaia_id\"," - " \"amex_disallowed\":true"; + " \"amex_disallowed\":true," + " \"gaia_profile\":" + " [" + " {" + " \"buyer_email\":\"user@chromium.org\"," + " \"gaia_index\":0," + " \"gaia_id\":\"123456789\"," + " \"buyer_name\":\"Joe Usecase\"," + " \"is_active\":true," + " \"avatar_url_27x27\":\"https://lh3.googleusercontent.com/27.jpg\"," + " \"avatar_url_54x54\":\"https://lh3.googleusercontent.com/54.jpg\"," + " \"avatar_url_48x48\":\"https://lh3.googleusercontent.com/48.jpg\"," + " \"avatar_url_96x96\":\"https://lh3.googleusercontent.com/96.jpg\"" + " }," + " {" + " \"buyer_email\":\"user2@chromium.org\"," + " \"gaia_index\":1," + " \"gaia_id\":\"123456789\"," + " \"buyer_name\":\"Jill Usecase\"," + " \"is_active\":false," + " \"avatar_url_27x27\":\"https://lh3.googleusercontent.com/27.jpg\"," + " \"avatar_url_54x54\":\"https://lh3.googleusercontent.com/54.jpg\"," + " \"avatar_url_48x48\":\"https://lh3.googleusercontent.com/48.jpg\"," + " \"avatar_url_96x96\":\"https://lh3.googleusercontent.com/96.jpg\"" + " }" + " ]"; const char kRequiredLegalDocument[] = " ," @@ -488,7 +513,8 @@ TEST_F(WalletItemsTest, CreateWalletItemsWithRequiredActions) { std::string(), std::string(), std::string(), - AMEX_DISALLOWED); + AMEX_DISALLOWED, + std::vector<std::string>()); EXPECT_EQ(expected, *WalletItems::CreateWalletItems(*dict)); ASSERT_FALSE(required_actions.empty()); @@ -498,7 +524,8 @@ TEST_F(WalletItemsTest, CreateWalletItemsWithRequiredActions) { std::string(), std::string(), std::string(), - AMEX_DISALLOWED); + AMEX_DISALLOWED, + std::vector<std::string>()); EXPECT_NE(expected, different_required_actions); } @@ -525,12 +552,16 @@ TEST_F(WalletItemsTest, CreateWalletItemsMissingAmexDisallowed) { TEST_F(WalletItemsTest, CreateWalletItems) { SetUpDictionary(std::string(kWalletItems) + std::string(kCloseJson)); std::vector<RequiredAction> required_actions; + std::vector<std::string> users; + users.push_back("user@chromium.org"); + users.push_back("user2@chromium.org"); WalletItems expected(required_actions, "google_transaction_id", "default_instrument_id", "default_address_id", "obfuscated_gaia_id", - AMEX_DISALLOWED); + AMEX_DISALLOWED, + users); scoped_ptr<Address> billing_address(new Address("US", ASCIIToUTF16("name"), diff --git a/components/autofill/content/browser/wallet/wallet_signin_helper.cc b/components/autofill/content/browser/wallet/wallet_signin_helper.cc index 304426f1..b16a1cd 100644 --- a/components/autofill/content/browser/wallet/wallet_signin_helper.cc +++ b/components/autofill/content/browser/wallet/wallet_signin_helper.cc @@ -30,11 +30,6 @@ namespace wallet { namespace { -// Toolbar::GetAccountInfo API URL (JSON). -const char kGetAccountInfoUrlFormat[] = - "https://clients1.google.com/tbproxy/getaccountinfo?key=%d&rv=2" - "&requestor=chrome"; - const char kWalletCookieName[] = "gdtoken"; // Callback for retrieving Google Wallet cookies. |callback| is passed the @@ -46,7 +41,7 @@ void GetGoogleCookiesCallback( DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); // Cookies for parent domains will also be returned; we only want cookies with - // exact host matches. + // exact host matches. TODO(estade): really? std::string host = wallet::GetPassiveAuthUrl().host(); std::string wallet_cookie; for (size_t i = 0; i < cookies.size(); ++i) { @@ -97,7 +92,6 @@ WalletSigninHelper::WalletSigninHelper( net::URLRequestContextGetter* getter) : delegate_(delegate), getter_(getter), - state_(IDLE), weak_ptr_factory_(this) { DCHECK(delegate_); } @@ -106,11 +100,8 @@ WalletSigninHelper::~WalletSigninHelper() { } void WalletSigninHelper::StartPassiveSignin() { - DCHECK_EQ(IDLE, state_); DCHECK(!url_fetcher_); - state_ = PASSIVE_EXECUTING_SIGNIN; - emails_.clear(); const GURL& url = wallet::GetPassiveAuthUrl(); url_fetcher_.reset(net::URLFetcher::Create( 0, url, net::URLFetcher::GET, this)); @@ -118,15 +109,6 @@ void WalletSigninHelper::StartPassiveSignin() { url_fetcher_->Start(); } -void WalletSigninHelper::StartUserNameFetch() { - DCHECK_EQ(state_, IDLE); - DCHECK(!url_fetcher_); - - state_ = USERNAME_FETCHING_USERINFO; - emails_.clear(); - StartFetchingUserNameFromSession(); -} - void WalletSigninHelper::StartWalletCookieValueFetch() { scoped_refptr<net::URLRequestContextGetter> request_context(getter_); if (!request_context.get()) { @@ -142,29 +124,8 @@ void WalletSigninHelper::StartWalletCookieValueFetch() { content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE, task); } -std::string WalletSigninHelper::GetGetAccountInfoUrlForTesting() const { - return base::StringPrintf(kGetAccountInfoUrlFormat, 0); -} - void WalletSigninHelper::OnServiceError(const GoogleServiceAuthError& error) { - const State state_with_error = state_; - state_ = IDLE; - url_fetcher_.reset(); - - switch(state_with_error) { - case IDLE: - NOTREACHED(); - break; - - case PASSIVE_EXECUTING_SIGNIN: /*FALLTHROUGH*/ - case PASSIVE_FETCHING_USERINFO: - delegate_->OnPassiveSigninFailure(error); - break; - - case USERNAME_FETCHING_USERINFO: - delegate_->OnUserNameFetchFailure(error); - break; - } + delegate_->OnPassiveSigninFailure(error); } void WalletSigninHelper::OnOtherError() { @@ -174,141 +135,33 @@ void WalletSigninHelper::OnOtherError() { void WalletSigninHelper::OnURLFetchComplete( const net::URLFetcher* fetcher) { DCHECK_EQ(url_fetcher_.get(), fetcher); + scoped_ptr<net::URLFetcher> url_fetcher(url_fetcher_.release()); + if (!fetcher->GetStatus().is_success() || fetcher->GetResponseCode() < 200 || fetcher->GetResponseCode() >= 300) { - LOG(ERROR) << "URLFetchFailure: state=" << state_ - << " r=" << fetcher->GetResponseCode() - << " s=" << fetcher->GetStatus().status() - << " e=" << fetcher->GetStatus().error(); + DVLOG(1) << "URLFetchFailure:" + << " r=" << fetcher->GetResponseCode() + << " s=" << fetcher->GetStatus().status() + << " e=" << fetcher->GetStatus().error(); OnOtherError(); return; } - switch (state_) { - case USERNAME_FETCHING_USERINFO: /*FALLTHROUGH*/ - case PASSIVE_FETCHING_USERINFO: - ProcessGetAccountInfoResponseAndFinish(); - break; - - case PASSIVE_EXECUTING_SIGNIN: - if (ParseSignInResponse()) { - url_fetcher_.reset(); - state_ = PASSIVE_FETCHING_USERINFO; - StartFetchingUserNameFromSession(); - } - break; - - default: - NOTREACHED() << "unexpected state_=" << state_; - } -} - -void WalletSigninHelper::StartFetchingUserNameFromSession() { - const int random_number = static_cast<int>(base::RandUint64() % INT_MAX); - url_fetcher_.reset( - net::URLFetcher::Create( - 0, - GURL(base::StringPrintf(kGetAccountInfoUrlFormat, random_number)), - net::URLFetcher::GET, - this)); - url_fetcher_->SetRequestContext(getter_); - url_fetcher_->Start(); // This will result in OnURLFetchComplete callback. -} - -void WalletSigninHelper::ProcessGetAccountInfoResponseAndFinish() { - if (!ParseGetAccountInfoResponse(url_fetcher_.get(), &emails_)) { - LOG(ERROR) << "failed to get the user emails"; - OnOtherError(); - return; - } - - const State finishing_state = state_; - state_ = IDLE; - url_fetcher_.reset(); - switch(finishing_state) { - case USERNAME_FETCHING_USERINFO: - delegate_->OnUserNameFetchSuccess(emails_); - break; - - case PASSIVE_FETCHING_USERINFO: - delegate_->OnPassiveSigninSuccess(emails_); - break; - - default: - NOTREACHED() << "unexpected state_=" << finishing_state; - } -} - -bool WalletSigninHelper::ParseSignInResponse() { - if (!url_fetcher_) { - NOTREACHED(); - return false; - } - std::string data; - if (!url_fetcher_->GetResponseAsString(&data)) { + if (!fetcher->GetResponseAsString(&data)) { DVLOG(1) << "failed to GetResponseAsString"; OnOtherError(); - return false; + return; } if (!LowerCaseEqualsASCII(data, "yes")) { OnServiceError( GoogleServiceAuthError(GoogleServiceAuthError::USER_NOT_SIGNED_UP)); - return false; - } - - return true; -} - -bool WalletSigninHelper::ParseGetAccountInfoResponse( - const net::URLFetcher* fetcher, std::vector<std::string>* emails) { - DCHECK(emails); - - std::string data; - if (!fetcher->GetResponseAsString(&data)) { - DVLOG(1) << "failed to GetResponseAsString"; - return false; - } - - scoped_ptr<base::Value> value(base::JSONReader::Read(data)); - if (!value.get() || value->GetType() != base::Value::TYPE_DICTIONARY) { - DVLOG(1) << "failed to parse JSON response"; - return false; - } - - DictionaryValue* dict = static_cast<base::DictionaryValue*>(value.get()); - base::ListValue* user_info; - if (!dict->GetListWithoutPathExpansion("user_info", &user_info)) { - DVLOG(1) << "no user_info in JSON response"; - return false; - } - - if (user_info->empty()) { - DVLOG(1) << "empty list in JSON response"; - return false; - } - - // |user_info| will contain each signed in user in the cookie jar. - for (size_t i = 0; i < user_info->GetSize(); ++i) { - base::DictionaryValue* user_info_detail; - if (!user_info->GetDictionary(i, &user_info_detail)) { - DVLOG(1) << "malformed dictionary in JSON response"; - return false; - } - - std::string email; - if (!user_info_detail->GetStringWithoutPathExpansion("email", &email) || - email.empty()) { - DVLOG(1) << "no email in JSON response"; - return false; - } - - emails->push_back(email); + return; } - return true; + delegate_->OnPassiveSigninSuccess(); } void WalletSigninHelper::ReturnWalletCookieValue( diff --git a/components/autofill/content/browser/wallet/wallet_signin_helper.h b/components/autofill/content/browser/wallet/wallet_signin_helper.h index e8a32f5..ebfcfaa 100644 --- a/components/autofill/content/browser/wallet/wallet_signin_helper.h +++ b/components/autofill/content/browser/wallet/wallet_signin_helper.h @@ -47,29 +47,9 @@ class WalletSigninHelper : public net::URLFetcherDelegate { // on the original thread. void StartPassiveSignin(); - // Initiates a fetch of the user name of a signed-in user. - // Either OnUserNameFetchSuccess or OnUserNameFetchFailure will - // be called on the original thread. - void StartUserNameFetch(); - // Initiates the fetch of the user's Google Wallet cookie. void StartWalletCookieValueFetch(); - protected: - // Sign-in helper states (for tests). - enum State { - IDLE, - PASSIVE_EXECUTING_SIGNIN, - PASSIVE_FETCHING_USERINFO, - USERNAME_FETCHING_USERINFO, - }; - - // (For tests) Current state of the sign-in helper. - State state() const { return state_; } - - // (For tests) URL used to fetch the currently signed-in user info. - std::string GetGetAccountInfoUrlForTesting() const; - private: // Called if a service authentication error occurs. void OnServiceError(const GoogleServiceAuthError& error); @@ -80,24 +60,6 @@ class WalletSigninHelper : public net::URLFetcherDelegate { // URLFetcherDelegate implementation. virtual void OnURLFetchComplete(const net::URLFetcher* fetcher) OVERRIDE; - // Initiates fetching of the currently signed-in user information. - void StartFetchingUserNameFromSession(); - - // Processes the user information received from the server by url_fetcher_ - // and calls the delegate callbacks on success/failure. - void ProcessGetAccountInfoResponseAndFinish(); - - // Attempts to parse a response from the Online Wallet sign-in. - // Returns true if the response is correct and the sign-in has succeeded. - // Otherwise, it calls OnServiceError() and returns false. - bool ParseSignInResponse(); - - // Attempts to parse the GetAccountInfo response from the server. - // Returns true on success; the obtained email addresses are stored into - // |emails|. - bool ParseGetAccountInfoResponse(const net::URLFetcher* fetcher, - std::vector<std::string>* emails); - // Callback for when the Google Wallet cookie has been retrieved. void ReturnWalletCookieValue(const std::string& cookie_value); @@ -110,12 +72,6 @@ class WalletSigninHelper : public net::URLFetcherDelegate { // While passive login/merge session URL fetches are going on: scoped_ptr<net::URLFetcher> url_fetcher_; - // User account names (emails) fetched from OnGetUserInfoSuccess(). - std::vector<std::string> emails_; - - // Current internal state of the helper. - State state_; - base::WeakPtrFactory<WalletSigninHelper> weak_ptr_factory_; DISALLOW_COPY_AND_ASSIGN(WalletSigninHelper); diff --git a/components/autofill/content/browser/wallet/wallet_signin_helper_delegate.h b/components/autofill/content/browser/wallet/wallet_signin_helper_delegate.h index f05e36e..28508a3 100644 --- a/components/autofill/content/browser/wallet/wallet_signin_helper_delegate.h +++ b/components/autofill/content/browser/wallet/wallet_signin_helper_delegate.h @@ -20,22 +20,11 @@ class WalletSigninHelperDelegate { virtual ~WalletSigninHelperDelegate() {} // Called on a successful passive sign-in. - // |usernames| contains the signed-in user account names (emails). - virtual void OnPassiveSigninSuccess(const std::vector<std::string>& usernames) - = 0; + virtual void OnPassiveSigninSuccess() = 0; // Called on a failed passive sign-in; |error| describes the error. virtual void OnPassiveSigninFailure(const GoogleServiceAuthError& error) = 0; - // Called on a successful fetch of the signed-in account name. - // |usernames| contains the signed-in user account names (emails). - virtual void OnUserNameFetchSuccess(const std::vector<std::string>& usernames) - = 0; - - // Called on a failed fetch of the signed-in account name. - // |error| described the error. - virtual void OnUserNameFetchFailure(const GoogleServiceAuthError& error) = 0; - // Called when the Google Wallet cookie value has been retrieved. virtual void OnDidFetchWalletCookieValue(const std::string& cookie_value) = 0; }; diff --git a/components/autofill/content/browser/wallet/wallet_signin_helper_unittest.cc b/components/autofill/content/browser/wallet/wallet_signin_helper_unittest.cc index 2247105..5f7d5a2 100644 --- a/components/autofill/content/browser/wallet/wallet_signin_helper_unittest.cc +++ b/components/autofill/content/browser/wallet/wallet_signin_helper_unittest.cc @@ -34,52 +34,23 @@ namespace wallet { namespace { -const char kGetAccountInfoValidResponseFormat[] = - "{\"user_info\":[" - " {" - " \"email\": \"%s\"" - " }" - "]}"; - class MockWalletSigninHelperDelegate : public WalletSigninHelperDelegate { public: - MOCK_METHOD1(OnPassiveSigninSuccess, - void(const std::vector<std::string>& usernames)); - MOCK_METHOD1(OnUserNameFetchSuccess, - void(const std::vector<std::string>& usernames)); + MOCK_METHOD0(OnPassiveSigninSuccess, void()); MOCK_METHOD1(OnPassiveSigninFailure, void(const GoogleServiceAuthError& error)); - MOCK_METHOD1(OnUserNameFetchFailure, - void(const GoogleServiceAuthError& error)); MOCK_METHOD1(OnDidFetchWalletCookieValue, void(const std::string& cookie_value)); }; -class WalletSigninHelperForTesting : public WalletSigninHelper { - public: - WalletSigninHelperForTesting(WalletSigninHelperDelegate* delegate, - net::URLRequestContextGetter* getter) - : WalletSigninHelper(delegate, getter) { - } - - // Bring in the test-only getters. - using WalletSigninHelper::GetGetAccountInfoUrlForTesting; - using WalletSigninHelper::state; - - // Bring in the State enum. - using WalletSigninHelper::State; - using WalletSigninHelper::IDLE; -}; - } // namespace class WalletSigninHelperTest : public testing::Test { protected: virtual void SetUp() OVERRIDE { - signin_helper_.reset(new WalletSigninHelperForTesting( + signin_helper_.reset(new WalletSigninHelper( &mock_delegate_, browser_context_.GetRequestContext())); - EXPECT_EQ(WalletSigninHelperForTesting::IDLE, state()); } virtual void TearDown() OVERRIDE { @@ -104,23 +75,6 @@ class WalletSigninHelperTest : public testing::Test { fetcher->delegate()->OnURLFetchComplete(fetcher); } - void MockSuccessfulGetAccountInfoResponse(const std::string& username) { - SetUpFetcherResponseAndCompleteRequest( - signin_helper_->GetGetAccountInfoUrlForTesting(), net::HTTP_OK, - net::ResponseCookies(), - base::StringPrintf( - kGetAccountInfoValidResponseFormat, - username.c_str())); - } - - void MockFailedGetAccountInfoResponse404() { - SetUpFetcherResponseAndCompleteRequest( - signin_helper_->GetGetAccountInfoUrlForTesting(), - net::HTTP_NOT_FOUND, - net::ResponseCookies(), - std::string()); - } - void MockSuccessfulPassiveSignInResponse() { SetUpFetcherResponseAndCompleteRequest(wallet::GetPassiveAuthUrl().spec(), net::HTTP_OK, @@ -142,12 +96,8 @@ class WalletSigninHelperTest : public testing::Test { std::string()); } - WalletSigninHelperForTesting::State state() const { - return signin_helper_->state(); - } - content::TestBrowserThreadBundle thread_bundle_; - scoped_ptr<WalletSigninHelperForTesting> signin_helper_; + scoped_ptr<WalletSigninHelper> signin_helper_; MockWalletSigninHelperDelegate mock_delegate_; TestingProfile browser_context_; @@ -156,12 +106,9 @@ class WalletSigninHelperTest : public testing::Test { }; TEST_F(WalletSigninHelperTest, PassiveSigninSuccessful) { - std::vector<std::string> usernames; - usernames.push_back("user@gmail.com"); - EXPECT_CALL(mock_delegate_, OnPassiveSigninSuccess(usernames)); + EXPECT_CALL(mock_delegate_, OnPassiveSigninSuccess()); signin_helper_->StartPassiveSignin(); MockSuccessfulPassiveSignInResponse(); - MockSuccessfulGetAccountInfoResponse("user@gmail.com"); } TEST_F(WalletSigninHelperTest, PassiveSigninFailedSignin404) { @@ -176,27 +123,6 @@ TEST_F(WalletSigninHelperTest, PassiveSigninFailedSigninNo) { MockFailedPassiveSignInResponseNo(); } -TEST_F(WalletSigninHelperTest, PassiveSigninFailedUserInfo) { - EXPECT_CALL(mock_delegate_, OnPassiveSigninFailure(_)); - signin_helper_->StartPassiveSignin(); - MockSuccessfulPassiveSignInResponse(); - MockFailedGetAccountInfoResponse404(); -} - -TEST_F(WalletSigninHelperTest, PassiveUserInfoSuccessful) { - std::vector<std::string> usernames; - usernames.push_back("user@gmail.com"); - EXPECT_CALL(mock_delegate_, OnUserNameFetchSuccess(usernames)); - signin_helper_->StartUserNameFetch(); - MockSuccessfulGetAccountInfoResponse("user@gmail.com"); -} - -TEST_F(WalletSigninHelperTest, PassiveUserInfoFailedUserInfo) { - EXPECT_CALL(mock_delegate_, OnUserNameFetchFailure(_)); - signin_helper_->StartUserNameFetch(); - MockFailedGetAccountInfoResponse404(); -} - TEST_F(WalletSigninHelperTest, GetWalletCookieValueWhenPresent) { EXPECT_CALL(mock_delegate_, OnDidFetchWalletCookieValue("gdToken")); net::CookieMonster* cookie_monster = new net::CookieMonster(NULL, NULL); diff --git a/components/autofill/content/browser/wallet/wallet_test_util.cc b/components/autofill/content/browser/wallet/wallet_test_util.cc index 1360e05..d5e5af0 100644 --- a/components/autofill/content/browser/wallet/wallet_test_util.cc +++ b/components/autofill/content/browser/wallet/wallet_test_util.cc @@ -235,24 +235,30 @@ scoped_ptr<WalletItems> GetTestWalletItems( const std::vector<RequiredAction>& required_actions, const std::string& default_instrument_id, const std::string& default_address_id, - AmexPermission amex_permission) { + AmexPermission amex_permission, + const std::vector<std::string>& users) { return scoped_ptr<WalletItems>( new wallet::WalletItems(required_actions, "google_transaction_id", default_instrument_id, default_address_id, "obfuscated_gaia_id", - amex_permission)); + amex_permission, + users)); } scoped_ptr<WalletItems> GetTestWalletItemsWithRequiredAction( RequiredAction action) { - std::vector<RequiredAction> required_actions; - required_actions.push_back(action); + std::vector<RequiredAction> required_actions(1, action); + std::vector<std::string> users; + if (action != GAIA_AUTH) + users.push_back("user@example.com"); + return GetTestWalletItems(required_actions, "default_instrument_id", "default_address_id", - AMEX_ALLOWED); + AMEX_ALLOWED, + users); } scoped_ptr<WalletItems> GetTestWalletItems(AmexPermission amex_permission) { @@ -261,14 +267,26 @@ scoped_ptr<WalletItems> GetTestWalletItems(AmexPermission amex_permission) { amex_permission); } + +scoped_ptr<WalletItems> GetTestWalletItemsWithUsers( + std::vector<std::string>& users) { + return GetTestWalletItems(std::vector<RequiredAction>(), + "default_instrument_id", + "default_address_id", + AMEX_ALLOWED, + users); +} + scoped_ptr<WalletItems> GetTestWalletItemsWithDefaultIds( const std::string& default_instrument_id, const std::string& default_address_id, AmexPermission amex_permission) { + std::vector<std::string> users(1, "user@example.com"); return GetTestWalletItems(std::vector<RequiredAction>(), default_instrument_id, default_address_id, - amex_permission); + amex_permission, + users); } } // namespace wallet diff --git a/components/autofill/content/browser/wallet/wallet_test_util.h b/components/autofill/content/browser/wallet/wallet_test_util.h index cc1fdf1..e6d33f6 100644 --- a/components/autofill/content/browser/wallet/wallet_test_util.h +++ b/components/autofill/content/browser/wallet/wallet_test_util.h @@ -50,6 +50,8 @@ scoped_ptr<Address> GetTestNonDefaultShippingAddress(); scoped_ptr<WalletItems> GetTestWalletItemsWithRequiredAction( RequiredAction action); scoped_ptr<WalletItems> GetTestWalletItems(AmexPermission amex_permission); +scoped_ptr<WalletItems> GetTestWalletItemsWithUsers( + const std::vector<std::string>& users); scoped_ptr<WalletItems> GetTestWalletItemsWithDefaultIds( const std::string& default_instrument_id, const std::string& default_address_id, |