Chromium Code Reviews| 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 22 matching lines...) Expand all Loading... | |
| 33 constexpr int kFirstTagValue = static_cast<int>( | 33 constexpr int kFirstTagValue = static_cast<int>( |
| 34 payments::PaymentRequestCommonTags::PAYMENT_REQUEST_COMMON_TAG_MAX); | 34 payments::PaymentRequestCommonTags::PAYMENT_REQUEST_COMMON_TAG_MAX); |
| 35 | 35 |
| 36 enum class PaymentMethodViewControllerTags : int { | 36 enum class PaymentMethodViewControllerTags : int { |
| 37 // The tag for the button that triggers the "add address" flow. Starts at | 37 // The tag for the button that triggers the "add address" flow. Starts at |
| 38 // |kFirstTagValue| not to conflict with tags common to all views. | 38 // |kFirstTagValue| not to conflict with tags common to all views. |
| 39 ADD_SHIPPING_ADDRESS_BUTTON = kFirstTagValue, | 39 ADD_SHIPPING_ADDRESS_BUTTON = kFirstTagValue, |
| 40 ADD_CONTACT_BUTTON, | 40 ADD_CONTACT_BUTTON, |
| 41 }; | 41 }; |
| 42 | 42 |
| 43 class ProfileItem : public PaymentRequestItemList::Item { | 43 class ProfileItem : public PaymentRequestItemList::Item { |
|
Evan Stade
2017/05/12 18:48:07
while I'm poking around (and this doesn't have to
anthonyvd
2017/05/12 20:16:48
Ack.
| |
| 44 public: | 44 public: |
| 45 // Constructs an object owned by |parent_list|, representing one element in | 45 // Constructs an object owned by |parent_list|, representing one element in |
| 46 // the list. |spec| and |state| are the PaymentRequestSpec/State objects that | 46 // the list. |spec| and |state| are the PaymentRequestSpec/State objects that |
| 47 // are represented by the current instance of the dialog. |parent_view| points | 47 // are represented by the current instance of the dialog. |parent_view| points |
| 48 // to the controller which owns |parent_list|. |profile| is the | 48 // to the controller which owns |parent_list|. |profile| is the |
| 49 // AutofillProfile that this specific list item represents. It's a cached | 49 // AutofillProfile that this specific list item represents. It's a cached |
| 50 // profile owned by |state|. | 50 // profile owned by |state|. |
| 51 ProfileItem(autofill::AutofillProfile* profile, | 51 ProfileItem(autofill::AutofillProfile* profile, |
| 52 PaymentRequestSpec* spec, | 52 PaymentRequestSpec* spec, |
| 53 PaymentRequestState* state, | 53 PaymentRequestState* state, |
| 54 PaymentRequestItemList* parent_list, | 54 PaymentRequestItemList* parent_list, |
| 55 ProfileListViewController* parent_view, | 55 ProfileListViewController* parent_view, |
| 56 PaymentRequestDialogView* dialog, | 56 PaymentRequestDialogView* dialog, |
| 57 bool selected) | 57 bool selected) |
| 58 : payments::PaymentRequestItemList::Item(spec, | 58 : payments::PaymentRequestItemList::Item(spec, |
| 59 state, | 59 state, |
| 60 parent_list, | 60 parent_list, |
| 61 selected), | 61 selected, |
| 62 /*show_edit_button=*/true), | |
| 62 parent_view_(parent_view), | 63 parent_view_(parent_view), |
| 63 profile_(profile), | 64 profile_(profile), |
| 64 dialog_(dialog) {} | 65 dialog_(dialog) {} |
| 65 ~ProfileItem() override {} | 66 ~ProfileItem() override {} |
| 66 | 67 |
| 67 private: | 68 private: |
| 68 // payments::PaymentRequestItemList::Item: | 69 // payments::PaymentRequestItemList::Item: |
| 69 std::unique_ptr<views::View> CreateContentView() override { | 70 std::unique_ptr<views::View> CreateContentView() override { |
| 70 DCHECK(profile_); | 71 DCHECK(profile_); |
| 71 | 72 |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 87 // PerformSelectionFallback() is called. | 88 // PerformSelectionFallback() is called. |
| 88 return IsEnabled() && parent_view_->IsValidProfile(*profile_); | 89 return IsEnabled() && parent_view_->IsValidProfile(*profile_); |
| 89 } | 90 } |
| 90 | 91 |
| 91 void PerformSelectionFallback() override { | 92 void PerformSelectionFallback() override { |
| 92 // If enabled, the editor is opened to complete the invalid profile. | 93 // If enabled, the editor is opened to complete the invalid profile. |
| 93 if (IsEnabled()) | 94 if (IsEnabled()) |
| 94 parent_view_->ShowEditor(profile_); | 95 parent_view_->ShowEditor(profile_); |
| 95 } | 96 } |
| 96 | 97 |
| 98 void EditButtonPressed() override { parent_view_->ShowEditor(profile_); } | |
| 99 | |
| 97 ProfileListViewController* parent_view_; | 100 ProfileListViewController* parent_view_; |
|
Evan Stade
2017/05/12 18:48:07
nit: confusing that the controller is named parent
anthonyvd
2017/05/12 20:16:48
Done.
| |
| 98 autofill::AutofillProfile* profile_; | 101 autofill::AutofillProfile* profile_; |
| 99 PaymentRequestDialogView* dialog_; | 102 PaymentRequestDialogView* dialog_; |
| 100 | 103 |
| 101 DISALLOW_COPY_AND_ASSIGN(ProfileItem); | 104 DISALLOW_COPY_AND_ASSIGN(ProfileItem); |
| 102 }; | 105 }; |
| 103 | 106 |
| 104 // The ProfileListViewController subtype for the Shipping address list | 107 // The ProfileListViewController subtype for the Shipping address list |
| 105 // screen of the Payment Request flow. | 108 // screen of the Payment Request flow. |
| 106 class ShippingProfileViewController : public ProfileListViewController { | 109 class ShippingProfileViewController : public ProfileListViewController { |
| 107 public: | 110 public: |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 374 | 377 |
| 375 void ProfileListViewController::ButtonPressed(views::Button* sender, | 378 void ProfileListViewController::ButtonPressed(views::Button* sender, |
| 376 const ui::Event& event) { | 379 const ui::Event& event) { |
| 377 if (sender->tag() == GetSecondaryButtonTag()) | 380 if (sender->tag() == GetSecondaryButtonTag()) |
| 378 ShowEditor(nullptr); | 381 ShowEditor(nullptr); |
| 379 else | 382 else |
| 380 PaymentRequestSheetController::ButtonPressed(sender, event); | 383 PaymentRequestSheetController::ButtonPressed(sender, event); |
| 381 } | 384 } |
| 382 | 385 |
| 383 } // namespace payments | 386 } // namespace payments |
| OLD | NEW |