Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3507)

Unified Diff: chrome/browser/ui/views/payments/payment_request_views_util.cc

Issue 2592833002: [WebPayments] Start populating the Payment Sheet. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/views/payments/payment_request_views_util.cc
diff --git a/chrome/browser/ui/views/payments/payment_request_views_util.cc b/chrome/browser/ui/views/payments/payment_request_views_util.cc
index f5fb1130312c7506e5644db9329b8e67c4cdabef..8ef2a98048349df045232ed328c6f9bb4c198a8b 100644
--- a/chrome/browser/ui/views/payments/payment_request_views_util.cc
+++ b/chrome/browser/ui/views/payments/payment_request_views_util.cc
@@ -5,16 +5,72 @@
#include "chrome/browser/ui/views/payments/payment_request_views_util.h"
#include "base/memory/ptr_util.h"
+#include "chrome/browser/ui/views/payments/payment_request_sheet_controller.h"
#include "third_party/skia/include/core/SkColor.h"
+#include "ui/gfx/vector_icons/vector_icons.h"
#include "ui/views/background.h"
+#include "ui/views/bubble/bubble_frame_view.h"
+#include "ui/views/controls/button/button.h"
+#include "ui/views/controls/button/vector_icon_button.h"
#include "ui/views/controls/label.h"
#include "ui/views/layout/grid_layout.h"
#include "ui/views/view.h"
+namespace {
please use gerrit instead 2017/01/04 15:55:27 Here and elsewhere: nit: Anonymous namespace usua
anthonyvd 2017/01/04 19:08:55 Wow I've been doing the opposite for 2 years. It l
please use gerrit instead 2017/01/04 19:17:11 Thank you. As long as we're consistent, I'm OK wit
+
+constexpr int kTopInsetSize = 9;
+constexpr int kBottomInsetSize = 18;
+constexpr int kSideInsetSize = 14;
please use gerrit instead 2017/01/04 15:55:27 Here and elsewhere: It's easier to read the code
anthonyvd 2017/01/04 19:08:55 Done.
+
+} // namespace
+
namespace payments {
+std::unique_ptr<views::View> CreateSheetHeaderView(
+ bool show_back_arrow,
+ const base::string16& title,
+ views::VectorIconButtonDelegate* delegate) {
+ std::unique_ptr<views::View> container = base::MakeUnique<views::View>();
+ views::GridLayout* layout = new views::GridLayout(container.get());
+ container->SetLayoutManager(layout);
+
+ views::ColumnSet* columns = layout->AddColumnSet(0);
+ // A column for the optional back arrow.
+ columns->AddColumn(views::GridLayout::LEADING, views::GridLayout::CENTER,
+ 0, views::GridLayout::USE_PREF, 0, 0);
+ // A column for the title.
+ columns->AddColumn(views::GridLayout::FILL, views::GridLayout::CENTER,
+ 1, views::GridLayout::USE_PREF, 0, 0);
+ // A column for the close button.
+ columns->AddColumn(views::GridLayout::TRAILING, views::GridLayout::CENTER,
+ 0, views::GridLayout::USE_PREF, 0, 0);
+
+ layout->StartRow(0, 0);
+ if (!show_back_arrow) {
+ layout->SkipColumns(1);
+ } else {
+ views::VectorIconButton* back_arrow = new views::VectorIconButton(delegate);
+ back_arrow->SetIcon(gfx::VectorIconId::NAVIGATE_BACK);
+ back_arrow->SetSize(back_arrow->GetPreferredSize());
+ back_arrow->set_tag(BACK_BUTTON_TAG);
+ layout->AddView(back_arrow);
+ }
+
+ views::Label* title_label = new views::Label(title);
+ title_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
+ layout->AddView(title_label);
+ views::Button* close_button =
+ views::BubbleFrameView::CreateCloseButton(delegate);
+ close_button->set_tag(CLOSE_BUTTON_TAG);
+ layout->AddView(close_button);
+
+ return container;
+}
+
+
std::unique_ptr<views::View> CreatePaymentView(
- const base::string16& title, std::unique_ptr<views::View> content_view) {
+ std::unique_ptr<views::View> header_view,
+ std::unique_ptr<views::View> content_view) {
std::unique_ptr<views::View> view = base::MakeUnique<views::View>();
view->set_background(views::Background::CreateSolidBackground(SK_ColorWHITE));
@@ -24,12 +80,15 @@ std::unique_ptr<views::View> CreatePaymentView(
views::GridLayout* layout = new views::GridLayout(view.get());
view->SetLayoutManager(layout);
+ layout->SetInsets(
+ kTopInsetSize, kSideInsetSize, kBottomInsetSize, kSideInsetSize);
views::ColumnSet* columns = layout->AddColumnSet(0);
columns->AddColumn(views::GridLayout::FILL, views::GridLayout::CENTER,
1, views::GridLayout::USE_PREF, 0, 0);
layout->StartRow(0, 0);
- layout->AddView(new views::Label(title));
+ // |header_view| will be deleted when |view| is.
+ layout->AddView(header_view.release());
layout->StartRow(0, 0);
// |content_view| will be deleted when |view| is.

Powered by Google App Engine
This is Rietveld 408576698