| 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_profile.h" | 14 #include "components/autofill/core/browser/autofill_profile.h" |
| 14 #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" |
| 15 #include "components/autofill/core/browser/field_types.h" | 17 #include "components/autofill/core/browser/field_types.h" |
| 16 #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" |
| 17 #include "ui/gfx/canvas.h" | 20 #include "ui/gfx/canvas.h" |
| 18 #include "ui/gfx/geometry/insets.h" | 21 #include "ui/gfx/geometry/insets.h" |
| 19 #include "ui/gfx/geometry/point_f.h" | 22 #include "ui/gfx/geometry/point_f.h" |
| 20 #include "ui/gfx/paint_vector_icon.h" | 23 #include "ui/gfx/paint_vector_icon.h" |
| 21 #include "ui/vector_icons/vector_icons.h" | 24 #include "ui/vector_icons/vector_icons.h" |
| 22 #include "ui/views/border.h" | 25 #include "ui/views/border.h" |
| 23 #include "ui/views/bubble/bubble_frame_view.h" | 26 #include "ui/views/bubble/bubble_frame_view.h" |
| 24 #include "ui/views/controls/button/button.h" | 27 #include "ui/views/controls/button/button.h" |
| 25 #include "ui/views/controls/button/vector_icon_button.h" | 28 #include "ui/views/controls/button/vector_icon_button.h" |
| 29 #include "ui/views/controls/image_view.h" |
| 26 #include "ui/views/controls/label.h" | 30 #include "ui/views/controls/label.h" |
| 27 #include "ui/views/controls/styled_label.h" | 31 #include "ui/views/controls/styled_label.h" |
| 28 #include "ui/views/layout/grid_layout.h" | 32 #include "ui/views/layout/grid_layout.h" |
| 29 #include "ui/views/painter.h" | 33 #include "ui/views/painter.h" |
| 30 #include "ui/views/view.h" | 34 #include "ui/views/view.h" |
| 31 | 35 |
| 32 namespace { | 36 namespace { |
| 33 | 37 |
| 34 // TODO(tmartino): Consider combining this with the Android equivalent in | 38 // TODO(tmartino): Consider combining this with the Android equivalent in |
| 35 // PersonalDataManager.java | 39 // PersonalDataManager.java |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 layout->AddView(back_arrow); | 111 layout->AddView(back_arrow); |
| 108 } | 112 } |
| 109 | 113 |
| 110 views::Label* title_label = new views::Label(title); | 114 views::Label* title_label = new views::Label(title); |
| 111 title_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 115 title_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 112 layout->AddView(title_label); | 116 layout->AddView(title_label); |
| 113 | 117 |
| 114 return container; | 118 return container; |
| 115 } | 119 } |
| 116 | 120 |
| 121 std::unique_ptr<views::ImageView> CreateCardIconView( |
| 122 const std::string& card_type) { |
| 123 std::unique_ptr<views::ImageView> card_icon_view = |
| 124 base::MakeUnique<views::ImageView>(); |
| 125 card_icon_view->set_interactive(false); |
| 126 card_icon_view->SetImage( |
| 127 ResourceBundle::GetSharedInstance() |
| 128 .GetImageNamed(autofill::data_util::GetPaymentRequestData(card_type) |
| 129 .icon_resource_id) |
| 130 .AsImageSkia()); |
| 131 card_icon_view->SetTooltipText( |
| 132 autofill::CreditCard::TypeForDisplay(card_type)); |
| 133 card_icon_view->SetBorder(views::CreateRoundedRectBorder( |
| 134 1, 3, card_icon_view->GetNativeTheme()->GetSystemColor( |
| 135 ui::NativeTheme::kColorId_UnfocusedBorderColor))); |
| 136 return card_icon_view; |
| 137 } |
| 138 |
| 117 std::unique_ptr<views::View> GetShippingAddressLabel( | 139 std::unique_ptr<views::View> GetShippingAddressLabel( |
| 118 AddressStyleType type, | 140 AddressStyleType type, |
| 119 const std::string& locale, | 141 const std::string& locale, |
| 120 const autofill::AutofillProfile& profile) { | 142 const autofill::AutofillProfile& profile) { |
| 121 base::string16 name_value = | 143 base::string16 name_value = |
| 122 profile.GetInfo(autofill::AutofillType(autofill::NAME_FULL), locale); | 144 profile.GetInfo(autofill::AutofillType(autofill::NAME_FULL), locale); |
| 123 | 145 |
| 124 // TODO(tmartino): Add bold styling for name in DETAILED style. | 146 // TODO(tmartino): Add bold styling for name in DETAILED style. |
| 125 | 147 |
| 126 base::string16 address_value = GetAddressFromProfile(profile, locale); | 148 base::string16 address_value = GetAddressFromProfile(profile, locale); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 | 204 |
| 183 // Creates a views::Border object that can paint the gray horizontal ruler used | 205 // Creates a views::Border object that can paint the gray horizontal ruler used |
| 184 // as a separator between items in the Payment Request dialog. | 206 // as a separator between items in the Payment Request dialog. |
| 185 std::unique_ptr<views::Border> CreatePaymentRequestRowBorder() { | 207 std::unique_ptr<views::Border> CreatePaymentRequestRowBorder() { |
| 186 return views::CreateBorderPainter( | 208 return views::CreateBorderPainter( |
| 187 base::MakeUnique<PaymentRequestRowBorderPainter>(), | 209 base::MakeUnique<PaymentRequestRowBorderPainter>(), |
| 188 gfx::Insets()); | 210 gfx::Insets()); |
| 189 } | 211 } |
| 190 | 212 |
| 191 } // namespace payments | 213 } // namespace payments |
| OLD | NEW |