Chromium Code Reviews| 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/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_data_util.h" | |
| 14 #include "components/autofill/core/browser/autofill_profile.h" | 15 #include "components/autofill/core/browser/autofill_profile.h" |
| 15 #include "components/autofill/core/browser/autofill_type.h" | 16 #include "components/autofill/core/browser/autofill_type.h" |
| 17 #include "components/autofill/core/browser/credit_card.h" | |
| 16 #include "components/autofill/core/browser/field_types.h" | 18 #include "components/autofill/core/browser/field_types.h" |
| 17 #include "third_party/skia/include/core/SkColor.h" | 19 #include "third_party/skia/include/core/SkColor.h" |
| 20 #include "ui/base/resource/resource_bundle.h" | |
| 18 #include "ui/gfx/canvas.h" | 21 #include "ui/gfx/canvas.h" |
| 19 #include "ui/gfx/geometry/insets.h" | 22 #include "ui/gfx/geometry/insets.h" |
| 20 #include "ui/gfx/geometry/point_f.h" | 23 #include "ui/gfx/geometry/point_f.h" |
| 21 #include "ui/gfx/paint_vector_icon.h" | 24 #include "ui/gfx/paint_vector_icon.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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 181 } | 185 } |
| 182 | 186 |
| 183 // Creates a views::Border object that can paint the gray horizontal ruler used | 187 // Creates a views::Border object that can paint the gray horizontal ruler used |
| 184 // as a separator between items in the Payment Request dialog. | 188 // as a separator between items in the Payment Request dialog. |
| 185 std::unique_ptr<views::Border> CreatePaymentRequestRowBorder() { | 189 std::unique_ptr<views::Border> CreatePaymentRequestRowBorder() { |
| 186 return views::CreateBorderPainter( | 190 return views::CreateBorderPainter( |
| 187 base::MakeUnique<PaymentRequestRowBorderPainter>(), | 191 base::MakeUnique<PaymentRequestRowBorderPainter>(), |
| 188 gfx::Insets()); | 192 gfx::Insets()); |
| 189 } | 193 } |
| 190 | 194 |
| 195 std::unique_ptr<views::View> CreateCreditCardIconView( | |
| 196 autofill::CreditCard* card) { | |
|
please use gerrit instead
2017/02/14 00:29:14
Since only card->type() is used, I'd prefer a tigh
anthonyvd
2017/02/22 20:15:21
Agreed. Turns out this was implemented while I was
| |
| 197 std::unique_ptr<views::ImageView> card_icon_view = | |
| 198 base::MakeUnique<views::ImageView>(); | |
| 199 card_icon_view->set_interactive(false); | |
| 200 card_icon_view->SetImage( | |
| 201 ResourceBundle::GetSharedInstance() | |
| 202 .GetImageNamed(autofill::data_util::GetPaymentRequestData( | |
| 203 card->type()).icon_resource_id) | |
| 204 .AsImageSkia()); | |
| 205 card_icon_view->SetBorder( | |
| 206 views::CreateRoundedRectBorder(1, 3, SK_ColorLTGRAY)); | |
| 207 | |
| 208 constexpr gfx::Size kCardIconSize = gfx::Size(32, 20); | |
| 209 card_icon_view->SetImageSize(kCardIconSize); | |
| 210 | |
| 211 return card_icon_view; | |
| 212 } | |
| 213 | |
| 191 } // namespace payments | 214 } // namespace payments |
| OLD | NEW |