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

Side by Side Diff: chrome/browser/ui/views/payments/payment_method_view_controller.cc

Issue 2768133002: [Web Payments] Refactor sheet display to allow updating view content (Closed)
Patch Set: Add comments. Created 3 years, 9 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/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
12 #include "chrome/browser/browser_process.h" 12 #include "chrome/browser/browser_process.h"
13 #include "chrome/browser/ui/views/payments/payment_request_dialog_view.h" 13 #include "chrome/browser/ui/views/payments/payment_request_dialog_view.h"
14 #include "chrome/browser/ui/views/payments/payment_request_dialog_view_ids.h" 14 #include "chrome/browser/ui/views/payments/payment_request_dialog_view_ids.h"
15 #include "chrome/browser/ui/views/payments/payment_request_row_view.h" 15 #include "chrome/browser/ui/views/payments/payment_request_row_view.h"
16 #include "chrome/browser/ui/views/payments/payment_request_views_util.h" 16 #include "chrome/browser/ui/views/payments/payment_request_views_util.h"
17 #include "chrome/grit/generated_resources.h" 17 #include "chrome/grit/generated_resources.h"
18 #include "components/payments/content/payment_request_state.h" 18 #include "components/payments/content/payment_request_state.h"
19 #include "components/payments/core/payment_instrument.h" 19 #include "components/payments/core/payment_instrument.h"
20 #include "components/strings/grit/components_strings.h" 20 #include "components/strings/grit/components_strings.h"
21 #include "third_party/skia/include/core/SkColor.h" 21 #include "third_party/skia/include/core/SkColor.h"
22 #include "ui/base/l10n/l10n_util.h" 22 #include "ui/base/l10n/l10n_util.h"
23 #include "ui/gfx/paint_vector_icon.h" 23 #include "ui/gfx/paint_vector_icon.h"
24 #include "ui/views/controls/button/label_button.h" 24 #include "ui/views/controls/button/label_button.h"
25 #include "ui/views/controls/button/md_text_button.h" 25 #include "ui/views/controls/button/md_text_button.h"
26 #include "ui/views/layout/box_layout.h" 26 #include "ui/views/layout/box_layout.h"
27 #include "ui/views/layout/fill_layout.h"
27 #include "ui/views/layout/grid_layout.h" 28 #include "ui/views/layout/grid_layout.h"
28 #include "ui/views/vector_icons.h" 29 #include "ui/views/vector_icons.h"
29 30
30 namespace payments { 31 namespace payments {
31 32
32 namespace { 33 namespace {
33 34
34 constexpr int kFirstTagValue = static_cast<int>( 35 constexpr int kFirstTagValue = static_cast<int>(
35 payments::PaymentRequestCommonTags::PAYMENT_REQUEST_COMMON_TAG_MAX); 36 payments::PaymentRequestCommonTags::PAYMENT_REQUEST_COMMON_TAG_MAX);
36 37
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 std::unique_ptr<PaymentMethodListItem> item = 123 std::unique_ptr<PaymentMethodListItem> item =
123 base::MakeUnique<PaymentMethodListItem>( 124 base::MakeUnique<PaymentMethodListItem>(
124 instrument.get(), spec, state, &payment_method_list_, dialog, 125 instrument.get(), spec, state, &payment_method_list_, dialog,
125 instrument.get() == state->selected_instrument()); 126 instrument.get() == state->selected_instrument());
126 payment_method_list_.AddItem(std::move(item)); 127 payment_method_list_.AddItem(std::move(item));
127 } 128 }
128 } 129 }
129 130
130 PaymentMethodViewController::~PaymentMethodViewController() {} 131 PaymentMethodViewController::~PaymentMethodViewController() {}
131 132
132 std::unique_ptr<views::View> PaymentMethodViewController::CreateView() { 133 base::string16 PaymentMethodViewController::GetSheetTitle() {
134 return l10n_util::GetStringUTF16(
135 IDS_PAYMENT_REQUEST_PAYMENT_METHOD_SECTION_NAME);
136 }
137
138 void PaymentMethodViewController::FillContentView(views::View* content_view) {
139 content_view->SetLayoutManager(new views::FillLayout);
133 std::unique_ptr<views::View> list_view = 140 std::unique_ptr<views::View> list_view =
134 payment_method_list_.CreateListView(); 141 payment_method_list_.CreateListView();
135 list_view->set_id( 142 list_view->set_id(
136 static_cast<int>(DialogViewID::PAYMENT_METHOD_SHEET_LIST_VIEW)); 143 static_cast<int>(DialogViewID::PAYMENT_METHOD_SHEET_LIST_VIEW));
137 return CreatePaymentView( 144 content_view->AddChildView(list_view.release());
138 CreateSheetHeaderView(
139 true,
140 l10n_util::GetStringUTF16(
141 IDS_PAYMENT_REQUEST_PAYMENT_METHOD_SECTION_NAME),
142 this),
143 std::move(list_view));
144 } 145 }
145 146
146 std::unique_ptr<views::View> 147 std::unique_ptr<views::View>
147 PaymentMethodViewController::CreateExtraFooterView() { 148 PaymentMethodViewController::CreateExtraFooterView() {
148 std::unique_ptr<views::View> extra_view = base::MakeUnique<views::View>(); 149 std::unique_ptr<views::View> extra_view = base::MakeUnique<views::View>();
149 150
150 extra_view->SetLayoutManager(new views::BoxLayout( 151 extra_view->SetLayoutManager(new views::BoxLayout(
151 views::BoxLayout::kHorizontal, 0, 0, kPaymentRequestButtonSpacing)); 152 views::BoxLayout::kHorizontal, 0, 0, kPaymentRequestButtonSpacing));
152 153
153 views::LabelButton* button = views::MdTextButton::CreateSecondaryUiButton( 154 views::LabelButton* button = views::MdTextButton::CreateSecondaryUiButton(
(...skipping 14 matching lines...) Expand all
168 PaymentMethodViewControllerTags::ADD_CREDIT_CARD_BUTTON): 169 PaymentMethodViewControllerTags::ADD_CREDIT_CARD_BUTTON):
169 dialog()->ShowCreditCardEditor(); 170 dialog()->ShowCreditCardEditor();
170 break; 171 break;
171 default: 172 default:
172 PaymentRequestSheetController::ButtonPressed(sender, event); 173 PaymentRequestSheetController::ButtonPressed(sender, event);
173 break; 174 break;
174 } 175 }
175 } 176 }
176 177
177 } // namespace payments 178 } // namespace payments
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698