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

Side by Side Diff: chrome/browser/ui/views/autofill/autofill_dialog_views.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 (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/views/autofill/autofill_dialog_views.h" 5 #include "chrome/browser/ui/views/autofill/autofill_dialog_views.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 1715 matching lines...) Expand 10 before | Expand all | Expand 10 after
1726 } 1726 }
1727 1727
1728 // Show an error bubble when the user focuses the input. 1728 // Show an error bubble when the user focuses the input.
1729 if (focused_now) { 1729 if (focused_now) {
1730 focused_now->ScrollRectToVisible(focused_now->GetLocalBounds()); 1730 focused_now->ScrollRectToVisible(focused_now->GetLocalBounds());
1731 ShowErrorBubbleForViewIfNecessary(focused_now); 1731 ShowErrorBubbleForViewIfNecessary(focused_now);
1732 } 1732 }
1733 } 1733 }
1734 1734
1735 void AutofillDialogViews::OnSelectedIndexChanged(views::Combobox* combobox) { 1735 void AutofillDialogViews::OnSelectedIndexChanged(views::Combobox* combobox) {
1736 DetailsGroup* group = GroupForView(combobox); 1736 DialogSection section = GroupForView(combobox)->section;
1737 ValidateGroup(*group, VALIDATE_EDIT); 1737 int index = combobox->selected_index();
1738 SetEditabilityForSection(group->section); 1738 delegate_->ComboboxItemSelected(combobox->model(), section, index);
1739 ValidateGroup(*GroupForSection(section), VALIDATE_EDIT);
1740 SetEditabilityForSection(section);
1739 } 1741 }
1740 1742
1741 void AutofillDialogViews::StyledLabelLinkClicked(const gfx::Range& range, 1743 void AutofillDialogViews::StyledLabelLinkClicked(const gfx::Range& range,
1742 int event_flags) { 1744 int event_flags) {
1743 delegate_->LegalDocumentLinkClicked(range); 1745 delegate_->LegalDocumentLinkClicked(range);
1744 } 1746 }
1745 1747
1746 void AutofillDialogViews::OnMenuButtonClicked(views::View* source, 1748 void AutofillDialogViews::OnMenuButtonClicked(views::View* source,
1747 const gfx::Point& point) { 1749 const gfx::Point& point) {
1748 DCHECK_EQ(kSuggestedButtonClassName, source->GetClassName()); 1750 DCHECK_EQ(kSuggestedButtonClassName, source->GetClassName());
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
1886 AddChildView(sign_in_web_view_); 1888 AddChildView(sign_in_web_view_);
1887 1889
1888 overlay_view_ = new OverlayView(delegate_); 1890 overlay_view_ = new OverlayView(delegate_);
1889 overlay_view_->SetVisible(false); 1891 overlay_view_->SetVisible(false);
1890 } 1892 }
1891 1893
1892 views::View* AutofillDialogViews::CreateDetailsContainer() { 1894 views::View* AutofillDialogViews::CreateDetailsContainer() {
1893 details_container_ = new DetailsContainerView( 1895 details_container_ = new DetailsContainerView(
1894 base::Bind(&AutofillDialogViews::DetailsContainerBoundsChanged, 1896 base::Bind(&AutofillDialogViews::DetailsContainerBoundsChanged,
1895 base::Unretained(this))); 1897 base::Unretained(this)));
1898
1896 // A box layout is used because it respects widget visibility. 1899 // A box layout is used because it respects widget visibility.
1897 details_container_->SetLayoutManager( 1900 details_container_->SetLayoutManager(
1898 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); 1901 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0));
1899 for (DetailGroupMap::iterator iter = detail_groups_.begin(); 1902 for (DetailGroupMap::iterator iter = detail_groups_.begin();
1900 iter != detail_groups_.end(); ++iter) { 1903 iter != detail_groups_.end(); ++iter) {
1901 CreateDetailsSection(iter->second.section); 1904 CreateDetailsSection(iter->second.section);
1902 details_container_->AddChildView(iter->second.container); 1905 details_container_->AddChildView(iter->second.container);
1903 } 1906 }
1904 1907
1905 return details_container_; 1908 return details_container_;
1906 } 1909 }
1907 1910
1908 void AutofillDialogViews::CreateDetailsSection(DialogSection section) { 1911 void AutofillDialogViews::CreateDetailsSection(DialogSection section) {
1909 // Inputs container (manual inputs + combobox). 1912 // Inputs container (manual inputs + combobox).
1910 views::View* inputs_container = CreateInputsContainer(section); 1913 views::View* inputs_container = CreateInputsContainer(section);
1914 DetailsGroup* group = GroupForSection(section);
1911 1915
1912 DetailsGroup* group = GroupForSection(section);
1913 // Container (holds label + inputs). 1916 // Container (holds label + inputs).
1914 group->container = new SectionContainer( 1917 group->container = new SectionContainer(
1915 delegate_->LabelForSection(section), 1918 delegate_->LabelForSection(section),
1916 inputs_container, 1919 inputs_container,
1917 group->suggested_button); 1920 group->suggested_button);
1918 DCHECK(group->suggested_button->parent()); 1921 DCHECK(group->suggested_button->parent());
1919 UpdateDetailsGroupState(*group); 1922 UpdateDetailsGroupState(*group);
1920 } 1923 }
1921 1924
1922 views::View* AutofillDialogViews::CreateInputsContainer(DialogSection section) { 1925 views::View* AutofillDialogViews::CreateInputsContainer(DialogSection section) {
(...skipping 14 matching lines...) Expand all
1937 group->suggested_button = new SuggestedButton(this); 1940 group->suggested_button = new SuggestedButton(this);
1938 group->manual_input = manual_inputs; 1941 group->manual_input = manual_inputs;
1939 group->suggested_info = suggested_info; 1942 group->suggested_info = suggested_info;
1940 1943
1941 return info_view; 1944 return info_view;
1942 } 1945 }
1943 1946
1944 // TODO(estade): we should be using Chrome-style constrained window padding 1947 // TODO(estade): we should be using Chrome-style constrained window padding
1945 // values. 1948 // values.
1946 views::View* AutofillDialogViews::InitInputsView(DialogSection section) { 1949 views::View* AutofillDialogViews::InitInputsView(DialogSection section) {
1947 const DetailInputs& inputs = delegate_->RequestedFieldsForSection(section);
1948 TextfieldMap* textfields = &GroupForSection(section)->textfields; 1950 TextfieldMap* textfields = &GroupForSection(section)->textfields;
1951 textfields->clear();
1952
1949 ComboboxMap* comboboxes = &GroupForSection(section)->comboboxes; 1953 ComboboxMap* comboboxes = &GroupForSection(section)->comboboxes;
1954 comboboxes->clear();
1950 1955
1951 views::View* view = new views::View(); 1956 views::View* view = new views::View();
1952 views::GridLayout* layout = new views::GridLayout(view); 1957 views::GridLayout* layout = new views::GridLayout(view);
1953 view->SetLayoutManager(layout); 1958 view->SetLayoutManager(layout);
1954 1959
1960 const DetailInputs& inputs = delegate_->RequestedFieldsForSection(section);
1955 for (DetailInputs::const_iterator it = inputs.begin(); 1961 for (DetailInputs::const_iterator it = inputs.begin();
1956 it != inputs.end(); ++it) { 1962 it != inputs.end(); ++it) {
1957 const DetailInput& input = *it; 1963 const DetailInput& input = *it;
1958 ui::ComboboxModel* input_model = 1964 ui::ComboboxModel* input_model =
1959 delegate_->ComboboxModelForAutofillType(input.type); 1965 delegate_->ComboboxModelForAutofillType(input.type);
1960 scoped_ptr<views::View> view_to_add; 1966 scoped_ptr<views::View> view_to_add;
1961 if (input_model) { 1967 if (input_model) {
1962 views::Combobox* combobox = new views::Combobox(input_model); 1968 views::Combobox* combobox = new views::Combobox(input_model);
1963 combobox->set_listener(this); 1969 combobox->set_listener(this);
1964 comboboxes->insert(std::make_pair(&input, combobox)); 1970 comboboxes->insert(std::make_pair(&input, combobox));
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
2020 loading_shield_->SetVisible(dialog_mode == LOADING); 2026 loading_shield_->SetVisible(dialog_mode == LOADING);
2021 sign_in_web_view_->SetVisible(dialog_mode == SIGN_IN); 2027 sign_in_web_view_->SetVisible(dialog_mode == SIGN_IN);
2022 notification_area_->SetVisible(dialog_mode == DETAIL_INPUT); 2028 notification_area_->SetVisible(dialog_mode == DETAIL_INPUT);
2023 scrollable_area_->SetVisible(dialog_mode == DETAIL_INPUT); 2029 scrollable_area_->SetVisible(dialog_mode == DETAIL_INPUT);
2024 FocusInitialView(); 2030 FocusInitialView();
2025 } 2031 }
2026 2032
2027 void AutofillDialogViews::UpdateSectionImpl( 2033 void AutofillDialogViews::UpdateSectionImpl(
2028 DialogSection section, 2034 DialogSection section,
2029 bool clobber_inputs) { 2035 bool clobber_inputs) {
2030 // Reset all validity marks for this section. 2036 DetailsGroup* group = GroupForSection(section);
2031 if (clobber_inputs) 2037
2032 MarkInputsInvalid(section, ValidityMessages(), true); 2038 if (clobber_inputs) {
2039 views::View* parent = group->manual_input->parent();
2040 int add_index = parent->GetIndexOf(group->manual_input);
2041 parent->RemoveChildView(group->manual_input);
2042 group->manual_input = InitInputsView(section);
2043 parent->AddChildViewAt(group->manual_input, add_index);
Dan Beam 2013/11/22 00:15:24 ^ there are still paint issues here, but the rest
2044 }
2033 2045
2034 const DetailInputs& updated_inputs = 2046 const DetailInputs& updated_inputs =
2035 delegate_->RequestedFieldsForSection(section); 2047 delegate_->RequestedFieldsForSection(section);
2036 DetailsGroup* group = GroupForSection(section);
2037 2048
2038 for (DetailInputs::const_iterator iter = updated_inputs.begin(); 2049 for (DetailInputs::const_iterator iter = updated_inputs.begin();
2039 iter != updated_inputs.end(); ++iter) { 2050 iter != updated_inputs.end(); ++iter) {
2040 const DetailInput& input = *iter; 2051 const DetailInput& input = *iter;
2052
2041 TextfieldMap::iterator text_mapping = group->textfields.find(&input); 2053 TextfieldMap::iterator text_mapping = group->textfields.find(&input);
2042
2043 if (text_mapping != group->textfields.end()) { 2054 if (text_mapping != group->textfields.end()) {
2044 DecoratedTextfield* decorated = text_mapping->second; 2055 DecoratedTextfield* decorated = text_mapping->second;
2045 if (decorated->text().empty() || clobber_inputs) 2056 if (decorated->text().empty() || clobber_inputs)
2046 decorated->SetText(iter->initial_value); 2057 decorated->SetText(iter->initial_value);
2047 } 2058 }
2048 2059
2049 ComboboxMap::iterator combo_mapping = group->comboboxes.find(&input); 2060 ComboboxMap::iterator combo_mapping = group->comboboxes.find(&input);
2050 if (combo_mapping != group->comboboxes.end()) { 2061 if (combo_mapping != group->comboboxes.end()) {
2051 views::Combobox* combobox = combo_mapping->second; 2062 views::Combobox* combobox = combo_mapping->second;
2052 if (combobox->selected_index() == combobox->model()->GetDefaultIndex() || 2063 if (combobox->selected_index() == combobox->model()->GetDefaultIndex() ||
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
2167 iter != group->comboboxes.end(); ++iter) { 2178 iter != group->comboboxes.end(); ++iter) {
2168 const ValidityMessage& message = 2179 const ValidityMessage& message =
2169 messages.GetMessageOrDefault(iter->first->type); 2180 messages.GetMessageOrDefault(iter->first->type);
2170 if (overwrite_unsure || message.sure) 2181 if (overwrite_unsure || message.sure)
2171 SetValidityForInput(iter->second, message.text); 2182 SetValidityForInput(iter->second, message.text);
2172 } 2183 }
2173 } else { 2184 } else {
2174 // Purge invisible views from |validity_map_|. 2185 // Purge invisible views from |validity_map_|.
2175 std::map<views::View*, base::string16>::iterator it; 2186 std::map<views::View*, base::string16>::iterator it;
2176 for (it = validity_map_.begin(); it != validity_map_.end();) { 2187 for (it = validity_map_.begin(); it != validity_map_.end();) {
2177 DCHECK(GroupForView(it->first));
2178 if (GroupForView(it->first) == group) 2188 if (GroupForView(it->first) == group)
2179 validity_map_.erase(it++); 2189 validity_map_.erase(it++);
2180 else 2190 else
2181 ++it; 2191 ++it;
2182 } 2192 }
2183 2193
2184 if (section == GetCreditCardSection()) { 2194 if (section == GetCreditCardSection()) {
2185 // Special case CVC as it's not part of |group->manual_input|. 2195 // Special case CVC as it's not part of |group->manual_input|.
2186 const ValidityMessage& message = 2196 const ValidityMessage& message =
2187 messages.GetMessageOrDefault(CREDIT_CARD_VERIFICATION_CODE); 2197 messages.GetMessageOrDefault(CREDIT_CARD_VERIFICATION_CODE);
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
2450 AutofillDialogViews::DetailsGroup::DetailsGroup(DialogSection section) 2460 AutofillDialogViews::DetailsGroup::DetailsGroup(DialogSection section)
2451 : section(section), 2461 : section(section),
2452 container(NULL), 2462 container(NULL),
2453 manual_input(NULL), 2463 manual_input(NULL),
2454 suggested_info(NULL), 2464 suggested_info(NULL),
2455 suggested_button(NULL) {} 2465 suggested_button(NULL) {}
2456 2466
2457 AutofillDialogViews::DetailsGroup::~DetailsGroup() {} 2467 AutofillDialogViews::DetailsGroup::~DetailsGroup() {}
2458 2468
2459 } // namespace autofill 2469 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698