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

Unified Diff: chrome/browser/ui/views/payments/shipping_option_view_controller.cc

Issue 2747943004: [Web Payments] Add the shipping options sheet. (Closed)
Patch Set: Address 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/views/payments/shipping_option_view_controller.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/payments/shipping_option_view_controller.cc
diff --git a/chrome/browser/ui/views/payments/shipping_option_view_controller.cc b/chrome/browser/ui/views/payments/shipping_option_view_controller.cc
new file mode 100644
index 0000000000000000000000000000000000000000..fdceffe9fe287a0107cc98f4cf7fe991fa1b0847
--- /dev/null
+++ b/chrome/browser/ui/views/payments/shipping_option_view_controller.cc
@@ -0,0 +1,70 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/views/payments/shipping_option_view_controller.h"
+
+#include "chrome/browser/ui/views/payments/payment_request_views_util.h"
+#include "components/payments/content/payment_request.h"
+
+namespace payments {
+
+namespace {
+
+class ShippingOptionItem : public PaymentRequestItemList::Item {
+ public:
+ ShippingOptionItem(payments::mojom::PaymentShippingOption* shipping_option,
+ PaymentRequest* request,
+ PaymentRequestItemList* parent_list,
+ bool selected)
+ : PaymentRequestItemList::Item(request, parent_list, selected),
+ shipping_option_(shipping_option) {}
+ ~ShippingOptionItem() override {}
+
+ private:
+ // payments::PaymentRequestItemList::Item:
+ std::unique_ptr<views::View> CreateItemView() override {
+ return CreateShippingOptionLabel(
+ shipping_option_,
+ request()->GetFormattedCurrencyAmount(shipping_option_->amount->value));
+ }
+
+ void SelectedStateChanged() override {}
+
+ mojom::PaymentShippingOption* shipping_option_;
+
+ DISALLOW_COPY_AND_ASSIGN(ShippingOptionItem);
+};
+
+} // namespace
+
+ShippingOptionViewController::ShippingOptionViewController(
+ PaymentRequest* request,
+ PaymentRequestDialogView* dialog)
+ : PaymentRequestSheetController(request, dialog) {
+ for (const auto& option : request->details()->shipping_options) {
+ shipping_option_list_.AddItem(base::MakeUnique<ShippingOptionItem>(
+ option.get(), request, &shipping_option_list_,
+ option.get() == request->selected_shipping_option()));
+ }
+}
+
+ShippingOptionViewController::~ShippingOptionViewController() {}
+
+std::unique_ptr<views::View> ShippingOptionViewController::CreateView() {
+ std::unique_ptr<views::View> list_view =
+ shipping_option_list_.CreateListView();
+ return CreatePaymentView(
+ CreateSheetHeaderView(
+ true,
+ GetShippingOptionSectionString(request()->options()->shipping_type),
+ this),
+ std::move(list_view));
+}
+
+std::unique_ptr<views::View>
+ShippingOptionViewController::CreateExtraFooterView() {
+ return nullptr;
+}
+
+} // namespace payments
« no previous file with comments | « chrome/browser/ui/views/payments/shipping_option_view_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698