Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(77)

Side by Side Diff: chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc

Issue 14904002: Load and send Wallet Risk params after user has agreed (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixes Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/autofill/autofill_dialog_controller_impl.h" 5 #include "chrome/browser/ui/autofill/autofill_dialog_controller_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/base64.h"
10 #include "base/bind.h" 11 #include "base/bind.h"
11 #include "base/logging.h" 12 #include "base/logging.h"
12 #include "base/prefs/pref_service.h" 13 #include "base/prefs/pref_service.h"
13 #include "base/string_util.h" 14 #include "base/string_util.h"
14 #include "base/strings/string_number_conversions.h" 15 #include "base/strings/string_number_conversions.h"
15 #include "base/strings/string_split.h" 16 #include "base/strings/string_split.h"
16 #include "base/time.h" 17 #include "base/time.h"
17 #include "base/utf_string_conversions.h" 18 #include "base/utf_string_conversions.h"
18 #include "chrome/browser/autofill/personal_data_manager_factory.h" 19 #include "chrome/browser/autofill/personal_data_manager_factory.h"
19 #include "chrome/browser/browser_process.h" 20 #include "chrome/browser/browser_process.h"
(...skipping 1473 matching lines...) Expand 10 before | Expand all | Expand 10 after
1493 1494
1494 const AutofillMetrics& AutofillDialogControllerImpl::GetMetricLogger() const { 1495 const AutofillMetrics& AutofillDialogControllerImpl::GetMetricLogger() const {
1495 return metric_logger_; 1496 return metric_logger_;
1496 } 1497 }
1497 1498
1498 DialogType AutofillDialogControllerImpl::GetDialogType() const { 1499 DialogType AutofillDialogControllerImpl::GetDialogType() const {
1499 return dialog_type_; 1500 return dialog_type_;
1500 } 1501 }
1501 1502
1502 std::string AutofillDialogControllerImpl::GetRiskData() const { 1503 std::string AutofillDialogControllerImpl::GetRiskData() const {
1503 // TODO(dbeam): Implement this. 1504 // TODO(dbeam): remove the server restriction that this must not be empty.
Ilya Sherman 2013/05/22 22:34:24 Could you file a tracking bug for the specific cha
Ilya Sherman 2013/05/22 23:53:59 ^^^
Dan Beam 2013/05/23 00:30:40 omitting risk params works now, I've updated the c
1504 return "risky business"; 1505 return risk_data_.empty() ? "risky business" : risk_data_;
1505 } 1506 }
1506 1507
1507 void AutofillDialogControllerImpl::OnDidAcceptLegalDocuments() { 1508 void AutofillDialogControllerImpl::OnDidAcceptLegalDocuments() {
1508 // TODO(dbeam): Don't send risk params until legal documents are accepted: 1509 accepted_legal_documents_ = true;
1509 // http://crbug.com/173505 1510 LoadRiskFingerprintData();
Ilya Sherman 2013/05/22 22:34:24 Is this method guaranteed to only be called after
Dan Beam 2013/05/22 23:25:20 Done.
1510 } 1511 }
1511 1512
1512 void AutofillDialogControllerImpl::OnDidAuthenticateInstrument(bool success) { 1513 void AutofillDialogControllerImpl::OnDidAuthenticateInstrument(bool success) {
1513 DCHECK(is_submitting_ && IsPayingWithWallet()); 1514 DCHECK(is_submitting_ && IsPayingWithWallet());
1514 1515
1515 // TODO(dbeam): use the returned full wallet. b/8332329 1516 // TODO(dbeam): use the returned full wallet. b/8332329
1516 if (success) 1517 if (success)
1517 GetFullWallet(); 1518 GetFullWallet();
1518 else 1519 else
1519 DisableWallet(); 1520 DisableWallet();
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1574 const GoogleServiceAuthError& error) { 1575 const GoogleServiceAuthError& error) {
1575 // TODO(aruslan): report an error. 1576 // TODO(aruslan): report an error.
1576 LOG(ERROR) << "failed to automatically sign in: " << error.ToString(); 1577 LOG(ERROR) << "failed to automatically sign in: " << error.ToString();
1577 OnWalletSigninError(); 1578 OnWalletSigninError();
1578 } 1579 }
1579 1580
1580 void AutofillDialogControllerImpl::OnDidGetWalletItems( 1581 void AutofillDialogControllerImpl::OnDidGetWalletItems(
1581 scoped_ptr<wallet::WalletItems> wallet_items) { 1582 scoped_ptr<wallet::WalletItems> wallet_items) {
1582 legal_documents_text_.clear(); 1583 legal_documents_text_.clear();
1583 legal_document_link_ranges_.clear(); 1584 legal_document_link_ranges_.clear();
1585 accepted_legal_documents_ = false;
1584 1586
1585 // TODO(dbeam): verify items support kCartCurrency? http://crbug.com/232952 1587 // TODO(dbeam): verify items support kCartCurrency? http://crbug.com/232952
1586 wallet_items_ = wallet_items.Pass(); 1588 wallet_items_ = wallet_items.Pass();
1587 OnWalletOrSigninUpdate(); 1589 OnWalletOrSigninUpdate();
1588 } 1590 }
1589 1591
1590 void AutofillDialogControllerImpl::OnDidSaveAddress( 1592 void AutofillDialogControllerImpl::OnDidSaveAddress(
1591 const std::string& address_id, 1593 const std::string& address_id,
1592 const std::vector<wallet::RequiredAction>& required_actions) { 1594 const std::vector<wallet::RequiredAction>& required_actions) {
1593 DCHECK(is_submitting_ && IsPayingWithWallet()); 1595 DCHECK(is_submitting_ && IsPayingWithWallet());
Dan Beam 2013/05/22 23:25:20 ^ this DCHECK()
1594 1596
1595 if (required_actions.empty()) { 1597 if (required_actions.empty()) {
1596 active_address_id_ = address_id; 1598 active_address_id_ = address_id;
1597 if (!active_instrument_id_.empty()) 1599 GetFullWalletIfReady();
1598 GetFullWallet();
1599 } else { 1600 } else {
1600 HandleSaveOrUpdateRequiredActions(required_actions); 1601 HandleSaveOrUpdateRequiredActions(required_actions);
1601 } 1602 }
1602 } 1603 }
1603 1604
1604 void AutofillDialogControllerImpl::OnDidSaveInstrument( 1605 void AutofillDialogControllerImpl::OnDidSaveInstrument(
1605 const std::string& instrument_id, 1606 const std::string& instrument_id,
1606 const std::vector<wallet::RequiredAction>& required_actions) { 1607 const std::vector<wallet::RequiredAction>& required_actions) {
1607 DCHECK(is_submitting_ && IsPayingWithWallet()); 1608 DCHECK(is_submitting_ && IsPayingWithWallet());
1608 1609
1609 if (required_actions.empty()) { 1610 if (required_actions.empty()) {
1610 active_instrument_id_ = instrument_id; 1611 active_instrument_id_ = instrument_id;
1611 if (!active_address_id_.empty()) 1612 GetFullWalletIfReady();
1612 GetFullWallet();
1613 } else { 1613 } else {
1614 HandleSaveOrUpdateRequiredActions(required_actions); 1614 HandleSaveOrUpdateRequiredActions(required_actions);
1615 } 1615 }
1616 } 1616 }
1617 1617
1618 void AutofillDialogControllerImpl::OnDidSaveInstrumentAndAddress( 1618 void AutofillDialogControllerImpl::OnDidSaveInstrumentAndAddress(
1619 const std::string& instrument_id, 1619 const std::string& instrument_id,
1620 const std::string& address_id, 1620 const std::string& address_id,
1621 const std::vector<wallet::RequiredAction>& required_actions) { 1621 const std::vector<wallet::RequiredAction>& required_actions) {
1622 OnDidSaveInstrument(instrument_id, required_actions); 1622 OnDidSaveInstrument(instrument_id, required_actions);
1623 OnDidSaveAddress(address_id, required_actions); 1623 if (is_submitting_)
1624 OnDidSaveAddress(address_id, required_actions);
Ilya Sherman 2013/05/22 22:34:24 Why is the address treated differently than the pa
Dan Beam 2013/05/22 23:25:20 OnDidSaveInstrument() can set is_submitting_ to fa
Ilya Sherman 2013/05/22 23:53:59 Ah, ok. Please add a comment to this effect so th
Dan Beam 2013/05/23 00:30:40 Done.
1624 } 1625 }
1625 1626
1626 void AutofillDialogControllerImpl::OnDidUpdateAddress( 1627 void AutofillDialogControllerImpl::OnDidUpdateAddress(
1627 const std::string& address_id, 1628 const std::string& address_id,
1628 const std::vector<wallet::RequiredAction>& required_actions) { 1629 const std::vector<wallet::RequiredAction>& required_actions) {
1629 OnDidSaveAddress(address_id, required_actions); 1630 OnDidSaveAddress(address_id, required_actions);
1630 } 1631 }
1631 1632
1632 void AutofillDialogControllerImpl::OnDidUpdateInstrument( 1633 void AutofillDialogControllerImpl::OnDidUpdateInstrument(
1633 const std::string& instrument_id, 1634 const std::string& instrument_id,
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
1724 wallet_client_(profile_->GetRequestContext(), this), 1725 wallet_client_(profile_->GetRequestContext(), this),
1725 suggested_email_(this), 1726 suggested_email_(this),
1726 suggested_cc_(this), 1727 suggested_cc_(this),
1727 suggested_billing_(this), 1728 suggested_billing_(this),
1728 suggested_cc_billing_(this), 1729 suggested_cc_billing_(this),
1729 suggested_shipping_(this), 1730 suggested_shipping_(this),
1730 input_showing_popup_(NULL), 1731 input_showing_popup_(NULL),
1731 weak_ptr_factory_(this), 1732 weak_ptr_factory_(this),
1732 is_first_run_(!profile_->GetPrefs()->HasPrefPath( 1733 is_first_run_(!profile_->GetPrefs()->HasPrefPath(
1733 ::prefs::kAutofillDialogPayWithoutWallet)), 1734 ::prefs::kAutofillDialogPayWithoutWallet)),
1735 accepted_legal_documents_(false),
1734 is_submitting_(false), 1736 is_submitting_(false),
1735 wallet_server_validation_error_(false), 1737 wallet_server_validation_error_(false),
1736 autocheckout_state_(AUTOCHECKOUT_NOT_STARTED), 1738 autocheckout_state_(AUTOCHECKOUT_NOT_STARTED),
1737 was_ui_latency_logged_(false) { 1739 was_ui_latency_logged_(false) {
1738 // TODO(estade): remove duplicates from |form_structure|? 1740 // TODO(estade): remove duplicates from |form_structure|?
1739 DCHECK(!callback_.is_null()); 1741 DCHECK(!callback_.is_null());
1740 } 1742 }
1741 1743
1742 AutofillDialogView* AutofillDialogControllerImpl::CreateView() { 1744 AutofillDialogView* AutofillDialogControllerImpl::CreateView() {
1743 return AutofillDialogView::Create(this); 1745 return AutofillDialogView::Create(this);
1744 } 1746 }
1745 1747
1746 PersonalDataManager* AutofillDialogControllerImpl::GetManager() { 1748 PersonalDataManager* AutofillDialogControllerImpl::GetManager() {
1747 return PersonalDataManagerFactory::GetForProfile(profile_); 1749 return PersonalDataManagerFactory::GetForProfile(profile_);
1748 } 1750 }
1749 1751
1750 wallet::WalletClient* AutofillDialogControllerImpl::GetWalletClient() { 1752 wallet::WalletClient* AutofillDialogControllerImpl::GetWalletClient() {
1751 return &wallet_client_; 1753 return &wallet_client_;
1752 } 1754 }
1753 1755
1754 bool AutofillDialogControllerImpl::IsPayingWithWallet() const { 1756 bool AutofillDialogControllerImpl::IsPayingWithWallet() const {
1755 return account_chooser_model_.WalletIsSelected() && 1757 return account_chooser_model_.WalletIsSelected() &&
1756 SignedInState() == SIGNED_IN; 1758 SignedInState() == SIGNED_IN;
1757 } 1759 }
1758 1760
1759 bool AutofillDialogControllerImpl::IsFirstRun() const { 1761 bool AutofillDialogControllerImpl::IsFirstRun() const {
1760 return is_first_run_; 1762 return is_first_run_;
1761 } 1763 }
1762 1764
1765 void AutofillDialogControllerImpl::LoadRiskFingerprintData() {
1766 DCHECK(LegalDocumentsAreCurrent());
1767
1768 // Clear potential stale data to ensure |GetFullWalletIfReady()| triggers only
1769 // when a new fingerprint is loaded.
1770 risk_data_.clear();
1771
1772 uint64 obfuscated_gaia_id = 0;
1773 bool success = base::StringToUint64(wallet_items_->obfuscated_gaia_id(),
1774 &obfuscated_gaia_id);
1775 DCHECK(success);
1776
1777 gfx::Rect window_bounds;
1778 #if !defined(OS_ANDROID)
1779 window_bounds = GetBaseWindowForWebContents(web_contents())->GetBounds();
1780 #else
1781 // TODO(dbeam): figure out the correct browser window size to pass along for
1782 // android.
1783 #endif
1784
1785 PrefService* user_prefs = profile_->GetPrefs();
1786 std::string charset = user_prefs->GetString(::prefs::kDefaultCharset);
1787 std::string accept_languages =
1788 user_prefs->GetString(::prefs::kAcceptLanguages);
1789 base::Time install_time = base::Time::FromTimeT(
1790 g_browser_process->local_state()->GetInt64(::prefs::kInstallDate));
1791
1792 risk::GetFingerprint(
1793 obfuscated_gaia_id, window_bounds, *web_contents(),
1794 chrome::VersionInfo().Version(), charset, accept_languages, install_time,
1795 dialog_type_, g_browser_process->GetApplicationLocale(),
1796 base::Bind(&AutofillDialogControllerImpl::OnDidLoadRiskFingerprintData,
1797 weak_ptr_factory_.GetWeakPtr()));
1798 }
1799
1763 void AutofillDialogControllerImpl::OpenTabWithUrl(const GURL& url) { 1800 void AutofillDialogControllerImpl::OpenTabWithUrl(const GURL& url) {
1764 #if !defined(OS_ANDROID) 1801 #if !defined(OS_ANDROID)
1765 chrome::NavigateParams params( 1802 chrome::NavigateParams params(
1766 chrome::FindBrowserWithWebContents(web_contents()), 1803 chrome::FindBrowserWithWebContents(web_contents()),
1767 url, 1804 url,
1768 content::PAGE_TRANSITION_AUTO_BOOKMARK); 1805 content::PAGE_TRANSITION_AUTO_BOOKMARK);
1769 params.disposition = NEW_FOREGROUND_TAB; 1806 params.disposition = NEW_FOREGROUND_TAB;
1770 chrome::Navigate(&params); 1807 chrome::Navigate(&params);
1771 #else 1808 #else
1772 // TODO(estade): use TabModelList? 1809 // TODO(estade): use TabModelList?
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
2094 DialogSection section) { 2131 DialogSection section) {
2095 return const_cast<DetailInputs*>(&RequestedFieldsForSection(section)); 2132 return const_cast<DetailInputs*>(&RequestedFieldsForSection(section));
2096 } 2133 }
2097 2134
2098 void AutofillDialogControllerImpl::HidePopup() { 2135 void AutofillDialogControllerImpl::HidePopup() {
2099 if (popup_controller_) 2136 if (popup_controller_)
2100 popup_controller_->Hide(); 2137 popup_controller_->Hide();
2101 input_showing_popup_ = NULL; 2138 input_showing_popup_ = NULL;
2102 } 2139 }
2103 2140
2104 void AutofillDialogControllerImpl::LoadRiskFingerprintData() {
2105 // TODO(dbeam): Add a CHECK or otherwise strong guarantee that the ToS have
2106 // been accepted prior to calling into this method. Also, ensure that the UI
2107 // contains a clear indication to the user as to what data will be collected.
2108 // Until then, this code should not be called. http://crbug.com/173505
2109
2110 int64 gaia_id = 0;
2111 bool success =
2112 base::StringToInt64(wallet_items_->obfuscated_gaia_id(), &gaia_id);
2113 DCHECK(success);
2114
2115 gfx::Rect window_bounds =
2116 GetBaseWindowForWebContents(web_contents())->GetBounds();
2117
2118 PrefService* user_prefs = profile_->GetPrefs();
2119 std::string charset = user_prefs->GetString(::prefs::kDefaultCharset);
2120 std::string accept_languages =
2121 user_prefs->GetString(::prefs::kAcceptLanguages);
2122 base::Time install_time = base::Time::FromTimeT(
2123 g_browser_process->local_state()->GetInt64(::prefs::kInstallDate));
2124
2125 risk::GetFingerprint(
2126 gaia_id, window_bounds, *web_contents(), chrome::VersionInfo().Version(),
2127 charset, accept_languages, install_time, GetDialogType(),
2128 g_browser_process->GetApplicationLocale(),
2129 base::Bind(&AutofillDialogControllerImpl::OnDidLoadRiskFingerprintData,
2130 weak_ptr_factory_.GetWeakPtr()));
2131 }
2132
2133 void AutofillDialogControllerImpl::OnDidLoadRiskFingerprintData( 2141 void AutofillDialogControllerImpl::OnDidLoadRiskFingerprintData(
2134 scoped_ptr<risk::Fingerprint> fingerprint) { 2142 scoped_ptr<risk::Fingerprint> fingerprint) {
2135 NOTIMPLEMENTED(); 2143 DCHECK(LegalDocumentsAreCurrent());
2144
2145 std::string proto_data;
2146 fingerprint->SerializeToString(&proto_data);
2147 bool success = base::Base64Encode(proto_data, &risk_data_);
2148 DCHECK(success);
2149
2150 GetFullWalletIfReady();
2136 } 2151 }
2137 2152
2138 bool AutofillDialogControllerImpl::IsManuallyEditingSection( 2153 bool AutofillDialogControllerImpl::IsManuallyEditingSection(
2139 DialogSection section) const { 2154 DialogSection section) const {
2140 std::map<DialogSection, bool>::const_iterator it = 2155 std::map<DialogSection, bool>::const_iterator it =
2141 section_editing_state_.find(section); 2156 section_editing_state_.find(section);
2142 return (it != section_editing_state_.end() && it->second) || 2157 return (it != section_editing_state_.end() && it->second) ||
2143 SuggestionsMenuModelForSection(section)-> 2158 SuggestionsMenuModelForSection(section)->
2144 GetItemKeyForCheckedItem() == kAddNewItemKey; 2159 GetItemKeyForCheckedItem() == kAddNewItemKey;
2145 } 2160 }
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
2233 2248
2234 void AutofillDialogControllerImpl::SetIsSubmitting(bool submitting) { 2249 void AutofillDialogControllerImpl::SetIsSubmitting(bool submitting) {
2235 is_submitting_ = submitting; 2250 is_submitting_ = submitting;
2236 2251
2237 if (view_) { 2252 if (view_) {
2238 view_->UpdateButtonStrip(); 2253 view_->UpdateButtonStrip();
2239 view_->UpdateNotificationArea(); 2254 view_->UpdateNotificationArea();
2240 } 2255 }
2241 } 2256 }
2242 2257
2258 bool AutofillDialogControllerImpl::LegalDocumentsAreCurrent() const {
2259 return accepted_legal_documents_ ||
2260 (wallet_items_ && wallet_items_->legal_documents().empty());
2261 }
2262
2243 void AutofillDialogControllerImpl::SubmitWithWallet() { 2263 void AutofillDialogControllerImpl::SubmitWithWallet() {
2244 // TODO(dbeam): disallow interacting with the dialog while submitting. 2264 // TODO(dbeam): disallow interacting with the dialog while submitting.
2245 // http://crbug.com/230932 2265 // http://crbug.com/230932
2246 2266
2247 active_instrument_id_.clear(); 2267 active_instrument_id_.clear();
2248 active_address_id_.clear(); 2268 active_address_id_.clear();
2249 full_wallet_.reset(); 2269 full_wallet_.reset();
2250 2270
2251 content::BrowserThread::PostTask( 2271 content::BrowserThread::PostTask(
2252 content::BrowserThread::IO, FROM_HERE, 2272 content::BrowserThread::IO, FROM_HERE,
2253 base::Bind(&UserDidOptIntoLocationServices)); 2273 base::Bind(&UserDidOptIntoLocationServices));
2254 2274
2255 GetWalletClient()->AcceptLegalDocuments( 2275 GetWalletClient()->AcceptLegalDocuments(
2256 wallet_items_->legal_documents(), 2276 wallet_items_->legal_documents(),
2257 wallet_items_->google_transaction_id(), 2277 wallet_items_->google_transaction_id(),
2258 source_url_); 2278 source_url_);
2259 2279
2280 if (LegalDocumentsAreCurrent())
2281 LoadRiskFingerprintData();
2282
2260 SuggestionsMenuModel* billing = 2283 SuggestionsMenuModel* billing =
2261 SuggestionsMenuModelForSection(SECTION_CC_BILLING); 2284 SuggestionsMenuModelForSection(SECTION_CC_BILLING);
2262 int instrument_index = -1; 2285 int instrument_index = -1;
2263 base::StringToInt(billing->GetItemKeyForCheckedItem(), &instrument_index); 2286 base::StringToInt(billing->GetItemKeyForCheckedItem(), &instrument_index);
2264 2287
2265 if (!IsManuallyEditingSection(SECTION_CC_BILLING)) { 2288 if (!IsManuallyEditingSection(SECTION_CC_BILLING)) {
2266 active_instrument_id_ = 2289 active_instrument_id_ =
2267 wallet_items_->instruments()[instrument_index]->object_id(); 2290 wallet_items_->instruments()[instrument_index]->object_id();
2268 DCHECK(!active_instrument_id_.empty()); 2291 DCHECK(!active_instrument_id_.empty());
2269 } 2292 }
2270 2293
2271 SuggestionsMenuModel* shipping = 2294 SuggestionsMenuModel* shipping =
2272 SuggestionsMenuModelForSection(SECTION_SHIPPING); 2295 SuggestionsMenuModelForSection(SECTION_SHIPPING);
2273 int address_index = -1; 2296 int address_index = -1;
2274 base::StringToInt(shipping->GetItemKeyForCheckedItem(), &address_index); 2297 base::StringToInt(shipping->GetItemKeyForCheckedItem(), &address_index);
2275 2298
2276 if (!IsManuallyEditingSection(SECTION_SHIPPING) && 2299 if (!IsManuallyEditingSection(SECTION_SHIPPING) &&
2277 shipping->GetItemKeyForCheckedItem() != kSameAsBillingKey) { 2300 shipping->GetItemKeyForCheckedItem() != kSameAsBillingKey) {
2278 active_address_id_ = 2301 active_address_id_ =
2279 wallet_items_->addresses()[address_index]->object_id(); 2302 wallet_items_->addresses()[address_index]->object_id();
2280 DCHECK(!active_address_id_.empty()); 2303 DCHECK(!active_address_id_.empty());
2281 } 2304 }
2282 2305
2283 if (!active_instrument_id_.empty() && !active_address_id_.empty()) { 2306 if (!active_instrument_id_.empty() && !active_address_id_.empty())
Ilya Sherman 2013/05/22 22:34:24 This block could use a comment now. Seems like it
Dan Beam 2013/05/22 23:25:20 Done.
2284 GetFullWallet();
2285 return; 2307 return;
2286 }
2287 2308
2288 scoped_ptr<wallet::Instrument> inputted_instrument = 2309 scoped_ptr<wallet::Instrument> inputted_instrument =
2289 CreateTransientInstrument(); 2310 CreateTransientInstrument();
2290 scoped_ptr<wallet::WalletClient::UpdateInstrumentRequest> update_request = 2311 scoped_ptr<wallet::WalletClient::UpdateInstrumentRequest> update_request =
2291 CreateUpdateInstrumentRequest( 2312 CreateUpdateInstrumentRequest(
2292 inputted_instrument.get(), 2313 inputted_instrument.get(),
2293 !section_editing_state_[SECTION_CC_BILLING] ? std::string() : 2314 !section_editing_state_[SECTION_CC_BILLING] ? std::string() :
2294 wallet_items_->instruments()[instrument_index]->object_id()); 2315 wallet_items_->instruments()[instrument_index]->object_id());
2295 2316
2296 scoped_ptr<wallet::Address> inputted_address; 2317 scoped_ptr<wallet::Address> inputted_address;
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
2383 DetailOutputMap output; 2404 DetailOutputMap output;
2384 view_->GetUserInput(SECTION_SHIPPING, &output); 2405 view_->GetUserInput(SECTION_SHIPPING, &output);
2385 2406
2386 AutofillProfile profile; 2407 AutofillProfile profile;
2387 FillFormGroupFromOutputs(output, &profile); 2408 FillFormGroupFromOutputs(output, &profile);
2388 2409
2389 return scoped_ptr<wallet::Address>(new wallet::Address(profile)); 2410 return scoped_ptr<wallet::Address>(new wallet::Address(profile));
2390 } 2411 }
2391 2412
2392 void AutofillDialogControllerImpl::GetFullWallet() { 2413 void AutofillDialogControllerImpl::GetFullWallet() {
2393 DCHECK(is_submitting_); 2414 DCHECK(is_submitting_ && IsPayingWithWallet());
Ilya Sherman 2013/05/22 22:34:24 nit: Better to have these as separate DCHECKs, so
Dan Beam 2013/05/22 23:25:20 Done.
2394 DCHECK(IsPayingWithWallet());
2395 DCHECK(wallet_items_);
2396 DCHECK(!active_instrument_id_.empty());
2397 DCHECK(!active_address_id_.empty());
Ilya Sherman 2013/05/22 22:34:24 Why did you remove these DCHECKs?
Dan Beam 2013/05/22 23:25:20 I made this function GetFullWalletIfReady(), but d
2398 2415
2399 std::vector<wallet::WalletClient::RiskCapability> capabilities; 2416 std::vector<wallet::WalletClient::RiskCapability> capabilities;
2400 capabilities.push_back(wallet::WalletClient::VERIFY_CVC); 2417 capabilities.push_back(wallet::WalletClient::VERIFY_CVC);
2401 2418
2402 GetWalletClient()->GetFullWallet(wallet::WalletClient::FullWalletRequest( 2419 GetWalletClient()->GetFullWallet(wallet::WalletClient::FullWalletRequest(
2403 active_instrument_id_, 2420 active_instrument_id_,
2404 active_address_id_, 2421 active_address_id_,
2405 source_url_, 2422 source_url_,
2406 wallet::Cart(base::IntToString(kCartMax), kCartCurrency), 2423 wallet::Cart(base::IntToString(kCartMax), kCartCurrency),
2407 wallet_items_->google_transaction_id(), 2424 wallet_items_->google_transaction_id(),
2408 capabilities)); 2425 capabilities));
2409 } 2426 }
2410 2427
2428 void AutofillDialogControllerImpl::GetFullWalletIfReady() {
2429 DCHECK(is_submitting_ && IsPayingWithWallet());
2430
2431 if (!active_instrument_id_.empty() && !active_address_id_.empty() &&
2432 !risk_data_.empty()) {
2433 GetFullWallet();
2434 }
2435 }
2436
2411 void AutofillDialogControllerImpl::HandleSaveOrUpdateRequiredActions( 2437 void AutofillDialogControllerImpl::HandleSaveOrUpdateRequiredActions(
2412 const std::vector<wallet::RequiredAction>& required_actions) { 2438 const std::vector<wallet::RequiredAction>& required_actions) {
2413 DCHECK(!required_actions.empty()); 2439 DCHECK(!required_actions.empty());
2414 2440
2415 for (std::vector<wallet::RequiredAction>::const_iterator iter = 2441 for (std::vector<wallet::RequiredAction>::const_iterator iter =
2416 required_actions.begin(); 2442 required_actions.begin();
2417 iter != required_actions.end(); ++iter) { 2443 iter != required_actions.end(); ++iter) {
2418 if (*iter == wallet::INVALID_FORM_FIELD) { 2444 if (*iter == wallet::INVALID_FORM_FIELD) {
2419 wallet_server_validation_error_ = true; 2445 wallet_server_validation_error_ = true;
2420 } else { 2446 } else {
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
2576 AutofillMetrics::DIALOG_USER_SIGNED_IN_NO_WALLET_NO_AUTOFILL; 2602 AutofillMetrics::DIALOG_USER_SIGNED_IN_NO_WALLET_NO_AUTOFILL;
2577 } 2603 }
2578 2604
2579 // Has Wallet items. 2605 // Has Wallet items.
2580 return has_autofill_profiles ? 2606 return has_autofill_profiles ?
2581 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_HAS_AUTOFILL : 2607 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_HAS_AUTOFILL :
2582 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_NO_AUTOFILL; 2608 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_NO_AUTOFILL;
2583 } 2609 }
2584 2610
2585 } // namespace autofill 2611 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698