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

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

Issue 2698353002: [Payments] Add the "Cards accepted" row at the top of CC editor. (Closed)
Patch Set: private 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_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>
(...skipping 11 matching lines...) Expand all
22 #include "components/autofill/core/browser/autofill_data_util.h" 22 #include "components/autofill/core/browser/autofill_data_util.h"
23 #include "components/autofill/core/browser/autofill_type.h" 23 #include "components/autofill/core/browser/autofill_type.h"
24 #include "components/autofill/core/browser/credit_card.h" 24 #include "components/autofill/core/browser/credit_card.h"
25 #include "components/autofill/core/browser/field_types.h" 25 #include "components/autofill/core/browser/field_types.h"
26 #include "components/autofill/core/browser/personal_data_manager.h" 26 #include "components/autofill/core/browser/personal_data_manager.h"
27 #include "components/payments/currency_formatter.h" 27 #include "components/payments/currency_formatter.h"
28 #include "components/payments/payment_request.h" 28 #include "components/payments/payment_request.h"
29 #include "components/strings/grit/components_strings.h" 29 #include "components/strings/grit/components_strings.h"
30 #include "content/public/browser/web_contents.h" 30 #include "content/public/browser/web_contents.h"
31 #include "ui/base/l10n/l10n_util.h" 31 #include "ui/base/l10n/l10n_util.h"
32 #include "ui/base/resource/resource_bundle.h"
33 #include "ui/gfx/color_utils.h" 32 #include "ui/gfx/color_utils.h"
34 #include "ui/gfx/font.h" 33 #include "ui/gfx/font.h"
35 #include "ui/gfx/paint_vector_icon.h" 34 #include "ui/gfx/paint_vector_icon.h"
36 #include "ui/gfx/range/range.h" 35 #include "ui/gfx/range/range.h"
37 #include "ui/views/border.h"
38 #include "ui/views/controls/button/label_button.h" 36 #include "ui/views/controls/button/label_button.h"
39 #include "ui/views/controls/button/md_text_button.h" 37 #include "ui/views/controls/button/md_text_button.h"
40 #include "ui/views/controls/image_view.h" 38 #include "ui/views/controls/image_view.h"
41 #include "ui/views/controls/label.h" 39 #include "ui/views/controls/label.h"
42 #include "ui/views/controls/styled_label.h" 40 #include "ui/views/controls/styled_label.h"
43 #include "ui/views/layout/fill_layout.h" 41 #include "ui/views/layout/fill_layout.h"
44 #include "ui/views/layout/grid_layout.h" 42 #include "ui/views/layout/grid_layout.h"
45 #include "ui/views/vector_icons.h" 43 #include "ui/views/vector_icons.h"
46 #include "ui/views/view.h" 44 #include "ui/views/view.h"
47 45
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 1, views::GridLayout::USE_PREF, 0, 0); 316 1, views::GridLayout::USE_PREF, 0, 0);
319 317
320 layout->StartRow(0, 0); 318 layout->StartRow(0, 0);
321 layout->AddView(new views::Label(selected_card->TypeAndLastFourDigits())); 319 layout->AddView(new views::Label(selected_card->TypeAndLastFourDigits()));
322 layout->StartRow(0, 0); 320 layout->StartRow(0, 0);
323 layout->AddView(new views::Label( 321 layout->AddView(new views::Label(
324 selected_card->GetInfo( 322 selected_card->GetInfo(
325 autofill::AutofillType(autofill::CREDIT_CARD_NAME_FULL), 323 autofill::AutofillType(autofill::CREDIT_CARD_NAME_FULL),
326 g_browser_process->GetApplicationLocale()))); 324 g_browser_process->GetApplicationLocale())));
327 325
328 card_icon_view = base::MakeUnique<views::ImageView>(); 326 card_icon_view = CreateCardIconView(selected_card->type());
329 card_icon_view->set_interactive(false); 327 card_icon_view->SetImageSize(gfx::Size(32, 20));
330 card_icon_view->SetImage(
331 ResourceBundle::GetSharedInstance()
332 .GetImageNamed(autofill::data_util::GetPaymentRequestData(
333 selected_card->type()).icon_resource_id)
334 .AsImageSkia());
335 card_icon_view->SetBorder(
336 views::CreateRoundedRectBorder(1, 3, SK_ColorLTGRAY));
337
338 constexpr gfx::Size kCardIconSize = gfx::Size(32, 20);
339 card_icon_view->SetImageSize(kCardIconSize);
340 } 328 }
341 329
342 std::unique_ptr<views::Button> section = CreatePaymentSheetRow( 330 std::unique_ptr<views::Button> section = CreatePaymentSheetRow(
343 this, 331 this,
344 l10n_util::GetStringUTF16( 332 l10n_util::GetStringUTF16(
345 IDS_PAYMENT_REQUEST_PAYMENT_METHOD_SECTION_NAME), 333 IDS_PAYMENT_REQUEST_PAYMENT_METHOD_SECTION_NAME),
346 std::move(content_view), 334 std::move(content_view),
347 std::move(card_icon_view), 335 std::move(card_icon_view),
348 widest_name_column_view_width_); 336 widest_name_column_view_width_);
349 section->set_tag(static_cast<int>( 337 section->set_tag(static_cast<int>(
(...skipping 28 matching lines...) Expand all
378 CreateContactInfoSectionContent(), std::unique_ptr<views::View>(nullptr), 366 CreateContactInfoSectionContent(), std::unique_ptr<views::View>(nullptr),
379 widest_name_column_view_width_); 367 widest_name_column_view_width_);
380 section->set_tag(static_cast<int>( 368 section->set_tag(static_cast<int>(
381 PaymentSheetViewControllerTags::SHOW_CONTACT_INFO_BUTTON)); 369 PaymentSheetViewControllerTags::SHOW_CONTACT_INFO_BUTTON));
382 section->set_id( 370 section->set_id(
383 static_cast<int>(DialogViewID::PAYMENT_SHEET_CONTACT_INFO_SECTION)); 371 static_cast<int>(DialogViewID::PAYMENT_SHEET_CONTACT_INFO_SECTION));
384 return section; 372 return section;
385 } 373 }
386 374
387 } // namespace payments 375 } // namespace payments
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/payments/payment_request_views_util.cc ('k') | components/payments/payment_request.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698