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 02d4b5cd0c973f43a0b6f41b00d44e0329e4eec8..6b2cad2481de308bfe620990167048421dd5c225 100644 |
--- a/chrome/browser/ui/views/payments/profile_list_view_controller.cc |
+++ b/chrome/browser/ui/views/payments/profile_list_view_controller.cc |
@@ -4,17 +4,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, |
+}; |
+ |
class ProfileItem : public PaymentRequestItemList::Item { |
public: |
// Constructs an object owned by |parent_list|, representing one element in |
@@ -89,6 +106,36 @@ class ShippingProfileViewController : public ProfileListViewController { |
} |
private: |
+ // PaymentRequestSheetController: |
+ std::unique_ptr<views::View> CreateExtraFooterView() override { |
anthonyvd
2017/03/21 21:18:24
This code could probably be in the base ProfileLis
MAD
2017/03/22 20:15:42
Done.
|
+ 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(IDS_AUTOFILL_ADD_ADDRESS_CAPTION)); |
+ button->set_tag(static_cast<int>( |
+ PaymentMethodViewControllerTags::ADD_SHIPPING_ADDRESS_BUTTON)); |
+ button->set_id( |
+ static_cast<int>(DialogViewID::PAYMENT_METHOD_ADD_CARD_BUTTON)); |
+ extra_view->AddChildView(button); |
+ |
+ return extra_view; |
+ } |
+ |
+ void ButtonPressed(views::Button* sender, const ui::Event& event) override { |
+ switch (sender->tag()) { |
+ case static_cast<int>( |
+ PaymentMethodViewControllerTags::ADD_SHIPPING_ADDRESS_BUTTON): |
+ dialog()->ShowShippingAddressEditor(); |
+ break; |
+ default: |
+ PaymentRequestSheetController::ButtonPressed(sender, event); |
+ break; |
+ } |
+ } |
+ |
DISALLOW_COPY_AND_ASSIGN(ShippingProfileViewController); |
}; |