| 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 6192515c801ea311145bb98e2eefdb74ce41f6ab..662fe9f01b9efb7816e0c9797b93f075e19bb30f 100644
|
| --- a/chrome/browser/ui/views/payments/payment_request_views_util.cc
|
| +++ b/chrome/browser/ui/views/payments/payment_request_views_util.cc
|
| @@ -4,18 +4,46 @@
|
|
|
| #include "chrome/browser/ui/views/payments/payment_request_views_util.h"
|
|
|
| +#include <vector>
|
| +
|
| #include "base/memory/ptr_util.h"
|
| +#include "base/strings/utf_string_conversions.h"
|
| #include "chrome/app/vector_icons/vector_icons.h"
|
| #include "chrome/browser/ui/views/payments/payment_request_sheet_controller.h"
|
| +#include "components/autofill/core/browser/autofill_profile.h"
|
| +#include "components/autofill/core/browser/autofill_type.h"
|
| +#include "components/autofill/core/browser/field_types.h"
|
| #include "third_party/skia/include/core/SkColor.h"
|
| #include "ui/views/background.h"
|
| #include "ui/views/bubble/bubble_frame_view.h"
|
| #include "ui/views/controls/button/button.h"
|
| #include "ui/views/controls/button/vector_icon_button.h"
|
| #include "ui/views/controls/label.h"
|
| +#include "ui/views/controls/styled_label.h"
|
| #include "ui/views/layout/grid_layout.h"
|
| #include "ui/views/view.h"
|
|
|
| +namespace {
|
| +
|
| +// TODO(tmartino): Consider combining this with the Android equivalent in
|
| +// PersonalDataManager.java
|
| +base::string16 GetAddressFromProfile(const autofill::AutofillProfile& profile,
|
| + const std::string& locale) {
|
| + std::vector<autofill::ServerFieldType> fields;
|
| + fields.push_back(autofill::COMPANY_NAME);
|
| + fields.push_back(autofill::ADDRESS_HOME_LINE1);
|
| + fields.push_back(autofill::ADDRESS_HOME_LINE2);
|
| + fields.push_back(autofill::ADDRESS_HOME_DEPENDENT_LOCALITY);
|
| + fields.push_back(autofill::ADDRESS_HOME_CITY);
|
| + fields.push_back(autofill::ADDRESS_HOME_STATE);
|
| + fields.push_back(autofill::ADDRESS_HOME_ZIP);
|
| + fields.push_back(autofill::ADDRESS_HOME_SORTING_CODE);
|
| +
|
| + return profile.ConstructInferredLabel(fields, fields.size(), locale);
|
| +}
|
| +
|
| +} // namespace
|
| +
|
| namespace payments {
|
|
|
| std::unique_ptr<views::View> CreateSheetHeaderView(
|
| @@ -87,4 +115,70 @@ std::unique_ptr<views::View> CreatePaymentView(
|
| return view;
|
| }
|
|
|
| +std::unique_ptr<views::View> GetShippingAddressLabel(
|
| + AddressStyleType type,
|
| + const std::string& locale,
|
| + const autofill::AutofillProfile& profile) {
|
| + base::string16 name_value =
|
| + profile.GetInfo(autofill::AutofillType(autofill::NAME_FULL), locale);
|
| +
|
| + // TODO(tmartino): Add bold styling for name in DETAILED style.
|
| +
|
| + base::string16 address_value = GetAddressFromProfile(profile, locale);
|
| +
|
| + base::string16 phone_value = profile.GetInfo(
|
| + autofill::AutofillType(autofill::PHONE_HOME_WHOLE_NUMBER), locale);
|
| +
|
| + std::vector<base::string16> values;
|
| + if (!name_value.empty())
|
| + values.push_back(name_value);
|
| + if (!address_value.empty())
|
| + values.push_back(address_value);
|
| + if (!phone_value.empty())
|
| + values.push_back(phone_value);
|
| +
|
| + return base::MakeUnique<views::StyledLabel>(
|
| + base::JoinString(values, base::ASCIIToUTF16("\n")), nullptr);
|
| +}
|
| +
|
| +std::unique_ptr<views::View> GetContactInfoLabel(
|
| + AddressStyleType type,
|
| + const std::string& locale,
|
| + const autofill::AutofillProfile& profile,
|
| + bool show_payer_name,
|
| + bool show_payer_email,
|
| + bool show_payer_phone) {
|
| + base::string16 name_value;
|
| + base::string16 phone_value;
|
| + base::string16 email_value;
|
| +
|
| + if (show_payer_name) {
|
| + name_value =
|
| + profile.GetInfo(autofill::AutofillType(autofill::NAME_FULL), locale);
|
| +
|
| + // TODO(tmartino): Add bold styling for name in DETAILED style.
|
| + }
|
| +
|
| + if (show_payer_phone) {
|
| + phone_value = profile.GetInfo(
|
| + autofill::AutofillType(autofill::PHONE_HOME_WHOLE_NUMBER), locale);
|
| + }
|
| +
|
| + if (show_payer_email) {
|
| + email_value = profile.GetInfo(
|
| + autofill::AutofillType(autofill::EMAIL_ADDRESS), locale);
|
| + }
|
| +
|
| + 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);
|
| +}
|
| +
|
| } // namespace payments
|
|
|