| 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/views/autofill_profiles_view_win.h" | 5 #include "chrome/browser/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 "app/l10n_util.h" | 10 #include "app/l10n_util.h" |
| 11 #include "app/resource_bundle.h" | 11 #include "app/resource_bundle.h" |
| 12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
| 13 #include "base/string16.h" |
| 13 #include "base/string_number_conversions.h" | 14 #include "base/string_number_conversions.h" |
| 14 #include "base/time.h" | 15 #include "base/time.h" |
| 15 #include "base/utf_string_conversions.h" | 16 #include "base/utf_string_conversions.h" |
| 16 #include "chrome/browser/autofill/autofill_manager.h" | 17 #include "chrome/browser/autofill/autofill_manager.h" |
| 17 #include "chrome/browser/autofill/phone_number.h" | 18 #include "chrome/browser/autofill/phone_number.h" |
| 18 #include "chrome/browser/browser.h" | 19 #include "chrome/browser/browser.h" |
| 19 #include "chrome/browser/browser_list.h" | 20 #include "chrome/browser/browser_list.h" |
| 20 #include "chrome/browser/browser_window.h" | 21 #include "chrome/browser/browser_window.h" |
| 21 #include "chrome/browser/metrics/user_metrics.h" | 22 #include "chrome/browser/metrics/user_metrics.h" |
| 22 #include "chrome/browser/pref_service.h" | 23 #include "chrome/browser/pref_service.h" |
| (...skipping 862 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 885 temporary_info_.credit_card.set_billing_address( | 886 temporary_info_.credit_card.set_billing_address( |
| 886 base::IntToString16( | 887 base::IntToString16( |
| 887 observer_->profiles_set_[new_index].address.unique_id())); | 888 observer_->profiles_set_[new_index].address.unique_id())); |
| 888 } | 889 } |
| 889 } else if (combo_box == combo_box_month_) { | 890 } else if (combo_box == combo_box_month_) { |
| 890 if (new_index == -1) { | 891 if (new_index == -1) { |
| 891 NOTREACHED(); | 892 NOTREACHED(); |
| 892 } else { | 893 } else { |
| 893 temporary_info_.credit_card.SetInfo( | 894 temporary_info_.credit_card.SetInfo( |
| 894 AutoFillType(CREDIT_CARD_EXP_MONTH), | 895 AutoFillType(CREDIT_CARD_EXP_MONTH), |
| 895 combo_box_model_month_->GetItemAt(new_index)); | 896 UTF16ToWideHack(combo_box_model_month_->GetItemAt(new_index))); |
| 896 } | 897 } |
| 897 } else if (combo_box == combo_box_year_) { | 898 } else if (combo_box == combo_box_year_) { |
| 898 if (new_index == -1) { | 899 if (new_index == -1) { |
| 899 NOTREACHED(); | 900 NOTREACHED(); |
| 900 } else { | 901 } else { |
| 901 temporary_info_.credit_card.SetInfo( | 902 temporary_info_.credit_card.SetInfo( |
| 902 AutoFillType(CREDIT_CARD_EXP_4_DIGIT_YEAR), | 903 AutoFillType(CREDIT_CARD_EXP_4_DIGIT_YEAR), |
| 903 combo_box_model_year_->GetItemAt(new_index)); | 904 UTF16ToWideHack(combo_box_model_year_->GetItemAt(new_index))); |
| 904 } | 905 } |
| 905 } else { | 906 } else { |
| 906 NOTREACHED(); | 907 NOTREACHED(); |
| 907 } | 908 } |
| 908 } | 909 } |
| 909 | 910 |
| 910 ///////////////////////////////////////////////////////////////////////////// | 911 ///////////////////////////////////////////////////////////////////////////// |
| 911 // AutoFillProfilesView::EditableSetViewContents, private: | 912 // AutoFillProfilesView::EditableSetViewContents, private: |
| 912 void AutoFillProfilesView::EditableSetViewContents::InitAddressFields( | 913 void AutoFillProfilesView::EditableSetViewContents::InitAddressFields( |
| 913 views::GridLayout* layout) { | 914 views::GridLayout* layout) { |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1272 return -1; | 1273 return -1; |
| 1273 } | 1274 } |
| 1274 | 1275 |
| 1275 ///////////////////////////////////////////////////////////////////////////// | 1276 ///////////////////////////////////////////////////////////////////////////// |
| 1276 // AutoFillProfilesView::AddressComboBoxModel, ComboboxModel methods | 1277 // AutoFillProfilesView::AddressComboBoxModel, ComboboxModel methods |
| 1277 int AutoFillProfilesView::AddressComboBoxModel::GetItemCount() { | 1278 int AutoFillProfilesView::AddressComboBoxModel::GetItemCount() { |
| 1278 int shift = is_billing_ ? 0 : 1; | 1279 int shift = is_billing_ ? 0 : 1; |
| 1279 return static_cast<int>(address_labels_.size()) + shift; | 1280 return static_cast<int>(address_labels_.size()) + shift; |
| 1280 } | 1281 } |
| 1281 | 1282 |
| 1282 std::wstring AutoFillProfilesView::AddressComboBoxModel::GetItemAt(int index) { | 1283 string16 AutoFillProfilesView::AddressComboBoxModel::GetItemAt(int index) { |
| 1283 int shift = is_billing_ ? 0 : 1; | 1284 int shift = is_billing_ ? 0 : 1; |
| 1284 DCHECK(index < (static_cast<int>(address_labels_.size()) + shift)); | 1285 DCHECK(index < (static_cast<int>(address_labels_.size()) + shift)); |
| 1285 if (!is_billing_ && !index) | 1286 if (!is_billing_ && !index) |
| 1286 return l10n_util::GetString(IDS_AUTOFILL_DIALOG_SAME_AS_BILLING); | 1287 return l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_SAME_AS_BILLING); |
| 1287 DCHECK(address_labels_.at(index - shift).is_address); | 1288 DCHECK(address_labels_.at(index - shift).is_address); |
| 1288 std::wstring label = | 1289 string16 label = |
| 1289 address_labels_.at(index - shift).address.Label(); | 1290 WideToUTF16Hack(address_labels_.at(index - shift).address.Label()); |
| 1290 if (label.empty()) | 1291 if (label.empty()) |
| 1291 label = l10n_util::GetString(IDS_AUTOFILL_NEW_ADDRESS); | 1292 label = l10n_util::GetStringUTF16(IDS_AUTOFILL_NEW_ADDRESS); |
| 1292 return label; | 1293 return label; |
| 1293 } | 1294 } |
| 1294 | 1295 |
| 1295 void AutoFillProfilesView::StringVectorComboboxModel::set_cb_strings( | 1296 void AutoFillProfilesView::StringVectorComboboxModel::set_cb_strings( |
| 1296 std::vector<std::wstring> *source) { | 1297 std::vector<std::wstring> *source) { |
| 1297 cb_strings_.swap(*source); | 1298 cb_strings_.swap(*source); |
| 1298 } | 1299 } |
| 1299 | 1300 |
| 1300 int AutoFillProfilesView::StringVectorComboboxModel::GetItemCount() { | 1301 int AutoFillProfilesView::StringVectorComboboxModel::GetItemCount() { |
| 1301 return cb_strings_.size(); | 1302 return cb_strings_.size(); |
| 1302 } | 1303 } |
| 1303 | 1304 |
| 1304 std::wstring AutoFillProfilesView::StringVectorComboboxModel::GetItemAt( | 1305 string16 AutoFillProfilesView::StringVectorComboboxModel::GetItemAt(int index) { |
| 1305 int index) { | |
| 1306 DCHECK_GT(static_cast<int>(cb_strings_.size()), index); | 1306 DCHECK_GT(static_cast<int>(cb_strings_.size()), index); |
| 1307 return cb_strings_[index]; | 1307 return WideToUTF16Hack(cb_strings_[index]); |
| 1308 } | 1308 } |
| 1309 | 1309 |
| 1310 int AutoFillProfilesView::StringVectorComboboxModel::GetIndex( | 1310 int AutoFillProfilesView::StringVectorComboboxModel::GetIndex( |
| 1311 const std::wstring& value) { | 1311 const std::wstring& value) { |
| 1312 for (size_t index = 0; index < cb_strings_.size(); ++index) { | 1312 for (size_t index = 0; index < cb_strings_.size(); ++index) { |
| 1313 if (cb_strings_[index] == value) | 1313 if (cb_strings_[index] == value) |
| 1314 return index; | 1314 return index; |
| 1315 } | 1315 } |
| 1316 return -1; | 1316 return -1; |
| 1317 } | 1317 } |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1396 AutoFillDialogObserver* observer, | 1396 AutoFillDialogObserver* observer, |
| 1397 Profile* profile) { | 1397 Profile* profile) { |
| 1398 DCHECK(profile); | 1398 DCHECK(profile); |
| 1399 | 1399 |
| 1400 PersonalDataManager* personal_data_manager = | 1400 PersonalDataManager* personal_data_manager = |
| 1401 profile->GetPersonalDataManager(); | 1401 profile->GetPersonalDataManager(); |
| 1402 DCHECK(personal_data_manager); | 1402 DCHECK(personal_data_manager); |
| 1403 AutoFillProfilesView::Show(parent, observer, personal_data_manager, profile, | 1403 AutoFillProfilesView::Show(parent, observer, personal_data_manager, profile, |
| 1404 profile->GetPrefs(), NULL, NULL); | 1404 profile->GetPrefs(), NULL, NULL); |
| 1405 } | 1405 } |
| OLD | NEW |