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

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

Issue 2611253004: [Payment Request] Change the lifetime management of PaymentRequestImpl (Closed)
Patch Set: PaymentRequestImpl -> PaymentRequest Created 3 years, 11 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') | chrome/test/BUILD.gn » ('j') | 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 <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "chrome/browser/payments/payment_request_impl.h"
13 #include "chrome/browser/ui/views/payments/payment_request_dialog.h" 12 #include "chrome/browser/ui/views/payments/payment_request_dialog.h"
14 #include "chrome/browser/ui/views/payments/payment_request_views_util.h" 13 #include "chrome/browser/ui/views/payments/payment_request_views_util.h"
15 #include "chrome/grit/generated_resources.h" 14 #include "chrome/grit/generated_resources.h"
15 #include "components/payments/payment_request.h"
16 #include "components/strings/grit/components_strings.h" 16 #include "components/strings/grit/components_strings.h"
17 #include "third_party/skia/include/core/SkColor.h" 17 #include "third_party/skia/include/core/SkColor.h"
18 #include "ui/base/l10n/l10n_util.h" 18 #include "ui/base/l10n/l10n_util.h"
19 #include "ui/gfx/color_utils.h" 19 #include "ui/gfx/color_utils.h"
20 #include "ui/gfx/font.h" 20 #include "ui/gfx/font.h"
21 #include "ui/gfx/geometry/insets.h" 21 #include "ui/gfx/geometry/insets.h"
22 #include "ui/gfx/paint_vector_icon.h" 22 #include "ui/gfx/paint_vector_icon.h"
23 #include "ui/gfx/range/range.h" 23 #include "ui/gfx/range/range.h"
24 #include "ui/gfx/vector_icons_public.h" 24 #include "ui/gfx/vector_icons_public.h"
25 #include "ui/views/border.h" 25 #include "ui/views/border.h"
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 color_utils::DeriveDefaultIconColor(name_label->enabled_color()))); 107 color_utils::DeriveDefaultIconColor(name_label->enabled_color())));
108 layout->AddView(chevron); 108 layout->AddView(chevron);
109 } 109 }
110 110
111 DISALLOW_COPY_AND_ASSIGN(PaymentSheetRow); 111 DISALLOW_COPY_AND_ASSIGN(PaymentSheetRow);
112 }; 112 };
113 113
114 } // namespace 114 } // namespace
115 115
116 PaymentSheetViewController::PaymentSheetViewController( 116 PaymentSheetViewController::PaymentSheetViewController(
117 PaymentRequestImpl* impl, PaymentRequestDialog* dialog) 117 PaymentRequest* request,
118 : PaymentRequestSheetController(impl, dialog) {} 118 PaymentRequestDialog* dialog)
119 : PaymentRequestSheetController(request, dialog) {}
119 120
120 PaymentSheetViewController::~PaymentSheetViewController() {} 121 PaymentSheetViewController::~PaymentSheetViewController() {}
121 122
122 std::unique_ptr<views::View> PaymentSheetViewController::CreateView() { 123 std::unique_ptr<views::View> PaymentSheetViewController::CreateView() {
123 std::unique_ptr<views::View> content_view = base::MakeUnique<views::View>(); 124 std::unique_ptr<views::View> content_view = base::MakeUnique<views::View>();
124 125
125 views::GridLayout* layout = new views::GridLayout(content_view.get()); 126 views::GridLayout* layout = new views::GridLayout(content_view.get());
126 content_view->SetLayoutManager(layout); 127 content_view->SetLayoutManager(layout);
127 views::ColumnSet* columns = layout->AddColumnSet(0); 128 views::ColumnSet* columns = layout->AddColumnSet(0);
128 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::CENTER, 129 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::CENTER,
(...skipping 20 matching lines...) Expand all
149 PaymentSheetViewControllerTags::SHOW_ORDER_SUMMARY_BUTTON): 150 PaymentSheetViewControllerTags::SHOW_ORDER_SUMMARY_BUTTON):
150 dialog()->ShowOrderSummary(); 151 dialog()->ShowOrderSummary();
151 break; 152 break;
152 default: 153 default:
153 NOTREACHED(); 154 NOTREACHED();
154 } 155 }
155 } 156 }
156 157
157 std::unique_ptr<views::View> 158 std::unique_ptr<views::View>
158 PaymentSheetViewController::CreateOrderSummarySectionContent() { 159 PaymentSheetViewController::CreateOrderSummarySectionContent() {
159 base::string16 label_value = 160 base::string16 label_value = l10n_util::GetStringFUTF16(
160 l10n_util::GetStringFUTF16( 161 IDS_PAYMENT_REQUEST_ORDER_SUMMARY_SECTION_TOTAL_FORMAT,
161 IDS_PAYMENT_REQUEST_ORDER_SUMMARY_SECTION_TOTAL_FORMAT, 162 base::ASCIIToUTF16(request()->details()->total->label),
162 base::ASCIIToUTF16(impl()->details()->total->label), 163 base::ASCIIToUTF16(request()->details()->total->amount->currency),
163 base::ASCIIToUTF16(impl()->details()->total->amount->currency), 164 base::ASCIIToUTF16(request()->details()->total->amount->value));
164 base::ASCIIToUTF16(impl()->details()->total->amount->value));
165 165
166 return base::MakeUnique<views::Label>(label_value); 166 return base::MakeUnique<views::Label>(label_value);
167 } 167 }
168 168
169 std::unique_ptr<views::Button> 169 std::unique_ptr<views::Button>
170 PaymentSheetViewController::CreatePaymentSheetSummaryRow() { 170 PaymentSheetViewController::CreatePaymentSheetSummaryRow() {
171 std::unique_ptr<views::Button> section = base::MakeUnique<PaymentSheetRow>( 171 std::unique_ptr<views::Button> section = base::MakeUnique<PaymentSheetRow>(
172 this, 172 this,
173 l10n_util::GetStringUTF16(IDS_PAYMENT_REQUEST_ORDER_SUMMARY_SECTION_NAME), 173 l10n_util::GetStringUTF16(IDS_PAYMENT_REQUEST_ORDER_SUMMARY_SECTION_NAME),
174 std::unique_ptr<views::View>(nullptr), 174 std::unique_ptr<views::View>(nullptr),
175 CreateOrderSummarySectionContent()); 175 CreateOrderSummarySectionContent());
176 section->set_tag(static_cast<int>( 176 section->set_tag(static_cast<int>(
177 PaymentSheetViewControllerTags::SHOW_ORDER_SUMMARY_BUTTON)); 177 PaymentSheetViewControllerTags::SHOW_ORDER_SUMMARY_BUTTON));
178 return section; 178 return section;
179 } 179 }
180 180
181 } // namespace payments 181 } // namespace payments
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/payments/payment_sheet_view_controller.h ('k') | chrome/test/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698