Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(211)

Side by Side Diff: chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc

Issue 365463002: rAc: When filling partial autofill data, don't fill across dialog sections. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 2133 matching lines...) Expand 10 before | Expand all | Expand 10 after
2144 &popup_icons); 2144 &popup_icons);
2145 } 2145 }
2146 2146
2147 if (popup_values.empty()) { 2147 if (popup_values.empty()) {
2148 HidePopup(); 2148 HidePopup();
2149 return; 2149 return;
2150 } 2150 }
2151 2151
2152 // |popup_input_type_| must be set before calling |Show()|. 2152 // |popup_input_type_| must be set before calling |Show()|.
2153 popup_input_type_ = type; 2153 popup_input_type_ = type;
2154 popup_section_ = section;
2154 2155
2155 // TODO(estade): do we need separators and control rows like 'Clear 2156 // TODO(estade): do we need separators and control rows like 'Clear
2156 // Form'? 2157 // Form'?
2157 std::vector<int> popup_ids; 2158 std::vector<int> popup_ids;
2158 for (size_t i = 0; i < popup_values.size(); ++i) { 2159 for (size_t i = 0; i < popup_values.size(); ++i) {
2159 popup_ids.push_back(i); 2160 popup_ids.push_back(i);
2160 } 2161 }
2161 2162
2162 popup_controller_ = AutofillPopupControllerImpl::GetOrCreate( 2163 popup_controller_ = AutofillPopupControllerImpl::GetOrCreate(
2163 popup_controller_, 2164 popup_controller_,
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
2415 &i18n_validator_suggestions_[identifier - popup_guids_.size()])); 2416 &i18n_validator_suggestions_[identifier - popup_guids_.size()]));
2416 } 2417 }
2417 2418
2418 // If the user hasn't switched away from the default country and |wrapper|'s 2419 // If the user hasn't switched away from the default country and |wrapper|'s
2419 // country differs from the |view_|'s, rebuild inputs and restore user data. 2420 // country differs from the |view_|'s, rebuild inputs and restore user data.
2420 const FieldValueMap snapshot = TakeUserInputSnapshot(); 2421 const FieldValueMap snapshot = TakeUserInputSnapshot();
2421 bool billing_rebuilt = false, shipping_rebuilt = false; 2422 bool billing_rebuilt = false, shipping_rebuilt = false;
2422 2423
2423 base::string16 billing_country = 2424 base::string16 billing_country =
2424 wrapper->GetInfo(AutofillType(ADDRESS_BILLING_COUNTRY)); 2425 wrapper->GetInfo(AutofillType(ADDRESS_BILLING_COUNTRY));
2425 if (!snapshot.count(ADDRESS_BILLING_COUNTRY) && 2426 if (popup_section_ == ActiveBillingSection() &&
2427 !snapshot.count(ADDRESS_BILLING_COUNTRY) &&
2426 !billing_country.empty()) { 2428 !billing_country.empty()) {
2427 billing_rebuilt = RebuildInputsForCountry( 2429 billing_rebuilt = RebuildInputsForCountry(
2428 ActiveBillingSection(), billing_country, false); 2430 ActiveBillingSection(), billing_country, false);
2429 } 2431 }
2430 2432
2431 base::string16 shipping_country = 2433 base::string16 shipping_country =
2432 wrapper->GetInfo(AutofillType(ADDRESS_HOME_COUNTRY)); 2434 wrapper->GetInfo(AutofillType(ADDRESS_HOME_COUNTRY));
2433 if (!snapshot.count(ADDRESS_HOME_COUNTRY) && 2435 if (popup_section_ == SECTION_SHIPPING &&
2436 !snapshot.count(ADDRESS_HOME_COUNTRY) &&
2434 !shipping_country.empty()) { 2437 !shipping_country.empty()) {
2435 shipping_rebuilt = RebuildInputsForCountry( 2438 shipping_rebuilt = RebuildInputsForCountry(
2436 SECTION_SHIPPING, shipping_country, false); 2439 SECTION_SHIPPING, shipping_country, false);
2437 } 2440 }
2438 2441
2439 if (billing_rebuilt || shipping_rebuilt) { 2442 if (billing_rebuilt || shipping_rebuilt) {
2440 RestoreUserInputFromSnapshot(snapshot); 2443 RestoreUserInputFromSnapshot(snapshot);
2441 if (billing_rebuilt) 2444 if (billing_rebuilt)
2442 UpdateSection(ActiveBillingSection()); 2445 UpdateSection(ActiveBillingSection());
2443 if (shipping_rebuilt) 2446 if (shipping_rebuilt)
2444 UpdateSection(SECTION_SHIPPING); 2447 UpdateSection(SECTION_SHIPPING);
2445 } 2448 }
2446 2449
2447 for (size_t i = SECTION_MIN; i <= SECTION_MAX; ++i) { 2450 DCHECK(SectionIsActive(popup_section_));
2448 DialogSection section = static_cast<DialogSection>(i); 2451 wrapper->FillInputs(MutableRequestedFieldsForSection(popup_section_));
2449 if (!SectionIsActive(section)) 2452 view_->FillSection(popup_section_, popup_input_type);
2450 continue;
2451
2452 wrapper->FillInputs(MutableRequestedFieldsForSection(section));
2453 view_->FillSection(section, popup_input_type);
2454 }
2455 2453
2456 GetMetricLogger().LogDialogPopupEvent( 2454 GetMetricLogger().LogDialogPopupEvent(
2457 AutofillMetrics::DIALOG_POPUP_FORM_FILLED); 2455 AutofillMetrics::DIALOG_POPUP_FORM_FILLED);
2458 2456
2459 // TODO(estade): not sure why it's necessary to do this explicitly. 2457 // TODO(estade): not sure why it's necessary to do this explicitly.
2460 HidePopup(); 2458 HidePopup();
2461 } 2459 }
2462 2460
2463 void AutofillDialogControllerImpl::RemoveSuggestion( 2461 void AutofillDialogControllerImpl::RemoveSuggestion(
2464 const base::string16& value, 2462 const base::string16& value,
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
2801 wallet_client_(profile_->GetRequestContext(), this, source_url), 2799 wallet_client_(profile_->GetRequestContext(), this, source_url),
2802 wallet_items_requested_(false), 2800 wallet_items_requested_(false),
2803 handling_use_wallet_link_click_(false), 2801 handling_use_wallet_link_click_(false),
2804 passive_failed_(false), 2802 passive_failed_(false),
2805 suggested_cc_(this), 2803 suggested_cc_(this),
2806 suggested_billing_(this), 2804 suggested_billing_(this),
2807 suggested_cc_billing_(this), 2805 suggested_cc_billing_(this),
2808 suggested_shipping_(this), 2806 suggested_shipping_(this),
2809 cares_about_shipping_(true), 2807 cares_about_shipping_(true),
2810 popup_input_type_(UNKNOWN_TYPE), 2808 popup_input_type_(UNKNOWN_TYPE),
2809 popup_section_(SECTION_MIN),
2811 waiting_for_explicit_sign_in_response_(false), 2810 waiting_for_explicit_sign_in_response_(false),
2812 has_accepted_legal_documents_(false), 2811 has_accepted_legal_documents_(false),
2813 is_submitting_(false), 2812 is_submitting_(false),
2814 choose_another_instrument_or_address_(false), 2813 choose_another_instrument_or_address_(false),
2815 wallet_server_validation_recoverable_(true), 2814 wallet_server_validation_recoverable_(true),
2816 data_was_passed_back_(false), 2815 data_was_passed_back_(false),
2817 was_ui_latency_logged_(false), 2816 was_ui_latency_logged_(false),
2818 card_generated_animation_(2000, 60, this), 2817 card_generated_animation_(2000, 60, this),
2819 weak_ptr_factory_(this) { 2818 weak_ptr_factory_(this) {
2820 DCHECK(!callback_.is_null()); 2819 DCHECK(!callback_.is_null());
(...skipping 1307 matching lines...) Expand 10 before | Expand all | Expand 10 after
4128 view_->UpdateButtonStrip(); 4127 view_->UpdateButtonStrip();
4129 } 4128 }
4130 4129
4131 void AutofillDialogControllerImpl::FetchWalletCookie() { 4130 void AutofillDialogControllerImpl::FetchWalletCookie() {
4132 net::URLRequestContextGetter* request_context = profile_->GetRequestContext(); 4131 net::URLRequestContextGetter* request_context = profile_->GetRequestContext();
4133 signin_helper_.reset(new wallet::WalletSigninHelper(this, request_context)); 4132 signin_helper_.reset(new wallet::WalletSigninHelper(this, request_context));
4134 signin_helper_->StartWalletCookieValueFetch(); 4133 signin_helper_->StartWalletCookieValueFetch();
4135 } 4134 }
4136 4135
4137 } // namespace autofill 4136 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698