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/ui/views/autofill_profiles_view_win.h" | 5 #include "chrome/browser/ui/views/autofill_profiles_view_win.h" |
6 | 6 |
7 #include <vsstyle.h> | 7 #include <vsstyle.h> |
8 #include <vssym32.h> | 8 #include <vssym32.h> |
9 | 9 |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 833 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
844 // AutofillProfilesView::EditableSetViewContents, | 844 // AutofillProfilesView::EditableSetViewContents, |
845 // views::TextfieldController implementations: | 845 // views::TextfieldController implementations: |
846 void AutofillProfilesView::EditableSetViewContents::ContentsChanged( | 846 void AutofillProfilesView::EditableSetViewContents::ContentsChanged( |
847 views::Textfield* sender, const string16& new_contents) { | 847 views::Textfield* sender, const string16& new_contents) { |
848 if (temporary_info_.is_address) { | 848 if (temporary_info_.is_address) { |
849 for (int field = 0; field < arraysize(address_fields_); ++field) { | 849 for (int field = 0; field < arraysize(address_fields_); ++field) { |
850 DCHECK(text_fields_[address_fields_[field].text_field]); | 850 DCHECK(text_fields_[address_fields_[field].text_field]); |
851 if (text_fields_[address_fields_[field].text_field] == sender) { | 851 if (text_fields_[address_fields_[field].text_field] == sender) { |
852 if (!UpdateContentsPhoneViews(address_fields_[field].text_field, | 852 if (!UpdateContentsPhoneViews(address_fields_[field].text_field, |
853 sender, new_contents)) { | 853 sender, new_contents)) { |
854 temporary_info_.address.SetInfo( | 854 temporary_info_.address.SetInfo(address_fields_[field].type, |
855 AutofillType(address_fields_[field].type), new_contents); | 855 new_contents); |
856 } | 856 } |
857 UpdateButtons(); | 857 UpdateButtons(); |
858 return; | 858 return; |
859 } | 859 } |
860 } | 860 } |
861 } else { | 861 } else { |
862 for (int field = 0; field < arraysize(credit_card_fields_); ++field) { | 862 for (int field = 0; field < arraysize(credit_card_fields_); ++field) { |
863 DCHECK(text_fields_[credit_card_fields_[field].text_field]); | 863 DCHECK(text_fields_[credit_card_fields_[field].text_field]); |
864 if (text_fields_[credit_card_fields_[field].text_field] == sender) { | 864 if (text_fields_[credit_card_fields_[field].text_field] == sender) { |
865 UpdateContentsPhoneViews(address_fields_[field].text_field, | 865 UpdateContentsPhoneViews(address_fields_[field].text_field, |
866 sender, new_contents); | 866 sender, new_contents); |
867 temporary_info_.credit_card.SetInfo( | 867 temporary_info_.credit_card.SetInfo(credit_card_fields_[field].type, |
868 AutofillType(credit_card_fields_[field].type), new_contents); | 868 new_contents); |
869 UpdateButtons(); | 869 UpdateButtons(); |
870 return; | 870 return; |
871 } | 871 } |
872 } | 872 } |
873 } | 873 } |
874 } | 874 } |
875 | 875 |
876 bool AutofillProfilesView::EditableSetViewContents::HandleKeyEvent( | 876 bool AutofillProfilesView::EditableSetViewContents::HandleKeyEvent( |
877 views::Textfield* sender, const views::KeyEvent& key_event) { | 877 views::Textfield* sender, const views::KeyEvent& key_event) { |
878 if (sender == text_fields_[TEXT_CC_NUMBER] && | 878 if (sender == text_fields_[TEXT_CC_NUMBER] && |
879 !has_credit_card_number_been_edited_) { | 879 !has_credit_card_number_been_edited_) { |
880 // You cannot edit obfuscated number, you must retype it anew. | 880 // You cannot edit obfuscated number, you must retype it anew. |
881 sender->SetText(string16()); | 881 sender->SetText(string16()); |
882 has_credit_card_number_been_edited_ = true; | 882 has_credit_card_number_been_edited_ = true; |
883 } | 883 } |
884 return false; | 884 return false; |
885 } | 885 } |
886 | 886 |
887 ///////////////////////////////////////////////////////////////////////////// | 887 ///////////////////////////////////////////////////////////////////////////// |
888 // AutofillProfilesView::EditableSetViewContents, | 888 // AutofillProfilesView::EditableSetViewContents, |
889 // views::Combobox::Listener implementations: | 889 // views::Combobox::Listener implementations: |
890 void AutofillProfilesView::EditableSetViewContents::ItemChanged( | 890 void AutofillProfilesView::EditableSetViewContents::ItemChanged( |
891 views::Combobox* combo_box, int prev_index, int new_index) { | 891 views::Combobox* combo_box, int prev_index, int new_index) { |
892 if (combo_box == combo_box_month_) { | 892 if (combo_box == combo_box_month_) { |
893 if (new_index == -1) { | 893 if (new_index == -1) { |
894 NOTREACHED(); | 894 NOTREACHED(); |
895 } else { | 895 } else { |
896 temporary_info_.credit_card.SetInfo( | 896 temporary_info_.credit_card.SetInfo( |
897 AutofillType(CREDIT_CARD_EXP_MONTH), | 897 CREDIT_CARD_EXP_MONTH, |
898 UTF16ToWideHack(combo_box_model_month_->GetItemAt(new_index))); | 898 UTF16ToWideHack(combo_box_model_month_->GetItemAt(new_index))); |
899 } | 899 } |
900 } else if (combo_box == combo_box_year_) { | 900 } else if (combo_box == combo_box_year_) { |
901 if (new_index == -1) { | 901 if (new_index == -1) { |
902 NOTREACHED(); | 902 NOTREACHED(); |
903 } else { | 903 } else { |
904 temporary_info_.credit_card.SetInfo( | 904 temporary_info_.credit_card.SetInfo( |
905 AutofillType(CREDIT_CARD_EXP_4_DIGIT_YEAR), | 905 CREDIT_CARD_EXP_4_DIGIT_YEAR, |
906 UTF16ToWideHack(combo_box_model_year_->GetItemAt(new_index))); | 906 UTF16ToWideHack(combo_box_model_year_->GetItemAt(new_index))); |
907 } | 907 } |
908 } else { | 908 } else { |
909 NOTREACHED(); | 909 NOTREACHED(); |
910 } | 910 } |
911 } | 911 } |
912 | 912 |
913 ///////////////////////////////////////////////////////////////////////////// | 913 ///////////////////////////////////////////////////////////////////////////// |
914 // AutofillProfilesView::EditableSetViewContents, private: | 914 // AutofillProfilesView::EditableSetViewContents, private: |
915 void AutofillProfilesView::EditableSetViewContents::InitAddressFields( | 915 void AutofillProfilesView::EditableSetViewContents::InitAddressFields( |
916 views::GridLayout* layout) { | 916 views::GridLayout* layout) { |
917 DCHECK(temporary_info_.is_address); | 917 DCHECK(temporary_info_.is_address); |
918 | 918 |
919 for (int field = 0; field < arraysize(address_fields_); ++field) { | 919 for (int field = 0; field < arraysize(address_fields_); ++field) { |
920 DCHECK(!text_fields_[address_fields_[field].text_field]); | 920 DCHECK(!text_fields_[address_fields_[field].text_field]); |
921 text_fields_[address_fields_[field].text_field] = | 921 text_fields_[address_fields_[field].text_field] = |
922 new views::Textfield(views::Textfield::STYLE_DEFAULT); | 922 new views::Textfield(views::Textfield::STYLE_DEFAULT); |
923 text_fields_[address_fields_[field].text_field]->SetController(this); | 923 text_fields_[address_fields_[field].text_field]->SetController(this); |
924 text_fields_[address_fields_[field].text_field]->SetText( | 924 text_fields_[address_fields_[field].text_field]->SetText( |
925 temporary_info_.address.GetFieldText( | 925 temporary_info_.address.GetFieldText(address_fields_[field].type)); |
926 AutofillType(address_fields_[field].type))); | |
927 } | 926 } |
928 | 927 |
929 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 928 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
930 layout->StartRow(0, double_column_fill_view_set_id_); | 929 layout->StartRow(0, double_column_fill_view_set_id_); |
931 layout->AddView(CreateLeftAlignedLabel(IDS_AUTOFILL_DIALOG_FULL_NAME)); | 930 layout->AddView(CreateLeftAlignedLabel(IDS_AUTOFILL_DIALOG_FULL_NAME)); |
932 | 931 |
933 layout->StartRow(0, double_column_fill_view_set_id_); | 932 layout->StartRow(0, double_column_fill_view_set_id_); |
934 layout->AddView(text_fields_[TEXT_FULL_NAME]); | 933 layout->AddView(text_fields_[TEXT_FULL_NAME]); |
935 | 934 |
936 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 935 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1030 combo_box_model_year_->set_cb_strings(&model_strings); | 1029 combo_box_model_year_->set_cb_strings(&model_strings); |
1031 | 1030 |
1032 for (int field = 0; field < arraysize(credit_card_fields_); ++field) { | 1031 for (int field = 0; field < arraysize(credit_card_fields_); ++field) { |
1033 DCHECK(!text_fields_[credit_card_fields_[field].text_field]); | 1032 DCHECK(!text_fields_[credit_card_fields_[field].text_field]); |
1034 text_fields_[credit_card_fields_[field].text_field] = | 1033 text_fields_[credit_card_fields_[field].text_field] = |
1035 new views::Textfield(views::Textfield::STYLE_DEFAULT); | 1034 new views::Textfield(views::Textfield::STYLE_DEFAULT); |
1036 text_fields_[credit_card_fields_[field].text_field]->SetController(this); | 1035 text_fields_[credit_card_fields_[field].text_field]->SetController(this); |
1037 string16 field_text; | 1036 string16 field_text; |
1038 if (credit_card_fields_[field].text_field == TEXT_CC_NUMBER) { | 1037 if (credit_card_fields_[field].text_field == TEXT_CC_NUMBER) { |
1039 field_text = temporary_info_.credit_card.GetFieldText( | 1038 field_text = temporary_info_.credit_card.GetFieldText( |
1040 AutofillType(credit_card_fields_[field].type)); | 1039 credit_card_fields_[field].type); |
1041 if (!field_text.empty()) | 1040 if (!field_text.empty()) |
1042 field_text = temporary_info_.credit_card.ObfuscatedNumber(); | 1041 field_text = temporary_info_.credit_card.ObfuscatedNumber(); |
1043 } else { | 1042 } else { |
1044 field_text = temporary_info_.credit_card.GetFieldText( | 1043 field_text = temporary_info_.credit_card.GetFieldText( |
1045 AutofillType(credit_card_fields_[field].type)); | 1044 credit_card_fields_[field].type); |
1046 } | 1045 } |
1047 text_fields_[credit_card_fields_[field].text_field]->SetText(field_text); | 1046 text_fields_[credit_card_fields_[field].text_field]->SetText(field_text); |
1048 } | 1047 } |
1049 | 1048 |
1050 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 1049 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
1051 layout->StartRow(0, double_column_fill_view_set_id_); | 1050 layout->StartRow(0, double_column_fill_view_set_id_); |
1052 layout->AddView(CreateLeftAlignedLabel(IDS_AUTOFILL_DIALOG_NAME_ON_CARD)); | 1051 layout->AddView(CreateLeftAlignedLabel(IDS_AUTOFILL_DIALOG_NAME_ON_CARD)); |
1053 layout->StartRow(0, double_column_fill_view_set_id_); | 1052 layout->StartRow(0, double_column_fill_view_set_id_); |
1054 layout->AddView(text_fields_[TEXT_CC_NAME]); | 1053 layout->AddView(text_fields_[TEXT_CC_NAME]); |
1055 | 1054 |
1056 // Layout credit card info | 1055 // Layout credit card info |
1057 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 1056 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
1058 layout->StartRow(0, double_column_ccnumber_cvc_); | 1057 layout->StartRow(0, double_column_ccnumber_cvc_); |
1059 layout->AddView( | 1058 layout->AddView( |
1060 CreateLeftAlignedLabel(IDS_AUTOFILL_DIALOG_CREDIT_CARD_NUMBER)); | 1059 CreateLeftAlignedLabel(IDS_AUTOFILL_DIALOG_CREDIT_CARD_NUMBER)); |
1061 layout->StartRow(0, double_column_ccnumber_cvc_); | 1060 layout->StartRow(0, double_column_ccnumber_cvc_); |
1062 // Number (20 chars), month(2 chars), year (4 chars), cvc (4 chars) | 1061 // Number (20 chars), month(2 chars), year (4 chars), cvc (4 chars) |
1063 text_fields_[TEXT_CC_NUMBER]->set_default_width_in_chars(20); | 1062 text_fields_[TEXT_CC_NUMBER]->set_default_width_in_chars(20); |
1064 layout->AddView(text_fields_[TEXT_CC_NUMBER]); | 1063 layout->AddView(text_fields_[TEXT_CC_NUMBER]); |
1065 | 1064 |
1066 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 1065 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
1067 layout->StartRow(0, double_column_ccexpiration_); | 1066 layout->StartRow(0, double_column_ccexpiration_); |
1068 layout->AddView( | 1067 layout->AddView( |
1069 CreateLeftAlignedLabel(IDS_AUTOFILL_DIALOG_EXPIRATION_DATE), 3, 1); | 1068 CreateLeftAlignedLabel(IDS_AUTOFILL_DIALOG_EXPIRATION_DATE), 3, 1); |
1070 | 1069 |
1071 combo_box_month_ = new views::Combobox(combo_box_model_month_.get()); | 1070 combo_box_month_ = new views::Combobox(combo_box_model_month_.get()); |
1072 combo_box_month_->set_listener(this); | 1071 combo_box_month_->set_listener(this); |
1073 string16 field_text; | 1072 string16 field_text; |
1074 field_text = temporary_info_.credit_card.GetFieldText( | 1073 field_text = temporary_info_.credit_card.GetFieldText(CREDIT_CARD_EXP_MONTH); |
1075 AutofillType(CREDIT_CARD_EXP_MONTH)); | |
1076 combo_box_month_->SetSelectedItem( | 1074 combo_box_month_->SetSelectedItem( |
1077 combo_box_model_month_->GetIndex(field_text)); | 1075 combo_box_model_month_->GetIndex(field_text)); |
1078 | 1076 |
1079 combo_box_year_ = new views::Combobox(combo_box_model_year_.get()); | 1077 combo_box_year_ = new views::Combobox(combo_box_model_year_.get()); |
1080 combo_box_year_->set_listener(this); | 1078 combo_box_year_->set_listener(this); |
1081 field_text = temporary_info_.credit_card.GetFieldText( | 1079 field_text = temporary_info_.credit_card.GetFieldText( |
1082 AutofillType(CREDIT_CARD_EXP_4_DIGIT_YEAR)); | 1080 CREDIT_CARD_EXP_4_DIGIT_YEAR); |
1083 combo_box_year_->SetSelectedItem(combo_box_model_year_->GetIndex(field_text)); | 1081 combo_box_year_->SetSelectedItem(combo_box_model_year_->GetIndex(field_text)); |
1084 | 1082 |
1085 layout->StartRow(0, double_column_ccexpiration_); | 1083 layout->StartRow(0, double_column_ccexpiration_); |
1086 layout->AddView(combo_box_month_); | 1084 layout->AddView(combo_box_month_); |
1087 layout->AddView(combo_box_year_); | 1085 layout->AddView(combo_box_year_); |
1088 | 1086 |
1089 UpdateButtons(); | 1087 UpdateButtons(); |
1090 } | 1088 } |
1091 | 1089 |
1092 void AutofillProfilesView::EditableSetViewContents::InitLayoutGrid( | 1090 void AutofillProfilesView::EditableSetViewContents::InitLayoutGrid( |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1187 switch (field) { | 1185 switch (field) { |
1188 case TEXT_PHONE_PHONE: | 1186 case TEXT_PHONE_PHONE: |
1189 case TEXT_FAX_PHONE: { | 1187 case TEXT_FAX_PHONE: { |
1190 for (std::vector<PhoneSubView*>::iterator it = phone_sub_views_.begin(); | 1188 for (std::vector<PhoneSubView*>::iterator it = phone_sub_views_.begin(); |
1191 it != phone_sub_views_.end(); ++it) | 1189 it != phone_sub_views_.end(); ++it) |
1192 (*it)->ContentsChanged(sender, new_contents); | 1190 (*it)->ContentsChanged(sender, new_contents); |
1193 DCHECK(temporary_info_.is_address); // Only addresses have phone numbers. | 1191 DCHECK(temporary_info_.is_address); // Only addresses have phone numbers. |
1194 string16 number, city, country; | 1192 string16 number, city, country; |
1195 PhoneNumber::ParsePhoneNumber(new_contents, &number, &city, &country); | 1193 PhoneNumber::ParsePhoneNumber(new_contents, &number, &city, &country); |
1196 temporary_info_.address.SetInfo( | 1194 temporary_info_.address.SetInfo( |
1197 AutofillType(field == TEXT_PHONE_PHONE ? PHONE_HOME_COUNTRY_CODE : | 1195 (field == TEXT_PHONE_PHONE ? PHONE_HOME_COUNTRY_CODE : |
dhollowa
2011/03/16 17:07:11
nit: Should be able to pull some of these ternarie
Ilya Sherman
2011/03/17 03:42:29
Just one of them
| |
1198 PHONE_FAX_COUNTRY_CODE), country); | 1196 PHONE_FAX_COUNTRY_CODE), |
1197 country); | |
1199 temporary_info_.address.SetInfo( | 1198 temporary_info_.address.SetInfo( |
1200 AutofillType(field == TEXT_PHONE_PHONE ? PHONE_HOME_CITY_CODE : | 1199 (field == TEXT_PHONE_PHONE ? PHONE_HOME_CITY_CODE : |
1201 PHONE_FAX_CITY_CODE), city); | 1200 PHONE_FAX_CITY_CODE), |
1201 city); | |
1202 temporary_info_.address.SetInfo( | 1202 temporary_info_.address.SetInfo( |
1203 AutofillType(field == TEXT_PHONE_PHONE ? PHONE_HOME_NUMBER : | 1203 (field == TEXT_PHONE_PHONE ? PHONE_HOME_NUMBER : |
1204 PHONE_FAX_NUMBER), number); | 1204 PHONE_FAX_NUMBER), |
1205 number); | |
1205 return true; | 1206 return true; |
1206 } | 1207 } |
1207 } | 1208 } |
1208 return false; | 1209 return false; |
1209 } | 1210 } |
1210 | 1211 |
1211 void AutofillProfilesView::StringVectorComboboxModel::set_cb_strings( | 1212 void AutofillProfilesView::StringVectorComboboxModel::set_cb_strings( |
1212 std::vector<std::wstring> *source) { | 1213 std::vector<std::wstring> *source) { |
1213 cb_strings_.swap(*source); | 1214 cb_strings_.swap(*source); |
1214 } | 1215 } |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1315 AutoFillDialogObserver* observer, | 1316 AutoFillDialogObserver* observer, |
1316 Profile* profile) { | 1317 Profile* profile) { |
1317 DCHECK(profile); | 1318 DCHECK(profile); |
1318 | 1319 |
1319 PersonalDataManager* personal_data_manager = | 1320 PersonalDataManager* personal_data_manager = |
1320 profile->GetPersonalDataManager(); | 1321 profile->GetPersonalDataManager(); |
1321 DCHECK(personal_data_manager); | 1322 DCHECK(personal_data_manager); |
1322 AutofillProfilesView::Show(parent, observer, personal_data_manager, profile, | 1323 AutofillProfilesView::Show(parent, observer, personal_data_manager, profile, |
1323 profile->GetPrefs(), NULL, NULL); | 1324 profile->GetPrefs(), NULL, NULL); |
1324 } | 1325 } |
OLD | NEW |