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

Unified Diff: chrome/browser/ui/views/payments/payment_method_view_controller.cc

Issue 2813203004: [Payments] Show what's missing for incomplete payment methods. (Closed)
Patch Set: Initial Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/views/payments/payment_method_view_controller.cc
diff --git a/chrome/browser/ui/views/payments/payment_method_view_controller.cc b/chrome/browser/ui/views/payments/payment_method_view_controller.cc
index 828fd2e7f037ec67a34c58828414e57bb66d666d..1a97e1917b5c16c49311a8b79bf1d0d4b3c701f6 100644
--- a/chrome/browser/ui/views/payments/payment_method_view_controller.cc
+++ b/chrome/browser/ui/views/payments/payment_method_view_controller.cc
@@ -25,6 +25,7 @@
#include "third_party/skia/include/core/SkColor.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/gfx/paint_vector_icon.h"
+#include "ui/native_theme/native_theme.h"
#include "ui/views/controls/button/label_button.h"
#include "ui/views/controls/button/md_text_button.h"
#include "ui/views/layout/box_layout.h"
@@ -82,11 +83,24 @@ class PaymentMethodListItem : public payments::PaymentRequestItemList::Item {
views::BoxLayout::CROSS_AXIS_ALIGNMENT_START);
card_info_container->SetLayoutManager(box_layout.release());
- card_info_container->AddChildView(new views::Label(instrument_->label()));
- card_info_container->AddChildView(
- new views::Label(instrument_->sublabel()));
- // TODO(anthonyvd): Add the "card is incomplete" label once the
- // completedness logic is implemented.
+ if (!instrument_->label().empty())
+ card_info_container->AddChildView(new views::Label(instrument_->label()));
+ if (!instrument_->sublabel().empty()) {
+ card_info_container->AddChildView(
+ new views::Label(instrument_->sublabel()));
+ }
+ base::string16 missing_info;
+ if (!instrument_->IsCompleteForPayment(&missing_info)) {
+ std::unique_ptr<views::Label> missing_info_label =
+ base::MakeUnique<views::Label>(missing_info);
+ missing_info_label->SetFontList(
+ missing_info_label->GetDefaultFontList().DeriveWithSizeDelta(-1));
+ missing_info_label->SetEnabledColor(
+ missing_info_label->GetNativeTheme()->GetSystemColor(
+ ui::NativeTheme::kColorId_LinkEnabled));
+ card_info_container->AddChildView(missing_info_label.release());
+ }
+
return card_info_container;
}
@@ -100,7 +114,7 @@ class PaymentMethodListItem : public payments::PaymentRequestItemList::Item {
bool CanBeSelected() const override {
// If an instrument can't be selected, PerformSelectionFallback is called,
// where the instrument can be made complete.
- return instrument_->IsCompleteForPayment();
+ return instrument_->IsCompleteForPayment(/*missing_info=*/nullptr);
}
void PerformSelectionFallback() override {

Powered by Google App Engine
This is Rietveld 408576698