| OLD | NEW |
| 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 <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
| 13 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
| 14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.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.h" | 16 #include "chrome/browser/ui/views/payments/payment_request_dialog_view.h" |
| 17 #include "chrome/browser/ui/views/payments/payment_request_views_util.h" | 17 #include "chrome/browser/ui/views/payments/payment_request_views_util.h" |
| 18 #include "chrome/grit/generated_resources.h" | 18 #include "chrome/grit/generated_resources.h" |
| 19 #include "components/autofill/core/browser/autofill_data_util.h" | 19 #include "components/autofill/core/browser/autofill_data_util.h" |
| 20 #include "components/autofill/core/browser/autofill_type.h" | 20 #include "components/autofill/core/browser/autofill_type.h" |
| 21 #include "components/autofill/core/browser/credit_card.h" | 21 #include "components/autofill/core/browser/credit_card.h" |
| 22 #include "components/autofill/core/browser/field_types.h" | 22 #include "components/autofill/core/browser/field_types.h" |
| 23 #include "components/autofill/core/browser/personal_data_manager.h" | 23 #include "components/autofill/core/browser/personal_data_manager.h" |
| 24 #include "components/payments/currency_formatter.h" | 24 #include "components/payments/currency_formatter.h" |
| 25 #include "components/payments/payment_request.h" | 25 #include "components/payments/payment_request.h" |
| 26 #include "components/strings/grit/components_strings.h" | 26 #include "components/strings/grit/components_strings.h" |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 widest_column_width); | 161 widest_column_width); |
| 162 } | 162 } |
| 163 | 163 |
| 164 return widest_column_width; | 164 return widest_column_width; |
| 165 } | 165 } |
| 166 | 166 |
| 167 } // namespace | 167 } // namespace |
| 168 | 168 |
| 169 PaymentSheetViewController::PaymentSheetViewController( | 169 PaymentSheetViewController::PaymentSheetViewController( |
| 170 PaymentRequest* request, | 170 PaymentRequest* request, |
| 171 PaymentRequestDialog* dialog) | 171 PaymentRequestDialogView* dialog) |
| 172 : PaymentRequestSheetController(request, dialog), | 172 : PaymentRequestSheetController(request, dialog), |
| 173 widest_name_column_view_width_(ComputeWidestNameColumnViewWidth()) {} | 173 widest_name_column_view_width_(ComputeWidestNameColumnViewWidth()) {} |
| 174 | 174 |
| 175 PaymentSheetViewController::~PaymentSheetViewController() {} | 175 PaymentSheetViewController::~PaymentSheetViewController() {} |
| 176 | 176 |
| 177 std::unique_ptr<views::View> PaymentSheetViewController::CreateView() { | 177 std::unique_ptr<views::View> PaymentSheetViewController::CreateView() { |
| 178 std::unique_ptr<views::View> content_view = base::MakeUnique<views::View>(); | 178 std::unique_ptr<views::View> content_view = base::MakeUnique<views::View>(); |
| 179 | 179 |
| 180 views::GridLayout* layout = new views::GridLayout(content_view.get()); | 180 views::GridLayout* layout = new views::GridLayout(content_view.get()); |
| 181 content_view->SetLayoutManager(layout); | 181 content_view->SetLayoutManager(layout); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 197 false, | 197 false, |
| 198 l10n_util::GetStringUTF16(IDS_PAYMENT_REQUEST_PAYMENT_SHEET_TITLE), | 198 l10n_util::GetStringUTF16(IDS_PAYMENT_REQUEST_PAYMENT_SHEET_TITLE), |
| 199 this), | 199 this), |
| 200 std::move(content_view)); | 200 std::move(content_view)); |
| 201 } | 201 } |
| 202 | 202 |
| 203 void PaymentSheetViewController::ButtonPressed( | 203 void PaymentSheetViewController::ButtonPressed( |
| 204 views::Button* sender, const ui::Event& event) { | 204 views::Button* sender, const ui::Event& event) { |
| 205 switch (sender->tag()) { | 205 switch (sender->tag()) { |
| 206 case static_cast<int>(PaymentRequestCommonTags::CLOSE_BUTTON_TAG): | 206 case static_cast<int>(PaymentRequestCommonTags::CLOSE_BUTTON_TAG): |
| 207 dialog()->CloseDialog(); | 207 dialog()->CloseDialog(true); |
| 208 break; | 208 break; |
| 209 | 209 |
| 210 case static_cast<int>( | 210 case static_cast<int>( |
| 211 PaymentSheetViewControllerTags::SHOW_ORDER_SUMMARY_BUTTON): | 211 PaymentSheetViewControllerTags::SHOW_ORDER_SUMMARY_BUTTON): |
| 212 dialog()->ShowOrderSummary(); | 212 dialog()->ShowOrderSummary(); |
| 213 break; | 213 break; |
| 214 | 214 |
| 215 case static_cast<int>(PaymentSheetViewControllerTags::SHOW_SHIPPING_BUTTON): | 215 case static_cast<int>(PaymentSheetViewControllerTags::SHOW_SHIPPING_BUTTON): |
| 216 // TODO(tmartino): Transition to shipping page once it exists. | 216 // TODO(tmartino): Transition to shipping page once it exists. |
| 217 break; | 217 break; |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 this, | 372 this, |
| 373 l10n_util::GetStringUTF16(IDS_PAYMENT_REQUEST_CONTACT_INFO_SECTION_NAME), | 373 l10n_util::GetStringUTF16(IDS_PAYMENT_REQUEST_CONTACT_INFO_SECTION_NAME), |
| 374 CreateContactInfoSectionContent(), std::unique_ptr<views::View>(nullptr), | 374 CreateContactInfoSectionContent(), std::unique_ptr<views::View>(nullptr), |
| 375 widest_name_column_view_width_); | 375 widest_name_column_view_width_); |
| 376 section->set_tag(static_cast<int>( | 376 section->set_tag(static_cast<int>( |
| 377 PaymentSheetViewControllerTags::SHOW_CONTACT_INFO_BUTTON)); | 377 PaymentSheetViewControllerTags::SHOW_CONTACT_INFO_BUTTON)); |
| 378 return section; | 378 return section; |
| 379 } | 379 } |
| 380 | 380 |
| 381 } // namespace payments | 381 } // namespace payments |
| OLD | NEW |