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

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: addressed comments 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 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 1, views::GridLayout::USE_PREF, 0, 0); 317 1, views::GridLayout::USE_PREF, 0, 0);
320 318
321 layout->StartRow(0, 0); 319 layout->StartRow(0, 0);
322 layout->AddView(new views::Label(selected_card->TypeAndLastFourDigits())); 320 layout->AddView(new views::Label(selected_card->TypeAndLastFourDigits()));
323 layout->StartRow(0, 0); 321 layout->StartRow(0, 0);
324 layout->AddView(new views::Label( 322 layout->AddView(new views::Label(
325 selected_card->GetInfo( 323 selected_card->GetInfo(
326 autofill::AutofillType(autofill::CREDIT_CARD_NAME_FULL), 324 autofill::AutofillType(autofill::CREDIT_CARD_NAME_FULL),
327 g_browser_process->GetApplicationLocale()))); 325 g_browser_process->GetApplicationLocale())));
328 326
329 card_icon_view = base::MakeUnique<views::ImageView>(); 327 card_icon_view = CreateCardIconView(selected_card->type());
330 card_icon_view->set_interactive(false); 328 card_icon_view->SetImageSize(gfx::Size(32, 20));
331 card_icon_view->SetImage(
332 ResourceBundle::GetSharedInstance()
333 .GetImageNamed(autofill::data_util::GetPaymentRequestData(
334 selected_card->type()).icon_resource_id)
335 .AsImageSkia());
336 card_icon_view->SetBorder(
337 views::CreateRoundedRectBorder(1, 3, SK_ColorLTGRAY));
338
339 constexpr gfx::Size kCardIconSize = gfx::Size(32, 20);
340 card_icon_view->SetImageSize(kCardIconSize);
341 } 329 }
342 330
343 std::unique_ptr<views::Button> section = CreatePaymentSheetRow( 331 std::unique_ptr<views::Button> section = CreatePaymentSheetRow(
344 this, 332 this,
345 l10n_util::GetStringUTF16( 333 l10n_util::GetStringUTF16(
346 IDS_PAYMENT_REQUEST_PAYMENT_METHOD_SECTION_NAME), 334 IDS_PAYMENT_REQUEST_PAYMENT_METHOD_SECTION_NAME),
347 std::move(content_view), 335 std::move(content_view),
348 std::move(card_icon_view), 336 std::move(card_icon_view),
349 widest_name_column_view_width_); 337 widest_name_column_view_width_);
350 section->set_tag(static_cast<int>( 338 section->set_tag(static_cast<int>(
(...skipping 28 matching lines...) Expand all
379 CreateContactInfoSectionContent(), std::unique_ptr<views::View>(nullptr), 367 CreateContactInfoSectionContent(), std::unique_ptr<views::View>(nullptr),
380 widest_name_column_view_width_); 368 widest_name_column_view_width_);
381 section->set_tag(static_cast<int>( 369 section->set_tag(static_cast<int>(
382 PaymentSheetViewControllerTags::SHOW_CONTACT_INFO_BUTTON)); 370 PaymentSheetViewControllerTags::SHOW_CONTACT_INFO_BUTTON));
383 section->set_id( 371 section->set_id(
384 static_cast<int>(DialogViewID::PAYMENT_SHEET_CONTACT_INFO_SECTION)); 372 static_cast<int>(DialogViewID::PAYMENT_SHEET_CONTACT_INFO_SECTION));
385 return section; 373 return section;
386 } 374 }
387 375
388 } // namespace payments 376 } // namespace payments
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698