| OLD | NEW |
| 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/browser/ui/views/payments/payment_request_sheet_controller.h" | 12 #include "chrome/browser/ui/views/payments/payment_request_sheet_controller.h" |
| 13 #include "components/autofill/core/browser/autofill_data_util.h" | 13 #include "components/autofill/core/browser/autofill_data_util.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/credit_card.h" | 16 #include "components/autofill/core/browser/credit_card.h" |
| 17 #include "components/autofill/core/browser/field_types.h" | 17 #include "components/autofill/core/browser/field_types.h" |
| 18 #include "third_party/skia/include/core/SkColor.h" | 18 #include "third_party/skia/include/core/SkColor.h" |
| 19 #include "ui/base/resource/resource_bundle.h" | 19 #include "ui/base/resource/resource_bundle.h" |
| 20 #include "ui/gfx/canvas.h" | 20 #include "ui/gfx/canvas.h" |
| 21 #include "ui/gfx/font_list.h" | 21 #include "ui/gfx/font_list.h" |
| 22 #include "ui/gfx/geometry/insets.h" | 22 #include "ui/gfx/geometry/insets.h" |
| 23 #include "ui/gfx/geometry/point_f.h" | 23 #include "ui/gfx/geometry/point_f.h" |
| 24 #include "ui/gfx/paint_vector_icon.h" | 24 #include "ui/gfx/paint_vector_icon.h" |
| 25 #include "ui/vector_icons/vector_icons.h" | 25 #include "ui/vector_icons/vector_icons.h" |
| 26 #include "ui/views/border.h" | 26 #include "ui/views/border.h" |
| 27 #include "ui/views/bubble/bubble_frame_view.h" | 27 #include "ui/views/bubble/bubble_frame_view.h" |
| 28 #include "ui/views/controls/button/button.h" | 28 #include "ui/views/controls/button/image_button.h" |
| 29 #include "ui/views/controls/button/vector_icon_button.h" | |
| 30 #include "ui/views/controls/image_view.h" | 29 #include "ui/views/controls/image_view.h" |
| 31 #include "ui/views/controls/label.h" | 30 #include "ui/views/controls/label.h" |
| 32 #include "ui/views/controls/styled_label.h" | 31 #include "ui/views/controls/styled_label.h" |
| 33 #include "ui/views/layout/box_layout.h" | 32 #include "ui/views/layout/box_layout.h" |
| 34 #include "ui/views/layout/grid_layout.h" | 33 #include "ui/views/layout/grid_layout.h" |
| 35 #include "ui/views/painter.h" | 34 #include "ui/views/painter.h" |
| 36 #include "ui/views/view.h" | 35 #include "ui/views/view.h" |
| 37 | 36 |
| 38 namespace { | 37 namespace { |
| 39 | 38 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 DISALLOW_COPY_AND_ASSIGN(PaymentRequestRowBorderPainter); | 78 DISALLOW_COPY_AND_ASSIGN(PaymentRequestRowBorderPainter); |
| 80 }; | 79 }; |
| 81 | 80 |
| 82 } // namespace | 81 } // namespace |
| 83 | 82 |
| 84 namespace payments { | 83 namespace payments { |
| 85 | 84 |
| 86 std::unique_ptr<views::View> CreateSheetHeaderView( | 85 std::unique_ptr<views::View> CreateSheetHeaderView( |
| 87 bool show_back_arrow, | 86 bool show_back_arrow, |
| 88 const base::string16& title, | 87 const base::string16& title, |
| 89 views::VectorIconButtonDelegate* delegate) { | 88 views::ImageButtonDelegate* delegate) { |
| 90 std::unique_ptr<views::View> container = base::MakeUnique<views::View>(); | 89 std::unique_ptr<views::View> container = base::MakeUnique<views::View>(); |
| 91 views::GridLayout* layout = new views::GridLayout(container.get()); | 90 views::GridLayout* layout = new views::GridLayout(container.get()); |
| 92 container->SetLayoutManager(layout); | 91 container->SetLayoutManager(layout); |
| 93 | 92 |
| 94 constexpr int kHeaderTopVerticalInset = 14; | 93 constexpr int kHeaderTopVerticalInset = 14; |
| 95 constexpr int kHeaderBottomVerticalInset = 8; | 94 constexpr int kHeaderBottomVerticalInset = 8; |
| 96 constexpr int kHeaderHorizontalInset = 16; | 95 constexpr int kHeaderHorizontalInset = 16; |
| 97 // Top, left, bottom, right. | 96 // Top, left, bottom, right. |
| 98 layout->SetInsets(kHeaderTopVerticalInset, kHeaderHorizontalInset, | 97 layout->SetInsets(kHeaderTopVerticalInset, kHeaderHorizontalInset, |
| 99 kHeaderBottomVerticalInset, kHeaderHorizontalInset); | 98 kHeaderBottomVerticalInset, kHeaderHorizontalInset); |
| 100 | 99 |
| 101 views::ColumnSet* columns = layout->AddColumnSet(0); | 100 views::ColumnSet* columns = layout->AddColumnSet(0); |
| 102 // A column for the optional back arrow. | 101 // A column for the optional back arrow. |
| 103 columns->AddColumn(views::GridLayout::LEADING, views::GridLayout::CENTER, | 102 columns->AddColumn(views::GridLayout::LEADING, views::GridLayout::CENTER, |
| 104 0, views::GridLayout::USE_PREF, 0, 0); | 103 0, views::GridLayout::USE_PREF, 0, 0); |
| 105 | 104 |
| 106 constexpr int kPaddingBetweenArrowAndTitle = 16; | 105 constexpr int kPaddingBetweenArrowAndTitle = 16; |
| 107 if (show_back_arrow) | 106 if (show_back_arrow) |
| 108 columns->AddPaddingColumn(0, kPaddingBetweenArrowAndTitle); | 107 columns->AddPaddingColumn(0, kPaddingBetweenArrowAndTitle); |
| 109 | 108 |
| 110 // A column for the title. | 109 // A column for the title. |
| 111 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::CENTER, | 110 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::CENTER, |
| 112 1, views::GridLayout::USE_PREF, 0, 0); | 111 1, views::GridLayout::USE_PREF, 0, 0); |
| 113 | 112 |
| 114 layout->StartRow(0, 0); | 113 layout->StartRow(0, 0); |
| 115 if (!show_back_arrow) { | 114 if (!show_back_arrow) { |
| 116 layout->SkipColumns(1); | 115 layout->SkipColumns(1); |
| 117 } else { | 116 } else { |
| 118 views::VectorIconButton* back_arrow = new views::VectorIconButton(delegate); | 117 views::ImageButton* back_arrow = |
| 119 back_arrow->SetIcon(ui::kBackArrowIcon); | 118 views::ImageButton::CreateDefaultVectorIconButton(ui::kBackArrowIcon, |
| 119 delegate); |
| 120 constexpr int kBackArrowSize = 16; | 120 constexpr int kBackArrowSize = 16; |
| 121 back_arrow->SetSize(gfx::Size(kBackArrowSize, kBackArrowSize)); | 121 back_arrow->SetSize(gfx::Size(kBackArrowSize, kBackArrowSize)); |
| 122 back_arrow->set_tag(static_cast<int>( | 122 back_arrow->set_tag(static_cast<int>( |
| 123 PaymentRequestCommonTags::BACK_BUTTON_TAG)); | 123 PaymentRequestCommonTags::BACK_BUTTON_TAG)); |
| 124 layout->AddView(back_arrow); | 124 layout->AddView(back_arrow); |
| 125 } | 125 } |
| 126 | 126 |
| 127 views::Label* title_label = new views::Label(title); | 127 views::Label* title_label = new views::Label(title); |
| 128 title_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 128 title_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 129 title_label->SetFontList( | 129 title_label->SetFontList( |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 std::unique_ptr<views::Label> CreateBoldLabel(const base::string16& text) { | 240 std::unique_ptr<views::Label> CreateBoldLabel(const base::string16& text) { |
| 241 std::unique_ptr<views::Label> label = base::MakeUnique<views::Label>(text); | 241 std::unique_ptr<views::Label> label = base::MakeUnique<views::Label>(text); |
| 242 | 242 |
| 243 label->SetFontList( | 243 label->SetFontList( |
| 244 label->font_list().DeriveWithWeight(gfx::Font::Weight::BOLD)); | 244 label->font_list().DeriveWithWeight(gfx::Font::Weight::BOLD)); |
| 245 | 245 |
| 246 return label; | 246 return label; |
| 247 } | 247 } |
| 248 | 248 |
| 249 } // namespace payments | 249 } // namespace payments |
| OLD | NEW |