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

Side by Side Diff: chrome/browser/autofill/autofill_dialog_gtk.cc

Issue 555023: Notify the AutoFillManager when the user clicks "Apply" or "OK". Adds an Aut... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 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
« no previous file with comments | « chrome/browser/autofill/autofill_dialog.cc ('k') | chrome/browser/autofill/autofill_manager.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #include "chrome/browser/autofill/autofill_dialog.h" 5 #include "chrome/browser/autofill/autofill_dialog.h"
6 6
7 #include <gtk/gtk.h> 7 #include <gtk/gtk.h>
8 8
9 #include <vector> 9 #include <vector>
10 10
11 #include "app/gfx/gtk_util.h" 11 #include "app/gfx/gtk_util.h"
12 #include "app/l10n_util.h" 12 #include "app/l10n_util.h"
13 #include "base/logging.h"
13 #include "base/message_loop.h" 14 #include "base/message_loop.h"
14 #include "chrome/browser/autofill/autofill_profile.h" 15 #include "chrome/browser/autofill/autofill_profile.h"
16 #include "chrome/browser/autofill/credit_card.h"
15 #include "chrome/browser/autofill/form_group.h" 17 #include "chrome/browser/autofill/form_group.h"
16 #include "chrome/browser/gtk/options/options_layout_gtk.h" 18 #include "chrome/browser/gtk/options/options_layout_gtk.h"
17 #include "chrome/common/gtk_util.h" 19 #include "chrome/common/gtk_util.h"
18 #include "grit/chromium_strings.h" 20 #include "grit/chromium_strings.h"
19 #include "grit/generated_resources.h" 21 #include "grit/generated_resources.h"
20 #include "grit/locale_settings.h" 22 #include "grit/locale_settings.h"
21 23
22 namespace { 24 namespace {
23 25
24 // Style for dialog group titles. 26 // Style for dialog group titles.
25 const char kDialogGroupTitleMarkup[] = "<span weight='bold'>%s</span>"; 27 const char kDialogGroupTitleMarkup[] = "<span weight='bold'>%s</span>";
26 28
27 // How far we indent dialog widgets, in pixels. 29 // How far we indent dialog widgets, in pixels.
28 const int kAutoFillDialogIndent = 5; 30 const int kAutoFillDialogIndent = 5;
29 31
32 // All of these widgets are GtkEntrys except for default_profile, which is a
33 // GtkCheckButton.
34 typedef struct _AddressWidgets {
35 GtkWidget* label;
36 GtkWidget* default_profile;
37 GtkWidget* first_name;
38 GtkWidget* middle_name;
39 GtkWidget* last_name;
40 GtkWidget* email;
41 GtkWidget* company_name;
42 GtkWidget* address_line1;
43 GtkWidget* address_line2;
44 GtkWidget* city;
45 GtkWidget* state;
46 GtkWidget* zipcode;
47 GtkWidget* country;
48 GtkWidget* phone1;
49 GtkWidget* phone2;
50 GtkWidget* phone3;
51 GtkWidget* fax1;
52 GtkWidget* fax2;
53 GtkWidget* fax3;
54 } AddressWidgets;
55
30 // Adds an alignment around |widget| which indents the widget by |offset|. 56 // Adds an alignment around |widget| which indents the widget by |offset|.
31 GtkWidget* IndentWidget(GtkWidget* widget, int offset) { 57 GtkWidget* IndentWidget(GtkWidget* widget, int offset) {
32 GtkWidget* alignment = gtk_alignment_new(0, 0, 0, 0); 58 GtkWidget* alignment = gtk_alignment_new(0, 0, 0, 0);
33 gtk_alignment_set_padding(GTK_ALIGNMENT(alignment), 0, 0, 59 gtk_alignment_set_padding(GTK_ALIGNMENT(alignment), 0, 0,
34 offset, 0); 60 offset, 0);
35 gtk_container_add(GTK_CONTAINER(alignment), widget); 61 gtk_container_add(GTK_CONTAINER(alignment), widget);
36 return alignment; 62 return alignment;
37 } 63 }
38 64
39 // Makes sure we use the gtk theme colors by loading the base color of an entry 65 // Makes sure we use the gtk theme colors by loading the base color of an entry
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 FormTableSetLabel(table, row, col, len, label_id); 151 FormTableSetLabel(table, row, col, len, label_id);
126 152
127 GtkWidget* entry = gtk_entry_new(); 153 GtkWidget* entry = gtk_entry_new();
128 FormTableSetWidget(table, entry, row, col, len, true); 154 FormTableSetWidget(table, entry, row, col, len, true);
129 155
130 return entry; 156 return entry;
131 } 157 }
132 158
133 // Adds a sized entry box to the form table. The entry widget width is set to 159 // Adds a sized entry box to the form table. The entry widget width is set to
134 // |char_len|. 160 // |char_len|.
135 void FormTableAddSizedEntry( 161 GtkWidget* FormTableAddSizedEntry(
136 GtkWidget* table, int row, int col, int char_len, int label_id) { 162 GtkWidget* table, int row, int col, int char_len, int label_id) {
137 GtkWidget* entry = FormTableAddEntry(table, row, col, 1, label_id); 163 GtkWidget* entry = FormTableAddEntry(table, row, col, 1, label_id);
138 gtk_entry_set_width_chars(GTK_ENTRY(entry), char_len); 164 gtk_entry_set_width_chars(GTK_ENTRY(entry), char_len);
165 return entry;
139 } 166 }
140 167
141 // Like FormTableAddEntry, but connects to the 'changed' signal. |changed| is a 168 // Like FormTableAddEntry, but connects to the 'changed' signal. |changed| is a
142 // callback to handle the 'changed' signal that is emitted when the user edits 169 // callback to handle the 'changed' signal that is emitted when the user edits
143 // the entry. |expander| is the expander widget that will be sent to the 170 // the entry. |expander| is the expander widget that will be sent to the
144 // callback as the user data. 171 // callback as the user data.
145 GtkWidget* FormTableAddLabelEntry( 172 GtkWidget* FormTableAddLabelEntry(
146 GtkWidget* table, int row, int col, int len, int label_id, 173 GtkWidget* table, int row, int col, int len, int label_id,
147 GtkWidget* expander, GCallback changed) { 174 GtkWidget* expander, GCallback changed) {
148 FormTableSetLabel(table, row, col, len, label_id); 175 FormTableSetLabel(table, row, col, len, label_id);
149 176
150 GtkWidget* entry = gtk_entry_new(); 177 GtkWidget* entry = gtk_entry_new();
151 g_signal_connect(entry, "changed", changed, expander); 178 g_signal_connect(entry, "changed", changed, expander);
152 FormTableSetWidget(table, entry, row, col, len, false); 179 FormTableSetWidget(table, entry, row, col, len, false);
153 180
154 return entry; 181 return entry;
155 } 182 }
156 183
157 } // namespace 184 } // namespace
158 185
159 //////////////////////////////////////////////////////////////////////////////// 186 ////////////////////////////////////////////////////////////////////////////////
160 // AutoFillDialog 187 // AutoFillDialog
161 // 188 //
162 // The contents of the AutoFill dialog. This dialog allows users to add, edit 189 // The contents of the AutoFill dialog. This dialog allows users to add, edit
163 // and remove AutoFill profiles. 190 // and remove AutoFill profiles.
164 class AutoFillDialog { 191 class AutoFillDialog {
165 public: 192 public:
166 AutoFillDialog(std::vector<AutoFillProfile>* profiles, 193 AutoFillDialog(AutoFillDialogObserver* observer,
167 std::vector<FormGroup>* credit_cards); 194 const std::vector<AutoFillProfile>& profiles,
195 const std::vector<CreditCard>& credit_cards);
168 ~AutoFillDialog() {} 196 ~AutoFillDialog() {}
169 197
170 // Shows the AutoFill dialog. 198 // Shows the AutoFill dialog.
171 void Show(); 199 void Show();
172 200
173 private: 201 private:
174 // 'destroy' signal handler. We DeleteSoon the global singleton dialog object 202 // 'destroy' signal handler. We DeleteSoon the global singleton dialog object
175 // from here. 203 // from here.
176 static void OnDestroy(GtkWidget* widget, AutoFillDialog* autofill_dialog); 204 static void OnDestroy(GtkWidget* widget, AutoFillDialog* autofill_dialog);
177 205
206 // 'response' signal handler. We notify the AutoFillDialogObserver that new
207 // data is available if the response is GTK_RESPONSE_APPLY or GTK_RESPONSE_OK.
208 // We close the dialog if the response is GTK_RESPONSE_OK or
209 // GTK_RESPONSE_CANCEL.
210 static void OnResponse(GtkDialog* dialog, gint response_id,
211 AutoFillDialog* autofill_dialog);
212
178 // 'clicked' signal handler. We add a new address. 213 // 'clicked' signal handler. We add a new address.
179 static void OnAddAddressClicked(GtkButton* button, AutoFillDialog* dialog); 214 static void OnAddAddressClicked(GtkButton* button, AutoFillDialog* dialog);
180 215
181 // 'clicked' signal handler. We add a new credit card. 216 // 'clicked' signal handler. We add a new credit card.
182 static void OnAddCreditCardClicked(GtkButton* button, AutoFillDialog* dialog); 217 static void OnAddCreditCardClicked(GtkButton* button, AutoFillDialog* dialog);
183 218
184 // 'changed' signal handler. We update the title of the expander widget with 219 // 'changed' signal handler. We update the title of the expander widget with
185 // the contents of the label entry widget. 220 // the contents of the label entry widget.
186 static void OnLabelChanged(GtkEntry* label, GtkWidget* expander); 221 static void OnLabelChanged(GtkEntry* label, GtkWidget* expander);
187 222
(...skipping 10 matching lines...) Expand all
198 // expander widget. The content vbox widget is returned in |content_vbox|. 233 // expander widget. The content vbox widget is returned in |content_vbox|.
199 // Returns the expander widget. 234 // Returns the expander widget.
200 GtkWidget* InitGroupContentArea(int name_id, GtkWidget** content_vbox); 235 GtkWidget* InitGroupContentArea(int name_id, GtkWidget** content_vbox);
201 236
202 // Returns a GtkExpander that is added to the appropriate vbox. Each method 237 // Returns a GtkExpander that is added to the appropriate vbox. Each method
203 // adds the necessary widgets and layout required to fill out information 238 // adds the necessary widgets and layout required to fill out information
204 // for either an address or a credit card. 239 // for either an address or a credit card.
205 GtkWidget* AddNewAddress(); 240 GtkWidget* AddNewAddress();
206 GtkWidget* AddNewCreditCard(); 241 GtkWidget* AddNewCreditCard();
207 242
208 // The list of current AutoFill profiles. Owned by AutoFillManager. 243 // The list of current AutoFill profiles.
209 std::vector<AutoFillProfile>* profiles_; 244 std::vector<AutoFillProfile> profiles_;
210 245
211 // The list of current AutoFill credit cards. Owned by AutoFillManager. 246 // The list of current AutoFill credit cards.
212 std::vector<FormGroup>* credit_cards_; 247 std::vector<CreditCard> credit_cards_;
248
249 // The list of address widgets, used to modify the AutoFill profiles.
250 std::vector<AddressWidgets> address_widgets_;
213 251
214 // The AutoFill dialog. 252 // The AutoFill dialog.
215 GtkWidget* dialog_; 253 GtkWidget* dialog_;
216 254
217 // The addresses group. 255 // The addresses group.
218 GtkWidget* addresses_vbox_; 256 GtkWidget* addresses_vbox_;
219 257
220 // The credit cards group. 258 // The credit cards group.
221 GtkWidget* creditcards_vbox_; 259 GtkWidget* creditcards_vbox_;
222 260
261 // Our observer.
262 AutoFillDialogObserver* observer_;
263
223 DISALLOW_COPY_AND_ASSIGN(AutoFillDialog); 264 DISALLOW_COPY_AND_ASSIGN(AutoFillDialog);
224 }; 265 };
225 266
226 // The singleton AutoFill dialog object. 267 // The singleton AutoFill dialog object.
227 static AutoFillDialog* dialog = NULL; 268 static AutoFillDialog* dialog = NULL;
228 269
229 AutoFillDialog::AutoFillDialog(std::vector<AutoFillProfile>* profiles, 270 AutoFillDialog::AutoFillDialog(AutoFillDialogObserver* observer,
230 std::vector<FormGroup>* credit_cards) 271 const std::vector<AutoFillProfile>& profiles,
272 const std::vector<CreditCard>& credit_cards)
231 : profiles_(profiles), 273 : profiles_(profiles),
232 credit_cards_(credit_cards) { 274 credit_cards_(credit_cards),
275 observer_(observer) {
276 DCHECK(observer);
277
233 dialog_ = gtk_dialog_new_with_buttons( 278 dialog_ = gtk_dialog_new_with_buttons(
234 l10n_util::GetStringUTF8(IDS_AUTOFILL_DIALOG_TITLE).c_str(), 279 l10n_util::GetStringUTF8(IDS_AUTOFILL_DIALOG_TITLE).c_str(),
235 // AutoFill dialog is shared between all browser windows. 280 // AutoFill dialog is shared between all browser windows.
236 NULL, 281 NULL,
237 // Non-modal. 282 // Non-modal.
238 GTK_DIALOG_NO_SEPARATOR, 283 GTK_DIALOG_NO_SEPARATOR,
239 GTK_STOCK_APPLY, 284 GTK_STOCK_APPLY,
240 GTK_RESPONSE_APPLY, 285 GTK_RESPONSE_APPLY,
241 GTK_STOCK_CANCEL, 286 GTK_STOCK_CANCEL,
242 GTK_RESPONSE_CANCEL, 287 GTK_RESPONSE_CANCEL,
243 GTK_STOCK_OK, 288 GTK_STOCK_OK,
244 GTK_RESPONSE_OK, 289 GTK_RESPONSE_OK,
245 NULL); 290 NULL);
246 291
247 gtk_widget_realize(dialog_); 292 gtk_widget_realize(dialog_);
248 gtk_util::SetWindowSizeFromResources(GTK_WINDOW(dialog_), 293 gtk_util::SetWindowSizeFromResources(GTK_WINDOW(dialog_),
249 IDS_AUTOFILL_DIALOG_WIDTH_CHARS, 294 IDS_AUTOFILL_DIALOG_WIDTH_CHARS,
250 IDS_AUTOFILL_DIALOG_HEIGHT_LINES, 295 IDS_AUTOFILL_DIALOG_HEIGHT_LINES,
251 true); 296 true);
252 297
253 // Allow browser windows to go in front of the AutoFill dialog in Metacity. 298 // Allow browser windows to go in front of the AutoFill dialog in Metacity.
254 gtk_window_set_type_hint(GTK_WINDOW(dialog_), GDK_WINDOW_TYPE_HINT_NORMAL); 299 gtk_window_set_type_hint(GTK_WINDOW(dialog_), GDK_WINDOW_TYPE_HINT_NORMAL);
255 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(dialog_)->vbox), 300 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(dialog_)->vbox),
256 gtk_util::kContentAreaSpacing); 301 gtk_util::kContentAreaSpacing);
257 g_signal_connect(dialog_, "response", G_CALLBACK(gtk_widget_destroy), NULL); 302 g_signal_connect(dialog_, "response", G_CALLBACK(OnResponse), this);
258 g_signal_connect(dialog_, "destroy", G_CALLBACK(OnDestroy), this); 303 g_signal_connect(dialog_, "destroy", G_CALLBACK(OnDestroy), this);
259 304
260 // Allow the contents to be scrolled. 305 // Allow the contents to be scrolled.
261 GtkWidget* scrolled_window = gtk_scrolled_window_new(NULL, NULL); 306 GtkWidget* scrolled_window = gtk_scrolled_window_new(NULL, NULL);
262 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window), 307 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window),
263 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); 308 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
264 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog_)->vbox), scrolled_window); 309 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog_)->vbox), scrolled_window);
265 310
266 // We create an event box so that we can color the frame background white. 311 // We create an event box so that we can color the frame background white.
267 GtkWidget* frame_event_box = gtk_event_box_new(); 312 GtkWidget* frame_event_box = gtk_event_box_new();
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 gtk_get_current_event_time()); 345 gtk_get_current_event_time());
301 } 346 }
302 347
303 // static 348 // static
304 void AutoFillDialog::OnDestroy(GtkWidget* widget, 349 void AutoFillDialog::OnDestroy(GtkWidget* widget,
305 AutoFillDialog* autofill_dialog) { 350 AutoFillDialog* autofill_dialog) {
306 dialog = NULL; 351 dialog = NULL;
307 MessageLoop::current()->DeleteSoon(FROM_HERE, autofill_dialog); 352 MessageLoop::current()->DeleteSoon(FROM_HERE, autofill_dialog);
308 } 353 }
309 354
355 static string16 GetEntryText(GtkWidget* entry) {
356 return UTF8ToUTF16(gtk_entry_get_text(GTK_ENTRY(entry)));
357 }
358
359 static AutoFillProfile AutoFillProfileFromWidgetValues(
360 const AddressWidgets& widgets) {
361 // TODO(jhawkins): unique id?
362 AutoFillProfile profile(GetEntryText(widgets.label), 0);
363 profile.SetInfo(AutoFillType(NAME_FIRST),
364 GetEntryText(widgets.first_name));
365 profile.SetInfo(AutoFillType(NAME_MIDDLE),
366 GetEntryText(widgets.middle_name));
367 profile.SetInfo(AutoFillType(NAME_LAST),
368 GetEntryText(widgets.last_name));
369 profile.SetInfo(AutoFillType(EMAIL_ADDRESS),
370 GetEntryText(widgets.email));
371 profile.SetInfo(AutoFillType(COMPANY_NAME),
372 GetEntryText(widgets.company_name));
373 profile.SetInfo(AutoFillType(ADDRESS_HOME_LINE1),
374 GetEntryText(widgets.address_line1));
375 profile.SetInfo(AutoFillType(ADDRESS_HOME_LINE2),
376 GetEntryText(widgets.address_line2));
377 profile.SetInfo(AutoFillType(ADDRESS_HOME_CITY),
378 GetEntryText(widgets.city));
379 profile.SetInfo(AutoFillType(ADDRESS_HOME_STATE),
380 GetEntryText(widgets.state));
381 profile.SetInfo(AutoFillType(ADDRESS_HOME_ZIP),
382 GetEntryText(widgets.zipcode));
383 profile.SetInfo(AutoFillType(ADDRESS_HOME_COUNTRY),
384 GetEntryText(widgets.country));
385 profile.SetInfo(AutoFillType(PHONE_HOME_COUNTRY_CODE),
386 GetEntryText(widgets.phone1));
387 profile.SetInfo(AutoFillType(PHONE_HOME_CITY_CODE),
388 GetEntryText(widgets.phone2));
389 profile.SetInfo(AutoFillType(PHONE_HOME_NUMBER),
390 GetEntryText(widgets.phone3));
391 profile.SetInfo(AutoFillType(PHONE_FAX_COUNTRY_CODE),
392 GetEntryText(widgets.fax1));
393 profile.SetInfo(AutoFillType(PHONE_FAX_CITY_CODE),
394 GetEntryText(widgets.fax2));
395 profile.SetInfo(AutoFillType(PHONE_FAX_NUMBER),
396 GetEntryText(widgets.fax3));
397 return profile;
398 }
399
400 // static
401 void AutoFillDialog::OnResponse(GtkDialog* dialog, gint response_id,
402 AutoFillDialog* autofill_dialog) {
403 if (response_id == GTK_RESPONSE_APPLY || response_id == GTK_RESPONSE_OK) {
404 autofill_dialog->profiles_.clear();
405 std::vector<AddressWidgets>::const_iterator iter;
406 for (iter = autofill_dialog->address_widgets_.begin();
407 iter != autofill_dialog->address_widgets_.end();
408 ++iter) {
409 autofill_dialog->profiles_.push_back(
410 AutoFillProfileFromWidgetValues(*iter));
411 }
412
413 autofill_dialog->observer_->OnAutoFillDialogApply(
414 autofill_dialog->profiles_, autofill_dialog->credit_cards_);
415 }
416
417 if (response_id == GTK_RESPONSE_OK || response_id == GTK_RESPONSE_CANCEL) {
418 gtk_widget_destroy(GTK_WIDGET(dialog));
419 }
420 }
421
310 // static 422 // static
311 void AutoFillDialog::OnAddAddressClicked(GtkButton* button, 423 void AutoFillDialog::OnAddAddressClicked(GtkButton* button,
312 AutoFillDialog* dialog) { 424 AutoFillDialog* dialog) {
313 GtkWidget* new_address = dialog->AddNewAddress(); 425 GtkWidget* new_address = dialog->AddNewAddress();
314 gtk_box_pack_start(GTK_BOX(dialog->addresses_vbox_), new_address, 426 gtk_box_pack_start(GTK_BOX(dialog->addresses_vbox_), new_address,
315 FALSE, FALSE, 0); 427 FALSE, FALSE, 0);
316 gtk_widget_show_all(new_address); 428 gtk_widget_show_all(new_address);
317 } 429 }
318 430
319 // static 431 // static
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 gtk_container_add(GTK_CONTAINER(frame), vbox_alignment); 493 gtk_container_add(GTK_CONTAINER(frame), vbox_alignment);
382 494
383 // Make it expand by default. 495 // Make it expand by default.
384 gtk_expander_set_expanded(GTK_EXPANDER(expander), true); 496 gtk_expander_set_expanded(GTK_EXPANDER(expander), true);
385 497
386 *content_vbox = vbox; 498 *content_vbox = vbox;
387 return expander; 499 return expander;
388 } 500 }
389 501
390 GtkWidget* AutoFillDialog::AddNewAddress() { 502 GtkWidget* AutoFillDialog::AddNewAddress() {
503 AddressWidgets widgets = {0};
391 GtkWidget* vbox; 504 GtkWidget* vbox;
392 GtkWidget* address = InitGroupContentArea(IDS_AUTOFILL_NEW_ADDRESS, &vbox); 505 GtkWidget* address = InitGroupContentArea(IDS_AUTOFILL_NEW_ADDRESS, &vbox);
393 506
394 GtkWidget* table = InitFormTable(5, 3); 507 GtkWidget* table = InitFormTable(5, 3);
395 gtk_box_pack_start_defaults(GTK_BOX(vbox), table); 508 gtk_box_pack_start_defaults(GTK_BOX(vbox), table);
396 509
397 FormTableAddLabelEntry(table, 0, 0, 1, IDS_AUTOFILL_DIALOG_LABEL, 510 widgets.label = FormTableAddLabelEntry(table, 0, 0, 1,
398 address, G_CALLBACK(OnLabelChanged)); 511 IDS_AUTOFILL_DIALOG_LABEL,
399 FormTableAddEntry(table, 1, 0, 1, IDS_AUTOFILL_DIALOG_FIRST_NAME); 512 address, G_CALLBACK(OnLabelChanged));
400 FormTableAddEntry(table, 1, 1, 1, IDS_AUTOFILL_DIALOG_MIDDLE_NAME); 513 widgets.first_name = FormTableAddEntry(table, 1, 0, 1,
401 FormTableAddEntry(table, 1, 2, 1, IDS_AUTOFILL_DIALOG_LAST_NAME); 514 IDS_AUTOFILL_DIALOG_FIRST_NAME);
402 FormTableAddEntry(table, 2, 0, 1, IDS_AUTOFILL_DIALOG_EMAIL); 515 widgets.middle_name = FormTableAddEntry(table, 1, 1, 1,
403 FormTableAddEntry(table, 2, 1, 1, IDS_AUTOFILL_DIALOG_COMPANY_NAME); 516 IDS_AUTOFILL_DIALOG_MIDDLE_NAME);
404 FormTableAddEntry(table, 3, 0, 2, IDS_AUTOFILL_DIALOG_ADDRESS_LINE_1); 517 widgets.last_name = FormTableAddEntry(table, 1, 2, 1,
405 FormTableAddEntry(table, 4, 0, 2, IDS_AUTOFILL_DIALOG_ADDRESS_LINE_2); 518 IDS_AUTOFILL_DIALOG_LAST_NAME);
519 widgets.email = FormTableAddEntry(table, 2, 0, 1,
520 IDS_AUTOFILL_DIALOG_EMAIL);
521 widgets.company_name = FormTableAddEntry(table, 2, 1, 1,
522 IDS_AUTOFILL_DIALOG_COMPANY_NAME);
523 widgets.address_line1 = FormTableAddEntry(table, 3, 0, 2,
524 IDS_AUTOFILL_DIALOG_ADDRESS_LINE_1);
525 widgets.address_line2 = FormTableAddEntry(table, 4, 0, 2,
526 IDS_AUTOFILL_DIALOG_ADDRESS_LINE_2);
406 527
407 // TODO(jhawkins): If there's not a default profile, automatically check this 528 // TODO(jhawkins): If there's not a default profile, automatically check this
408 // check button. 529 // check button.
409 GtkWidget* default_check = gtk_check_button_new_with_label( 530 GtkWidget* default_check = gtk_check_button_new_with_label(
410 l10n_util::GetStringUTF8(IDS_AUTOFILL_DIALOG_MAKE_DEFAULT).c_str()); 531 l10n_util::GetStringUTF8(IDS_AUTOFILL_DIALOG_MAKE_DEFAULT).c_str());
532 widgets.default_profile = default_check;
411 FormTableSetWidget(table, default_check, 0, 1, 1, false); 533 FormTableSetWidget(table, default_check, 0, 1, 1, false);
412 534
413 GtkWidget* address_table = InitFormTable(1, 4); 535 GtkWidget* address_table = InitFormTable(1, 4);
414 gtk_box_pack_start_defaults(GTK_BOX(vbox), address_table); 536 gtk_box_pack_start_defaults(GTK_BOX(vbox), address_table);
415 537
416 FormTableAddEntry(address_table, 0, 0, 1, IDS_AUTOFILL_DIALOG_CITY); 538 widgets.city = FormTableAddEntry(address_table, 0, 0, 1,
417 FormTableAddEntry(address_table, 0, 1, 1, IDS_AUTOFILL_DIALOG_STATE); 539 IDS_AUTOFILL_DIALOG_CITY);
418 FormTableAddSizedEntry(address_table, 0, 2, 7, IDS_AUTOFILL_DIALOG_ZIP_CODE); 540 widgets.state = FormTableAddEntry(address_table, 0, 1, 1,
419 FormTableAddSizedEntry(address_table, 0, 3, 10, IDS_AUTOFILL_DIALOG_COUNTRY); 541 IDS_AUTOFILL_DIALOG_STATE);
542 widgets.zipcode = FormTableAddSizedEntry(address_table, 0, 2, 7,
543 IDS_AUTOFILL_DIALOG_ZIP_CODE);
544 widgets.country = FormTableAddSizedEntry(address_table, 0, 3, 10,
545 IDS_AUTOFILL_DIALOG_COUNTRY);
420 546
421 GtkWidget* phone_table = InitFormTable(1, 8); 547 GtkWidget* phone_table = InitFormTable(1, 8);
422 gtk_box_pack_start_defaults(GTK_BOX(vbox), phone_table); 548 gtk_box_pack_start_defaults(GTK_BOX(vbox), phone_table);
423 549
424 FormTableAddSizedEntry(phone_table, 0, 0, 4, IDS_AUTOFILL_DIALOG_PHONE); 550 widgets.phone1 = FormTableAddSizedEntry(phone_table, 0, 0, 4,
425 FormTableAddSizedEntry(phone_table, 0, 1, 4, 0); 551 IDS_AUTOFILL_DIALOG_PHONE);
426 FormTableAddEntry(phone_table, 0, 2, 2, 0); 552 widgets.phone2 = FormTableAddSizedEntry(phone_table, 0, 1, 4, 0);
427 FormTableAddSizedEntry(phone_table, 0, 4, 4, IDS_AUTOFILL_DIALOG_FAX); 553 widgets.phone3 = FormTableAddEntry(phone_table, 0, 2, 2, 0);
428 FormTableAddSizedEntry(phone_table, 0, 5, 4, 0); 554 widgets.fax1 = FormTableAddSizedEntry(phone_table, 0, 4, 4,
429 FormTableAddEntry(phone_table, 0, 6, 2, 0); 555 IDS_AUTOFILL_DIALOG_FAX);
556 widgets.fax2 = FormTableAddSizedEntry(phone_table, 0, 5, 4, 0);
557 widgets.fax3 = FormTableAddEntry(phone_table, 0, 6, 2, 0);
430 558
431 GtkWidget* button = gtk_button_new_with_label( 559 GtkWidget* button = gtk_button_new_with_label(
432 l10n_util::GetStringUTF8(IDS_AUTOFILL_DELETE_BUTTON).c_str()); 560 l10n_util::GetStringUTF8(IDS_AUTOFILL_DELETE_BUTTON).c_str());
433 GtkWidget* alignment = gtk_alignment_new(0, 0, 0, 0); 561 GtkWidget* alignment = gtk_alignment_new(0, 0, 0, 0);
434 gtk_container_add(GTK_CONTAINER(alignment), button); 562 gtk_container_add(GTK_CONTAINER(alignment), button);
435 gtk_box_pack_start_defaults(GTK_BOX(vbox), alignment); 563 gtk_box_pack_start_defaults(GTK_BOX(vbox), alignment);
436 564
565 address_widgets_.push_back(widgets);
437 return address; 566 return address;
438 } 567 }
439 568
440 GtkWidget* AutoFillDialog::AddNewCreditCard() { 569 GtkWidget* AutoFillDialog::AddNewCreditCard() {
441 GtkWidget* vbox; 570 GtkWidget* vbox;
442 GtkWidget* credit_card = InitGroupContentArea(IDS_AUTOFILL_NEW_CREDITCARD, 571 GtkWidget* credit_card = InitGroupContentArea(IDS_AUTOFILL_NEW_CREDITCARD,
443 &vbox); 572 &vbox);
444 573
445 GtkWidget* label_table = InitFormTable(1, 2); 574 GtkWidget* label_table = InitFormTable(1, 2);
446 gtk_box_pack_start_defaults(GTK_BOX(vbox), label_table); 575 gtk_box_pack_start_defaults(GTK_BOX(vbox), label_table);
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 GtkWidget* alignment = gtk_alignment_new(0, 0, 0, 0); 633 GtkWidget* alignment = gtk_alignment_new(0, 0, 0, 0);
505 gtk_container_add(GTK_CONTAINER(alignment), button); 634 gtk_container_add(GTK_CONTAINER(alignment), button);
506 gtk_box_pack_start_defaults(GTK_BOX(vbox), alignment); 635 gtk_box_pack_start_defaults(GTK_BOX(vbox), alignment);
507 636
508 return credit_card; 637 return credit_card;
509 } 638 }
510 639
511 /////////////////////////////////////////////////////////////////////////////// 640 ///////////////////////////////////////////////////////////////////////////////
512 // Factory/finder method: 641 // Factory/finder method:
513 642
514 void ShowAutoFillDialog(std::vector<AutoFillProfile>* profiles, 643 void ShowAutoFillDialog(AutoFillDialogObserver* observer,
515 std::vector<FormGroup>* credit_cards) { 644 const std::vector<AutoFillProfile>& profiles,
645 const std::vector<CreditCard>& credit_cards) {
516 if (!dialog) { 646 if (!dialog) {
517 dialog = new AutoFillDialog(profiles, credit_cards); 647 dialog = new AutoFillDialog(observer, profiles, credit_cards);
518 } 648 }
519 dialog->Show(); 649 dialog->Show();
520 } 650 }
OLDNEW
« no previous file with comments | « chrome/browser/autofill/autofill_dialog.cc ('k') | chrome/browser/autofill/autofill_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698