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