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

Side by Side Diff: chrome/browser/ui/autofill/autofill_dialog_controller.h

Issue 11743036: requestAutocomplete: change comboboxes to dropdown menus (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: isherman review Created 7 years, 11 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_AUTOFILL_AUTOFILL_DIALOG_CONTROLLER_H_ 5 #ifndef CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_CONTROLLER_H_
6 #define CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_CONTROLLER_H_ 6 #define CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_CONTROLLER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <utility> 10 #include <utility>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/callback.h" 13 #include "base/callback.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "base/string16.h" 15 #include "base/string16.h"
16 #include "chrome/browser/autofill/field_types.h" 16 #include "chrome/browser/autofill/field_types.h"
17 #include "chrome/browser/autofill/form_structure.h" 17 #include "chrome/browser/autofill/form_structure.h"
18 #include "chrome/browser/autofill/personal_data_manager.h" 18 #include "chrome/browser/autofill/personal_data_manager.h"
19 #include "chrome/browser/ui/autofill/autofill_dialog_comboboxes.h" 19 #include "chrome/browser/ui/autofill/autofill_dialog_models.h"
20 #include "chrome/browser/ui/autofill/autofill_popup_controller_impl.h" 20 #include "chrome/browser/ui/autofill/autofill_popup_controller_impl.h"
21 #include "chrome/browser/ui/autofill/autofill_popup_delegate.h" 21 #include "chrome/browser/ui/autofill/autofill_popup_delegate.h"
22 #include "content/public/common/ssl_status.h" 22 #include "content/public/common/ssl_status.h"
23 #include "ui/base/models/combobox_model.h" 23 #include "ui/base/models/combobox_model.h"
24 #include "ui/base/models/simple_menu_model.h"
24 #include "ui/gfx/native_widget_types.h" 25 #include "ui/gfx/native_widget_types.h"
25 26
26 class AutofillPopupControllerImpl; 27 class AutofillPopupControllerImpl;
27 class FormGroup; 28 class FormGroup;
28 class GURL; 29 class GURL;
29 class Profile; 30 class Profile;
30 31
31 namespace content { 32 namespace content {
32 class WebContents; 33 class WebContents;
33 } 34 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 enum DialogAction { 74 enum DialogAction {
74 ACTION_ABORT, 75 ACTION_ABORT,
75 ACTION_SUBMIT, 76 ACTION_SUBMIT,
76 }; 77 };
77 78
78 typedef std::vector<DetailInput> DetailInputs; 79 typedef std::vector<DetailInput> DetailInputs;
79 typedef std::map<const DetailInput*, string16> DetailOutputMap; 80 typedef std::map<const DetailInput*, string16> DetailOutputMap;
80 81
81 // This class drives the dialog that appears when a site uses the imperative 82 // This class drives the dialog that appears when a site uses the imperative
82 // autocomplete API to fill out a form. 83 // autocomplete API to fill out a form.
83 class AutofillDialogController : public AutofillPopupDelegate { 84 class AutofillDialogController : public AutofillPopupDelegate,
85 public SuggestionsMenuModelDelegate {
84 public: 86 public:
85 AutofillDialogController( 87 AutofillDialogController(
86 content::WebContents* contents, 88 content::WebContents* contents,
87 const FormData& form_structure, 89 const FormData& form_structure,
88 const GURL& source_url, 90 const GURL& source_url,
89 const content::SSLStatus& ssl_status, 91 const content::SSLStatus& ssl_status,
90 const base::Callback<void(const FormStructure*)>& callback); 92 const base::Callback<void(const FormStructure*)>& callback);
91 virtual ~AutofillDialogController(); 93 virtual ~AutofillDialogController();
92 94
93 void Show(); 95 void Show();
94 96
95 // Called by the view. 97 // Called by the view.
96 string16 DialogTitle() const; 98 string16 DialogTitle() const;
97 string16 SecurityWarning() const; 99 string16 SecurityWarning() const;
98 string16 SiteLabel() const; 100 string16 SiteLabel() const;
99 string16 IntroText() const; 101 string16 IntroText() const;
100 // Returns the text before and after |SiteLabel()| in |IntroText()|. This is 102 // Returns the text before and after |SiteLabel()| in |IntroText()|. This is
101 // needed because views need to bold just part of a translation. 103 // needed because views need to bold just part of a translation.
102 std::pair<string16, string16> GetIntroTextParts() const; 104 std::pair<string16, string16> GetIntroTextParts() const;
103 string16 LabelForSection(DialogSection section) const; 105 string16 LabelForSection(DialogSection section) const;
104 string16 UseBillingForShippingText() const; 106 string16 UseBillingForShippingText() const;
105 string16 WalletOptionText() const; 107 string16 WalletOptionText() const;
106 string16 CancelButtonText() const; 108 string16 CancelButtonText() const;
107 string16 ConfirmButtonText() const; 109 string16 ConfirmButtonText() const;
108 bool ConfirmButtonEnabled() const; 110 bool ConfirmButtonEnabled() const;
109 // Returns the set of inputs the page has requested which fall under 111 // Returns the set of inputs the page has requested which fall under
110 // |section|. 112 // |section|.
111 const DetailInputs& RequestedFieldsForSection(DialogSection section) const; 113 const DetailInputs& RequestedFieldsForSection(DialogSection section) const;
114 // Returns the combobox model for inputs of type |type|, or NULL if the input
115 // should be a text field.
112 ui::ComboboxModel* ComboboxModelForAutofillType(AutofillFieldType type); 116 ui::ComboboxModel* ComboboxModelForAutofillType(AutofillFieldType type);
113 // Returns the model for suggestions for fields that fall under |section|. 117 // Returns the model for suggestions for fields that fall under |section|.
114 ui::ComboboxModel* ComboboxModelForSection(DialogSection section); 118 ui::MenuModel* MenuModelForSection(DialogSection section);
119 string16 SuggestionTextForSection(DialogSection section);
115 120
116 // Called when the view has been closed. The value for |action| indicates 121 // Called when the view has been closed. The value for |action| indicates
117 // whether the Autofill operation should be aborted. 122 // whether the Autofill operation should be aborted.
118 void ViewClosed(DialogAction action); 123 void ViewClosed(DialogAction action);
119 124
120 // Called by the view when the user changes the contents of a text field. 125 // Called by the view when the user changes the contents of a text field.
121 void UserEditedInput(const DetailInput* input, 126 void UserEditedInput(const DetailInput* input,
122 gfx::NativeView view, 127 gfx::NativeView view,
123 const gfx::Rect& content_bounds, 128 const gfx::Rect& content_bounds,
124 const string16& field_contents); 129 const string16& field_contents);
125 130
126 // Called when focus has changed position within the view. 131 // Called when focus has changed position within the view.
127 void FocusMoved(); 132 void FocusMoved();
128 133
129 // AutofillPopupDelegate implementation. 134 // AutofillPopupDelegate implementation.
130 virtual void DidSelectSuggestion(int identifier) OVERRIDE; 135 virtual void DidSelectSuggestion(int identifier) OVERRIDE;
131 virtual void DidAcceptSuggestion(const string16& value, 136 virtual void DidAcceptSuggestion(const string16& value,
132 int identifier) OVERRIDE; 137 int identifier) OVERRIDE;
133 virtual void RemoveSuggestion(const string16& value, 138 virtual void RemoveSuggestion(const string16& value,
134 int identifier) OVERRIDE; 139 int identifier) OVERRIDE;
135 virtual void ClearPreviewedForm() OVERRIDE; 140 virtual void ClearPreviewedForm() OVERRIDE;
136 virtual void ControllerDestroyed() OVERRIDE; 141 virtual void ControllerDestroyed() OVERRIDE;
137 142
143 // SuggestionsMenuModelDelegate implementation.
144 virtual void SuggestionItemSelected(const SuggestionsMenuModel& model)
145 OVERRIDE;
146
138 content::WebContents* web_contents() { return contents_; } 147 content::WebContents* web_contents() { return contents_; }
139 148
140 private: 149 private:
141 // Determines whether |input| and |field| match. 150 // Determines whether |input| and |field| match.
142 typedef base::Callback<bool(const DetailInput& input, 151 typedef base::Callback<bool(const DetailInput& input,
143 const AutofillField& field)> InputFieldComparator; 152 const AutofillField& field)> InputFieldComparator;
144 153
145 // Whether or not the current request wants credit info back. 154 // Whether or not the current request wants credit info back.
146 bool RequestingCreditCardInfo() const; 155 bool RequestingCreditCardInfo() const;
147 156
148 // Whether or not the view should show a security warning. 157 // Whether or not the view should show a security warning.
149 bool ShouldShowSecurityWarning() const; 158 bool ShouldShowSecurityWarning() const;
150 159
151 // Initializes |suggested_email_| et al. 160 // Initializes |suggested_email_| et al.
152 void GenerateComboboxModels(); 161 void GenerateSuggestionsModels();
153 162
154 // Returns whether |profile| is complete, i.e. can fill out all the relevant 163 // Returns whether |profile| is complete, i.e. can fill out all the relevant
155 // address info. Incomplete profiles will not be displayed in the dropdown 164 // address info. Incomplete profiles will not be displayed in the dropdown
156 // menu. 165 // menu.
157 bool IsCompleteProfile(const AutofillProfile& profile); 166 bool IsCompleteProfile(const AutofillProfile& profile);
158 167
159 // Fills in |section|-related fields in |output_| according to the state of 168 // Fills in |section|-related fields in |output_| according to the state of
160 // |view_|. 169 // |view_|.
161 void FillOutputForSection(DialogSection section); 170 void FillOutputForSection(DialogSection section);
162 // As above, but uses |compare| to determine whether a DetailInput matches 171 // As above, but uses |compare| to determine whether a DetailInput matches
163 // a field. 172 // a field.
164 void FillOutputForSectionWithComparator(DialogSection section, 173 void FillOutputForSectionWithComparator(DialogSection section,
165 const InputFieldComparator& compare); 174 const InputFieldComparator& compare);
166 175
167 // Fills in |form_structure_| using |form_group|. Utility method for 176 // Fills in |form_structure_| using |form_group|. Utility method for
168 // FillOutputForSection. 177 // FillOutputForSection.
169 void FillFormStructureForSection(const FormGroup& form_group, 178 void FillFormStructureForSection(const FormGroup& form_group,
170 DialogSection section, 179 DialogSection section,
171 const InputFieldComparator& compare); 180 const InputFieldComparator& compare);
172 181
173 // Gets the SuggestionsComboboxModel for |section|. 182 // Gets the SuggestionsMenuModel for |section|.
174 SuggestionsComboboxModel* SuggestionsModelForSection(DialogSection section); 183 SuggestionsMenuModel* SuggestionsMenuModelForSection(DialogSection section);
184 // And the reverse.
185 DialogSection SectionForSuggestionsMenuModel(
186 const SuggestionsMenuModel& model);
175 187
176 // Loads profiles that can suggest data for |type|. |field_contents| is the 188 // Loads profiles that can suggest data for |type|. |field_contents| is the
177 // part the user has already typed. |inputs| is the rest of section. 189 // part the user has already typed. |inputs| is the rest of section.
178 // Identifying info is loaded into the last three outparams as well as 190 // Identifying info is loaded into the last three outparams as well as
179 // |popup_guids_|. 191 // |popup_guids_|.
180 void GetProfileSuggestions( 192 void GetProfileSuggestions(
181 AutofillFieldType type, 193 AutofillFieldType type,
182 const string16& field_contents, 194 const string16& field_contents,
183 const DetailInputs& inputs, 195 const DetailInputs& inputs,
184 std::vector<string16>* popup_values, 196 std::vector<string16>* popup_values,
(...skipping 23 matching lines...) Expand all
208 DetailInputs requested_email_fields_; 220 DetailInputs requested_email_fields_;
209 DetailInputs requested_cc_fields_; 221 DetailInputs requested_cc_fields_;
210 DetailInputs requested_billing_fields_; 222 DetailInputs requested_billing_fields_;
211 DetailInputs requested_shipping_fields_; 223 DetailInputs requested_shipping_fields_;
212 224
213 // Models for the credit card expiration inputs. 225 // Models for the credit card expiration inputs.
214 MonthComboboxModel cc_exp_month_combobox_model_; 226 MonthComboboxModel cc_exp_month_combobox_model_;
215 YearComboboxModel cc_exp_year_combobox_model_; 227 YearComboboxModel cc_exp_year_combobox_model_;
216 228
217 // Models for the suggestion views. 229 // Models for the suggestion views.
218 SuggestionsComboboxModel suggested_email_; 230 SuggestionsMenuModel suggested_email_;
219 SuggestionsComboboxModel suggested_cc_; 231 SuggestionsMenuModel suggested_cc_;
220 SuggestionsComboboxModel suggested_billing_; 232 SuggestionsMenuModel suggested_billing_;
221 SuggestionsComboboxModel suggested_shipping_; 233 SuggestionsMenuModel suggested_shipping_;
222 234
223 // The GUIDs for the currently showing unverified profiles popup. 235 // The GUIDs for the currently showing unverified profiles popup.
224 std::vector<PersonalDataManager::GUIDPair> popup_guids_; 236 std::vector<PersonalDataManager::GUIDPair> popup_guids_;
225 237
226 AutofillPopupControllerImpl* popup_controller_; 238 AutofillPopupControllerImpl* popup_controller_;
227 239
228 scoped_ptr<AutofillDialogView> view_; 240 scoped_ptr<AutofillDialogView> view_;
229 241
230 DISALLOW_COPY_AND_ASSIGN(AutofillDialogController); 242 DISALLOW_COPY_AND_ASSIGN(AutofillDialogController);
231 }; 243 };
232 244
233 } // namespace autofill 245 } // namespace autofill
234 246
235 #endif // CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_CONTROLLER_H_ 247 #endif // CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_CONTROLLER_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/autofill/autofill_dialog_comboboxes.cc ('k') | chrome/browser/ui/autofill/autofill_dialog_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698