| Index: chrome/browser/ui/views/payments/profile_list_view_controller.cc
|
| diff --git a/chrome/browser/ui/views/payments/profile_list_view_controller.cc b/chrome/browser/ui/views/payments/profile_list_view_controller.cc
|
| index 025571e4873dc24bc9858761cfeeb363896468f0..d328f2e79672b50eaa3a8d4f1cc8b40fe65e05d4 100644
|
| --- a/chrome/browser/ui/views/payments/profile_list_view_controller.cc
|
| +++ b/chrome/browser/ui/views/payments/profile_list_view_controller.cc
|
| @@ -5,17 +5,34 @@
|
| #include "chrome/browser/ui/views/payments/profile_list_view_controller.h"
|
|
|
| #include "chrome/browser/ui/views/payments/payment_request_dialog_view.h"
|
| +#include "chrome/browser/ui/views/payments/payment_request_dialog_view_ids.h"
|
| #include "chrome/browser/ui/views/payments/payment_request_row_view.h"
|
| #include "chrome/browser/ui/views/payments/payment_request_views_util.h"
|
| +#include "chrome/grit/generated_resources.h"
|
| #include "components/payments/content/payment_request_spec.h"
|
| #include "components/payments/content/payment_request_state.h"
|
| #include "components/strings/grit/components_strings.h"
|
| #include "ui/base/l10n/l10n_util.h"
|
| +#include "ui/views/controls/button/label_button.h"
|
| +#include "ui/views/controls/button/md_text_button.h"
|
| +#include "ui/views/controls/image_view.h"
|
| +#include "ui/views/layout/box_layout.h"
|
| +#include "ui/views/layout/grid_layout.h"
|
|
|
| namespace payments {
|
|
|
| namespace {
|
|
|
| +constexpr int kFirstTagValue = static_cast<int>(
|
| + payments::PaymentRequestCommonTags::PAYMENT_REQUEST_COMMON_TAG_MAX);
|
| +
|
| +enum class PaymentMethodViewControllerTags : int {
|
| + // The tag for the button that triggers the "add address" flow. Starts at
|
| + // |kFirstTagValue| not to conflict with tags common to all views.
|
| + ADD_SHIPPING_ADDRESS_BUTTON = kFirstTagValue,
|
| + ADD_CONTACT_BUTTON,
|
| +};
|
| +
|
| class ProfileItem : public PaymentRequestItemList::Item {
|
| public:
|
| // Constructs an object owned by |parent_list|, representing one element in
|
| @@ -105,6 +122,23 @@ class ShippingProfileViewController : public ProfileListViewController {
|
| return GetShippingAddressSectionString(spec()->options().shipping_type);
|
| }
|
|
|
| + int GetSecondaryButtonTextId() override {
|
| + return IDS_AUTOFILL_ADD_ADDRESS_CAPTION;
|
| + }
|
| +
|
| + int GetSecondaryButtonTag() override {
|
| + return static_cast<int>(
|
| + PaymentMethodViewControllerTags::ADD_SHIPPING_ADDRESS_BUTTON);
|
| + }
|
| +
|
| + int GetSecondaryButtonViewId() override {
|
| + return static_cast<int>(DialogViewID::PAYMENT_METHOD_ADD_SHIPPING_BUTTON);
|
| + }
|
| +
|
| + void OnSecondaryButtonPressed() override {
|
| + dialog()->ShowShippingAddressEditor();
|
| + }
|
| +
|
| private:
|
| DISALLOW_COPY_AND_ASSIGN(ShippingProfileViewController);
|
| };
|
| @@ -144,6 +178,23 @@ class ContactProfileViewController : public ProfileListViewController {
|
| IDS_PAYMENT_REQUEST_CONTACT_INFO_SECTION_NAME);
|
| }
|
|
|
| + int GetSecondaryButtonTextId() override {
|
| + return IDS_AUTOFILL_ADD_CONTACT_CAPTION;
|
| + }
|
| +
|
| + int GetSecondaryButtonTag() override {
|
| + return static_cast<int>(
|
| + PaymentMethodViewControllerTags::ADD_CONTACT_BUTTON);
|
| + }
|
| +
|
| + int GetSecondaryButtonViewId() override {
|
| + return static_cast<int>(DialogViewID::PAYMENT_METHOD_ADD_CONTACT_BUTTON);
|
| + }
|
| +
|
| + void OnSecondaryButtonPressed() override {
|
| + // TODO(crbug.com/704263): Add Contact Editor.
|
| + }
|
| +
|
| private:
|
| DISALLOW_COPY_AND_ASSIGN(ContactProfileViewController);
|
| };
|
| @@ -193,4 +244,28 @@ std::unique_ptr<views::View> ProfileListViewController::CreateView() {
|
| list_.CreateListView());
|
| }
|
|
|
| +std::unique_ptr<views::View>
|
| +ProfileListViewController::CreateExtraFooterView() {
|
| + std::unique_ptr<views::View> extra_view = base::MakeUnique<views::View>();
|
| +
|
| + extra_view->SetLayoutManager(new views::BoxLayout(
|
| + views::BoxLayout::kHorizontal, 0, 0, kPaymentRequestButtonSpacing));
|
| +
|
| + views::LabelButton* button = views::MdTextButton::CreateSecondaryUiButton(
|
| + this, l10n_util::GetStringUTF16(GetSecondaryButtonTextId()));
|
| + button->set_tag(GetSecondaryButtonTag());
|
| + button->set_id(GetSecondaryButtonViewId());
|
| + extra_view->AddChildView(button);
|
| +
|
| + return extra_view;
|
| +}
|
| +
|
| +void ProfileListViewController::ButtonPressed(views::Button* sender,
|
| + const ui::Event& event) {
|
| + if (sender->tag() == GetSecondaryButtonTag())
|
| + OnSecondaryButtonPressed();
|
| + else
|
| + PaymentRequestSheetController::ButtonPressed(sender, event);
|
| +}
|
| +
|
| } // namespace payments
|
|
|