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

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

Issue 2725943002: [Payments] Add product branding to Payment Request dialog. (Closed)
Patch Set: rebase 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
« no previous file with comments | « chrome/browser/ui/views/payments/payment_sheet_view_controller.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_sheet_view_controller.h" 5 #include "chrome/browser/ui/views/payments/payment_sheet_view_controller.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/ptr_util.h" 14 #include "base/memory/ptr_util.h"
15 #include "base/strings/string_util.h" 15 #include "base/strings/string_util.h"
16 #include "base/strings/utf_string_conversions.h" 16 #include "base/strings/utf_string_conversions.h"
17 #include "chrome/browser/browser_process.h" 17 #include "chrome/browser/browser_process.h"
18 #include "chrome/browser/ui/views/payments/payment_request_dialog_view.h" 18 #include "chrome/browser/ui/views/payments/payment_request_dialog_view.h"
19 #include "chrome/browser/ui/views/payments/payment_request_dialog_view_ids.h" 19 #include "chrome/browser/ui/views/payments/payment_request_dialog_view_ids.h"
20 #include "chrome/browser/ui/views/payments/payment_request_row_view.h" 20 #include "chrome/browser/ui/views/payments/payment_request_row_view.h"
21 #include "chrome/browser/ui/views/payments/payment_request_views_util.h" 21 #include "chrome/browser/ui/views/payments/payment_request_views_util.h"
22 #include "chrome/grit/chromium_strings.h"
22 #include "chrome/grit/generated_resources.h" 23 #include "chrome/grit/generated_resources.h"
24 #include "chrome/grit/theme_resources.h"
23 #include "components/autofill/core/browser/autofill_type.h" 25 #include "components/autofill/core/browser/autofill_type.h"
24 #include "components/autofill/core/browser/credit_card.h" 26 #include "components/autofill/core/browser/credit_card.h"
25 #include "components/autofill/core/browser/field_types.h" 27 #include "components/autofill/core/browser/field_types.h"
26 #include "components/autofill/core/browser/personal_data_manager.h" 28 #include "components/autofill/core/browser/personal_data_manager.h"
27 #include "components/payments/core/currency_formatter.h" 29 #include "components/payments/core/currency_formatter.h"
28 #include "components/strings/grit/components_strings.h" 30 #include "components/strings/grit/components_strings.h"
29 #include "content/public/browser/web_contents.h" 31 #include "content/public/browser/web_contents.h"
30 #include "ui/base/l10n/l10n_util.h" 32 #include "ui/base/l10n/l10n_util.h"
33 #include "ui/base/resource/resource_bundle.h"
31 #include "ui/gfx/color_utils.h" 34 #include "ui/gfx/color_utils.h"
32 #include "ui/gfx/font.h" 35 #include "ui/gfx/font.h"
33 #include "ui/gfx/paint_vector_icon.h" 36 #include "ui/gfx/paint_vector_icon.h"
34 #include "ui/gfx/range/range.h" 37 #include "ui/gfx/range/range.h"
35 #include "ui/views/controls/button/md_text_button.h" 38 #include "ui/views/controls/button/md_text_button.h"
36 #include "ui/views/controls/image_view.h" 39 #include "ui/views/controls/image_view.h"
37 #include "ui/views/controls/label.h" 40 #include "ui/views/controls/label.h"
38 #include "ui/views/controls/styled_label.h" 41 #include "ui/views/controls/styled_label.h"
42 #include "ui/views/layout/box_layout.h"
39 #include "ui/views/layout/grid_layout.h" 43 #include "ui/views/layout/grid_layout.h"
40 #include "ui/views/vector_icons.h" 44 #include "ui/views/vector_icons.h"
41 #include "ui/views/view.h" 45 #include "ui/views/view.h"
42 46
43 namespace payments { 47 namespace payments {
44 namespace { 48 namespace {
45 49
46 constexpr int kFirstTagValue = static_cast<int>( 50 constexpr int kFirstTagValue = static_cast<int>(
47 payments::PaymentRequestCommonTags::PAYMENT_REQUEST_COMMON_TAG_MAX); 51 payments::PaymentRequestCommonTags::PAYMENT_REQUEST_COMMON_TAG_MAX);
48 52
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 } 205 }
202 206
203 return CreatePaymentView( 207 return CreatePaymentView(
204 CreateSheetHeaderView( 208 CreateSheetHeaderView(
205 false, 209 false,
206 l10n_util::GetStringUTF16(IDS_PAYMENT_REQUEST_PAYMENT_SHEET_TITLE), 210 l10n_util::GetStringUTF16(IDS_PAYMENT_REQUEST_PAYMENT_SHEET_TITLE),
207 this), 211 this),
208 std::move(content_view)); 212 std::move(content_view));
209 } 213 }
210 214
215 void PaymentSheetViewController::OnSelectedInformationChanged() {
216 UpdatePayButtonState(request()->is_ready_to_pay());
217 }
218
211 std::unique_ptr<views::Button> 219 std::unique_ptr<views::Button>
212 PaymentSheetViewController::CreatePrimaryButton() { 220 PaymentSheetViewController::CreatePrimaryButton() {
213 std::unique_ptr<views::Button> button( 221 std::unique_ptr<views::Button> button(
214 views::MdTextButton::CreateSecondaryUiBlueButton( 222 views::MdTextButton::CreateSecondaryUiBlueButton(
215 this, l10n_util::GetStringUTF16(IDS_PAYMENTS_PAY_BUTTON))); 223 this, l10n_util::GetStringUTF16(IDS_PAYMENTS_PAY_BUTTON)));
216 button->set_tag(static_cast<int>(PaymentRequestCommonTags::PAY_BUTTON_TAG)); 224 button->set_tag(static_cast<int>(PaymentRequestCommonTags::PAY_BUTTON_TAG));
217 button->set_id(static_cast<int>(DialogViewID::PAY_BUTTON)); 225 button->set_id(static_cast<int>(DialogViewID::PAY_BUTTON));
218 pay_button_ = button.get(); 226 pay_button_ = button.get();
219 UpdatePayButtonState(request()->is_ready_to_pay()); 227 UpdatePayButtonState(request()->is_ready_to_pay());
220 return button; 228 return button;
221 } 229 }
222 230
223 void PaymentSheetViewController::OnSelectedInformationChanged() { 231 // Adds the product logo to the footer.
224 UpdatePayButtonState(request()->is_ready_to_pay()); 232 // +---------------------------------------------------------+
233 // | (•) chrome | PAY | CANCEL |
234 // +---------------------------------------------------------+
235 std::unique_ptr<views::View>
236 PaymentSheetViewController::CreateExtraFooterView() {
237 std::unique_ptr<views::View> content_view = base::MakeUnique<views::View>();
238
239 views::BoxLayout* layout =
240 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0);
241 layout->set_main_axis_alignment(views::BoxLayout::MAIN_AXIS_ALIGNMENT_START);
242 layout->set_cross_axis_alignment(
243 views::BoxLayout::CROSS_AXIS_ALIGNMENT_START);
244 content_view->SetLayoutManager(layout);
245
246 // Adds the Chrome logo image.
247 std::unique_ptr<views::ImageView> chrome_logo =
248 base::MakeUnique<views::ImageView>();
249 chrome_logo->set_can_process_events_within_subtree(false);
250 chrome_logo->SetImage(ResourceBundle::GetSharedInstance()
251 .GetImageNamed(IDR_PRODUCT_LOGO_NAME_22)
252 .AsImageSkia());
253 chrome_logo->SetTooltipText(l10n_util::GetStringUTF16(IDS_PRODUCT_NAME));
254 content_view->AddChildView(chrome_logo.release());
255
256 return content_view;
225 } 257 }
226 258
227 void PaymentSheetViewController::ButtonPressed( 259 void PaymentSheetViewController::ButtonPressed(
228 views::Button* sender, const ui::Event& event) { 260 views::Button* sender, const ui::Event& event) {
229 switch (sender->tag()) { 261 switch (sender->tag()) {
230 case static_cast<int>( 262 case static_cast<int>(
231 PaymentSheetViewControllerTags::SHOW_ORDER_SUMMARY_BUTTON): 263 PaymentSheetViewControllerTags::SHOW_ORDER_SUMMARY_BUTTON):
232 dialog()->ShowOrderSummary(); 264 dialog()->ShowOrderSummary();
233 break; 265 break;
234 266
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 CreateContactInfoSectionContent(), std::unique_ptr<views::View>(nullptr), 427 CreateContactInfoSectionContent(), std::unique_ptr<views::View>(nullptr),
396 widest_name_column_view_width_); 428 widest_name_column_view_width_);
397 section->set_tag(static_cast<int>( 429 section->set_tag(static_cast<int>(
398 PaymentSheetViewControllerTags::SHOW_CONTACT_INFO_BUTTON)); 430 PaymentSheetViewControllerTags::SHOW_CONTACT_INFO_BUTTON));
399 section->set_id( 431 section->set_id(
400 static_cast<int>(DialogViewID::PAYMENT_SHEET_CONTACT_INFO_SECTION)); 432 static_cast<int>(DialogViewID::PAYMENT_SHEET_CONTACT_INFO_SECTION));
401 return section; 433 return section;
402 } 434 }
403 435
404 } // namespace payments 436 } // namespace payments
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/payments/payment_sheet_view_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698