OLD | NEW |
---|---|
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 Loading... | |
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. |
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 DCHECK(is_submitting_ && IsPayingWithWallet()); |
1509 // http://crbug.com/173505 | 1510 |
1511 has_accepted_legal_documents_ = true; | |
1512 LoadRiskFingerprintData(); | |
1510 } | 1513 } |
1511 | 1514 |
1512 void AutofillDialogControllerImpl::OnDidAuthenticateInstrument(bool success) { | 1515 void AutofillDialogControllerImpl::OnDidAuthenticateInstrument(bool success) { |
1513 DCHECK(is_submitting_ && IsPayingWithWallet()); | 1516 DCHECK(is_submitting_ && IsPayingWithWallet()); |
1514 | 1517 |
1515 // TODO(dbeam): use the returned full wallet. b/8332329 | 1518 // TODO(dbeam): use the returned full wallet. b/8332329 |
1516 if (success) | 1519 if (success) |
1517 GetFullWallet(); | 1520 GetFullWallet(); |
1518 else | 1521 else |
1519 DisableWallet(); | 1522 DisableWallet(); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1574 const GoogleServiceAuthError& error) { | 1577 const GoogleServiceAuthError& error) { |
1575 // TODO(aruslan): report an error. | 1578 // TODO(aruslan): report an error. |
1576 LOG(ERROR) << "failed to automatically sign in: " << error.ToString(); | 1579 LOG(ERROR) << "failed to automatically sign in: " << error.ToString(); |
1577 OnWalletSigninError(); | 1580 OnWalletSigninError(); |
1578 } | 1581 } |
1579 | 1582 |
1580 void AutofillDialogControllerImpl::OnDidGetWalletItems( | 1583 void AutofillDialogControllerImpl::OnDidGetWalletItems( |
1581 scoped_ptr<wallet::WalletItems> wallet_items) { | 1584 scoped_ptr<wallet::WalletItems> wallet_items) { |
1582 legal_documents_text_.clear(); | 1585 legal_documents_text_.clear(); |
1583 legal_document_link_ranges_.clear(); | 1586 legal_document_link_ranges_.clear(); |
1587 has_accepted_legal_documents_ = false; | |
1584 | 1588 |
1585 // TODO(dbeam): verify items support kCartCurrency? http://crbug.com/232952 | 1589 // TODO(dbeam): verify items support kCartCurrency? http://crbug.com/232952 |
1586 wallet_items_ = wallet_items.Pass(); | 1590 wallet_items_ = wallet_items.Pass(); |
1587 OnWalletOrSigninUpdate(); | 1591 OnWalletOrSigninUpdate(); |
1588 } | 1592 } |
1589 | 1593 |
1590 void AutofillDialogControllerImpl::OnDidSaveAddress( | 1594 void AutofillDialogControllerImpl::OnDidSaveAddress( |
1591 const std::string& address_id, | 1595 const std::string& address_id, |
1592 const std::vector<wallet::RequiredAction>& required_actions) { | 1596 const std::vector<wallet::RequiredAction>& required_actions) { |
1593 DCHECK(is_submitting_ && IsPayingWithWallet()); | 1597 DCHECK(is_submitting_ && IsPayingWithWallet()); |
1594 | 1598 |
1595 if (required_actions.empty()) { | 1599 if (required_actions.empty()) { |
1596 active_address_id_ = address_id; | 1600 active_address_id_ = address_id; |
1597 if (!active_instrument_id_.empty()) | 1601 GetFullWalletIfReady(); |
1598 GetFullWallet(); | |
1599 } else { | 1602 } else { |
1600 HandleSaveOrUpdateRequiredActions(required_actions); | 1603 HandleSaveOrUpdateRequiredActions(required_actions); |
1601 } | 1604 } |
1602 } | 1605 } |
1603 | 1606 |
1604 void AutofillDialogControllerImpl::OnDidSaveInstrument( | 1607 void AutofillDialogControllerImpl::OnDidSaveInstrument( |
1605 const std::string& instrument_id, | 1608 const std::string& instrument_id, |
1606 const std::vector<wallet::RequiredAction>& required_actions) { | 1609 const std::vector<wallet::RequiredAction>& required_actions) { |
1607 DCHECK(is_submitting_ && IsPayingWithWallet()); | 1610 DCHECK(is_submitting_ && IsPayingWithWallet()); |
1608 | 1611 |
1609 if (required_actions.empty()) { | 1612 if (required_actions.empty()) { |
1610 active_instrument_id_ = instrument_id; | 1613 active_instrument_id_ = instrument_id; |
1611 if (!active_address_id_.empty()) | 1614 GetFullWalletIfReady(); |
1612 GetFullWallet(); | |
1613 } else { | 1615 } else { |
1614 HandleSaveOrUpdateRequiredActions(required_actions); | 1616 HandleSaveOrUpdateRequiredActions(required_actions); |
1615 } | 1617 } |
1616 } | 1618 } |
1617 | 1619 |
1618 void AutofillDialogControllerImpl::OnDidSaveInstrumentAndAddress( | 1620 void AutofillDialogControllerImpl::OnDidSaveInstrumentAndAddress( |
1619 const std::string& instrument_id, | 1621 const std::string& instrument_id, |
1620 const std::string& address_id, | 1622 const std::string& address_id, |
1621 const std::vector<wallet::RequiredAction>& required_actions) { | 1623 const std::vector<wallet::RequiredAction>& required_actions) { |
1622 OnDidSaveInstrument(instrument_id, required_actions); | 1624 OnDidSaveInstrument(instrument_id, required_actions); |
1623 OnDidSaveAddress(address_id, required_actions); | 1625 if (is_submitting_) |
1626 OnDidSaveAddress(address_id, required_actions); | |
1624 } | 1627 } |
1625 | 1628 |
1626 void AutofillDialogControllerImpl::OnDidUpdateAddress( | 1629 void AutofillDialogControllerImpl::OnDidUpdateAddress( |
1627 const std::string& address_id, | 1630 const std::string& address_id, |
1628 const std::vector<wallet::RequiredAction>& required_actions) { | 1631 const std::vector<wallet::RequiredAction>& required_actions) { |
1629 OnDidSaveAddress(address_id, required_actions); | 1632 OnDidSaveAddress(address_id, required_actions); |
1630 } | 1633 } |
1631 | 1634 |
1632 void AutofillDialogControllerImpl::OnDidUpdateInstrument( | 1635 void AutofillDialogControllerImpl::OnDidUpdateInstrument( |
1633 const std::string& instrument_id, | 1636 const std::string& instrument_id, |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1724 wallet_client_(profile_->GetRequestContext(), this), | 1727 wallet_client_(profile_->GetRequestContext(), this), |
1725 suggested_email_(this), | 1728 suggested_email_(this), |
1726 suggested_cc_(this), | 1729 suggested_cc_(this), |
1727 suggested_billing_(this), | 1730 suggested_billing_(this), |
1728 suggested_cc_billing_(this), | 1731 suggested_cc_billing_(this), |
1729 suggested_shipping_(this), | 1732 suggested_shipping_(this), |
1730 input_showing_popup_(NULL), | 1733 input_showing_popup_(NULL), |
1731 weak_ptr_factory_(this), | 1734 weak_ptr_factory_(this), |
1732 is_first_run_(!profile_->GetPrefs()->HasPrefPath( | 1735 is_first_run_(!profile_->GetPrefs()->HasPrefPath( |
1733 ::prefs::kAutofillDialogPayWithoutWallet)), | 1736 ::prefs::kAutofillDialogPayWithoutWallet)), |
1737 has_accepted_legal_documents_(false), | |
1734 is_submitting_(false), | 1738 is_submitting_(false), |
1735 wallet_server_validation_error_(false), | 1739 wallet_server_validation_error_(false), |
1736 autocheckout_state_(AUTOCHECKOUT_NOT_STARTED), | 1740 autocheckout_state_(AUTOCHECKOUT_NOT_STARTED), |
1737 was_ui_latency_logged_(false) { | 1741 was_ui_latency_logged_(false) { |
1738 // TODO(estade): remove duplicates from |form_structure|? | 1742 // TODO(estade): remove duplicates from |form_structure|? |
1739 DCHECK(!callback_.is_null()); | 1743 DCHECK(!callback_.is_null()); |
1740 } | 1744 } |
1741 | 1745 |
1742 AutofillDialogView* AutofillDialogControllerImpl::CreateView() { | 1746 AutofillDialogView* AutofillDialogControllerImpl::CreateView() { |
1743 return AutofillDialogView::Create(this); | 1747 return AutofillDialogView::Create(this); |
1744 } | 1748 } |
1745 | 1749 |
1746 PersonalDataManager* AutofillDialogControllerImpl::GetManager() { | 1750 PersonalDataManager* AutofillDialogControllerImpl::GetManager() { |
1747 return PersonalDataManagerFactory::GetForProfile(profile_); | 1751 return PersonalDataManagerFactory::GetForProfile(profile_); |
1748 } | 1752 } |
1749 | 1753 |
1750 wallet::WalletClient* AutofillDialogControllerImpl::GetWalletClient() { | 1754 wallet::WalletClient* AutofillDialogControllerImpl::GetWalletClient() { |
1751 return &wallet_client_; | 1755 return &wallet_client_; |
1752 } | 1756 } |
1753 | 1757 |
1754 bool AutofillDialogControllerImpl::IsPayingWithWallet() const { | 1758 bool AutofillDialogControllerImpl::IsPayingWithWallet() const { |
1755 return account_chooser_model_.WalletIsSelected() && | 1759 return account_chooser_model_.WalletIsSelected() && |
1756 SignedInState() == SIGNED_IN; | 1760 SignedInState() == SIGNED_IN; |
1757 } | 1761 } |
1758 | 1762 |
1759 bool AutofillDialogControllerImpl::IsFirstRun() const { | 1763 bool AutofillDialogControllerImpl::IsFirstRun() const { |
1760 return is_first_run_; | 1764 return is_first_run_; |
1761 } | 1765 } |
1762 | 1766 |
1767 void AutofillDialogControllerImpl::LoadRiskFingerprintData() { | |
1768 DCHECK(LegalDocumentsAreCurrent()); | |
1769 | |
1770 // Clear potential stale data to ensure |GetFullWalletIfReady()| triggers only | |
1771 // when a new fingerprint is loaded. | |
1772 risk_data_.clear(); | |
1773 | |
1774 uint64 obfuscated_gaia_id = 0; | |
1775 bool success = base::StringToUint64(wallet_items_->obfuscated_gaia_id(), | |
1776 &obfuscated_gaia_id); | |
1777 DCHECK(success); | |
1778 | |
1779 gfx::Rect window_bounds; | |
1780 #if !defined(OS_ANDROID) | |
1781 window_bounds = GetBaseWindowForWebContents(web_contents())->GetBounds(); | |
1782 #else | |
1783 // TODO(dbeam): figure out the correct browser window size to pass along for | |
1784 // android. | |
1785 #endif | |
Ilya Sherman
2013/05/22 23:53:59
nit: Would be nice to merge this change into the s
| |
1786 | |
1787 PrefService* user_prefs = profile_->GetPrefs(); | |
1788 std::string charset = user_prefs->GetString(::prefs::kDefaultCharset); | |
1789 std::string accept_languages = | |
1790 user_prefs->GetString(::prefs::kAcceptLanguages); | |
1791 base::Time install_time = base::Time::FromTimeT( | |
1792 g_browser_process->local_state()->GetInt64(::prefs::kInstallDate)); | |
1793 | |
1794 risk::GetFingerprint( | |
1795 obfuscated_gaia_id, window_bounds, *web_contents(), | |
1796 chrome::VersionInfo().Version(), charset, accept_languages, install_time, | |
1797 dialog_type_, g_browser_process->GetApplicationLocale(), | |
1798 base::Bind(&AutofillDialogControllerImpl::OnDidLoadRiskFingerprintData, | |
1799 weak_ptr_factory_.GetWeakPtr())); | |
1800 } | |
1801 | |
1802 void AutofillDialogControllerImpl::OnDidLoadRiskFingerprintData( | |
1803 scoped_ptr<risk::Fingerprint> fingerprint) { | |
1804 DCHECK(LegalDocumentsAreCurrent()); | |
1805 | |
1806 std::string proto_data; | |
1807 fingerprint->SerializeToString(&proto_data); | |
1808 bool success = base::Base64Encode(proto_data, &risk_data_); | |
1809 DCHECK(success); | |
1810 | |
1811 GetFullWalletIfReady(); | |
1812 } | |
1813 | |
1763 void AutofillDialogControllerImpl::OpenTabWithUrl(const GURL& url) { | 1814 void AutofillDialogControllerImpl::OpenTabWithUrl(const GURL& url) { |
1764 #if !defined(OS_ANDROID) | 1815 #if !defined(OS_ANDROID) |
1765 chrome::NavigateParams params( | 1816 chrome::NavigateParams params( |
1766 chrome::FindBrowserWithWebContents(web_contents()), | 1817 chrome::FindBrowserWithWebContents(web_contents()), |
1767 url, | 1818 url, |
1768 content::PAGE_TRANSITION_AUTO_BOOKMARK); | 1819 content::PAGE_TRANSITION_AUTO_BOOKMARK); |
1769 params.disposition = NEW_FOREGROUND_TAB; | 1820 params.disposition = NEW_FOREGROUND_TAB; |
1770 chrome::Navigate(¶ms); | 1821 chrome::Navigate(¶ms); |
1771 #else | 1822 #else |
1772 // TODO(estade): use TabModelList? | 1823 // TODO(estade): use TabModelList? |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2094 DialogSection section) { | 2145 DialogSection section) { |
2095 return const_cast<DetailInputs*>(&RequestedFieldsForSection(section)); | 2146 return const_cast<DetailInputs*>(&RequestedFieldsForSection(section)); |
2096 } | 2147 } |
2097 | 2148 |
2098 void AutofillDialogControllerImpl::HidePopup() { | 2149 void AutofillDialogControllerImpl::HidePopup() { |
2099 if (popup_controller_) | 2150 if (popup_controller_) |
2100 popup_controller_->Hide(); | 2151 popup_controller_->Hide(); |
2101 input_showing_popup_ = NULL; | 2152 input_showing_popup_ = NULL; |
2102 } | 2153 } |
2103 | 2154 |
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 uint64 obfuscated_gaia_id = 0; | |
2111 bool success = base::StringToUint64(wallet_items_->obfuscated_gaia_id(), | |
2112 &obfuscated_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 obfuscated_gaia_id, window_bounds, *web_contents(), | |
2127 chrome::VersionInfo().Version(), charset, accept_languages, install_time, | |
2128 GetDialogType(), g_browser_process->GetApplicationLocale(), | |
2129 base::Bind(&AutofillDialogControllerImpl::OnDidLoadRiskFingerprintData, | |
2130 weak_ptr_factory_.GetWeakPtr())); | |
2131 } | |
2132 | |
2133 void AutofillDialogControllerImpl::OnDidLoadRiskFingerprintData( | |
2134 scoped_ptr<risk::Fingerprint> fingerprint) { | |
2135 NOTIMPLEMENTED(); | |
2136 } | |
2137 | |
2138 bool AutofillDialogControllerImpl::IsManuallyEditingSection( | 2155 bool AutofillDialogControllerImpl::IsManuallyEditingSection( |
2139 DialogSection section) const { | 2156 DialogSection section) const { |
2140 std::map<DialogSection, bool>::const_iterator it = | 2157 std::map<DialogSection, bool>::const_iterator it = |
2141 section_editing_state_.find(section); | 2158 section_editing_state_.find(section); |
2142 return (it != section_editing_state_.end() && it->second) || | 2159 return (it != section_editing_state_.end() && it->second) || |
2143 SuggestionsMenuModelForSection(section)-> | 2160 SuggestionsMenuModelForSection(section)-> |
2144 GetItemKeyForCheckedItem() == kAddNewItemKey; | 2161 GetItemKeyForCheckedItem() == kAddNewItemKey; |
2145 } | 2162 } |
2146 | 2163 |
2147 bool AutofillDialogControllerImpl::IsASuggestionItemKey( | 2164 bool AutofillDialogControllerImpl::IsASuggestionItemKey( |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2233 | 2250 |
2234 void AutofillDialogControllerImpl::SetIsSubmitting(bool submitting) { | 2251 void AutofillDialogControllerImpl::SetIsSubmitting(bool submitting) { |
2235 is_submitting_ = submitting; | 2252 is_submitting_ = submitting; |
2236 | 2253 |
2237 if (view_) { | 2254 if (view_) { |
2238 view_->UpdateButtonStrip(); | 2255 view_->UpdateButtonStrip(); |
2239 view_->UpdateNotificationArea(); | 2256 view_->UpdateNotificationArea(); |
2240 } | 2257 } |
2241 } | 2258 } |
2242 | 2259 |
2260 bool AutofillDialogControllerImpl::LegalDocumentsAreCurrent() const { | |
2261 return has_accepted_legal_documents_ || | |
2262 (wallet_items_ && wallet_items_->legal_documents().empty()); | |
2263 } | |
2264 | |
2243 void AutofillDialogControllerImpl::SubmitWithWallet() { | 2265 void AutofillDialogControllerImpl::SubmitWithWallet() { |
2244 // TODO(dbeam): disallow interacting with the dialog while submitting. | 2266 // TODO(dbeam): disallow interacting with the dialog while submitting. |
2245 // http://crbug.com/230932 | 2267 // http://crbug.com/230932 |
2246 | 2268 |
2247 active_instrument_id_.clear(); | 2269 active_instrument_id_.clear(); |
2248 active_address_id_.clear(); | 2270 active_address_id_.clear(); |
2249 full_wallet_.reset(); | 2271 full_wallet_.reset(); |
2250 | 2272 |
2251 content::BrowserThread::PostTask( | 2273 content::BrowserThread::PostTask( |
2252 content::BrowserThread::IO, FROM_HERE, | 2274 content::BrowserThread::IO, FROM_HERE, |
2253 base::Bind(&UserDidOptIntoLocationServices)); | 2275 base::Bind(&UserDidOptIntoLocationServices)); |
2254 | 2276 |
2255 GetWalletClient()->AcceptLegalDocuments( | 2277 GetWalletClient()->AcceptLegalDocuments( |
2256 wallet_items_->legal_documents(), | 2278 wallet_items_->legal_documents(), |
2257 wallet_items_->google_transaction_id(), | 2279 wallet_items_->google_transaction_id(), |
2258 source_url_); | 2280 source_url_); |
2259 | 2281 |
2282 if (LegalDocumentsAreCurrent()) | |
2283 LoadRiskFingerprintData(); | |
2284 | |
2260 SuggestionsMenuModel* billing = | 2285 SuggestionsMenuModel* billing = |
2261 SuggestionsMenuModelForSection(SECTION_CC_BILLING); | 2286 SuggestionsMenuModelForSection(SECTION_CC_BILLING); |
2262 int instrument_index = -1; | 2287 int instrument_index = -1; |
2263 base::StringToInt(billing->GetItemKeyForCheckedItem(), &instrument_index); | 2288 base::StringToInt(billing->GetItemKeyForCheckedItem(), &instrument_index); |
2264 | 2289 |
2265 if (!IsManuallyEditingSection(SECTION_CC_BILLING)) { | 2290 if (!IsManuallyEditingSection(SECTION_CC_BILLING)) { |
2266 active_instrument_id_ = | 2291 active_instrument_id_ = |
2267 wallet_items_->instruments()[instrument_index]->object_id(); | 2292 wallet_items_->instruments()[instrument_index]->object_id(); |
2268 DCHECK(!active_instrument_id_.empty()); | 2293 DCHECK(!active_instrument_id_.empty()); |
2269 } | 2294 } |
2270 | 2295 |
2271 SuggestionsMenuModel* shipping = | 2296 SuggestionsMenuModel* shipping = |
2272 SuggestionsMenuModelForSection(SECTION_SHIPPING); | 2297 SuggestionsMenuModelForSection(SECTION_SHIPPING); |
2273 int address_index = -1; | 2298 int address_index = -1; |
2274 base::StringToInt(shipping->GetItemKeyForCheckedItem(), &address_index); | 2299 base::StringToInt(shipping->GetItemKeyForCheckedItem(), &address_index); |
2275 | 2300 |
2276 if (!IsManuallyEditingSection(SECTION_SHIPPING) && | 2301 if (!IsManuallyEditingSection(SECTION_SHIPPING) && |
2277 shipping->GetItemKeyForCheckedItem() != kSameAsBillingKey) { | 2302 shipping->GetItemKeyForCheckedItem() != kSameAsBillingKey) { |
2278 active_address_id_ = | 2303 active_address_id_ = |
2279 wallet_items_->addresses()[address_index]->object_id(); | 2304 wallet_items_->addresses()[address_index]->object_id(); |
2280 DCHECK(!active_address_id_.empty()); | 2305 DCHECK(!active_address_id_.empty()); |
2281 } | 2306 } |
2282 | 2307 |
2283 if (!active_instrument_id_.empty() && !active_address_id_.empty()) { | 2308 // If there's neither an address nor instrument to save, |GetFullWallet()| |
2284 GetFullWallet(); | 2309 // is called when the risk fingerprint is loaded. |
2310 if (!active_instrument_id_.empty() && !active_address_id_.empty()) | |
2285 return; | 2311 return; |
2286 } | |
2287 | 2312 |
2288 scoped_ptr<wallet::Instrument> inputted_instrument = | 2313 scoped_ptr<wallet::Instrument> inputted_instrument = |
2289 CreateTransientInstrument(); | 2314 CreateTransientInstrument(); |
2290 scoped_ptr<wallet::WalletClient::UpdateInstrumentRequest> update_request = | 2315 scoped_ptr<wallet::WalletClient::UpdateInstrumentRequest> update_request = |
2291 CreateUpdateInstrumentRequest( | 2316 CreateUpdateInstrumentRequest( |
2292 inputted_instrument.get(), | 2317 inputted_instrument.get(), |
2293 !section_editing_state_[SECTION_CC_BILLING] ? std::string() : | 2318 !section_editing_state_[SECTION_CC_BILLING] ? std::string() : |
2294 wallet_items_->instruments()[instrument_index]->object_id()); | 2319 wallet_items_->instruments()[instrument_index]->object_id()); |
2295 | 2320 |
2296 scoped_ptr<wallet::Address> inputted_address; | 2321 scoped_ptr<wallet::Address> inputted_address; |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2401 | 2426 |
2402 GetWalletClient()->GetFullWallet(wallet::WalletClient::FullWalletRequest( | 2427 GetWalletClient()->GetFullWallet(wallet::WalletClient::FullWalletRequest( |
2403 active_instrument_id_, | 2428 active_instrument_id_, |
2404 active_address_id_, | 2429 active_address_id_, |
2405 source_url_, | 2430 source_url_, |
2406 wallet::Cart(base::IntToString(kCartMax), kCartCurrency), | 2431 wallet::Cart(base::IntToString(kCartMax), kCartCurrency), |
2407 wallet_items_->google_transaction_id(), | 2432 wallet_items_->google_transaction_id(), |
2408 capabilities)); | 2433 capabilities)); |
2409 } | 2434 } |
2410 | 2435 |
2436 void AutofillDialogControllerImpl::GetFullWalletIfReady() { | |
2437 DCHECK(is_submitting_ && IsPayingWithWallet()); | |
Ilya Sherman
2013/05/22 23:53:59
nit: Please write this as two separate DCHECKs
Dan Beam
2013/05/23 00:30:40
Done.
| |
2438 | |
2439 if (!active_instrument_id_.empty() && !active_address_id_.empty() && | |
2440 !risk_data_.empty()) { | |
2441 GetFullWallet(); | |
2442 } | |
2443 } | |
2444 | |
2411 void AutofillDialogControllerImpl::HandleSaveOrUpdateRequiredActions( | 2445 void AutofillDialogControllerImpl::HandleSaveOrUpdateRequiredActions( |
2412 const std::vector<wallet::RequiredAction>& required_actions) { | 2446 const std::vector<wallet::RequiredAction>& required_actions) { |
2413 DCHECK(!required_actions.empty()); | 2447 DCHECK(!required_actions.empty()); |
2414 | 2448 |
2415 for (std::vector<wallet::RequiredAction>::const_iterator iter = | 2449 for (std::vector<wallet::RequiredAction>::const_iterator iter = |
2416 required_actions.begin(); | 2450 required_actions.begin(); |
2417 iter != required_actions.end(); ++iter) { | 2451 iter != required_actions.end(); ++iter) { |
2418 if (*iter == wallet::INVALID_FORM_FIELD) { | 2452 if (*iter == wallet::INVALID_FORM_FIELD) { |
2419 wallet_server_validation_error_ = true; | 2453 wallet_server_validation_error_ = true; |
2420 } else { | 2454 } else { |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2576 AutofillMetrics::DIALOG_USER_SIGNED_IN_NO_WALLET_NO_AUTOFILL; | 2610 AutofillMetrics::DIALOG_USER_SIGNED_IN_NO_WALLET_NO_AUTOFILL; |
2577 } | 2611 } |
2578 | 2612 |
2579 // Has Wallet items. | 2613 // Has Wallet items. |
2580 return has_autofill_profiles ? | 2614 return has_autofill_profiles ? |
2581 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_HAS_AUTOFILL : | 2615 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_HAS_AUTOFILL : |
2582 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_NO_AUTOFILL; | 2616 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_NO_AUTOFILL; |
2583 } | 2617 } |
2584 | 2618 |
2585 } // namespace autofill | 2619 } // namespace autofill |
OLD | NEW |