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

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

Issue 17970003: New encryption/escrow endpoints for Wallet (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Deleting old escrow unit tests Created 7 years, 5 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 <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 10
(...skipping 1719 matching lines...) Expand 10 before | Expand all | Expand 10 after
1730 DialogAutocheckoutStep(AUTOCHECKOUT_STEP_PROXY_CARD, 1730 DialogAutocheckoutStep(AUTOCHECKOUT_STEP_PROXY_CARD,
1731 AUTOCHECKOUT_STEP_UNSTARTED)); 1731 AUTOCHECKOUT_STEP_UNSTARTED));
1732 } 1732 }
1733 } 1733 }
1734 1734
1735 SetIsSubmitting(true); 1735 SetIsSubmitting(true);
1736 if (IsSubmitPausedOn(wallet::VERIFY_CVV)) { 1736 if (IsSubmitPausedOn(wallet::VERIFY_CVV)) {
1737 DCHECK(!active_instrument_id_.empty()); 1737 DCHECK(!active_instrument_id_.empty());
1738 GetWalletClient()->AuthenticateInstrument( 1738 GetWalletClient()->AuthenticateInstrument(
1739 active_instrument_id_, 1739 active_instrument_id_,
1740 UTF16ToUTF8(view_->GetCvc()), 1740 UTF16ToUTF8(view_->GetCvc()));
1741 wallet_items_->obfuscated_gaia_id());
1742 } else if (IsPayingWithWallet()) { 1741 } else if (IsPayingWithWallet()) {
1743 // TODO(dbeam): disallow interacting with the dialog while submitting. 1742 // TODO(dbeam): disallow interacting with the dialog while submitting.
1744 // http://crbug.com/230932 1743 // http://crbug.com/230932
1745 AcceptLegalDocuments(); 1744 AcceptLegalDocuments();
1746 } else { 1745 } else {
1747 FinishSubmit(); 1746 FinishSubmit();
1748 } 1747 }
1749 } 1748 }
1750 1749
1751 Profile* AutofillDialogControllerImpl::profile() { 1750 Profile* AutofillDialogControllerImpl::profile() {
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
1973 void AutofillDialogControllerImpl::OnDidGetWalletItems( 1972 void AutofillDialogControllerImpl::OnDidGetWalletItems(
1974 scoped_ptr<wallet::WalletItems> wallet_items) { 1973 scoped_ptr<wallet::WalletItems> wallet_items) {
1975 legal_documents_text_.clear(); 1974 legal_documents_text_.clear();
1976 legal_document_link_ranges_.clear(); 1975 legal_document_link_ranges_.clear();
1977 has_accepted_legal_documents_ = false; 1976 has_accepted_legal_documents_ = false;
1978 1977
1979 wallet_items_ = wallet_items.Pass(); 1978 wallet_items_ = wallet_items.Pass();
1980 OnWalletOrSigninUpdate(); 1979 OnWalletOrSigninUpdate();
1981 } 1980 }
1982 1981
1983 void AutofillDialogControllerImpl::OnDidSaveAddress( 1982 void AutofillDialogControllerImpl::OnDidSaveToWallet(
1983 const std::string& instrument_id,
1984 const std::string& address_id, 1984 const std::string& address_id,
1985 const std::vector<wallet::RequiredAction>& required_actions, 1985 const std::vector<wallet::RequiredAction>& required_actions,
1986 const std::vector<wallet::FormFieldError>& form_field_errors) { 1986 const std::vector<wallet::FormFieldError>& form_field_errors) {
1987 DCHECK(is_submitting_ && IsPayingWithWallet());
1988
1989 if (required_actions.empty()) { 1987 if (required_actions.empty()) {
1990 active_address_id_ = address_id; 1988 if (active_address_id_.empty() && !address_id.empty())
Raman Kakilate 2013/07/01 19:37:56 Is this good? Address ID's change on every edit r
ahutter 2013/07/01 21:37:45 Done.
1989 active_address_id_ = address_id;
1990 if (active_instrument_id_.empty() && !instrument_id.empty())
1991 active_instrument_id_ = instrument_id;
1991 GetFullWalletIfReady(); 1992 GetFullWalletIfReady();
1992 } else { 1993 } else {
1993 OnWalletFormFieldError(form_field_errors); 1994 OnWalletFormFieldError(form_field_errors);
1994 HandleSaveOrUpdateRequiredActions(required_actions);
1995 }
1996 }
1997
1998 void AutofillDialogControllerImpl::OnDidSaveInstrument(
1999 const std::string& instrument_id,
2000 const std::vector<wallet::RequiredAction>& required_actions,
2001 const std::vector<wallet::FormFieldError>& form_field_errors) {
2002 DCHECK(is_submitting_ && IsPayingWithWallet());
2003
2004 if (required_actions.empty()) {
2005 active_instrument_id_ = instrument_id;
2006 GetFullWalletIfReady();
2007 } else {
2008 OnWalletFormFieldError(form_field_errors);
2009 HandleSaveOrUpdateRequiredActions(required_actions); 1995 HandleSaveOrUpdateRequiredActions(required_actions);
2010 } 1996 }
2011 } 1997 }
2012 1998
2013 void AutofillDialogControllerImpl::OnDidSaveInstrumentAndAddress(
2014 const std::string& instrument_id,
2015 const std::string& address_id,
2016 const std::vector<wallet::RequiredAction>& required_actions,
2017 const std::vector<wallet::FormFieldError>& form_field_errors) {
2018 OnDidSaveInstrument(instrument_id, required_actions, form_field_errors);
2019 // |is_submitting_| can change while in |OnDidSaveInstrument()|.
2020 if (is_submitting_)
2021 OnDidSaveAddress(address_id, required_actions, form_field_errors);
2022 }
2023
2024 void AutofillDialogControllerImpl::OnDidUpdateAddress(
2025 const std::string& address_id,
2026 const std::vector<wallet::RequiredAction>& required_actions,
2027 const std::vector<wallet::FormFieldError>& form_field_errors) {
2028 OnDidSaveAddress(address_id, required_actions, form_field_errors);
2029 }
2030
2031 void AutofillDialogControllerImpl::OnDidUpdateInstrument(
2032 const std::string& instrument_id,
2033 const std::vector<wallet::RequiredAction>& required_actions,
2034 const std::vector<wallet::FormFieldError>& form_field_errors) {
2035 OnDidSaveInstrument(instrument_id, required_actions, form_field_errors);
2036 }
2037
2038 void AutofillDialogControllerImpl::OnWalletError( 1999 void AutofillDialogControllerImpl::OnWalletError(
2039 wallet::WalletClient::ErrorType error_type) { 2000 wallet::WalletClient::ErrorType error_type) {
2040 DisableWallet(error_type); 2001 DisableWallet(error_type);
2041 } 2002 }
2042 2003
2043 //////////////////////////////////////////////////////////////////////////////// 2004 ////////////////////////////////////////////////////////////////////////////////
2044 // PersonalDataManagerObserver implementation. 2005 // PersonalDataManagerObserver implementation.
2045 2006
2046 void AutofillDialogControllerImpl::OnPersonalDataChanged() { 2007 void AutofillDialogControllerImpl::OnPersonalDataChanged() {
2047 if (is_submitting_) 2008 if (is_submitting_)
(...skipping 743 matching lines...) Expand 10 before | Expand all | Expand 10 after
2791 autocheckout_state_ = AUTOCHECKOUT_IN_PROGRESS; 2752 autocheckout_state_ = AUTOCHECKOUT_IN_PROGRESS;
2792 if (view_) { 2753 if (view_) {
2793 view_->UpdateButtonStrip(); 2754 view_->UpdateButtonStrip();
2794 view_->UpdateAutocheckoutStepsArea(); 2755 view_->UpdateAutocheckoutStepsArea();
2795 view_->UpdateDetailArea(); 2756 view_->UpdateDetailArea();
2796 } 2757 }
2797 } 2758 }
2798 2759
2799 scoped_ptr<wallet::Instrument> inputted_instrument = 2760 scoped_ptr<wallet::Instrument> inputted_instrument =
2800 CreateTransientInstrument(); 2761 CreateTransientInstrument();
2801 scoped_ptr<wallet::WalletClient::UpdateInstrumentRequest> update_request = 2762 if (inputted_instrument && IsEditingExistingData(SECTION_CC_BILLING)) {
2802 CreateUpdateInstrumentRequest( 2763 inputted_instrument->set_object_id(active_instrument->object_id());
2803 inputted_instrument.get(), 2764 DCHECK(!inputted_instrument->object_id().empty());
2804 !IsEditingExistingData(SECTION_CC_BILLING) ? std::string() : 2765 }
2805 active_instrument->object_id());
2806 2766
2807 scoped_ptr<wallet::Address> inputted_address; 2767 scoped_ptr<wallet::Address> inputted_address;
2808 if (active_address_id_.empty()) { 2768 if (active_address_id_.empty()) {
2809 if (ShouldUseBillingForShipping()) { 2769 if (ShouldUseBillingForShipping()) {
2810 const wallet::Address& address = inputted_instrument ? 2770 const wallet::Address& address = inputted_instrument ?
2811 inputted_instrument->address() : active_instrument->address(); 2771 *inputted_instrument->address() : active_instrument->address();
2812 // Try to find an exact matched shipping address and use it for shipping, 2772 // Try to find an exact matched shipping address and use it for shipping,
2813 // otherwise save it as a new shipping address. http://crbug.com/225442 2773 // otherwise save it as a new shipping address. http://crbug.com/225442
2814 const wallet::Address* duplicated_address = 2774 const wallet::Address* duplicated_address =
2815 FindDuplicateAddress(wallet_items_->addresses(), address); 2775 FindDuplicateAddress(wallet_items_->addresses(), address);
2816 if (duplicated_address) { 2776 if (duplicated_address) {
2817 active_address_id_ = duplicated_address->object_id(); 2777 active_address_id_ = duplicated_address->object_id();
2818 DCHECK(!active_address_id_.empty()); 2778 DCHECK(!active_address_id_.empty());
2819 } else { 2779 } else {
2820 inputted_address.reset(new wallet::Address(address)); 2780 inputted_address.reset(new wallet::Address(address));
2821 DCHECK(inputted_address->object_id().empty()); 2781 DCHECK(inputted_address->object_id().empty());
2822 } 2782 }
2823 } else { 2783 } else {
2824 inputted_address = CreateTransientAddress(); 2784 inputted_address = CreateTransientAddress();
2825 if (IsEditingExistingData(SECTION_SHIPPING)) { 2785 if (IsEditingExistingData(SECTION_SHIPPING)) {
2826 inputted_address->set_object_id(active_address->object_id()); 2786 inputted_address->set_object_id(active_address->object_id());
2827 DCHECK(!inputted_address->object_id().empty()); 2787 DCHECK(!inputted_address->object_id().empty());
2828 } 2788 }
2829 } 2789 }
2830 } 2790 }
2831 2791
2832 // If there's neither an address nor instrument to save, |GetFullWallet()| 2792 // If there's neither an address nor instrument to save, |GetFullWallet()|
2833 // is called when the risk fingerprint is loaded. 2793 // is called when the risk fingerprint is loaded.
2834 if (!active_instrument_id_.empty() && !active_address_id_.empty()) { 2794 if (!active_instrument_id_.empty() && !active_address_id_.empty()) {
2835 GetFullWallet(); 2795 GetFullWallet();
2836 return; 2796 return;
2837 } 2797 }
2838 2798
2839 // If instrument and address aren't based off of any existing data, save both. 2799 GetWalletClient()->SaveToWallet(
2840 if (inputted_instrument && inputted_address && !update_request && 2800 inputted_instrument.Pass(),
2841 inputted_address->object_id().empty()) { 2801 inputted_address.Pass(),
2842 GetWalletClient()->SaveInstrumentAndAddress( 2802 source_url_);
2843 *inputted_instrument,
2844 *inputted_address,
2845 wallet_items_->obfuscated_gaia_id(),
2846 source_url_);
2847 return;
2848 }
2849
2850 if (inputted_instrument) {
2851 if (update_request) {
2852 scoped_ptr<wallet::Address> billing_address(
2853 new wallet::Address(inputted_instrument->address()));
2854 GetWalletClient()->UpdateInstrument(*update_request,
2855 billing_address.Pass());
2856 } else {
2857 GetWalletClient()->SaveInstrument(*inputted_instrument,
2858 wallet_items_->obfuscated_gaia_id(),
2859 source_url_);
2860 }
2861 }
2862
2863 if (inputted_address) {
2864 if (!inputted_address->object_id().empty())
2865 GetWalletClient()->UpdateAddress(*inputted_address, source_url_);
2866 else
2867 GetWalletClient()->SaveAddress(*inputted_address, source_url_);
2868 }
2869 } 2803 }
2870 2804
2871 scoped_ptr<wallet::Instrument> AutofillDialogControllerImpl:: 2805 scoped_ptr<wallet::Instrument> AutofillDialogControllerImpl::
2872 CreateTransientInstrument() { 2806 CreateTransientInstrument() {
2873 if (!active_instrument_id_.empty()) 2807 if (!active_instrument_id_.empty())
2874 return scoped_ptr<wallet::Instrument>(); 2808 return scoped_ptr<wallet::Instrument>();
2875 2809
2876 DetailOutputMap output; 2810 DetailOutputMap output;
2877 view_->GetUserInput(SECTION_CC_BILLING, &output); 2811 view_->GetUserInput(SECTION_CC_BILLING, &output);
2878 2812
2879 CreditCard card; 2813 CreditCard card;
2880 AutofillProfile profile; 2814 AutofillProfile profile;
2881 string16 cvc; 2815 string16 cvc;
2882 GetBillingInfoFromOutputs(output, &card, &cvc, &profile); 2816 GetBillingInfoFromOutputs(output, &card, &cvc, &profile);
2883 2817
2884 return scoped_ptr<wallet::Instrument>( 2818 return scoped_ptr<wallet::Instrument>(
2885 new wallet::Instrument(card, cvc, profile)); 2819 new wallet::Instrument(card, cvc, profile));
2886 } 2820 }
2887 2821
2888 scoped_ptr<wallet::WalletClient::UpdateInstrumentRequest>
2889 AutofillDialogControllerImpl::CreateUpdateInstrumentRequest(
2890 const wallet::Instrument* instrument,
2891 const std::string& instrument_id) {
2892 if (!instrument || instrument_id.empty())
2893 return scoped_ptr<wallet::WalletClient::UpdateInstrumentRequest>();
2894
2895 scoped_ptr<wallet::WalletClient::UpdateInstrumentRequest> update_request(
2896 new wallet::WalletClient::UpdateInstrumentRequest(
2897 instrument_id, source_url_));
2898 update_request->expiration_month = instrument->expiration_month();
2899 update_request->expiration_year = instrument->expiration_year();
2900 update_request->card_verification_number =
2901 UTF16ToUTF8(instrument->card_verification_number());
2902 update_request->obfuscated_gaia_id = wallet_items_->obfuscated_gaia_id();
2903 return update_request.Pass();
2904 }
2905
2906 scoped_ptr<wallet::Address>AutofillDialogControllerImpl:: 2822 scoped_ptr<wallet::Address>AutofillDialogControllerImpl::
2907 CreateTransientAddress() { 2823 CreateTransientAddress() {
2908 // If not using billing for shipping, just scrape the view. 2824 // If not using billing for shipping, just scrape the view.
2909 DetailOutputMap output; 2825 DetailOutputMap output;
2910 view_->GetUserInput(SECTION_SHIPPING, &output); 2826 view_->GetUserInput(SECTION_SHIPPING, &output);
2911 2827
2912 AutofillProfile profile; 2828 AutofillProfile profile;
2913 FillFormGroupFromOutputs(output, &profile); 2829 FillFormGroupFromOutputs(output, &profile);
2914 2830
2915 return scoped_ptr<wallet::Address>(new wallet::Address(profile)); 2831 return scoped_ptr<wallet::Address>(new wallet::Address(profile));
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
3194 AutofillMetrics::DIALOG_USER_SIGNED_IN_NO_WALLET_NO_AUTOFILL; 3110 AutofillMetrics::DIALOG_USER_SIGNED_IN_NO_WALLET_NO_AUTOFILL;
3195 } 3111 }
3196 3112
3197 // Has Wallet items. 3113 // Has Wallet items.
3198 return has_autofill_profiles ? 3114 return has_autofill_profiles ?
3199 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_HAS_AUTOFILL : 3115 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_HAS_AUTOFILL :
3200 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_NO_AUTOFILL; 3116 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_NO_AUTOFILL;
3201 } 3117 }
3202 3118
3203 } // namespace autofill 3119 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698