| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 | 184 |
| 185 // Sets the size request for the widget to match the size of the good/bad | 185 // Sets the size request for the widget to match the size of the good/bad |
| 186 // images. We must do this as the image of the phone widgets is set to null | 186 // images. We must do this as the image of the phone widgets is set to null |
| 187 // when not empty. | 187 // when not empty. |
| 188 void SetPhoneSizeRequest(GtkWidget* widget); | 188 void SetPhoneSizeRequest(GtkWidget* widget); |
| 189 | 189 |
| 190 // Updates the enabled state of the ok button. | 190 // Updates the enabled state of the ok button. |
| 191 void UpdateOkButton(); | 191 void UpdateOkButton(); |
| 192 | 192 |
| 193 CHROMEGTK_CALLBACK_0(AutoFillProfileEditor, void, OnDestroy); | 193 CHROMEGTK_CALLBACK_0(AutoFillProfileEditor, void, OnDestroy); |
| 194 CHROMEG_CALLBACK_1(AutoFillProfileEditor, void, OnResponse, GtkDialog*, gint); | 194 CHROMEGTK_CALLBACK_1(AutoFillProfileEditor, void, OnResponse, int); |
| 195 CHROMEG_CALLBACK_0(AutoFillProfileEditor, void, OnPhoneChanged, GtkEditable*); | 195 CHROMEG_CALLBACK_0(AutoFillProfileEditor, void, OnPhoneChanged, GtkEditable*); |
| 196 CHROMEG_CALLBACK_0(AutoFillProfileEditor, void, OnFaxChanged, GtkEditable*); | 196 CHROMEG_CALLBACK_0(AutoFillProfileEditor, void, OnFaxChanged, GtkEditable*); |
| 197 CHROMEG_CALLBACK_0(AutoFillProfileEditor, void, OnFieldChanged, GtkEditable*); | 197 CHROMEG_CALLBACK_0(AutoFillProfileEditor, void, OnFieldChanged, GtkEditable*); |
| 198 | 198 |
| 199 // Are we creating a new profile? | 199 // Are we creating a new profile? |
| 200 const bool is_new_; | 200 const bool is_new_; |
| 201 | 201 |
| 202 // If is_new_ is false this is the unique id of the profile the user is | 202 // If is_new_ is false this is the unique id of the profile the user is |
| 203 // editing. | 203 // editing. |
| 204 const std::string profile_guid_; | 204 const std::string profile_guid_; |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 485 (!GetEntryText(full_name_).empty() || | 485 (!GetEntryText(full_name_).empty() || |
| 486 !GetEntryText(company_).empty()); | 486 !GetEntryText(company_).empty()); |
| 487 } | 487 } |
| 488 gtk_widget_set_sensitive(ok_button_, valid); | 488 gtk_widget_set_sensitive(ok_button_, valid); |
| 489 } | 489 } |
| 490 | 490 |
| 491 void AutoFillProfileEditor::OnDestroy(GtkWidget* widget) { | 491 void AutoFillProfileEditor::OnDestroy(GtkWidget* widget) { |
| 492 MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 492 MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
| 493 } | 493 } |
| 494 | 494 |
| 495 void AutoFillProfileEditor::OnResponse(GtkDialog* dialog, gint response_id) { | 495 void AutoFillProfileEditor::OnResponse(GtkWidget* dialog, int response_id) { |
| 496 if (response_id == GTK_RESPONSE_APPLY || response_id == GTK_RESPONSE_OK) | 496 if (response_id == GTK_RESPONSE_APPLY || response_id == GTK_RESPONSE_OK) |
| 497 ApplyEdits(); | 497 ApplyEdits(); |
| 498 | 498 |
| 499 if (response_id == GTK_RESPONSE_OK || | 499 if (response_id == GTK_RESPONSE_OK || |
| 500 response_id == GTK_RESPONSE_APPLY || | 500 response_id == GTK_RESPONSE_APPLY || |
| 501 response_id == GTK_RESPONSE_CANCEL || | 501 response_id == GTK_RESPONSE_CANCEL || |
| 502 response_id == GTK_RESPONSE_DELETE_EVENT) { | 502 response_id == GTK_RESPONSE_DELETE_EVENT) { |
| 503 gtk_widget_destroy(GTK_WIDGET(dialog)); | 503 gtk_widget_destroy(dialog); |
| 504 } | 504 } |
| 505 } | 505 } |
| 506 | 506 |
| 507 void AutoFillProfileEditor::OnPhoneChanged(GtkEditable* editable) { | 507 void AutoFillProfileEditor::OnPhoneChanged(GtkEditable* editable) { |
| 508 UpdatePhoneImage(phone_, phone_image_); | 508 UpdatePhoneImage(phone_, phone_image_); |
| 509 } | 509 } |
| 510 | 510 |
| 511 void AutoFillProfileEditor::OnFaxChanged(GtkEditable* editable) { | 511 void AutoFillProfileEditor::OnFaxChanged(GtkEditable* editable) { |
| 512 UpdatePhoneImage(fax_, fax_image_); | 512 UpdatePhoneImage(fax_, fax_image_); |
| 513 } | 513 } |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 550 // Updates the observer with the CreditCard being edited. | 550 // Updates the observer with the CreditCard being edited. |
| 551 void ApplyEdits(); | 551 void ApplyEdits(); |
| 552 | 552 |
| 553 // Updates |card| with the values from the widgets. | 553 // Updates |card| with the values from the widgets. |
| 554 void SetCreditCardValuesFromWidgets(CreditCard* card); | 554 void SetCreditCardValuesFromWidgets(CreditCard* card); |
| 555 | 555 |
| 556 // Updates the enabled state of the ok button. | 556 // Updates the enabled state of the ok button. |
| 557 void UpdateOkButton(); | 557 void UpdateOkButton(); |
| 558 | 558 |
| 559 CHROMEGTK_CALLBACK_0(AutoFillCreditCardEditor, void, OnDestroy); | 559 CHROMEGTK_CALLBACK_0(AutoFillCreditCardEditor, void, OnDestroy); |
| 560 CHROMEG_CALLBACK_1(AutoFillCreditCardEditor, void, OnResponse, GtkDialog*, | 560 CHROMEGTK_CALLBACK_1(AutoFillCreditCardEditor, void, OnResponse, int); |
| 561 gint); | |
| 562 CHROMEG_CALLBACK_0(AutoFillCreditCardEditor, void, OnFieldChanged, | 561 CHROMEG_CALLBACK_0(AutoFillCreditCardEditor, void, OnFieldChanged, |
| 563 GtkEditable*); | 562 GtkEditable*); |
| 564 CHROMEG_CALLBACK_2(AutoFillCreditCardEditor, void, OnDeleteTextFromNumber, | 563 CHROMEG_CALLBACK_2(AutoFillCreditCardEditor, void, OnDeleteTextFromNumber, |
| 565 GtkEditable*, gint, gint); | 564 GtkEditable*, gint, gint); |
| 566 CHROMEG_CALLBACK_3(AutoFillCreditCardEditor, void, OnInsertTextIntoNumber, | 565 CHROMEG_CALLBACK_3(AutoFillCreditCardEditor, void, OnInsertTextIntoNumber, |
| 567 GtkEditable*, gchar*, gint, gint*); | 566 GtkEditable*, gchar*, gint, gint*); |
| 568 | 567 |
| 569 // Are we creating a new credit card? | 568 // Are we creating a new credit card? |
| 570 const bool is_new_; | 569 const bool is_new_; |
| 571 | 570 |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 797 // Enable the ok button if at least one field is non-empty and the phone | 796 // Enable the ok button if at least one field is non-empty and the phone |
| 798 // numbers are valid. | 797 // numbers are valid. |
| 799 bool valid = !GetEntryText(name_).empty() || !GetEntryText(number_).empty(); | 798 bool valid = !GetEntryText(name_).empty() || !GetEntryText(number_).empty(); |
| 800 gtk_widget_set_sensitive(ok_button_, valid); | 799 gtk_widget_set_sensitive(ok_button_, valid); |
| 801 } | 800 } |
| 802 | 801 |
| 803 void AutoFillCreditCardEditor::OnDestroy(GtkWidget* widget) { | 802 void AutoFillCreditCardEditor::OnDestroy(GtkWidget* widget) { |
| 804 MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 803 MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
| 805 } | 804 } |
| 806 | 805 |
| 807 void AutoFillCreditCardEditor::OnResponse(GtkDialog* dialog, gint response_id) { | 806 void AutoFillCreditCardEditor::OnResponse(GtkWidget* dialog, int response_id) { |
| 808 if (response_id == GTK_RESPONSE_APPLY || response_id == GTK_RESPONSE_OK) | 807 if (response_id == GTK_RESPONSE_APPLY || response_id == GTK_RESPONSE_OK) |
| 809 ApplyEdits(); | 808 ApplyEdits(); |
| 810 | 809 |
| 811 if (response_id == GTK_RESPONSE_OK || | 810 if (response_id == GTK_RESPONSE_OK || |
| 812 response_id == GTK_RESPONSE_APPLY || | 811 response_id == GTK_RESPONSE_APPLY || |
| 813 response_id == GTK_RESPONSE_CANCEL || | 812 response_id == GTK_RESPONSE_CANCEL || |
| 814 response_id == GTK_RESPONSE_DELETE_EVENT) { | 813 response_id == GTK_RESPONSE_DELETE_EVENT) { |
| 815 gtk_widget_destroy(GTK_WIDGET(dialog)); | 814 gtk_widget_destroy(dialog); |
| 816 } | 815 } |
| 817 } | 816 } |
| 818 | 817 |
| 819 void AutoFillCreditCardEditor::OnFieldChanged(GtkEditable* editable) { | 818 void AutoFillCreditCardEditor::OnFieldChanged(GtkEditable* editable) { |
| 820 if (editable == GTK_EDITABLE(number_)) | 819 if (editable == GTK_EDITABLE(number_)) |
| 821 edited_number_ = true; | 820 edited_number_ = true; |
| 822 UpdateOkButton(); | 821 UpdateOkButton(); |
| 823 } | 822 } |
| 824 | 823 |
| 825 void AutoFillCreditCardEditor::OnDeleteTextFromNumber(GtkEditable* editable, | 824 void AutoFillCreditCardEditor::OnDeleteTextFromNumber(GtkEditable* editable, |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 867 new AutoFillProfileEditor(observer, profile, auto_fill_profile); | 866 new AutoFillProfileEditor(observer, profile, auto_fill_profile); |
| 868 } | 867 } |
| 869 | 868 |
| 870 void ShowAutoFillCreditCardEditor(gfx::NativeView parent, | 869 void ShowAutoFillCreditCardEditor(gfx::NativeView parent, |
| 871 AutoFillDialogObserver* observer, | 870 AutoFillDialogObserver* observer, |
| 872 Profile* profile, | 871 Profile* profile, |
| 873 CreditCard* credit_card) { | 872 CreditCard* credit_card) { |
| 874 // AutoFillCreditCardEditor takes care of deleting itself. | 873 // AutoFillCreditCardEditor takes care of deleting itself. |
| 875 new AutoFillCreditCardEditor(observer, profile, credit_card); | 874 new AutoFillCreditCardEditor(observer, profile, credit_card); |
| 876 } | 875 } |
| OLD | NEW |