Chromium Code Reviews| 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 <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 626 form_structure_.ParseFieldTypesFromAutocompleteAttributes( | 626 form_structure_.ParseFieldTypesFromAutocompleteAttributes( |
| 627 &has_types, &has_sections); | 627 &has_types, &has_sections); |
| 628 | 628 |
| 629 // Fail if the author didn't specify autocomplete types. | 629 // Fail if the author didn't specify autocomplete types. |
| 630 if (!has_types) { | 630 if (!has_types) { |
| 631 callback_.Run(NULL); | 631 callback_.Run(NULL); |
| 632 delete this; | 632 delete this; |
| 633 return; | 633 return; |
| 634 } | 634 } |
| 635 | 635 |
| 636 billing_country_combobox_model_.reset(new CountryComboboxModel( | |
| 637 *GetManager(), | |
| 638 form_structure_.PossibleValues(ADDRESS_BILLING_COUNTRY), | |
| 639 false)); | |
| 640 shipping_country_combobox_model_.reset(new CountryComboboxModel( | |
| 641 *GetManager(), | |
| 642 form_structure_.PossibleValues(ADDRESS_HOME_COUNTRY), | |
| 643 false)); | |
| 644 | |
| 636 // Log any relevant UI metrics and security exceptions. | 645 // Log any relevant UI metrics and security exceptions. |
| 637 GetMetricLogger().LogDialogUiEvent(AutofillMetrics::DIALOG_UI_SHOWN); | 646 GetMetricLogger().LogDialogUiEvent(AutofillMetrics::DIALOG_UI_SHOWN); |
| 638 | 647 |
| 639 GetMetricLogger().LogDialogSecurityMetric( | 648 GetMetricLogger().LogDialogSecurityMetric( |
| 640 AutofillMetrics::SECURITY_METRIC_DIALOG_SHOWN); | 649 AutofillMetrics::SECURITY_METRIC_DIALOG_SHOWN); |
| 641 | 650 |
| 642 // The Autofill dialog is shown in response to a message from the renderer and | 651 // The Autofill dialog is shown in response to a message from the renderer and |
| 643 // as such, it can only be made in the context of the current document. A call | 652 // as such, it can only be made in the context of the current document. A call |
| 644 // to GetActiveEntry would return a pending entry, if there was one, which | 653 // to GetActiveEntry would return a pending entry, if there was one, which |
| 645 // would be a security bug. Therefore, we use the last committed URL for the | 654 // would be a security bug. Therefore, we use the last committed URL for the |
| (...skipping 722 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1368 ui::ComboboxModel* AutofillDialogControllerImpl::ComboboxModelForAutofillType( | 1377 ui::ComboboxModel* AutofillDialogControllerImpl::ComboboxModelForAutofillType( |
| 1369 ServerFieldType type) { | 1378 ServerFieldType type) { |
| 1370 switch (type) { | 1379 switch (type) { |
| 1371 case CREDIT_CARD_EXP_MONTH: | 1380 case CREDIT_CARD_EXP_MONTH: |
| 1372 return &cc_exp_month_combobox_model_; | 1381 return &cc_exp_month_combobox_model_; |
| 1373 | 1382 |
| 1374 case CREDIT_CARD_EXP_4_DIGIT_YEAR: | 1383 case CREDIT_CARD_EXP_4_DIGIT_YEAR: |
| 1375 return &cc_exp_year_combobox_model_; | 1384 return &cc_exp_year_combobox_model_; |
| 1376 | 1385 |
| 1377 case ADDRESS_BILLING_COUNTRY: | 1386 case ADDRESS_BILLING_COUNTRY: |
| 1378 return &billing_country_combobox_model_; | 1387 return billing_country_combobox_model_.get(); |
| 1379 | 1388 |
| 1380 case ADDRESS_HOME_COUNTRY: | 1389 case ADDRESS_HOME_COUNTRY: |
| 1381 return &shipping_country_combobox_model_; | 1390 return shipping_country_combobox_model_.get(); |
| 1382 | 1391 |
| 1383 default: | 1392 default: |
| 1384 return NULL; | 1393 return NULL; |
| 1385 } | 1394 } |
| 1386 } | 1395 } |
| 1387 | 1396 |
| 1388 ui::MenuModel* AutofillDialogControllerImpl::MenuModelForSection( | 1397 ui::MenuModel* AutofillDialogControllerImpl::MenuModelForSection( |
| 1389 DialogSection section) { | 1398 DialogSection section) { |
| 1390 SuggestionsMenuModel* model = SuggestionsMenuModelForSection(section); | 1399 SuggestionsMenuModel* model = SuggestionsMenuModelForSection(section); |
| 1391 // The shipping section menu is special. It will always show because there is | 1400 // The shipping section menu is special. It will always show because there is |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1482 return false; | 1491 return false; |
| 1483 | 1492 |
| 1484 SuggestionsMenuModel* model = SuggestionsMenuModelForSection(section); | 1493 SuggestionsMenuModel* model = SuggestionsMenuModelForSection(section); |
| 1485 std::string item_key = model->GetItemKeyForCheckedItem(); | 1494 std::string item_key = model->GetItemKeyForCheckedItem(); |
| 1486 if (item_key == kSameAsBillingKey) { | 1495 if (item_key == kSameAsBillingKey) { |
| 1487 *vertically_compact = *horizontally_compact = l10n_util::GetStringUTF16( | 1496 *vertically_compact = *horizontally_compact = l10n_util::GetStringUTF16( |
| 1488 IDS_AUTOFILL_DIALOG_USING_BILLING_FOR_SHIPPING); | 1497 IDS_AUTOFILL_DIALOG_USING_BILLING_FOR_SHIPPING); |
| 1489 return true; | 1498 return true; |
| 1490 } | 1499 } |
| 1491 | 1500 |
| 1492 if (!IsASuggestionItemKey(item_key)) | 1501 if (!IsASuggestionItemKey(item_key)) { |
| 1493 return false; | 1502 return false; |
| 1503 } | |
|
Dan Beam
2014/03/01 03:38:10
nit: revert
Evan Stade
2014/03/04 00:11:30
Done.
| |
| 1494 | 1504 |
| 1495 if (!IsPayingWithWallet() && | 1505 if (!IsPayingWithWallet() && |
| 1496 (section == SECTION_BILLING || section == SECTION_SHIPPING)) { | 1506 (section == SECTION_BILLING || section == SECTION_SHIPPING)) { |
| 1497 // Also check if the address is invalid (rules may have loaded since | 1507 // Also check if the address is invalid (rules may have loaded since |
| 1498 // the dialog was shown). | 1508 // the dialog was shown). |
| 1499 if (HasInvalidAddress(*GetManager()->GetProfileByGUID(item_key))) | 1509 if (HasInvalidAddress(*GetManager()->GetProfileByGUID(item_key))) |
| 1500 return false; | 1510 return false; |
| 1501 } | 1511 } |
| 1502 | 1512 |
| 1503 scoped_ptr<DataModelWrapper> wrapper = CreateWrapper(section); | 1513 scoped_ptr<DataModelWrapper> wrapper = CreateWrapper(section); |
| (...skipping 1186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2690 profile_(Profile::FromBrowserContext(contents->GetBrowserContext())), | 2700 profile_(Profile::FromBrowserContext(contents->GetBrowserContext())), |
| 2691 initial_user_state_(AutofillMetrics::DIALOG_USER_STATE_UNKNOWN), | 2701 initial_user_state_(AutofillMetrics::DIALOG_USER_STATE_UNKNOWN), |
| 2692 form_structure_(form_structure), | 2702 form_structure_(form_structure), |
| 2693 invoked_from_same_origin_(true), | 2703 invoked_from_same_origin_(true), |
| 2694 source_url_(source_url), | 2704 source_url_(source_url), |
| 2695 callback_(callback), | 2705 callback_(callback), |
| 2696 wallet_client_(profile_->GetRequestContext(), this, source_url), | 2706 wallet_client_(profile_->GetRequestContext(), this, source_url), |
| 2697 wallet_items_requested_(false), | 2707 wallet_items_requested_(false), |
| 2698 handling_use_wallet_link_click_(false), | 2708 handling_use_wallet_link_click_(false), |
| 2699 passive_failed_(false), | 2709 passive_failed_(false), |
| 2700 billing_country_combobox_model_(*GetManager(), false), | |
| 2701 shipping_country_combobox_model_(*GetManager(), false), | |
| 2702 suggested_cc_(this), | 2710 suggested_cc_(this), |
| 2703 suggested_billing_(this), | 2711 suggested_billing_(this), |
| 2704 suggested_cc_billing_(this), | 2712 suggested_cc_billing_(this), |
| 2705 suggested_shipping_(this), | 2713 suggested_shipping_(this), |
| 2706 cares_about_shipping_(true), | 2714 cares_about_shipping_(true), |
| 2707 popup_input_type_(UNKNOWN_TYPE), | 2715 popup_input_type_(UNKNOWN_TYPE), |
| 2708 waiting_for_explicit_sign_in_response_(false), | 2716 waiting_for_explicit_sign_in_response_(false), |
| 2709 has_accepted_legal_documents_(false), | 2717 has_accepted_legal_documents_(false), |
| 2710 is_submitting_(false), | 2718 is_submitting_(false), |
| 2711 choose_another_instrument_or_address_(false), | 2719 choose_another_instrument_or_address_(false), |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2847 | 2855 |
| 2848 if (shipping_same_as_billing) | 2856 if (shipping_same_as_billing) |
| 2849 suggested_shipping_.SetCheckedItem(kSameAsBillingKey); | 2857 suggested_shipping_.SetCheckedItem(kSameAsBillingKey); |
| 2850 | 2858 |
| 2851 for (size_t i = 0; i < addresses.size(); ++i) { | 2859 for (size_t i = 0; i < addresses.size(); ++i) { |
| 2852 std::string key = base::IntToString(i); | 2860 std::string key = base::IntToString(i); |
| 2853 suggested_shipping_.AddKeyedItemWithMinorText( | 2861 suggested_shipping_.AddKeyedItemWithMinorText( |
| 2854 key, | 2862 key, |
| 2855 addresses[i]->DisplayName(), | 2863 addresses[i]->DisplayName(), |
| 2856 addresses[i]->DisplayNameDetail()); | 2864 addresses[i]->DisplayNameDetail()); |
| 2865 suggested_shipping_.SetEnabled( | |
| 2866 key, | |
| 2867 CanAcceptCountry(SECTION_SHIPPING, | |
| 2868 addresses[i]->country_name_code())); | |
| 2857 | 2869 |
| 2858 // TODO(scr): Move this assignment outside the loop or comment why it | 2870 // TODO(scr): Move this assignment outside the loop or comment why it |
| 2859 // can't be there. | 2871 // can't be there. |
| 2860 const std::string default_shipping_address_id = | 2872 const std::string default_shipping_address_id = |
| 2861 GetIdToSelect(wallet_items_->default_address_id(), | 2873 GetIdToSelect(wallet_items_->default_address_id(), |
| 2862 previous_default_shipping_address_id_, | 2874 previous_default_shipping_address_id_, |
| 2863 previously_selected_shipping_address_id_); | 2875 previously_selected_shipping_address_id_); |
| 2864 | 2876 |
| 2865 if (!shipping_same_as_billing && | 2877 if (!shipping_same_as_billing && |
| 2866 addresses[i]->object_id() == default_shipping_address_id) { | 2878 addresses[i]->object_id() == default_shipping_address_id) { |
| 2867 suggested_shipping_.SetCheckedItem(key); | 2879 suggested_shipping_.SetCheckedItem(key); |
| 2868 } | 2880 } |
| 2869 } | 2881 } |
| 2870 | 2882 |
| 2871 if (!IsSubmitPausedOn(wallet::VERIFY_CVV)) { | 2883 if (!IsSubmitPausedOn(wallet::VERIFY_CVV)) { |
| 2872 const std::vector<wallet::WalletItems::MaskedInstrument*>& instruments = | 2884 const std::vector<wallet::WalletItems::MaskedInstrument*>& instruments = |
| 2873 wallet_items_->instruments(); | 2885 wallet_items_->instruments(); |
| 2874 std::string first_active_instrument_key; | 2886 std::string first_active_instrument_key; |
| 2875 std::string default_instrument_key; | 2887 std::string default_instrument_key; |
| 2876 for (size_t i = 0; i < instruments.size(); ++i) { | 2888 for (size_t i = 0; i < instruments.size(); ++i) { |
| 2877 bool allowed = IsInstrumentAllowed(*instruments[i]); | 2889 bool allowed = IsInstrumentAllowed(*instruments[i]) && |
| 2890 CanAcceptCountry(SECTION_BILLING, | |
| 2891 instruments[i]->address().country_name_code()); | |
| 2878 gfx::Image icon = instruments[i]->CardIcon(); | 2892 gfx::Image icon = instruments[i]->CardIcon(); |
| 2879 if (!allowed && !icon.IsEmpty()) { | 2893 if (!allowed && !icon.IsEmpty()) { |
| 2880 // Create a grayed disabled icon. | 2894 // Create a grayed disabled icon. |
| 2881 SkBitmap disabled_bitmap = SkBitmapOperations::CreateHSLShiftedBitmap( | 2895 SkBitmap disabled_bitmap = SkBitmapOperations::CreateHSLShiftedBitmap( |
| 2882 *icon.ToSkBitmap(), kGrayImageShift); | 2896 *icon.ToSkBitmap(), kGrayImageShift); |
| 2883 icon = gfx::Image( | 2897 icon = gfx::Image( |
| 2884 gfx::ImageSkia::CreateFrom1xBitmap(disabled_bitmap)); | 2898 gfx::ImageSkia::CreateFrom1xBitmap(disabled_bitmap)); |
| 2885 } | 2899 } |
| 2886 std::string key = base::IntToString(i); | 2900 std::string key = base::IntToString(i); |
| 2887 suggested_cc_billing_.AddKeyedItemWithMinorTextAndIcon( | 2901 suggested_cc_billing_.AddKeyedItemWithMinorTextAndIcon( |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2938 rb.GetImageNamed(CreditCard::IconResourceId(cards[i]->type()))); | 2952 rb.GetImageNamed(CreditCard::IconResourceId(cards[i]->type()))); |
| 2939 } | 2953 } |
| 2940 | 2954 |
| 2941 const std::vector<AutofillProfile*>& profiles = manager->GetProfiles(); | 2955 const std::vector<AutofillProfile*>& profiles = manager->GetProfiles(); |
| 2942 std::vector<base::string16> labels; | 2956 std::vector<base::string16> labels; |
| 2943 AutofillProfile::CreateDifferentiatingLabels(profiles, &labels); | 2957 AutofillProfile::CreateDifferentiatingLabels(profiles, &labels); |
| 2944 DCHECK_EQ(labels.size(), profiles.size()); | 2958 DCHECK_EQ(labels.size(), profiles.size()); |
| 2945 for (size_t i = 0; i < profiles.size(); ++i) { | 2959 for (size_t i = 0; i < profiles.size(); ++i) { |
| 2946 const AutofillProfile& profile = *profiles[i]; | 2960 const AutofillProfile& profile = *profiles[i]; |
| 2947 if (!i18ninput::AddressHasCompleteAndVerifiedData(profile) || | 2961 if (!i18ninput::AddressHasCompleteAndVerifiedData(profile) || |
| 2948 !i18ninput::CountryIsFullySupported( | |
| 2949 UTF16ToASCII(profile.GetRawInfo(ADDRESS_HOME_COUNTRY))) || | |
| 2950 (!i18ninput::Enabled() && HasInvalidAddress(*profiles[i]))) { | 2962 (!i18ninput::Enabled() && HasInvalidAddress(*profiles[i]))) { |
| 2951 continue; | 2963 continue; |
| 2952 } | 2964 } |
| 2953 | 2965 |
| 2954 // Don't add variants for addresses: name is part of credit card and | 2966 // Don't add variants for addresses: name is part of credit card and |
| 2955 // we'll just ignore email and phone number variants. | 2967 // we'll just ignore email and phone number variants. |
| 2956 suggested_shipping_.AddKeyedItem(profile.guid(), labels[i]); | 2968 suggested_shipping_.AddKeyedItem(profile.guid(), labels[i]); |
| 2969 suggested_shipping_.SetEnabled( | |
| 2970 profile.guid(), | |
| 2971 CanAcceptCountry( | |
| 2972 SECTION_SHIPPING, | |
| 2973 UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_COUNTRY)))); | |
| 2957 if (!profile.GetRawInfo(EMAIL_ADDRESS).empty() && | 2974 if (!profile.GetRawInfo(EMAIL_ADDRESS).empty() && |
| 2958 !profile.IsPresentButInvalid(EMAIL_ADDRESS)) { | 2975 !profile.IsPresentButInvalid(EMAIL_ADDRESS)) { |
| 2959 suggested_billing_.AddKeyedItem(profile.guid(), labels[i]); | 2976 suggested_billing_.AddKeyedItem(profile.guid(), labels[i]); |
| 2977 suggested_billing_.SetEnabled( | |
| 2978 profile.guid(), | |
| 2979 CanAcceptCountry( | |
| 2980 SECTION_BILLING, | |
| 2981 UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_COUNTRY)))); | |
| 2960 } | 2982 } |
| 2961 } | 2983 } |
| 2962 } | 2984 } |
| 2963 | 2985 |
| 2964 suggested_cc_.AddKeyedItem( | 2986 suggested_cc_.AddKeyedItem( |
| 2965 kAddNewItemKey, | 2987 kAddNewItemKey, |
| 2966 l10n_util::GetStringUTF16(IsAutofillEnabled() ? | 2988 l10n_util::GetStringUTF16(IsAutofillEnabled() ? |
| 2967 IDS_AUTOFILL_DIALOG_ADD_CREDIT_CARD : | 2989 IDS_AUTOFILL_DIALOG_ADD_CREDIT_CARD : |
| 2968 IDS_AUTOFILL_DIALOG_ENTER_CREDIT_CARD)); | 2990 IDS_AUTOFILL_DIALOG_ENTER_CREDIT_CARD)); |
| 2969 suggested_cc_.AddKeyedItem( | 2991 suggested_cc_.AddKeyedItem( |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3156 | 3178 |
| 3157 scoped_ptr<DataModelWrapper> wrapper = CreateWrapper(section); | 3179 scoped_ptr<DataModelWrapper> wrapper = CreateWrapper(section); |
| 3158 if (wrapper) | 3180 if (wrapper) |
| 3159 return wrapper->GetInfo(AutofillType(type)); | 3181 return wrapper->GetInfo(AutofillType(type)); |
| 3160 | 3182 |
| 3161 FieldValueMap output; | 3183 FieldValueMap output; |
| 3162 view_->GetUserInput(section, &output); | 3184 view_->GetUserInput(section, &output); |
| 3163 return output[type]; | 3185 return output[type]; |
| 3164 } | 3186 } |
| 3165 | 3187 |
| 3188 bool AutofillDialogControllerImpl::CanAcceptCountry( | |
| 3189 DialogSection section, | |
| 3190 const std::string& country_code) { | |
| 3191 CountryComboboxModel* model = CountryComboboxModelForSection(section); | |
| 3192 const std::vector<AutofillCountry*>& countries = model->countries(); | |
| 3193 for (size_t i = 0; i < countries.size(); ++i) { | |
| 3194 if (countries[i] && countries[i]->country_code() == country_code) | |
| 3195 return true; | |
| 3196 } | |
| 3197 | |
| 3198 return false; | |
| 3199 } | |
| 3200 | |
| 3166 SuggestionsMenuModel* AutofillDialogControllerImpl:: | 3201 SuggestionsMenuModel* AutofillDialogControllerImpl:: |
| 3167 SuggestionsMenuModelForSection(DialogSection section) { | 3202 SuggestionsMenuModelForSection(DialogSection section) { |
| 3168 switch (section) { | 3203 switch (section) { |
| 3169 case SECTION_CC: | 3204 case SECTION_CC: |
| 3170 return &suggested_cc_; | 3205 return &suggested_cc_; |
| 3171 case SECTION_BILLING: | 3206 case SECTION_BILLING: |
| 3172 return &suggested_billing_; | 3207 return &suggested_billing_; |
| 3173 case SECTION_SHIPPING: | 3208 case SECTION_SHIPPING: |
| 3174 return &suggested_shipping_; | 3209 return &suggested_shipping_; |
| 3175 case SECTION_CC_BILLING: | 3210 case SECTION_CC_BILLING: |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 3197 if (&model == &suggested_cc_billing_) | 3232 if (&model == &suggested_cc_billing_) |
| 3198 return SECTION_CC_BILLING; | 3233 return SECTION_CC_BILLING; |
| 3199 | 3234 |
| 3200 DCHECK_EQ(&model, &suggested_shipping_); | 3235 DCHECK_EQ(&model, &suggested_shipping_); |
| 3201 return SECTION_SHIPPING; | 3236 return SECTION_SHIPPING; |
| 3202 } | 3237 } |
| 3203 | 3238 |
| 3204 CountryComboboxModel* AutofillDialogControllerImpl:: | 3239 CountryComboboxModel* AutofillDialogControllerImpl:: |
| 3205 CountryComboboxModelForSection(DialogSection section) { | 3240 CountryComboboxModelForSection(DialogSection section) { |
| 3206 if (section == SECTION_BILLING) | 3241 if (section == SECTION_BILLING) |
| 3207 return &billing_country_combobox_model_; | 3242 return billing_country_combobox_model_.get(); |
| 3208 | 3243 |
| 3209 if (section == SECTION_SHIPPING) | 3244 if (section == SECTION_SHIPPING) |
| 3210 return &shipping_country_combobox_model_; | 3245 return shipping_country_combobox_model_.get(); |
| 3211 | 3246 |
| 3212 return NULL; | 3247 return NULL; |
| 3213 } | 3248 } |
| 3214 | 3249 |
| 3215 DetailInputs* AutofillDialogControllerImpl::MutableRequestedFieldsForSection( | 3250 DetailInputs* AutofillDialogControllerImpl::MutableRequestedFieldsForSection( |
| 3216 DialogSection section) { | 3251 DialogSection section) { |
| 3217 return const_cast<DetailInputs*>(&RequestedFieldsForSection(section)); | 3252 return const_cast<DetailInputs*>(&RequestedFieldsForSection(section)); |
| 3218 } | 3253 } |
| 3219 | 3254 |
| 3220 std::vector<ServerFieldType> AutofillDialogControllerImpl:: | 3255 std::vector<ServerFieldType> AutofillDialogControllerImpl:: |
| (...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3698 } | 3733 } |
| 3699 | 3734 |
| 3700 void AutofillDialogControllerImpl::GetDefaultAutofillChoice( | 3735 void AutofillDialogControllerImpl::GetDefaultAutofillChoice( |
| 3701 DialogSection section, | 3736 DialogSection section, |
| 3702 std::string* guid) { | 3737 std::string* guid) { |
| 3703 DCHECK(!IsPayingWithWallet() && IsAutofillEnabled()); | 3738 DCHECK(!IsPayingWithWallet() && IsAutofillEnabled()); |
| 3704 // The default choice is the first thing in the menu that is a suggestion | 3739 // The default choice is the first thing in the menu that is a suggestion |
| 3705 // item. | 3740 // item. |
| 3706 SuggestionsMenuModel* model = SuggestionsMenuModelForSection(section); | 3741 SuggestionsMenuModel* model = SuggestionsMenuModelForSection(section); |
| 3707 for (int i = 0; i < model->GetItemCount(); ++i) { | 3742 for (int i = 0; i < model->GetItemCount(); ++i) { |
| 3708 if (IsASuggestionItemKey(model->GetItemKeyAt(i))) { | 3743 // Try the first suggestion item that is enabled. |
| 3744 if (IsASuggestionItemKey(model->GetItemKeyAt(i)) && model->IsEnabledAt(i)) { | |
| 3709 *guid = model->GetItemKeyAt(i); | 3745 *guid = model->GetItemKeyAt(i); |
| 3710 break; | 3746 return; |
| 3747 // Fall back to the first non-suggestion key. | |
|
Ilya Sherman
2014/03/03 23:55:54
I think this code chooses the last non-suggestion
Evan Stade
2014/03/04 00:11:30
that's what the guid->empty() check is for
Ilya Sherman
2014/03/04 00:53:57
Ah, true dat. Maybe DCHECK at the beginning of th
| |
| 3748 } else if (!IsASuggestionItemKey(model->GetItemKeyAt(i)) && guid->empty()) { | |
| 3749 *guid = model->GetItemKeyAt(i); | |
| 3711 } | 3750 } |
| 3712 } | 3751 } |
| 3713 } | 3752 } |
| 3714 | 3753 |
| 3715 bool AutofillDialogControllerImpl::GetAutofillChoice(DialogSection section, | 3754 bool AutofillDialogControllerImpl::GetAutofillChoice(DialogSection section, |
| 3716 std::string* guid) { | 3755 std::string* guid) { |
| 3717 DCHECK(!IsPayingWithWallet() && IsAutofillEnabled()); | 3756 DCHECK(!IsPayingWithWallet() && IsAutofillEnabled()); |
| 3718 const base::DictionaryValue* choices = profile()->GetPrefs()->GetDictionary( | 3757 const base::DictionaryValue* choices = profile()->GetPrefs()->GetDictionary( |
| 3719 ::prefs::kAutofillDialogAutofillDefault); | 3758 ::prefs::kAutofillDialogAutofillDefault); |
| 3720 if (!choices) | 3759 if (!choices) |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3868 view_->UpdateButtonStrip(); | 3907 view_->UpdateButtonStrip(); |
| 3869 } | 3908 } |
| 3870 | 3909 |
| 3871 void AutofillDialogControllerImpl::FetchWalletCookie() { | 3910 void AutofillDialogControllerImpl::FetchWalletCookie() { |
| 3872 net::URLRequestContextGetter* request_context = profile_->GetRequestContext(); | 3911 net::URLRequestContextGetter* request_context = profile_->GetRequestContext(); |
| 3873 signin_helper_.reset(new wallet::WalletSigninHelper(this, request_context)); | 3912 signin_helper_.reset(new wallet::WalletSigninHelper(this, request_context)); |
| 3874 signin_helper_->StartWalletCookieValueFetch(); | 3913 signin_helper_->StartWalletCookieValueFetch(); |
| 3875 } | 3914 } |
| 3876 | 3915 |
| 3877 } // namespace autofill | 3916 } // namespace autofill |
| OLD | NEW |