| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 #import "ios/chrome/browser/ui/payments/address_edit_coordinator.h" | 5 #import "ios/chrome/browser/ui/payments/address_edit_coordinator.h" |
| 6 | 6 |
| 7 #include "base/guid.h" | 7 #include "base/guid.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/strings/sys_string_conversions.h" | 9 #include "base/strings/sys_string_conversions.h" |
| 10 #include "components/autofill/core/browser/autofill_profile.h" | 10 #include "components/autofill/core/browser/autofill_profile.h" |
| 11 #include "components/autofill/core/browser/personal_data_manager.h" | 11 #include "components/autofill/core/browser/personal_data_manager.h" |
| 12 #include "components/autofill/core/common/autofill_constants.h" | 12 #include "components/autofill/core/common/autofill_constants.h" |
| 13 #include "components/payments/core/payments_profile_comparator.h" |
| 13 #include "components/strings/grit/components_strings.h" | 14 #include "components/strings/grit/components_strings.h" |
| 14 #include "ios/chrome/browser/payments/payment_request.h" | 15 #include "ios/chrome/browser/payments/payment_request.h" |
| 15 #import "ios/chrome/browser/ui/autofill/autofill_ui_type_util.h" | 16 #import "ios/chrome/browser/ui/autofill/autofill_ui_type_util.h" |
| 16 #import "ios/chrome/browser/ui/payments/address_edit_mediator.h" | 17 #import "ios/chrome/browser/ui/payments/address_edit_mediator.h" |
| 17 #import "ios/chrome/browser/ui/payments/payment_request_editor_field.h" | 18 #import "ios/chrome/browser/ui/payments/payment_request_editor_field.h" |
| 18 #include "ui/base/l10n/l10n_util.h" | 19 #include "ui/base/l10n/l10n_util.h" |
| 19 | 20 |
| 20 #if !defined(__has_feature) || !__has_feature(objc_arc) | 21 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 21 #error "This file requires ARC support." | 22 #error "This file requires ARC support." |
| 22 #endif | 23 #endif |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 if (!self.address) { | 123 if (!self.address) { |
| 123 self.paymentRequest->GetPersonalDataManager()->AddProfile(address); | 124 self.paymentRequest->GetPersonalDataManager()->AddProfile(address); |
| 124 | 125 |
| 125 // Add the profile to the list of profiles in |self.paymentRequest|. | 126 // Add the profile to the list of profiles in |self.paymentRequest|. |
| 126 self.address = self.paymentRequest->AddAutofillProfile(address); | 127 self.address = self.paymentRequest->AddAutofillProfile(address); |
| 127 } else { | 128 } else { |
| 128 // Override the origin. | 129 // Override the origin. |
| 129 address.set_origin(autofill::kSettingsOrigin); | 130 address.set_origin(autofill::kSettingsOrigin); |
| 130 self.paymentRequest->GetPersonalDataManager()->UpdateProfile(address); | 131 self.paymentRequest->GetPersonalDataManager()->UpdateProfile(address); |
| 131 | 132 |
| 133 // Cached profile must be invalidated once the profile is modified. |
| 134 _paymentRequest->profile_comparator()->Invalidate(address); |
| 135 |
| 132 // Update the original profile instance that is being edited. | 136 // Update the original profile instance that is being edited. |
| 133 *self.address = address; | 137 *self.address = address; |
| 134 } | 138 } |
| 135 | 139 |
| 136 [self.delegate addressEditCoordinator:self | 140 [self.delegate addressEditCoordinator:self |
| 137 didFinishEditingAddress:self.address]; | 141 didFinishEditingAddress:self.address]; |
| 138 } | 142 } |
| 139 | 143 |
| 140 - (void)paymentRequestEditViewControllerDidCancel: | 144 - (void)paymentRequestEditViewControllerDidCancel: |
| 141 (PaymentRequestEditViewController*)controller { | 145 (PaymentRequestEditViewController*)controller { |
| 142 [self.delegate addressEditCoordinatorDidCancel:self]; | 146 [self.delegate addressEditCoordinatorDidCancel:self]; |
| 143 } | 147 } |
| 144 | 148 |
| 145 #pragma mark - CountrySelectionCoordinatorDelegate | 149 #pragma mark - CountrySelectionCoordinatorDelegate |
| 146 | 150 |
| 147 - (void)countrySelectionCoordinator:(CountrySelectionCoordinator*)coordinator | 151 - (void)countrySelectionCoordinator:(CountrySelectionCoordinator*)coordinator |
| 148 didSelectCountryWithCode:(NSString*)countryCode { | 152 didSelectCountryWithCode:(NSString*)countryCode { |
| 149 if (self.mediator.selectedCountryCode != countryCode) { | 153 if (self.mediator.selectedCountryCode != countryCode) { |
| 150 [self.mediator setSelectedCountryCode:countryCode]; | 154 [self.mediator setSelectedCountryCode:countryCode]; |
| 151 [self.viewController loadModel]; | 155 [self.viewController loadModel]; |
| 152 [self.viewController.collectionView reloadData]; | 156 [self.viewController.collectionView reloadData]; |
| 153 } | 157 } |
| 154 [self.countrySelectionCoordinator stop]; | 158 [self.countrySelectionCoordinator stop]; |
| 155 self.countrySelectionCoordinator = nil; | 159 self.countrySelectionCoordinator = nil; |
| 156 } | 160 } |
| 157 | 161 |
| 158 @end | 162 @end |
| OLD | NEW |