OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 1819 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1830 if (instruments[i]->object_id() == | 1830 if (instruments[i]->object_id() == |
1831 wallet_items_->default_instrument_id()) { | 1831 wallet_items_->default_instrument_id()) { |
1832 suggested_cc_billing_.SetCheckedItem(key); | 1832 suggested_cc_billing_.SetCheckedItem(key); |
1833 } | 1833 } |
1834 } | 1834 } |
1835 | 1835 |
1836 // TODO(estade): this should have a URL sublabel. | 1836 // TODO(estade): this should have a URL sublabel. |
1837 suggested_cc_billing_.AddKeyedItem( | 1837 suggested_cc_billing_.AddKeyedItem( |
1838 kAddNewItemKey, | 1838 kAddNewItemKey, |
1839 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_ADD_BILLING_DETAILS)); | 1839 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_ADD_BILLING_DETAILS)); |
1840 suggested_cc_billing_.AddKeyedItem( | 1840 if (!wallet_items_ || |
Evan Stade
2013/05/23 16:32:12
don't need to check wallet_items_ imo --- several
Dan Beam
2013/05/23 19:31:16
Done. (didn't see the IsPayingWithWallet() above)
| |
1841 kManageItemsKey, | 1841 !wallet_items_->HasRequiredAction(wallet::SETUP_WALLET)) { |
1842 l10n_util::GetStringUTF16( | 1842 suggested_cc_billing_.AddKeyedItem( |
1843 IDS_AUTOFILL_DIALOG_MANAGE_BILLING_DETAILS)); | 1843 kManageItemsKey, |
1844 l10n_util::GetStringUTF16( | |
1845 IDS_AUTOFILL_DIALOG_MANAGE_BILLING_DETAILS)); | |
1846 } | |
1844 } | 1847 } |
1845 } else { | 1848 } else { |
1846 PersonalDataManager* manager = GetManager(); | 1849 PersonalDataManager* manager = GetManager(); |
1847 const std::vector<CreditCard*>& cards = manager->GetCreditCards(); | 1850 const std::vector<CreditCard*>& cards = manager->GetCreditCards(); |
1848 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 1851 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
1849 for (size_t i = 0; i < cards.size(); ++i) { | 1852 for (size_t i = 0; i < cards.size(); ++i) { |
1850 suggested_cc_.AddKeyedItemWithIcon( | 1853 suggested_cc_.AddKeyedItemWithIcon( |
1851 cards[i]->guid(), | 1854 cards[i]->guid(), |
1852 cards[i]->Label(), | 1855 cards[i]->Label(), |
1853 rb.GetImageNamed(cards[i]->IconResourceId())); | 1856 rb.GetImageNamed(cards[i]->IconResourceId())); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1895 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_ADD_EMAIL_ADDRESS)); | 1898 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_ADD_EMAIL_ADDRESS)); |
1896 if (!IsPayingWithWallet()) { | 1899 if (!IsPayingWithWallet()) { |
1897 suggested_email_.AddKeyedItem( | 1900 suggested_email_.AddKeyedItem( |
1898 kManageItemsKey, | 1901 kManageItemsKey, |
1899 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_MANAGE_EMAIL_ADDRESS)); | 1902 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_MANAGE_EMAIL_ADDRESS)); |
1900 } | 1903 } |
1901 | 1904 |
1902 suggested_shipping_.AddKeyedItem( | 1905 suggested_shipping_.AddKeyedItem( |
1903 kAddNewItemKey, | 1906 kAddNewItemKey, |
1904 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_ADD_SHIPPING_ADDRESS)); | 1907 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_ADD_SHIPPING_ADDRESS)); |
1905 suggested_shipping_.AddKeyedItem( | 1908 if (!IsPayingWithWallet() || |
1906 kManageItemsKey, | 1909 !wallet_items_->HasRequiredAction(wallet::SETUP_WALLET)) { |
1907 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_MANAGE_SHIPPING_ADDRESS)); | 1910 suggested_shipping_.AddKeyedItem( |
1911 kManageItemsKey, | |
1912 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_MANAGE_SHIPPING_ADDRESS)); | |
1913 } | |
1908 | 1914 |
1909 if (!IsPayingWithWallet()) { | 1915 if (!IsPayingWithWallet()) { |
1910 // When using Autofill, the default option is the first suggestion, if | 1916 // When using Autofill, the default option is the first suggestion, if |
1911 // one exists. Otherwise it's the "Use shipping for billing" item. | 1917 // one exists. Otherwise it's the "Use shipping for billing" item. |
1912 const std::string& first_real_suggestion_item_key = | 1918 const std::string& first_real_suggestion_item_key = |
1913 suggested_shipping_.GetItemKeyAt(1); | 1919 suggested_shipping_.GetItemKeyAt(1); |
1914 if (IsASuggestionItemKey(first_real_suggestion_item_key)) | 1920 if (IsASuggestionItemKey(first_real_suggestion_item_key)) |
1915 suggested_shipping_.SetCheckedItem(first_real_suggestion_item_key); | 1921 suggested_shipping_.SetCheckedItem(first_real_suggestion_item_key); |
1916 } | 1922 } |
1917 | 1923 |
(...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2576 AutofillMetrics::DIALOG_USER_SIGNED_IN_NO_WALLET_NO_AUTOFILL; | 2582 AutofillMetrics::DIALOG_USER_SIGNED_IN_NO_WALLET_NO_AUTOFILL; |
2577 } | 2583 } |
2578 | 2584 |
2579 // Has Wallet items. | 2585 // Has Wallet items. |
2580 return has_autofill_profiles ? | 2586 return has_autofill_profiles ? |
2581 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_HAS_AUTOFILL : | 2587 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_HAS_AUTOFILL : |
2582 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_NO_AUTOFILL; | 2588 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_NO_AUTOFILL; |
2583 } | 2589 } |
2584 | 2590 |
2585 } // namespace autofill | 2591 } // namespace autofill |
OLD | NEW |