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_request_views_util.h" | 5 #include "chrome/browser/ui/views/payments/payment_request_views_util.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 } | 298 } |
299 | 299 |
300 std::unique_ptr<views::View> GetShippingAddressLabelWithMissingInfo( | 300 std::unique_ptr<views::View> GetShippingAddressLabelWithMissingInfo( |
301 AddressStyleType type, | 301 AddressStyleType type, |
302 const std::string& locale, | 302 const std::string& locale, |
303 const autofill::AutofillProfile& profile, | 303 const autofill::AutofillProfile& profile, |
304 const PaymentsProfileComparator& comp) { | 304 const PaymentsProfileComparator& comp) { |
305 std::unique_ptr<views::View> base_label = | 305 std::unique_ptr<views::View> base_label = |
306 GetShippingAddressLabel(type, locale, profile, /*disabled_state=*/false); | 306 GetShippingAddressLabel(type, locale, profile, /*disabled_state=*/false); |
307 | 307 |
308 base_label->AddChildView(GetLabelForMissingInformation( | 308 base::string16 missing = comp.GetStringForMissingShippingFields(profile); |
309 comp.GetStringForMissingShippingFields(profile)) | 309 if (!missing.empty()) { |
310 .release()); | 310 base_label->AddChildView(GetLabelForMissingInformation(missing).release()); |
| 311 } |
311 return base_label; | 312 return base_label; |
312 } | 313 } |
313 | 314 |
314 // TODO(anthonyvd): unit test the label layout. | 315 // TODO(anthonyvd): unit test the label layout. |
315 std::unique_ptr<views::View> GetContactInfoLabel( | 316 std::unique_ptr<views::View> GetContactInfoLabel( |
316 AddressStyleType type, | 317 AddressStyleType type, |
317 const std::string& locale, | 318 const std::string& locale, |
318 const autofill::AutofillProfile& profile, | 319 const autofill::AutofillProfile& profile, |
319 const PaymentOptionsProvider& options, | 320 const PaymentOptionsProvider& options, |
320 const PaymentsProfileComparator& comp) { | 321 const PaymentsProfileComparator& comp) { |
(...skipping 11 matching lines...) Expand all Loading... |
332 | 333 |
333 base::string16 email = | 334 base::string16 email = |
334 options.request_payer_email() | 335 options.request_payer_email() |
335 ? profile.GetInfo(autofill::AutofillType(autofill::EMAIL_ADDRESS), | 336 ? profile.GetInfo(autofill::AutofillType(autofill::EMAIL_ADDRESS), |
336 locale) | 337 locale) |
337 : base::string16(); | 338 : base::string16(); |
338 | 339 |
339 std::unique_ptr<views::View> base_label = | 340 std::unique_ptr<views::View> base_label = |
340 GetBaseProfileLabel(type, name, phone, email); | 341 GetBaseProfileLabel(type, name, phone, email); |
341 | 342 |
342 base_label->AddChildView(GetLabelForMissingInformation( | 343 base::string16 missing = comp.GetStringForMissingContactFields(profile); |
343 comp.GetStringForMissingContactFields(profile)) | 344 if (!missing.empty()) { |
344 .release()); | 345 base_label->AddChildView(GetLabelForMissingInformation(missing).release()); |
| 346 } |
345 return base_label; | 347 return base_label; |
346 } | 348 } |
347 | 349 |
348 std::unique_ptr<views::Border> CreatePaymentRequestRowBorder( | 350 std::unique_ptr<views::Border> CreatePaymentRequestRowBorder( |
349 SkColor color, | 351 SkColor color, |
350 const gfx::Insets& insets) { | 352 const gfx::Insets& insets) { |
351 return views::CreateBorderPainter( | 353 return views::CreateBorderPainter( |
352 base::MakeUnique<PaymentRequestRowBorderPainter>(color), insets); | 354 base::MakeUnique<PaymentRequestRowBorderPainter>(color), insets); |
353 } | 355 } |
354 | 356 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 amount_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 393 amount_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
392 amount_label->set_id( | 394 amount_label->set_id( |
393 static_cast<int>(DialogViewID::SHIPPING_OPTION_AMOUNT)); | 395 static_cast<int>(DialogViewID::SHIPPING_OPTION_AMOUNT)); |
394 container->AddChildView(amount_label.release()); | 396 container->AddChildView(amount_label.release()); |
395 } | 397 } |
396 | 398 |
397 return container; | 399 return container; |
398 } | 400 } |
399 | 401 |
400 } // namespace payments | 402 } // namespace payments |
OLD | NEW |