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

Unified Diff: chrome/browser/ui/views/payments/shipping_address_editor_view_controller.h

Issue 2709093006: Adding new shipping address editor view to payment flow. (Closed)
Patch Set: Bot failure fix 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
Index: chrome/browser/ui/views/payments/shipping_address_editor_view_controller.h
diff --git a/chrome/browser/ui/views/payments/shipping_address_editor_view_controller.h b/chrome/browser/ui/views/payments/shipping_address_editor_view_controller.h
new file mode 100644
index 0000000000000000000000000000000000000000..871d523b917f63bc7728f0d3a3e9277697a7c402
--- /dev/null
+++ b/chrome/browser/ui/views/payments/shipping_address_editor_view_controller.h
@@ -0,0 +1,89 @@
+// 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.
+
+#ifndef CHROME_BROWSER_UI_VIEWS_PAYMENTS_SHIPPING_ADDRESS_EDITOR_VIEW_CONTROLLER_H_
+#define CHROME_BROWSER_UI_VIEWS_PAYMENTS_SHIPPING_ADDRESS_EDITOR_VIEW_CONTROLLER_H_
+
+#include <memory>
+#include <string>
+#include <vector>
+
+#include "base/macros.h"
+#include "chrome/browser/ui/views/payments/editor_view_controller.h"
+#include "chrome/browser/ui/views/payments/validating_textfield.h"
+
+namespace payments {
+
+class PaymentRequestSpec;
+class PaymentRequestState;
+class PaymentRequestDialogView;
+
+// Shipping Address editor screen of the Payment Request flow.
+class ShippingAddressEditorViewController : public EditorViewController {
+ public:
+ // Does not take ownership of the arguments, which should outlive this object.
+ ShippingAddressEditorViewController(PaymentRequestSpec* spec,
+ PaymentRequestState* state,
+ PaymentRequestDialogView* dialog);
+ ~ShippingAddressEditorViewController() override;
+
+ // EditorViewController:
+ std::unique_ptr<views::View> CreateHeaderView() override;
+ int GetViewHeaderTitleId() const override;
+ std::vector<EditorField> GetFieldDefinitions() override;
+ bool ValidateModelAndSave() override;
+ std::unique_ptr<ValidationDelegate> CreateValidationDelegate(
+ const EditorField& field) override;
+ std::unique_ptr<ui::ComboboxModel> GetComboboxModelForType(
+ const autofill::ServerFieldType& type) override;
+ void OnPerformAction(views::Combobox* combobox) override;
+ void UpdateEditorView() override;
+
+ private:
+ class ShippingAddressValidationDelegate : public ValidationDelegate {
+ public:
+ ShippingAddressValidationDelegate(
+ ShippingAddressEditorViewController* parent,
+ const EditorField& field);
+ ~ShippingAddressValidationDelegate() override;
+
+ // ValidationDelegate:
+ bool ValidateTextfield(views::Textfield* textfield) override;
+ bool ValidateCombobox(views::Combobox* combobox) override;
+
+ private:
+ bool ValidateValue(const base::string16& value);
+
+ EditorField field_;
+ // TODO(mad): Bring back when needed.
+ // ShippingAddressEditorViewController* parent_{nullptr};
+
+ DISALLOW_COPY_AND_ASSIGN(ShippingAddressValidationDelegate);
+ };
+ friend class ShippingAddressValidationDelegate;
+
+ // List of fields, reset everytime the current country changes.
+ std::vector<EditorField> editor_fields_;
+
+ // The currently chosen country. Defaults to 0 as the first entry in the
+ // combobox, which is the generated default value received from
+ // autofill::CountryComboboxModel::countries() which is documented to always
+ // have the default country at the top as well as within the sorted list.
+ size_t chosen_country_index_{0};
+
+ // The list of country codes as ordered in the country combobox model.
+ std::vector<std::string> country_codes_;
+
+ // Updates |editor_fields_| based on the current country.
+ void UpdateEditorFields();
+
+ // Called by the validation delegate when the country combobox changed.
+ void OnCountryChanged(views::Combobox* combobox);
+
+ DISALLOW_COPY_AND_ASSIGN(ShippingAddressEditorViewController);
+};
+
+} // namespace payments
+
+#endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_SHIPPING_ADDRESS_EDITOR_VIEW_CONTROLLER_H_

Powered by Google App Engine
This is Rietveld 408576698