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

Side by Side Diff: chrome/browser/ui/views/payments/shipping_address_editor_view_controller.h

Issue 2805263003: [Payments] Selecting incomplete items will open editors (Closed)
Patch Set: fix ios test for realz Created 3 years, 8 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
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 #ifndef CHROME_BROWSER_UI_VIEWS_PAYMENTS_SHIPPING_ADDRESS_EDITOR_VIEW_CONTROLLER _H_ 5 #ifndef CHROME_BROWSER_UI_VIEWS_PAYMENTS_SHIPPING_ADDRESS_EDITOR_VIEW_CONTROLLER _H_
6 #define CHROME_BROWSER_UI_VIEWS_PAYMENTS_SHIPPING_ADDRESS_EDITOR_VIEW_CONTROLLER _H_ 6 #define CHROME_BROWSER_UI_VIEWS_PAYMENTS_SHIPPING_ADDRESS_EDITOR_VIEW_CONTROLLER _H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "chrome/browser/ui/views/payments/editor_view_controller.h" 13 #include "chrome/browser/ui/views/payments/editor_view_controller.h"
14 #include "chrome/browser/ui/views/payments/validating_textfield.h" 14 #include "chrome/browser/ui/views/payments/validating_textfield.h"
15 15
16 namespace autofill {
17 class AutofillProfile;
18 } // namespace autofill
19
16 namespace payments { 20 namespace payments {
17 21
18 class PaymentRequestSpec; 22 class PaymentRequestSpec;
19 class PaymentRequestState; 23 class PaymentRequestState;
20 class PaymentRequestDialogView; 24 class PaymentRequestDialogView;
21 25
22 // Shipping Address editor screen of the Payment Request flow. 26 // Shipping Address editor screen of the Payment Request flow.
23 class ShippingAddressEditorViewController : public EditorViewController { 27 class ShippingAddressEditorViewController : public EditorViewController {
24 public: 28 public:
25 // Does not take ownership of the arguments, which should outlive this object. 29 // Does not take ownership of the arguments, which should outlive this object.
26 ShippingAddressEditorViewController(PaymentRequestSpec* spec, 30 ShippingAddressEditorViewController(PaymentRequestSpec* spec,
27 PaymentRequestState* state, 31 PaymentRequestState* state,
28 PaymentRequestDialogView* dialog); 32 PaymentRequestDialogView* dialog,
33 autofill::AutofillProfile* profile);
29 ~ShippingAddressEditorViewController() override; 34 ~ShippingAddressEditorViewController() override;
30 35
31 // EditorViewController: 36 // EditorViewController:
32 std::unique_ptr<views::View> CreateHeaderView() override; 37 std::unique_ptr<views::View> CreateHeaderView() override;
33 std::vector<EditorField> GetFieldDefinitions() override; 38 std::vector<EditorField> GetFieldDefinitions() override;
39 base::string16 GetInitialValueForType(
40 autofill::ServerFieldType type) override;
34 bool ValidateModelAndSave() override; 41 bool ValidateModelAndSave() override;
35 std::unique_ptr<ValidationDelegate> CreateValidationDelegate( 42 std::unique_ptr<ValidationDelegate> CreateValidationDelegate(
36 const EditorField& field) override; 43 const EditorField& field) override;
37 std::unique_ptr<ui::ComboboxModel> GetComboboxModelForType( 44 std::unique_ptr<ui::ComboboxModel> GetComboboxModelForType(
38 const autofill::ServerFieldType& type) override; 45 const autofill::ServerFieldType& type) override;
39 void OnPerformAction(views::Combobox* combobox) override; 46 void OnPerformAction(views::Combobox* combobox) override;
40 void UpdateEditorView() override; 47 void UpdateEditorView() override;
41 48
42 // PaymentRequestSheetController: 49 // PaymentRequestSheetController:
43 base::string16 GetSheetTitle() override; 50 base::string16 GetSheetTitle() override;
(...skipping 14 matching lines...) Expand all
58 bool ValidateValue(const base::string16& value); 65 bool ValidateValue(const base::string16& value);
59 66
60 EditorField field_; 67 EditorField field_;
61 // Raw pointer back to the owner of this class, therefore will not be null. 68 // Raw pointer back to the owner of this class, therefore will not be null.
62 ShippingAddressEditorViewController* controller_; 69 ShippingAddressEditorViewController* controller_;
63 70
64 DISALLOW_COPY_AND_ASSIGN(ShippingAddressValidationDelegate); 71 DISALLOW_COPY_AND_ASSIGN(ShippingAddressValidationDelegate);
65 }; 72 };
66 friend class ShippingAddressValidationDelegate; 73 friend class ShippingAddressValidationDelegate;
67 74
75 // If non-nullptr, a point to an object to be edited, which should outlive
76 // this controller.
77 autofill::AutofillProfile* profile_to_edit_;
78
68 // List of fields, reset everytime the current country changes. 79 // List of fields, reset everytime the current country changes.
69 std::vector<EditorField> editor_fields_; 80 std::vector<EditorField> editor_fields_;
70 81
71 // The currently chosen country. Defaults to 0 as the first entry in the 82 // The currently chosen country. Defaults to 0 as the first entry in the
72 // combobox, which is the generated default value received from 83 // combobox, which is the generated default value received from
73 // autofill::CountryComboboxModel::countries() which is documented to always 84 // autofill::CountryComboboxModel::countries() which is documented to always
74 // have the default country at the top as well as within the sorted list. 85 // have the default country at the top as well as within the sorted list.
75 size_t chosen_country_index_{0}; 86 size_t chosen_country_index_{0};
76 87
77 // The list of country codes as ordered in the country combobox model. 88 // The list of country codes as ordered in the country combobox model.
78 std::vector<std::string> country_codes_; 89 std::vector<std::string> country_codes_;
79 90
80 // Updates |editor_fields_| based on the current country. 91 // Updates |editor_fields_| based on the current country.
81 void UpdateEditorFields(); 92 void UpdateEditorFields();
82 93
83 // Called by the validation delegate when the country combobox changed. 94 // Called by the validation delegate when the country combobox changed.
84 void OnCountryChanged(views::Combobox* combobox); 95 void OnCountryChanged(views::Combobox* combobox);
85 96
86 DISALLOW_COPY_AND_ASSIGN(ShippingAddressEditorViewController); 97 DISALLOW_COPY_AND_ASSIGN(ShippingAddressEditorViewController);
87 }; 98 };
88 99
89 } // namespace payments 100 } // namespace payments
90 101
91 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_SHIPPING_ADDRESS_EDITOR_VIEW_CONTROL LER_H_ 102 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_SHIPPING_ADDRESS_EDITOR_VIEW_CONTROL LER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698