| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/autofill/autofill_dialog_controller_impl.h" | 5 #include "chrome/browser/ui/autofill/autofill_dialog_controller_impl.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/string_split.h" | 10 #include "base/string_split.h" |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 | 241 |
| 242 string16 AutofillDialogControllerImpl::EditSuggestionText() const { | 242 string16 AutofillDialogControllerImpl::EditSuggestionText() const { |
| 243 return l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_EDIT); | 243 return l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_EDIT); |
| 244 } | 244 } |
| 245 | 245 |
| 246 string16 AutofillDialogControllerImpl::UseBillingForShippingText() const { | 246 string16 AutofillDialogControllerImpl::UseBillingForShippingText() const { |
| 247 return l10n_util::GetStringUTF16( | 247 return l10n_util::GetStringUTF16( |
| 248 IDS_AUTOFILL_DIALOG_USE_BILLING_FOR_SHIPPING); | 248 IDS_AUTOFILL_DIALOG_USE_BILLING_FOR_SHIPPING); |
| 249 } | 249 } |
| 250 | 250 |
| 251 string16 AutofillDialogControllerImpl::WalletOptionText() const { | |
| 252 // TODO(estade): real strings and l10n. | |
| 253 return string16(ASCIIToUTF16("I love lamp.")); | |
| 254 } | |
| 255 | |
| 256 string16 AutofillDialogControllerImpl::CancelButtonText() const { | 251 string16 AutofillDialogControllerImpl::CancelButtonText() const { |
| 257 return l10n_util::GetStringUTF16(IDS_CANCEL); | 252 return l10n_util::GetStringUTF16(IDS_CANCEL); |
| 258 } | 253 } |
| 259 | 254 |
| 260 string16 AutofillDialogControllerImpl::ConfirmButtonText() const { | 255 string16 AutofillDialogControllerImpl::ConfirmButtonText() const { |
| 261 return l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_SUBMIT_BUTTON); | 256 return l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_SUBMIT_BUTTON); |
| 262 } | 257 } |
| 263 | 258 |
| 264 string16 AutofillDialogControllerImpl::CancelSignInText() const { | 259 string16 AutofillDialogControllerImpl::CancelSignInText() const { |
| 265 // TODO(abodenha): real strings and l10n. | 260 // TODO(abodenha): real strings and l10n. |
| (...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 845 if (refresh_wallet_items_queued_) | 840 if (refresh_wallet_items_queued_) |
| 846 ScheduleRefreshWalletItems(); | 841 ScheduleRefreshWalletItems(); |
| 847 } | 842 } |
| 848 | 843 |
| 849 void AutofillDialogControllerImpl::GenerateSuggestionsModels() { | 844 void AutofillDialogControllerImpl::GenerateSuggestionsModels() { |
| 850 PersonalDataManager* manager = GetManager(); | 845 PersonalDataManager* manager = GetManager(); |
| 851 const std::vector<CreditCard*>& cards = manager->credit_cards(); | 846 const std::vector<CreditCard*>& cards = manager->credit_cards(); |
| 852 for (size_t i = 0; i < cards.size(); ++i) { | 847 for (size_t i = 0; i < cards.size(); ++i) { |
| 853 suggested_cc_.AddKeyedItem(cards[i]->guid(), cards[i]->Label()); | 848 suggested_cc_.AddKeyedItem(cards[i]->guid(), cards[i]->Label()); |
| 854 } | 849 } |
| 855 // TODO(estade): real strings and i18n. | |
| 856 suggested_cc_.AddKeyedItem("", ASCIIToUTF16("Enter new card")); | |
| 857 | 850 |
| 858 const std::vector<AutofillProfile*>& profiles = manager->GetProfiles(); | 851 const std::vector<AutofillProfile*>& profiles = manager->GetProfiles(); |
| 859 const std::string app_locale = AutofillCountry::ApplicationLocale(); | 852 const std::string app_locale = AutofillCountry::ApplicationLocale(); |
| 860 for (size_t i = 0; i < profiles.size(); ++i) { | 853 for (size_t i = 0; i < profiles.size(); ++i) { |
| 861 if (!IsCompleteProfile(*profiles[i])) | 854 if (!IsCompleteProfile(*profiles[i])) |
| 862 continue; | 855 continue; |
| 863 | 856 |
| 864 // Add all email addresses. | 857 // Add all email addresses. |
| 865 std::vector<string16> values; | 858 std::vector<string16> values; |
| 866 profiles[i]->GetMultiInfo(EMAIL_ADDRESS, app_locale, &values); | 859 profiles[i]->GetMultiInfo(EMAIL_ADDRESS, app_locale, &values); |
| 867 for (size_t j = 0; j < values.size(); ++j) { | 860 for (size_t j = 0; j < values.size(); ++j) { |
| 868 if (!values[j].empty()) | 861 if (!values[j].empty()) |
| 869 suggested_email_.AddKeyedItem(profiles[i]->guid(), values[j]); | 862 suggested_email_.AddKeyedItem(profiles[i]->guid(), values[j]); |
| 870 } | 863 } |
| 871 | 864 |
| 872 // Don't add variants for addresses: the email variants are handled above, | 865 // Don't add variants for addresses: the email variants are handled above, |
| 873 // name is part of credit card and we'll just ignore phone number variants. | 866 // name is part of credit card and we'll just ignore phone number variants. |
| 874 suggested_billing_.AddKeyedItem(profiles[i]->guid(), profiles[i]->Label()); | 867 suggested_billing_.AddKeyedItem(profiles[i]->guid(), profiles[i]->Label()); |
| 875 suggested_shipping_.AddKeyedItem(profiles[i]->guid(), profiles[i]->Label()); | 868 suggested_shipping_.AddKeyedItem(profiles[i]->guid(), profiles[i]->Label()); |
| 876 } | 869 } |
| 877 | 870 |
| 878 // TODO(estade): real strings and i18n. | 871 suggested_email_.AddKeyedItem( |
| 879 suggested_billing_.AddKeyedItem("", ASCIIToUTF16("Enter new billing")); | 872 std::string(), |
| 880 suggested_email_.AddKeyedItem("", ASCIIToUTF16("Enter new email")); | 873 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_ADD_EMAIL_ADDRESS)); |
| 881 suggested_shipping_.AddKeyedItem("", ASCIIToUTF16("Enter new shipping")); | 874 suggested_cc_.AddKeyedItem( |
| 875 std::string(), |
| 876 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_ADD_CREDIT_CARD)); |
| 877 suggested_billing_.AddKeyedItem( |
| 878 std::string(), |
| 879 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_ADD_BILLING_ADDRESS)); |
| 880 suggested_shipping_.AddKeyedItem( |
| 881 std::string(), |
| 882 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_ADD_SHIPPING_ADDRESS)); |
| 882 } | 883 } |
| 883 | 884 |
| 884 bool AutofillDialogControllerImpl::IsCompleteProfile( | 885 bool AutofillDialogControllerImpl::IsCompleteProfile( |
| 885 const AutofillProfile& profile) { | 886 const AutofillProfile& profile) { |
| 886 const std::string app_locale = AutofillCountry::ApplicationLocale(); | 887 const std::string app_locale = AutofillCountry::ApplicationLocale(); |
| 887 for (size_t i = 0; i < requested_shipping_fields_.size(); ++i) { | 888 for (size_t i = 0; i < requested_shipping_fields_.size(); ++i) { |
| 888 if (profile.GetInfo(requested_shipping_fields_[i].type, | 889 if (profile.GetInfo(requested_shipping_fields_[i].type, |
| 889 app_locale).empty()) { | 890 app_locale).empty()) { |
| 890 return false; | 891 return false; |
| 891 } | 892 } |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1031 DialogSection section) { | 1032 DialogSection section) { |
| 1032 return const_cast<DetailInputs*>(&RequestedFieldsForSection(section)); | 1033 return const_cast<DetailInputs*>(&RequestedFieldsForSection(section)); |
| 1033 } | 1034 } |
| 1034 | 1035 |
| 1035 void AutofillDialogControllerImpl::HidePopup() { | 1036 void AutofillDialogControllerImpl::HidePopup() { |
| 1036 if (popup_controller_) | 1037 if (popup_controller_) |
| 1037 popup_controller_->Hide(); | 1038 popup_controller_->Hide(); |
| 1038 } | 1039 } |
| 1039 | 1040 |
| 1040 } // namespace autofill | 1041 } // namespace autofill |
| OLD | NEW |