| 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 #include "chrome/browser/ui/views/payments/profile_list_view_controller.h" | 5 #include "chrome/browser/ui/views/payments/profile_list_view_controller.h" |
| 6 | 6 |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "chrome/browser/ui/views/payments/payment_request_dialog_view.h" | 8 #include "chrome/browser/ui/views/payments/payment_request_dialog_view.h" |
| 9 #include "chrome/browser/ui/views/payments/payment_request_dialog_view_ids.h" | 9 #include "chrome/browser/ui/views/payments/payment_request_dialog_view_ids.h" |
| 10 #include "chrome/browser/ui/views/payments/payment_request_row_view.h" | 10 #include "chrome/browser/ui/views/payments/payment_request_row_view.h" |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 AddressStyleType::DETAILED, state()->GetApplicationLocale(), *profile, | 128 AddressStyleType::DETAILED, state()->GetApplicationLocale(), *profile, |
| 129 *(state()->profile_comparator())); | 129 *(state()->profile_comparator())); |
| 130 } | 130 } |
| 131 | 131 |
| 132 void SelectProfile(autofill::AutofillProfile* profile) override { | 132 void SelectProfile(autofill::AutofillProfile* profile) override { |
| 133 state()->SetSelectedShippingProfile(profile); | 133 state()->SetSelectedShippingProfile(profile); |
| 134 } | 134 } |
| 135 | 135 |
| 136 void ShowEditor(autofill::AutofillProfile* profile) override { | 136 void ShowEditor(autofill::AutofillProfile* profile) override { |
| 137 dialog()->ShowShippingAddressEditor( | 137 dialog()->ShowShippingAddressEditor( |
| 138 /*on_edited=*/base::BindOnce( | 138 BackNavigationType::kPaymentSheet, |
| 139 &PaymentRequestState::SetSelectedShippingProfile, | 139 /*on_edited=*/ |
| 140 base::Unretained(state()), profile), | 140 base::BindOnce(&PaymentRequestState::SetSelectedShippingProfile, |
| 141 base::Unretained(state()), profile), |
| 141 /*on_added=*/ | 142 /*on_added=*/ |
| 142 base::BindOnce(&PaymentRequestState::AddAutofillShippingProfile, | 143 base::BindOnce(&PaymentRequestState::AddAutofillShippingProfile, |
| 143 base::Unretained(state()), /*selected=*/true), | 144 base::Unretained(state()), /*selected=*/true), |
| 144 profile); | 145 profile); |
| 145 } | 146 } |
| 146 | 147 |
| 147 autofill::AutofillProfile* GetSelectedProfile() override { | 148 autofill::AutofillProfile* GetSelectedProfile() override { |
| 148 // If there are no errors with the currently selected profile, return it. | 149 // If there are no errors with the currently selected profile, return it. |
| 149 return spec()->selected_shipping_option_error().empty() | 150 return spec()->selected_shipping_option_error().empty() |
| 150 ? state()->selected_shipping_profile() | 151 ? state()->selected_shipping_profile() |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 return GetContactInfoLabel(AddressStyleType::DETAILED, | 238 return GetContactInfoLabel(AddressStyleType::DETAILED, |
| 238 state()->GetApplicationLocale(), *profile, | 239 state()->GetApplicationLocale(), *profile, |
| 239 *spec(), *(state()->profile_comparator())); | 240 *spec(), *(state()->profile_comparator())); |
| 240 } | 241 } |
| 241 | 242 |
| 242 void SelectProfile(autofill::AutofillProfile* profile) override { | 243 void SelectProfile(autofill::AutofillProfile* profile) override { |
| 243 state()->SetSelectedContactProfile(profile); | 244 state()->SetSelectedContactProfile(profile); |
| 244 } | 245 } |
| 245 | 246 |
| 246 void ShowEditor(autofill::AutofillProfile* profile) override { | 247 void ShowEditor(autofill::AutofillProfile* profile) override { |
| 247 dialog()->ShowContactInfoEditor(profile); | 248 dialog()->ShowContactInfoEditor(BackNavigationType::kPaymentSheet, profile); |
| 248 } | 249 } |
| 249 | 250 |
| 250 autofill::AutofillProfile* GetSelectedProfile() override { | 251 autofill::AutofillProfile* GetSelectedProfile() override { |
| 251 return state()->selected_contact_profile(); | 252 return state()->selected_contact_profile(); |
| 252 } | 253 } |
| 253 | 254 |
| 254 bool IsValidProfile(const autofill::AutofillProfile& profile) override { | 255 bool IsValidProfile(const autofill::AutofillProfile& profile) override { |
| 255 return state()->profile_comparator()->IsContactInfoComplete(&profile); | 256 return state()->profile_comparator()->IsContactInfoComplete(&profile); |
| 256 } | 257 } |
| 257 | 258 |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 | 374 |
| 374 void ProfileListViewController::ButtonPressed(views::Button* sender, | 375 void ProfileListViewController::ButtonPressed(views::Button* sender, |
| 375 const ui::Event& event) { | 376 const ui::Event& event) { |
| 376 if (sender->tag() == GetSecondaryButtonTag()) | 377 if (sender->tag() == GetSecondaryButtonTag()) |
| 377 ShowEditor(nullptr); | 378 ShowEditor(nullptr); |
| 378 else | 379 else |
| 379 PaymentRequestSheetController::ButtonPressed(sender, event); | 380 PaymentRequestSheetController::ButtonPressed(sender, event); |
| 380 } | 381 } |
| 381 | 382 |
| 382 } // namespace payments | 383 } // namespace payments |
| OLD | NEW |