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 <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 3145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3156 const wallet::Address* active_address = ActiveShippingAddress(); | 3156 const wallet::Address* active_address = ActiveShippingAddress(); |
3157 if (!IsManuallyEditingSection(SECTION_SHIPPING) && | 3157 if (!IsManuallyEditingSection(SECTION_SHIPPING) && |
3158 !ShouldUseBillingForShipping() && | 3158 !ShouldUseBillingForShipping() && |
3159 IsShippingAddressRequired()) { | 3159 IsShippingAddressRequired()) { |
3160 active_address_id_ = active_address->object_id(); | 3160 active_address_id_ = active_address->object_id(); |
3161 DCHECK(!active_address_id_.empty()); | 3161 DCHECK(!active_address_id_.empty()); |
3162 } | 3162 } |
3163 | 3163 |
3164 scoped_ptr<wallet::Instrument> inputted_instrument = | 3164 scoped_ptr<wallet::Instrument> inputted_instrument = |
3165 CreateTransientInstrument(); | 3165 CreateTransientInstrument(); |
3166 if (inputted_instrument && IsEditingExistingData(SECTION_CC_BILLING)) { | |
3167 inputted_instrument->set_object_id(active_instrument->object_id()); | |
3168 DCHECK(!inputted_instrument->object_id().empty()); | |
3169 } | |
3170 | 3166 |
3171 scoped_ptr<wallet::Address> inputted_address; | 3167 scoped_ptr<wallet::Address> inputted_address; |
3172 if (active_address_id_.empty() && IsShippingAddressRequired()) { | 3168 if (active_address_id_.empty() && IsShippingAddressRequired()) { |
3173 if (ShouldUseBillingForShipping()) { | 3169 if (ShouldUseBillingForShipping()) { |
3174 const wallet::Address& address = inputted_instrument ? | 3170 const wallet::Address& address = inputted_instrument ? |
3175 *inputted_instrument->address() : active_instrument->address(); | 3171 *inputted_instrument->address() : active_instrument->address(); |
3176 // Try to find an exact matched shipping address and use it for shipping, | 3172 // Try to find an exact matched shipping address and use it for shipping, |
3177 // otherwise save it as a new shipping address. http://crbug.com/225442 | 3173 // otherwise save it as a new shipping address. http://crbug.com/225442 |
3178 const wallet::Address* duplicated_address = | 3174 const wallet::Address* duplicated_address = |
3179 FindDuplicateAddress(wallet_items_->addresses(), address); | 3175 FindDuplicateAddress(wallet_items_->addresses(), address); |
3180 if (duplicated_address) { | 3176 if (duplicated_address) { |
3181 active_address_id_ = duplicated_address->object_id(); | 3177 active_address_id_ = duplicated_address->object_id(); |
3182 DCHECK(!active_address_id_.empty()); | 3178 DCHECK(!active_address_id_.empty()); |
3183 } else { | 3179 } else { |
3184 inputted_address.reset(new wallet::Address(address)); | 3180 inputted_address.reset(new wallet::Address(address)); |
3185 DCHECK(inputted_address->object_id().empty()); | 3181 DCHECK(inputted_address->object_id().empty()); |
3186 } | 3182 } |
3187 } else { | 3183 } else { |
3188 inputted_address = CreateTransientAddress(); | 3184 inputted_address = CreateTransientAddress(); |
3189 if (IsEditingExistingData(SECTION_SHIPPING)) { | |
3190 inputted_address->set_object_id(active_address->object_id()); | |
3191 DCHECK(!inputted_address->object_id().empty()); | |
3192 } | |
3193 } | 3185 } |
3194 } | 3186 } |
3195 | 3187 |
3196 // If there's neither an address nor instrument to save, |GetFullWallet()| | 3188 // If there's neither an address nor instrument to save, |GetFullWallet()| |
3197 // is called when the risk fingerprint is loaded. | 3189 // is called when the risk fingerprint is loaded. |
3198 if (!active_instrument_id_.empty() && | 3190 if (!active_instrument_id_.empty() && |
3199 (!active_address_id_.empty() || !IsShippingAddressRequired())) { | 3191 (!active_address_id_.empty() || !IsShippingAddressRequired())) { |
3200 GetFullWallet(); | 3192 GetFullWallet(); |
3201 return; | 3193 return; |
3202 } | 3194 } |
3203 | 3195 |
3204 GetWalletClient()->SaveToWallet(inputted_instrument.Pass(), | 3196 GetWalletClient()->SaveToWallet( |
3205 inputted_address.Pass()); | 3197 inputted_instrument.Pass(), |
| 3198 inputted_address.Pass(), |
| 3199 IsEditingExistingData(SECTION_CC_BILLING) ? active_instrument : NULL, |
| 3200 IsEditingExistingData(SECTION_SHIPPING) ? active_address : NULL); |
3206 } | 3201 } |
3207 | 3202 |
3208 scoped_ptr<wallet::Instrument> AutofillDialogControllerImpl:: | 3203 scoped_ptr<wallet::Instrument> AutofillDialogControllerImpl:: |
3209 CreateTransientInstrument() { | 3204 CreateTransientInstrument() { |
3210 if (!active_instrument_id_.empty()) | 3205 if (!active_instrument_id_.empty()) |
3211 return scoped_ptr<wallet::Instrument>(); | 3206 return scoped_ptr<wallet::Instrument>(); |
3212 | 3207 |
3213 FieldValueMap output; | 3208 FieldValueMap output; |
3214 view_->GetUserInput(SECTION_CC_BILLING, &output); | 3209 view_->GetUserInput(SECTION_CC_BILLING, &output); |
3215 | 3210 |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3538 view_->UpdateButtonStrip(); | 3533 view_->UpdateButtonStrip(); |
3539 } | 3534 } |
3540 | 3535 |
3541 void AutofillDialogControllerImpl::FetchWalletCookie() { | 3536 void AutofillDialogControllerImpl::FetchWalletCookie() { |
3542 net::URLRequestContextGetter* request_context = profile_->GetRequestContext(); | 3537 net::URLRequestContextGetter* request_context = profile_->GetRequestContext(); |
3543 signin_helper_.reset(new wallet::WalletSigninHelper(this, request_context)); | 3538 signin_helper_.reset(new wallet::WalletSigninHelper(this, request_context)); |
3544 signin_helper_->StartWalletCookieValueFetch(); | 3539 signin_helper_->StartWalletCookieValueFetch(); |
3545 } | 3540 } |
3546 | 3541 |
3547 } // namespace autofill | 3542 } // namespace autofill |
OLD | NEW |