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

Side by Side Diff: chrome/browser/ui/views/payments/payment_request_views_util.cc

Issue 2668063003: [Web Payments] Add Cancel button to all sheets (Closed)
Patch Set: Rebase Created 3 years, 10 months 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/payment_request_views_util.h" 5 #include "chrome/browser/ui/views/payments/payment_request_views_util.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "chrome/app/vector_icons/vector_icons.h" 12 #include "chrome/app/vector_icons/vector_icons.h"
13 #include "chrome/browser/ui/views/payments/payment_request_sheet_controller.h" 13 #include "chrome/browser/ui/views/payments/payment_request_sheet_controller.h"
14 #include "components/autofill/core/browser/autofill_profile.h" 14 #include "components/autofill/core/browser/autofill_profile.h"
15 #include "components/autofill/core/browser/autofill_type.h" 15 #include "components/autofill/core/browser/autofill_type.h"
16 #include "components/autofill/core/browser/field_types.h" 16 #include "components/autofill/core/browser/field_types.h"
17 #include "third_party/skia/include/core/SkColor.h" 17 #include "third_party/skia/include/core/SkColor.h"
18 #include "ui/gfx/canvas.h" 18 #include "ui/gfx/canvas.h"
19 #include "ui/gfx/geometry/insets.h" 19 #include "ui/gfx/geometry/insets.h"
20 #include "ui/gfx/geometry/point_f.h" 20 #include "ui/gfx/geometry/point_f.h"
21 #include "ui/gfx/paint_vector_icon.h" 21 #include "ui/gfx/paint_vector_icon.h"
22 #include "ui/views/background.h"
23 #include "ui/views/border.h" 22 #include "ui/views/border.h"
24 #include "ui/views/bubble/bubble_frame_view.h" 23 #include "ui/views/bubble/bubble_frame_view.h"
25 #include "ui/views/controls/button/button.h" 24 #include "ui/views/controls/button/button.h"
26 #include "ui/views/controls/button/vector_icon_button.h" 25 #include "ui/views/controls/button/vector_icon_button.h"
27 #include "ui/views/controls/label.h" 26 #include "ui/views/controls/label.h"
28 #include "ui/views/controls/styled_label.h" 27 #include "ui/views/controls/styled_label.h"
29 #include "ui/views/layout/grid_layout.h" 28 #include "ui/views/layout/grid_layout.h"
30 #include "ui/views/painter.h" 29 #include "ui/views/painter.h"
31 #include "ui/views/view.h" 30 #include "ui/views/view.h"
32 31
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 layout->AddView(back_arrow); 107 layout->AddView(back_arrow);
109 } 108 }
110 109
111 views::Label* title_label = new views::Label(title); 110 views::Label* title_label = new views::Label(title);
112 title_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); 111 title_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
113 layout->AddView(title_label); 112 layout->AddView(title_label);
114 113
115 return container; 114 return container;
116 } 115 }
117 116
118
119 std::unique_ptr<views::View> CreatePaymentView(
120 std::unique_ptr<views::View> header_view,
121 std::unique_ptr<views::View> content_view) {
122 std::unique_ptr<views::View> view = base::MakeUnique<views::View>();
123 view->set_background(views::Background::CreateSolidBackground(SK_ColorWHITE));
124
125 // Paint the sheets to layers, otherwise the MD buttons (which do paint to a
126 // layer) won't do proper clipping.
127 view->SetPaintToLayer();
128
129 views::GridLayout* layout = new views::GridLayout(view.get());
130 view->SetLayoutManager(layout);
131
132 constexpr int kTopInsetSize = 9;
133 constexpr int kBottomInsetSize = 18;
134 layout->SetInsets(kTopInsetSize, 0, kBottomInsetSize, 0);
135 views::ColumnSet* columns = layout->AddColumnSet(0);
136 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::CENTER,
137 1, views::GridLayout::USE_PREF, 0, 0);
138
139 layout->StartRow(0, 0);
140 // |header_view| will be deleted when |view| is.
141 layout->AddView(header_view.release());
142
143 layout->StartRow(0, 0);
144 // |content_view| will be deleted when |view| is.
145 layout->AddView(content_view.release());
146
147 return view;
148 }
149
150 std::unique_ptr<views::View> GetShippingAddressLabel( 117 std::unique_ptr<views::View> GetShippingAddressLabel(
151 AddressStyleType type, 118 AddressStyleType type,
152 const std::string& locale, 119 const std::string& locale,
153 const autofill::AutofillProfile& profile) { 120 const autofill::AutofillProfile& profile) {
154 base::string16 name_value = 121 base::string16 name_value =
155 profile.GetInfo(autofill::AutofillType(autofill::NAME_FULL), locale); 122 profile.GetInfo(autofill::AutofillType(autofill::NAME_FULL), locale);
156 123
157 // TODO(tmartino): Add bold styling for name in DETAILED style. 124 // TODO(tmartino): Add bold styling for name in DETAILED style.
158 125
159 base::string16 address_value = GetAddressFromProfile(profile, locale); 126 base::string16 address_value = GetAddressFromProfile(profile, locale);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 182
216 // Creates a views::Border object that can paint the gray horizontal ruler used 183 // Creates a views::Border object that can paint the gray horizontal ruler used
217 // as a separator between items in the Payment Request dialog. 184 // as a separator between items in the Payment Request dialog.
218 std::unique_ptr<views::Border> CreatePaymentRequestRowBorder() { 185 std::unique_ptr<views::Border> CreatePaymentRequestRowBorder() {
219 return views::CreateBorderPainter( 186 return views::CreateBorderPainter(
220 base::MakeUnique<PaymentRequestRowBorderPainter>(), 187 base::MakeUnique<PaymentRequestRowBorderPainter>(),
221 gfx::Insets()); 188 gfx::Insets());
222 } 189 }
223 190
224 } // namespace payments 191 } // namespace payments
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698