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

Side by Side 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: addressed comments, now two functions 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 unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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_method_view_controller.h" 5 #include "chrome/browser/ui/views/payments/payment_method_view_controller.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/bind_helpers.h" 12 #include "base/bind_helpers.h"
13 #include "base/callback_forward.h" 13 #include "base/callback_forward.h"
14 #include "base/memory/ptr_util.h" 14 #include "base/memory/ptr_util.h"
15 #include "chrome/browser/browser_process.h" 15 #include "chrome/browser/browser_process.h"
16 #include "chrome/browser/ui/views/payments/payment_request_dialog_view.h" 16 #include "chrome/browser/ui/views/payments/payment_request_dialog_view.h"
17 #include "chrome/browser/ui/views/payments/payment_request_dialog_view_ids.h" 17 #include "chrome/browser/ui/views/payments/payment_request_dialog_view_ids.h"
18 #include "chrome/browser/ui/views/payments/payment_request_row_view.h" 18 #include "chrome/browser/ui/views/payments/payment_request_row_view.h"
19 #include "chrome/browser/ui/views/payments/payment_request_views_util.h" 19 #include "chrome/browser/ui/views/payments/payment_request_views_util.h"
20 #include "chrome/grit/generated_resources.h" 20 #include "chrome/grit/generated_resources.h"
21 #include "components/payments/content/payment_request_state.h" 21 #include "components/payments/content/payment_request_state.h"
22 #include "components/payments/core/autofill_payment_instrument.h" 22 #include "components/payments/core/autofill_payment_instrument.h"
23 #include "components/payments/core/payment_instrument.h" 23 #include "components/payments/core/payment_instrument.h"
24 #include "components/strings/grit/components_strings.h" 24 #include "components/strings/grit/components_strings.h"
25 #include "third_party/skia/include/core/SkColor.h" 25 #include "third_party/skia/include/core/SkColor.h"
26 #include "ui/base/l10n/l10n_util.h" 26 #include "ui/base/l10n/l10n_util.h"
27 #include "ui/gfx/paint_vector_icon.h" 27 #include "ui/gfx/paint_vector_icon.h"
28 #include "ui/native_theme/native_theme.h"
28 #include "ui/views/controls/button/label_button.h" 29 #include "ui/views/controls/button/label_button.h"
29 #include "ui/views/controls/button/md_text_button.h" 30 #include "ui/views/controls/button/md_text_button.h"
30 #include "ui/views/layout/box_layout.h" 31 #include "ui/views/layout/box_layout.h"
31 #include "ui/views/layout/fill_layout.h" 32 #include "ui/views/layout/fill_layout.h"
32 #include "ui/views/layout/grid_layout.h" 33 #include "ui/views/layout/grid_layout.h"
33 #include "ui/views/vector_icons.h" 34 #include "ui/views/vector_icons.h"
34 35
35 namespace payments { 36 namespace payments {
36 37
37 namespace { 38 namespace {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 base::MakeUnique<views::View>(); 76 base::MakeUnique<views::View>();
76 card_info_container->set_can_process_events_within_subtree(false); 77 card_info_container->set_can_process_events_within_subtree(false);
77 78
78 std::unique_ptr<views::BoxLayout> box_layout = 79 std::unique_ptr<views::BoxLayout> box_layout =
79 base::MakeUnique<views::BoxLayout>(views::BoxLayout::kVertical, 0, 80 base::MakeUnique<views::BoxLayout>(views::BoxLayout::kVertical, 0,
80 kPaymentRequestRowVerticalInsets, 0); 81 kPaymentRequestRowVerticalInsets, 0);
81 box_layout->set_cross_axis_alignment( 82 box_layout->set_cross_axis_alignment(
82 views::BoxLayout::CROSS_AXIS_ALIGNMENT_START); 83 views::BoxLayout::CROSS_AXIS_ALIGNMENT_START);
83 card_info_container->SetLayoutManager(box_layout.release()); 84 card_info_container->SetLayoutManager(box_layout.release());
84 85
85 card_info_container->AddChildView(new views::Label(instrument_->label())); 86 if (!instrument_->label().empty())
86 card_info_container->AddChildView( 87 card_info_container->AddChildView(new views::Label(instrument_->label()));
87 new views::Label(instrument_->sublabel())); 88 if (!instrument_->sublabel().empty()) {
88 // TODO(anthonyvd): Add the "card is incomplete" label once the 89 card_info_container->AddChildView(
89 // completedness logic is implemented. 90 new views::Label(instrument_->sublabel()));
91 }
92 if (!instrument_->IsCompleteForPayment()) {
93 std::unique_ptr<views::Label> missing_info_label =
94 base::MakeUnique<views::Label>(instrument_->GetMissingInfoLabel());
95 missing_info_label->SetFontList(
96 missing_info_label->GetDefaultFontList().DeriveWithSizeDelta(-1));
97 missing_info_label->SetEnabledColor(
98 missing_info_label->GetNativeTheme()->GetSystemColor(
99 ui::NativeTheme::kColorId_LinkEnabled));
100 card_info_container->AddChildView(missing_info_label.release());
101 }
102
90 return card_info_container; 103 return card_info_container;
91 } 104 }
92 105
93 void SelectedStateChanged() override { 106 void SelectedStateChanged() override {
94 if (selected()) { 107 if (selected()) {
95 state()->SetSelectedInstrument(instrument_); 108 state()->SetSelectedInstrument(instrument_);
96 dialog_->GoBack(); 109 dialog_->GoBack();
97 } 110 }
98 } 111 }
99 112
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 base::Unretained(state()), /*selected=*/true), 205 base::Unretained(state()), /*selected=*/true),
193 /*credit_card=*/nullptr); 206 /*credit_card=*/nullptr);
194 break; 207 break;
195 default: 208 default:
196 PaymentRequestSheetController::ButtonPressed(sender, event); 209 PaymentRequestSheetController::ButtonPressed(sender, event);
197 break; 210 break;
198 } 211 }
199 } 212 }
200 213
201 } // namespace payments 214 } // namespace payments
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/payments/credit_card_editor_view_controller.cc ('k') | components/autofill/core/browser/validation.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698