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..88cf074bb20269b34766770ff7d638e143f940fc |
--- /dev/null |
+++ b/chrome/browser/ui/views/payments/shipping_address_editor_view_controller.h |
@@ -0,0 +1,86 @@ |
+// 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: |
+ explicit ShippingAddressValidationDelegate( |
Mathieu
2017/03/21 15:55:25
remove explicit
MAD
2017/03/21 19:28:34
Done.
|
+ ShippingAddressEditorViewController* parent, |
+ const EditorField& field); |
+ ~ShippingAddressValidationDelegate() override; |
+ |
+ // ValidationDelegate: |
+ bool ValidateTextfield(views::Textfield* textfield) override; |
+ bool ValidateCombobox(views::Combobox* combobox) override; |
+ |
+ private: |
+ // Validates a specific |value|. |
Mathieu
2017/03/21 15:55:26
nit: remove obvious comment :)
MAD
2017/03/21 19:28:34
Done.
|
+ bool ValidateValue(const base::string16& value); |
+ |
+ EditorField field_; |
+ ShippingAddressEditorViewController* parent_{nullptr}; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(ShippingAddressValidationDelegate); |
+ }; |
+ friend class ShippingAddressValidationDelegate; |
Mathieu
2017/03/21 15:55:25
Curious, why is this needed?
MAD
2017/03/21 19:28:34
It will be needed once we use the parent to valida
|
+ |
+ // List of fields, reset everytime the current country changes. |
+ std::vector<EditorField> editor_fields_; |
+ |
+ // The currently chosen country. |
Mathieu
2017/03/21 15:55:25
Can you add a comment about what the "0" means. Is
MAD
2017/03/21 19:28:34
Done.
|
+ size_t chosen_country_index_{0}; |
+ |
+ // The list of country codes as ordered in the country combo box model. |
Mathieu
2017/03/21 15:55:25
nit: here and below: "combobox"
MAD
2017/03/21 19:28:34
Done.
|
+ std::vector<std::string> country_codes_; |
+ |
+ // Updates |editor_fields_| based on the current country. |
+ void UpdateEditorFields(); |
+ |
+ // Called by the validation delegate when the country combo box 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_ |