Chromium Code Reviews| Index: chrome/browser/ui/views/payments/payment_request_views_util.cc |
| diff --git a/chrome/browser/ui/views/payments/payment_request_views_util.cc b/chrome/browser/ui/views/payments/payment_request_views_util.cc |
| index 46505589095ad8802f1ddb509c8430a4b11a671b..933443ef6c5795966077cd0944a3963515230dab 100644 |
| --- a/chrome/browser/ui/views/payments/payment_request_views_util.cc |
| +++ b/chrome/browser/ui/views/payments/payment_request_views_util.cc |
| @@ -18,6 +18,7 @@ |
| #include "third_party/skia/include/core/SkColor.h" |
| #include "ui/base/resource/resource_bundle.h" |
| #include "ui/gfx/canvas.h" |
| +#include "ui/gfx/font_list.h" |
| #include "ui/gfx/geometry/insets.h" |
| #include "ui/gfx/geometry/point_f.h" |
| #include "ui/gfx/paint_vector_icon.h" |
| @@ -29,6 +30,7 @@ |
| #include "ui/views/controls/image_view.h" |
| #include "ui/views/controls/label.h" |
| #include "ui/views/controls/styled_label.h" |
| +#include "ui/views/layout/box_layout.h" |
| #include "ui/views/layout/grid_layout.h" |
| #include "ui/views/painter.h" |
| #include "ui/views/view.h" |
| @@ -182,37 +184,59 @@ std::unique_ptr<views::View> GetContactInfoLabel( |
| bool show_payer_name, |
| bool show_payer_email, |
| bool show_payer_phone) { |
| - base::string16 name_value; |
| - base::string16 phone_value; |
| - base::string16 email_value; |
| + std::unique_ptr<views::View> container = base::MakeUnique<views::View>(); |
| + container->SetLayoutManager( |
| + new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); |
| + |
| + constexpr int kMissingName = 1; |
| + constexpr int kMissingPhone = 1 << 1; |
| + constexpr int kMissingEmail = 1 << 2; |
| + int missing_fields = 0; |
|
Mathieu
2017/02/28 17:36:00
unused?
anthonyvd
2017/02/28 18:36:27
Not used yet, added a TODO about that below.
Mathieu
2017/02/28 21:15:16
nit: I would remove |missing_fields| if it's not u
anthonyvd
2017/03/01 15:27:55
Fair point, done.
|
| if (show_payer_name) { |
| - name_value = |
| + base::string16 name = |
| profile.GetInfo(autofill::AutofillType(autofill::NAME_FULL), locale); |
| - |
| - // TODO(tmartino): Add bold styling for name in DETAILED style. |
| + if (!name.empty()) { |
| + std::unique_ptr<views::Label> label = |
| + base::MakeUnique<views::Label>(name); |
| + label->SetHorizontalAlignment(gfx::HorizontalAlignment::ALIGN_LEFT); |
| + if (type == AddressStyleType::DETAILED) { |
| + const gfx::FontList& font_list = label->font_list(); |
| + label->SetFontList(font_list.DeriveWithWeight(gfx::Font::Weight::BOLD)); |
| + } |
| + container->AddChildView(label.release()); |
| + } else { |
| + missing_fields |= kMissingName; |
| + } |
| } |
| if (show_payer_phone) { |
| - phone_value = profile.GetInfo( |
| + base::string16 phone = profile.GetInfo( |
| autofill::AutofillType(autofill::PHONE_HOME_WHOLE_NUMBER), locale); |
| + if (!phone.empty()) { |
| + std::unique_ptr<views::Label> label = |
| + base::MakeUnique<views::Label>(phone); |
| + label->SetHorizontalAlignment(gfx::HorizontalAlignment::ALIGN_LEFT); |
|
Mathieu
2017/02/28 17:35:59
appears to be the default?
anthonyvd
2017/02/28 18:36:27
The BoxLayout was changing it. I added a call to B
|
| + container->AddChildView(label.release()); |
| + } else { |
| + missing_fields |= kMissingPhone; |
| + } |
| } |
| if (show_payer_email) { |
| - email_value = profile.GetInfo( |
| + base::string16 email = profile.GetInfo( |
| autofill::AutofillType(autofill::EMAIL_ADDRESS), locale); |
| + if (!email.empty()) { |
| + std::unique_ptr<views::Label> label = |
| + base::MakeUnique<views::Label>(email); |
| + label->SetHorizontalAlignment(gfx::HorizontalAlignment::ALIGN_LEFT); |
| + container->AddChildView(label.release()); |
| + } else { |
| + missing_fields |= kMissingEmail; |
| + } |
| } |
| - std::vector<base::string16> values; |
| - if (!name_value.empty()) |
| - values.push_back(name_value); |
| - if (!phone_value.empty()) |
| - values.push_back(phone_value); |
| - if (!email_value.empty()) |
| - values.push_back(email_value); |
| - |
| - return base::MakeUnique<views::StyledLabel>( |
| - base::JoinString(values, base::ASCIIToUTF16("\n")), nullptr); |
| + return container; |
| } |
| // Creates a views::Border object that can paint the gray horizontal ruler used |