| OLD | NEW |
| 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 "app/gtk_signal.h" | 9 #include "app/gtk_signal.h" |
| 10 #include "app/l10n_util.h" | 10 #include "app/l10n_util.h" |
| (...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 624 base::Time::Exploded exploded_time; | 624 base::Time::Exploded exploded_time; |
| 625 base::Time::Now().LocalExplode(&exploded_time); | 625 base::Time::Now().LocalExplode(&exploded_time); |
| 626 base_year_ = exploded_time.year; | 626 base_year_ = exploded_time.year; |
| 627 | 627 |
| 628 Init(); | 628 Init(); |
| 629 | 629 |
| 630 if (credit_card) { | 630 if (credit_card) { |
| 631 SetWidgetValues(credit_card); | 631 SetWidgetValues(credit_card); |
| 632 } else { | 632 } else { |
| 633 // We're creating a new credit card. Select a default billing address (if | 633 // We're creating a new credit card. Select a default billing address (if |
| 634 // there are any) and select Januay of next year. | 634 // there are any) and select January of next year. |
| 635 PersonalDataManager* data_manager = profile_->GetPersonalDataManager(); | 635 PersonalDataManager* data_manager = profile_->GetPersonalDataManager(); |
| 636 if (!data_manager->profiles().empty()) | 636 if (!data_manager->profiles().empty()) |
| 637 gtk_combo_box_set_active(GTK_COMBO_BOX(address_), 0); | 637 gtk_combo_box_set_active(GTK_COMBO_BOX(address_), 0); |
| 638 gtk_combo_box_set_active(GTK_COMBO_BOX(month_), 0); | 638 gtk_combo_box_set_active(GTK_COMBO_BOX(month_), 0); |
| 639 gtk_combo_box_set_active(GTK_COMBO_BOX(year_), 1); | 639 gtk_combo_box_set_active(GTK_COMBO_BOX(year_), 1); |
| 640 } | 640 } |
| 641 | 641 |
| 642 RegisterForTextChanged(); | 642 RegisterForTextChanged(); |
| 643 | 643 |
| 644 UpdateOkButton(); | 644 UpdateOkButton(); |
| 645 | 645 |
| 646 gtk_util::ShowDialogWithLocalizedSize( | 646 gtk_util::ShowDialogWithLocalizedSize( |
| 647 dialog_, | 647 dialog_, |
| 648 IDS_AUTOFILL_DIALOG_EDIT_CCARD_WIDTH_CHARS, | 648 IDS_AUTOFILL_DIALOG_EDIT_CCARD_WIDTH_CHARS, |
| 649 IDS_AUTOFILL_DIALOG_EDIT_CCARD_HEIGHT_LINES, | 649 IDS_AUTOFILL_DIALOG_EDIT_CCARD_HEIGHT_LINES, |
| 650 true); | 650 true); |
| 651 gtk_util::PresentWindow(dialog_, gtk_get_current_event_time()); | 651 gtk_util::PresentWindow(dialog_, gtk_get_current_event_time()); |
| 652 } | 652 } |
| 653 | 653 |
| 654 GtkListStore* AutoFillCreditCardEditor::CreateAddressStore() { | 654 GtkListStore* AutoFillCreditCardEditor::CreateAddressStore() { |
| 655 GtkListStore* store = | 655 GtkListStore* store = |
| 656 gtk_list_store_new(COL_COUNT, G_TYPE_INT, G_TYPE_STRING); | 656 gtk_list_store_new(COL_COUNT, G_TYPE_INT, G_TYPE_STRING); |
| 657 | 657 |
| 658 GtkTreeIter iter; | 658 GtkTreeIter iter; |
| 659 | 659 |
| 660 PersonalDataManager* data_manager = profile_->GetPersonalDataManager(); | 660 PersonalDataManager* data_manager = profile_->GetPersonalDataManager(); |
| 661 for (std::vector<AutoFillProfile*>::const_iterator i = | 661 for (std::vector<AutoFillProfile*>::const_iterator i = |
| 662 data_manager->profiles().begin(); | 662 data_manager->profiles().begin(); |
| 663 i != data_manager->profiles().end(); ++i) { | 663 i != data_manager->profiles().end(); ++i) { |
| 664 FieldTypeSet fields; |
| 665 (*i)->GetAvailableFieldTypes(&fields); |
| 666 if (fields.find(ADDRESS_HOME_LINE1) == fields.end() && |
| 667 fields.find(ADDRESS_HOME_LINE2) == fields.end() && |
| 668 fields.find(ADDRESS_HOME_APT_NUM) == fields.end() && |
| 669 fields.find(ADDRESS_HOME_CITY) == fields.end() && |
| 670 fields.find(ADDRESS_HOME_STATE) == fields.end() && |
| 671 fields.find(ADDRESS_HOME_ZIP) == fields.end() && |
| 672 fields.find(ADDRESS_HOME_COUNTRY) == fields.end()) { |
| 673 // No address information in this profile; it's useless as a billing |
| 674 // address. |
| 675 continue; |
| 676 } |
| 677 |
| 664 gtk_list_store_append(store, &iter); | 678 gtk_list_store_append(store, &iter); |
| 665 gtk_list_store_set( | 679 gtk_list_store_set( |
| 666 store, &iter, | 680 store, &iter, |
| 667 COL_ID, (*i)->unique_id(), | 681 COL_ID, (*i)->unique_id(), |
| 668 COL_TITLE, UTF16ToUTF8((*i)->PreviewSummary()).c_str(), | 682 COL_TITLE, UTF16ToUTF8((*i)->PreviewSummary()).c_str(), |
| 669 -1); | 683 -1); |
| 670 } | 684 } |
| 671 return store; | 685 return store; |
| 672 } | 686 } |
| 673 | 687 |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 950 new AutoFillProfileEditor(observer, profile, auto_fill_profile); | 964 new AutoFillProfileEditor(observer, profile, auto_fill_profile); |
| 951 } | 965 } |
| 952 | 966 |
| 953 void ShowAutoFillCreditCardEditor(gfx::NativeView parent, | 967 void ShowAutoFillCreditCardEditor(gfx::NativeView parent, |
| 954 AutoFillDialogObserver* observer, | 968 AutoFillDialogObserver* observer, |
| 955 Profile* profile, | 969 Profile* profile, |
| 956 CreditCard* credit_card) { | 970 CreditCard* credit_card) { |
| 957 // AutoFillCreditCardEditor takes care of deleting itself. | 971 // AutoFillCreditCardEditor takes care of deleting itself. |
| 958 new AutoFillCreditCardEditor(observer, profile, credit_card); | 972 new AutoFillCreditCardEditor(observer, profile, credit_card); |
| 959 } | 973 } |
| OLD | NEW |