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_sheet_view_controller.h" | 5 #include "chrome/browser/ui/views/payments/payment_sheet_view_controller.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <memory> | 8 #include <memory> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/memory/ptr_util.h" | 13 #include "base/memory/ptr_util.h" |
14 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
16 #include "chrome/browser/browser_process.h" | 16 #include "chrome/browser/browser_process.h" |
17 #include "chrome/browser/ui/views/payments/payment_request_dialog_view.h" | 17 #include "chrome/browser/ui/views/payments/payment_request_dialog_view.h" |
18 #include "chrome/browser/ui/views/payments/payment_request_dialog_view_ids.h" | 18 #include "chrome/browser/ui/views/payments/payment_request_dialog_view_ids.h" |
19 #include "chrome/browser/ui/views/payments/payment_request_row_view.h" | 19 #include "chrome/browser/ui/views/payments/payment_request_row_view.h" |
20 #include "chrome/browser/ui/views/payments/payment_request_views_util.h" | 20 #include "chrome/browser/ui/views/payments/payment_request_views_util.h" |
21 #include "chrome/grit/generated_resources.h" | 21 #include "chrome/grit/generated_resources.h" |
22 #include "components/autofill/core/browser/autofill_data_util.h" | |
23 #include "components/autofill/core/browser/autofill_type.h" | 22 #include "components/autofill/core/browser/autofill_type.h" |
24 #include "components/autofill/core/browser/credit_card.h" | 23 #include "components/autofill/core/browser/credit_card.h" |
25 #include "components/autofill/core/browser/field_types.h" | 24 #include "components/autofill/core/browser/field_types.h" |
26 #include "components/autofill/core/browser/personal_data_manager.h" | 25 #include "components/autofill/core/browser/personal_data_manager.h" |
27 #include "components/payments/currency_formatter.h" | 26 #include "components/payments/currency_formatter.h" |
28 #include "components/payments/payment_request.h" | 27 #include "components/payments/payment_request.h" |
29 #include "components/strings/grit/components_strings.h" | 28 #include "components/strings/grit/components_strings.h" |
30 #include "content/public/browser/web_contents.h" | 29 #include "content/public/browser/web_contents.h" |
31 #include "ui/base/l10n/l10n_util.h" | 30 #include "ui/base/l10n/l10n_util.h" |
32 #include "ui/gfx/color_utils.h" | 31 #include "ui/gfx/color_utils.h" |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 | 293 |
295 // Creates the Payment Method row, which contains a "Payment" label, the user's | 294 // Creates the Payment Method row, which contains a "Payment" label, the user's |
296 // masked Credit Card details, the icon for the selected card, and a chevron. | 295 // masked Credit Card details, the icon for the selected card, and a chevron. |
297 // +----------------------------------------------+ | 296 // +----------------------------------------------+ |
298 // | Payment Visa ****0000 | | 297 // | Payment Visa ****0000 | |
299 // | John Smith | VISA | > | | 298 // | John Smith | VISA | > | |
300 // | | | 299 // | | |
301 // +----------------------------------------------+ | 300 // +----------------------------------------------+ |
302 std::unique_ptr<views::Button> | 301 std::unique_ptr<views::Button> |
303 PaymentSheetViewController::CreatePaymentMethodRow() { | 302 PaymentSheetViewController::CreatePaymentMethodRow() { |
304 autofill::CreditCard* selected_card = | 303 autofill::CreditCard* selected_card = request()->selected_credit_card(); |
305 request()->GetCurrentlySelectedCreditCard(); | |
306 | 304 |
307 std::unique_ptr<views::View> content_view; | 305 std::unique_ptr<views::View> content_view; |
308 std::unique_ptr<views::ImageView> card_icon_view; | 306 std::unique_ptr<views::ImageView> card_icon_view; |
309 if (selected_card) { | 307 if (selected_card) { |
310 content_view = base::MakeUnique<views::View>(); | 308 content_view = base::MakeUnique<views::View>(); |
311 | 309 |
312 views::GridLayout* layout = new views::GridLayout(content_view.get()); | 310 views::GridLayout* layout = new views::GridLayout(content_view.get()); |
313 content_view->SetLayoutManager(layout); | 311 content_view->SetLayoutManager(layout); |
314 views::ColumnSet* columns = layout->AddColumnSet(0); | 312 views::ColumnSet* columns = layout->AddColumnSet(0); |
315 columns->AddColumn(views::GridLayout::LEADING, views::GridLayout::CENTER, | 313 columns->AddColumn(views::GridLayout::LEADING, views::GridLayout::CENTER, |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 CreateContactInfoSectionContent(), std::unique_ptr<views::View>(nullptr), | 364 CreateContactInfoSectionContent(), std::unique_ptr<views::View>(nullptr), |
367 widest_name_column_view_width_); | 365 widest_name_column_view_width_); |
368 section->set_tag(static_cast<int>( | 366 section->set_tag(static_cast<int>( |
369 PaymentSheetViewControllerTags::SHOW_CONTACT_INFO_BUTTON)); | 367 PaymentSheetViewControllerTags::SHOW_CONTACT_INFO_BUTTON)); |
370 section->set_id( | 368 section->set_id( |
371 static_cast<int>(DialogViewID::PAYMENT_SHEET_CONTACT_INFO_SECTION)); | 369 static_cast<int>(DialogViewID::PAYMENT_SHEET_CONTACT_INFO_SECTION)); |
372 return section; | 370 return section; |
373 } | 371 } |
374 | 372 |
375 } // namespace payments | 373 } // namespace payments |
OLD | NEW |