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

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

Issue 63053003: Ask libaddressinput for address components to use in requestAutocomplete(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 1 month 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 11 matching lines...) Expand all
22 #include "base/rand_util.h" 22 #include "base/rand_util.h"
23 #include "base/strings/string_number_conversions.h" 23 #include "base/strings/string_number_conversions.h"
24 #include "base/strings/string_split.h" 24 #include "base/strings/string_split.h"
25 #include "base/strings/string_util.h" 25 #include "base/strings/string_util.h"
26 #include "base/strings/utf_string_conversions.h" 26 #include "base/strings/utf_string_conversions.h"
27 #include "base/time/time.h" 27 #include "base/time/time.h"
28 #include "chrome/browser/autofill/personal_data_manager_factory.h" 28 #include "chrome/browser/autofill/personal_data_manager_factory.h"
29 #include "chrome/browser/browser_process.h" 29 #include "chrome/browser/browser_process.h"
30 #include "chrome/browser/profiles/profile.h" 30 #include "chrome/browser/profiles/profile.h"
31 #include "chrome/browser/ui/autofill/autofill_dialog_common.h" 31 #include "chrome/browser/ui/autofill/autofill_dialog_common.h"
32 #include "chrome/browser/ui/autofill/autofill_dialog_i18n_input.h"
32 #include "chrome/browser/ui/autofill/autofill_dialog_view.h" 33 #include "chrome/browser/ui/autofill/autofill_dialog_view.h"
33 #include "chrome/browser/ui/autofill/data_model_wrapper.h" 34 #include "chrome/browser/ui/autofill/data_model_wrapper.h"
34 #if !defined(OS_ANDROID) 35 #if !defined(OS_ANDROID)
35 #include "chrome/browser/ui/autofill/generated_credit_card_bubble_controller.h" 36 #include "chrome/browser/ui/autofill/generated_credit_card_bubble_controller.h"
36 #include "chrome/browser/ui/autofill/new_credit_card_bubble_controller.h" 37 #include "chrome/browser/ui/autofill/new_credit_card_bubble_controller.h"
37 #endif 38 #endif
38 #include "chrome/browser/ui/browser.h" 39 #include "chrome/browser/ui/browser.h"
39 #include "chrome/browser/ui/browser_finder.h" 40 #include "chrome/browser/ui/browser_finder.h"
40 #include "chrome/browser/ui/browser_navigator.h" 41 #include "chrome/browser/ui/browser_navigator.h"
41 #include "chrome/browser/ui/browser_window.h" 42 #include "chrome/browser/ui/browser_window.h"
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 AutofillMetrics::SECURITY_METRIC_CROSS_ORIGIN_FRAME); 617 AutofillMetrics::SECURITY_METRIC_CROSS_ORIGIN_FRAME);
617 } 618 }
618 619
619 // Fail if the author didn't specify autocomplete types. 620 // Fail if the author didn't specify autocomplete types.
620 if (!has_types) { 621 if (!has_types) {
621 callback_.Run(NULL); 622 callback_.Run(NULL);
622 delete this; 623 delete this;
623 return; 624 return;
624 } 625 }
625 626
626 common::BuildInputsForSection(SECTION_CC, 627 std::string country_guess = i18ninput::GuessCountry();
627 &requested_cc_fields_); 628 for (size_t section = SECTION_MIN; section <= SECTION_MAX; ++section) {
628 common::BuildInputsForSection(SECTION_BILLING, 629 BuildInputsForSection(static_cast<DialogSection>(section), country_guess);
629 &requested_billing_fields_); 630 }
630 common::BuildInputsForSection(SECTION_CC_BILLING,
631 &requested_cc_billing_fields_);
632 common::BuildInputsForSection(SECTION_SHIPPING,
633 &requested_shipping_fields_);
634 631
635 // Test whether we need to show the shipping section. If filling that section 632 // Test whether we need to show the shipping section. If filling that section
636 // would be a no-op, don't show it. 633 // would be a no-op, don't show it.
637 const DetailInputs& inputs = RequestedFieldsForSection(SECTION_SHIPPING); 634 const DetailInputs& inputs = RequestedFieldsForSection(SECTION_SHIPPING);
638 EmptyDataModelWrapper empty_wrapper; 635 EmptyDataModelWrapper empty_wrapper;
639 cares_about_shipping_ = empty_wrapper.FillFormStructure( 636 cares_about_shipping_ = empty_wrapper.FillFormStructure(
640 inputs, 637 inputs,
641 base::Bind(common::DetailInputMatchesField, SECTION_SHIPPING), 638 base::Bind(common::DetailInputMatchesField, SECTION_SHIPPING),
642 &form_structure_); 639 &form_structure_);
643 640
(...skipping 1295 matching lines...) Expand 10 before | Expand all | Expand 10 after
1939 1936
1940 // |input_showing_popup_| must be set before calling |Show()|. 1937 // |input_showing_popup_| must be set before calling |Show()|.
1941 input_showing_popup_ = input; 1938 input_showing_popup_ = input;
1942 1939
1943 popup_controller_->Show(popup_values, 1940 popup_controller_->Show(popup_values,
1944 popup_labels, 1941 popup_labels,
1945 popup_icons, 1942 popup_icons,
1946 popup_ids); 1943 popup_ids);
1947 } 1944 }
1948 1945
1946 void AutofillDialogControllerImpl::ComboboxItemSelected(
1947 ui::ComboboxModel* model,
1948 DialogSection section,
1949 int index) {
1950 if (model == &country_combobox_model_) {
1951 base::string16 country = model->GetItemAt(index);
1952 std::string locale = g_browser_process->GetApplicationLocale();
1953 std::string country_code = AutofillCountry::GetCountryCode(country, locale);
1954 BuildInputsForSection(section, country_code);
1955 }
1956 }
1957
1949 void AutofillDialogControllerImpl::FocusMoved() { 1958 void AutofillDialogControllerImpl::FocusMoved() {
1950 HidePopup(); 1959 HidePopup();
1951 } 1960 }
1952 1961
1953 bool AutofillDialogControllerImpl::ShouldShowErrorBubble() const { 1962 bool AutofillDialogControllerImpl::ShouldShowErrorBubble() const {
1954 return !input_showing_popup_; 1963 return !input_showing_popup_;
1955 } 1964 }
1956 1965
1957 void AutofillDialogControllerImpl::ViewClosed() { 1966 void AutofillDialogControllerImpl::ViewClosed() {
1958 GetManager()->RemoveObserver(this); 1967 GetManager()->RemoveObserver(this);
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after
2445 void AutofillDialogControllerImpl::UpdateAccountChooserView() { 2454 void AutofillDialogControllerImpl::UpdateAccountChooserView() {
2446 if (view_) { 2455 if (view_) {
2447 ScopedViewUpdates updates(view_.get()); 2456 ScopedViewUpdates updates(view_.get());
2448 view_->UpdateAccountChooser(); 2457 view_->UpdateAccountChooser();
2449 view_->UpdateNotificationArea(); 2458 view_->UpdateNotificationArea();
2450 } 2459 }
2451 } 2460 }
2452 2461
2453 //////////////////////////////////////////////////////////////////////////////// 2462 ////////////////////////////////////////////////////////////////////////////////
2454 2463
2464
2465 void AutofillDialogControllerImpl::BuildInputsForSection(
2466 DialogSection section,
2467 const std::string& country_code) {
2468 DetailInputs* inputs = MutableRequestedFieldsForSection(section);
2469 common::BuildInputsForSection(section, inputs, country_code);
2470
2471 if (view_)
2472 view_->UpdateSection(section);
2473 }
2474
2455 bool AutofillDialogControllerImpl::HandleKeyPressEventInInput( 2475 bool AutofillDialogControllerImpl::HandleKeyPressEventInInput(
2456 const content::NativeWebKeyboardEvent& event) { 2476 const content::NativeWebKeyboardEvent& event) {
2457 if (popup_controller_.get()) 2477 if (popup_controller_.get())
2458 return popup_controller_->HandleKeyPressEvent(event); 2478 return popup_controller_->HandleKeyPressEvent(event);
2459 2479
2460 return false; 2480 return false;
2461 } 2481 }
2462 2482
2463 bool AutofillDialogControllerImpl::RequestingCreditCardInfo() const { 2483 bool AutofillDialogControllerImpl::RequestingCreditCardInfo() const {
2464 DCHECK_GT(form_structure_.field_count(), 0U); 2484 DCHECK_GT(form_structure_.field_count(), 0U);
(...skipping 1069 matching lines...) Expand 10 before | Expand all | Expand 10 after
3534 view_->UpdateButtonStrip(); 3554 view_->UpdateButtonStrip();
3535 } 3555 }
3536 3556
3537 void AutofillDialogControllerImpl::FetchWalletCookie() { 3557 void AutofillDialogControllerImpl::FetchWalletCookie() {
3538 net::URLRequestContextGetter* request_context = profile_->GetRequestContext(); 3558 net::URLRequestContextGetter* request_context = profile_->GetRequestContext();
3539 signin_helper_.reset(new wallet::WalletSigninHelper(this, request_context)); 3559 signin_helper_.reset(new wallet::WalletSigninHelper(this, request_context));
3540 signin_helper_->StartWalletCookieValueFetch(); 3560 signin_helper_->StartWalletCookieValueFetch();
3541 } 3561 }
3542 3562
3543 } // namespace autofill 3563 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698