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/bind.h" | 10 #include "base/bind.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 #include "chrome/common/chrome_version_info.h" | 31 #include "chrome/common/chrome_version_info.h" |
32 #include "chrome/common/pref_names.h" | 32 #include "chrome/common/pref_names.h" |
33 #include "chrome/common/url_constants.h" | 33 #include "chrome/common/url_constants.h" |
34 #include "components/autofill/browser/autofill_data_model.h" | 34 #include "components/autofill/browser/autofill_data_model.h" |
35 #include "components/autofill/browser/autofill_manager.h" | 35 #include "components/autofill/browser/autofill_manager.h" |
36 #include "components/autofill/browser/autofill_type.h" | 36 #include "components/autofill/browser/autofill_type.h" |
37 #include "components/autofill/browser/personal_data_manager.h" | 37 #include "components/autofill/browser/personal_data_manager.h" |
38 #include "components/autofill/browser/risk/fingerprint.h" | 38 #include "components/autofill/browser/risk/fingerprint.h" |
39 #include "components/autofill/browser/risk/proto/fingerprint.pb.h" | 39 #include "components/autofill/browser/risk/proto/fingerprint.pb.h" |
40 #include "components/autofill/browser/validation.h" | 40 #include "components/autofill/browser/validation.h" |
41 #include "components/autofill/browser/wallet/cart.h" | |
42 #include "components/autofill/browser/wallet/full_wallet.h" | 41 #include "components/autofill/browser/wallet/full_wallet.h" |
43 #include "components/autofill/browser/wallet/instrument.h" | 42 #include "components/autofill/browser/wallet/instrument.h" |
44 #include "components/autofill/browser/wallet/wallet_address.h" | 43 #include "components/autofill/browser/wallet/wallet_address.h" |
45 #include "components/autofill/browser/wallet/wallet_items.h" | 44 #include "components/autofill/browser/wallet/wallet_items.h" |
46 #include "components/autofill/browser/wallet/wallet_service_url.h" | 45 #include "components/autofill/browser/wallet/wallet_service_url.h" |
47 #include "components/autofill/browser/wallet/wallet_signin_helper.h" | 46 #include "components/autofill/browser/wallet/wallet_signin_helper.h" |
48 #include "components/autofill/common/form_data.h" | 47 #include "components/autofill/common/form_data.h" |
49 #include "components/user_prefs/pref_registry_syncable.h" | 48 #include "components/user_prefs/pref_registry_syncable.h" |
50 #include "content/public/browser/navigation_controller.h" | 49 #include "content/public/browser/navigation_controller.h" |
51 #include "content/public/browser/navigation_details.h" | 50 #include "content/public/browser/navigation_details.h" |
(...skipping 13 matching lines...) Expand all Loading... |
65 #include "ui/gfx/canvas.h" | 64 #include "ui/gfx/canvas.h" |
66 #include "ui/gfx/color_utils.h" | 65 #include "ui/gfx/color_utils.h" |
67 #include "ui/gfx/skbitmap_operations.h" | 66 #include "ui/gfx/skbitmap_operations.h" |
68 | 67 |
69 namespace autofill { | 68 namespace autofill { |
70 | 69 |
71 namespace { | 70 namespace { |
72 | 71 |
73 const bool kPayWithoutWalletDefault = false; | 72 const bool kPayWithoutWalletDefault = false; |
74 | 73 |
75 // This is a pseudo-scientifically chosen maximum amount we want a fronting | |
76 // (proxy) card to be able to charge. The current actual max is $2000. Using | |
77 // only $1850 leaves some room for tax and shipping, etc. TODO(dbeam): send a | |
78 // special value to the server to just ask for the maximum so we don't need to | |
79 // hardcode it here (http://crbug.com/180731). TODO(dbeam): also maybe allow | |
80 // users to give us this number via an <input> (http://crbug.com/180733). | |
81 const int kCartMax = 1850; | |
82 const char kCartCurrency[] = "USD"; | |
83 | |
84 const char kAddNewItemKey[] = "add-new-item"; | 74 const char kAddNewItemKey[] = "add-new-item"; |
85 const char kManageItemsKey[] = "manage-items"; | 75 const char kManageItemsKey[] = "manage-items"; |
86 const char kSameAsBillingKey[] = "same-as-billing"; | 76 const char kSameAsBillingKey[] = "same-as-billing"; |
87 | 77 |
88 // Returns true if |input| should be shown when |field_type| has been requested. | 78 // Returns true if |input| should be shown when |field_type| has been requested. |
89 bool InputTypeMatchesFieldType(const DetailInput& input, | 79 bool InputTypeMatchesFieldType(const DetailInput& input, |
90 AutofillFieldType field_type) { | 80 AutofillFieldType field_type) { |
91 // If any credit card expiration info is asked for, show both month and year | 81 // If any credit card expiration info is asked for, show both month and year |
92 // inputs. | 82 // inputs. |
93 if (field_type == CREDIT_CARD_EXP_4_DIGIT_YEAR || | 83 if (field_type == CREDIT_CARD_EXP_4_DIGIT_YEAR || |
(...skipping 1448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1542 LOG(ERROR) << "failed to automatically sign in: " << error.ToString(); | 1532 LOG(ERROR) << "failed to automatically sign in: " << error.ToString(); |
1543 OnWalletSigninError(); | 1533 OnWalletSigninError(); |
1544 } | 1534 } |
1545 | 1535 |
1546 void AutofillDialogControllerImpl::OnDidGetWalletItems( | 1536 void AutofillDialogControllerImpl::OnDidGetWalletItems( |
1547 scoped_ptr<wallet::WalletItems> wallet_items) { | 1537 scoped_ptr<wallet::WalletItems> wallet_items) { |
1548 DCHECK(account_chooser_model_.WalletIsSelected()); | 1538 DCHECK(account_chooser_model_.WalletIsSelected()); |
1549 legal_documents_text_.clear(); | 1539 legal_documents_text_.clear(); |
1550 legal_document_link_ranges_.clear(); | 1540 legal_document_link_ranges_.clear(); |
1551 | 1541 |
1552 // TODO(dbeam): verify items support kCartCurrency? http://crbug.com/232952 | |
1553 wallet_items_ = wallet_items.Pass(); | 1542 wallet_items_ = wallet_items.Pass(); |
1554 OnWalletOrSigninUpdate(); | 1543 OnWalletOrSigninUpdate(); |
1555 } | 1544 } |
1556 | 1545 |
1557 void AutofillDialogControllerImpl::OnDidSaveAddress( | 1546 void AutofillDialogControllerImpl::OnDidSaveAddress( |
1558 const std::string& address_id, | 1547 const std::string& address_id, |
1559 const std::vector<wallet::RequiredAction>& required_actions) { | 1548 const std::vector<wallet::RequiredAction>& required_actions) { |
1560 // TODO(dbeam): handle required actions. http://crbug.com/163508 | 1549 // TODO(dbeam): handle required actions. http://crbug.com/163508 |
1561 active_address_id_ = address_id; | 1550 active_address_id_ = address_id; |
1562 GetFullWallet(); | 1551 GetFullWallet(); |
(...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2255 DCHECK(!active_instrument_id_.empty()); | 2244 DCHECK(!active_instrument_id_.empty()); |
2256 DCHECK(!active_address_id_.empty()); | 2245 DCHECK(!active_address_id_.empty()); |
2257 | 2246 |
2258 std::vector<wallet::WalletClient::RiskCapability> capabilities; | 2247 std::vector<wallet::WalletClient::RiskCapability> capabilities; |
2259 capabilities.push_back(wallet::WalletClient::VERIFY_CVC); | 2248 capabilities.push_back(wallet::WalletClient::VERIFY_CVC); |
2260 | 2249 |
2261 GetWalletClient()->GetFullWallet(wallet::WalletClient::FullWalletRequest( | 2250 GetWalletClient()->GetFullWallet(wallet::WalletClient::FullWalletRequest( |
2262 active_instrument_id_, | 2251 active_instrument_id_, |
2263 active_address_id_, | 2252 active_address_id_, |
2264 source_url_, | 2253 source_url_, |
2265 wallet::Cart(base::IntToString(kCartMax), kCartCurrency), | |
2266 wallet_items_->google_transaction_id(), | 2254 wallet_items_->google_transaction_id(), |
2267 capabilities)); | 2255 capabilities)); |
2268 } | 2256 } |
2269 | 2257 |
2270 void AutofillDialogControllerImpl::FinishSubmit() { | 2258 void AutofillDialogControllerImpl::FinishSubmit() { |
2271 FillOutputForSection(SECTION_EMAIL); | 2259 FillOutputForSection(SECTION_EMAIL); |
2272 FillOutputForSection(SECTION_CC); | 2260 FillOutputForSection(SECTION_CC); |
2273 FillOutputForSection(SECTION_BILLING); | 2261 FillOutputForSection(SECTION_BILLING); |
2274 FillOutputForSection(SECTION_CC_BILLING); | 2262 FillOutputForSection(SECTION_CC_BILLING); |
2275 | 2263 |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2411 AutofillMetrics::DIALOG_USER_SIGNED_IN_NO_WALLET_NO_AUTOFILL; | 2399 AutofillMetrics::DIALOG_USER_SIGNED_IN_NO_WALLET_NO_AUTOFILL; |
2412 } | 2400 } |
2413 | 2401 |
2414 // Has Wallet items. | 2402 // Has Wallet items. |
2415 return has_autofill_profiles ? | 2403 return has_autofill_profiles ? |
2416 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_HAS_AUTOFILL : | 2404 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_HAS_AUTOFILL : |
2417 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_NO_AUTOFILL; | 2405 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_NO_AUTOFILL; |
2418 } | 2406 } |
2419 | 2407 |
2420 } // namespace autofill | 2408 } // namespace autofill |
OLD | NEW |