OLD | NEW |
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 1299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1310 } | 1310 } |
1311 | 1311 |
1312 void AutofillDialogViews::UpdateErrorBubble() { | 1312 void AutofillDialogViews::UpdateErrorBubble() { |
1313 if (!delegate_->ShouldShowErrorBubble()) | 1313 if (!delegate_->ShouldShowErrorBubble()) |
1314 HideErrorBubble(); | 1314 HideErrorBubble(); |
1315 } | 1315 } |
1316 | 1316 |
1317 void AutofillDialogViews::FillSection(DialogSection section, | 1317 void AutofillDialogViews::FillSection(DialogSection section, |
1318 ServerFieldType originating_type) { | 1318 ServerFieldType originating_type) { |
1319 DetailsGroup* group = GroupForSection(section); | 1319 DetailsGroup* group = GroupForSection(section); |
1320 // Make sure to overwrite the originating input. | 1320 // Make sure to overwrite the originating input if it exists. |
1321 TextfieldMap::iterator text_mapping = | 1321 TextfieldMap::iterator text_mapping = |
1322 group->textfields.find(originating_type); | 1322 group->textfields.find(originating_type); |
1323 if (text_mapping != group->textfields.end()) | 1323 if (text_mapping != group->textfields.end()) |
1324 text_mapping->second->SetText(base::string16()); | 1324 text_mapping->second->SetText(base::string16()); |
1325 | 1325 |
1326 // If the Autofill data comes from a credit card, make sure to overwrite the | 1326 // If the Autofill data comes from a credit card, make sure to overwrite the |
1327 // CC comboboxes (even if they already have something in them). If the | 1327 // CC comboboxes (even if they already have something in them). If the |
1328 // Autofill data comes from an AutofillProfile, leave the comboboxes alone. | 1328 // Autofill data comes from an AutofillProfile, leave the comboboxes alone. |
1329 if (section == GetCreditCardSection() && | 1329 if (section == GetCreditCardSection() && |
1330 AutofillType(originating_type).group() == CREDIT_CARD) { | 1330 AutofillType(originating_type).group() == CREDIT_CARD) { |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1460 ServerFieldType type, | 1460 ServerFieldType type, |
1461 const base::string16& contents) { | 1461 const base::string16& contents) { |
1462 views::Textfield* textfield = TextfieldForType(type); | 1462 views::Textfield* textfield = TextfieldForType(type); |
1463 if (textfield) { | 1463 if (textfield) { |
1464 textfield->SetText(contents); | 1464 textfield->SetText(contents); |
1465 return; | 1465 return; |
1466 } | 1466 } |
1467 | 1467 |
1468 views::Combobox* combobox = ComboboxForType(type); | 1468 views::Combobox* combobox = ComboboxForType(type); |
1469 if (combobox) { | 1469 if (combobox) { |
| 1470 int selected_index = combobox->selected_index(); |
1470 SelectComboboxValueOrSetToDefault(combobox, contents); | 1471 SelectComboboxValueOrSetToDefault(combobox, contents); |
| 1472 if (combobox->selected_index() != selected_index) |
| 1473 OnSelectedIndexChanged(combobox); |
1471 return; | 1474 return; |
1472 } | 1475 } |
1473 | 1476 |
1474 NOTREACHED(); | 1477 NOTREACHED(); |
1475 } | 1478 } |
1476 | 1479 |
1477 void AutofillDialogViews::SetTextContentsOfSuggestionInput( | 1480 void AutofillDialogViews::SetTextContentsOfSuggestionInput( |
1478 DialogSection section, | 1481 DialogSection section, |
1479 const base::string16& text) { | 1482 const base::string16& text) { |
1480 GroupForSection(section)->suggested_info->decorated_textfield()-> | 1483 GroupForSection(section)->suggested_info->decorated_textfield()-> |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1529 | 1532 |
1530 // The rest (the |scrollable_area_|) takes up whatever's left. | 1533 // The rest (the |scrollable_area_|) takes up whatever's left. |
1531 if (scrollable_area_->visible()) { | 1534 if (scrollable_area_->visible()) { |
1532 int scroll_y = y; | 1535 int scroll_y = y; |
1533 if (notification_height > notification_area_->GetInsets().height()) | 1536 if (notification_height > notification_area_->GetInsets().height()) |
1534 scroll_y += notification_height + views::kRelatedControlVerticalSpacing; | 1537 scroll_y += notification_height + views::kRelatedControlVerticalSpacing; |
1535 | 1538 |
1536 int scroll_bottom = content_bounds.bottom(); | 1539 int scroll_bottom = content_bounds.bottom(); |
1537 DCHECK_EQ(scrollable_area_->contents(), details_container_); | 1540 DCHECK_EQ(scrollable_area_->contents(), details_container_); |
1538 details_container_->SizeToPreferredSize(); | 1541 details_container_->SizeToPreferredSize(); |
| 1542 details_container_->Layout(); |
1539 // TODO(estade): remove this hack. See crbug.com/285996 | 1543 // TODO(estade): remove this hack. See crbug.com/285996 |
1540 details_container_->set_ignore_layouts(true); | 1544 details_container_->set_ignore_layouts(true); |
1541 scrollable_area_->SetBounds(x, scroll_y, width, scroll_bottom - scroll_y); | 1545 scrollable_area_->SetBounds(x, scroll_y, width, scroll_bottom - scroll_y); |
1542 details_container_->set_ignore_layouts(false); | 1546 details_container_->set_ignore_layouts(false); |
1543 } | 1547 } |
1544 | 1548 |
1545 if (error_bubble_) | 1549 if (error_bubble_) |
1546 error_bubble_->UpdatePosition(); | 1550 error_bubble_->UpdatePosition(); |
1547 } | 1551 } |
1548 | 1552 |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1736 } | 1740 } |
1737 | 1741 |
1738 // Show an error bubble when the user focuses the input. | 1742 // Show an error bubble when the user focuses the input. |
1739 if (focused_now) { | 1743 if (focused_now) { |
1740 focused_now->ScrollRectToVisible(focused_now->GetLocalBounds()); | 1744 focused_now->ScrollRectToVisible(focused_now->GetLocalBounds()); |
1741 ShowErrorBubbleForViewIfNecessary(focused_now); | 1745 ShowErrorBubbleForViewIfNecessary(focused_now); |
1742 } | 1746 } |
1743 } | 1747 } |
1744 | 1748 |
1745 void AutofillDialogViews::OnSelectedIndexChanged(views::Combobox* combobox) { | 1749 void AutofillDialogViews::OnSelectedIndexChanged(views::Combobox* combobox) { |
1746 DetailsGroup* group = GroupForView(combobox); | 1750 DialogSection section = GroupForView(combobox)->section; |
1747 ValidateGroup(*group, VALIDATE_EDIT); | 1751 |
1748 SetEditabilityForSection(group->section); | 1752 delegate_->ComboboxItemSelected(TypeForCombobox(combobox), |
| 1753 combobox->selected_index()); |
| 1754 // NOTE: |combobox| may have been deleted. |
| 1755 |
| 1756 ValidateGroup(*GroupForSection(section), VALIDATE_EDIT); |
| 1757 SetEditabilityForSection(section); |
1749 } | 1758 } |
1750 | 1759 |
1751 void AutofillDialogViews::StyledLabelLinkClicked(const gfx::Range& range, | 1760 void AutofillDialogViews::StyledLabelLinkClicked(const gfx::Range& range, |
1752 int event_flags) { | 1761 int event_flags) { |
1753 delegate_->LegalDocumentLinkClicked(range); | 1762 delegate_->LegalDocumentLinkClicked(range); |
1754 } | 1763 } |
1755 | 1764 |
1756 void AutofillDialogViews::OnMenuButtonClicked(views::View* source, | 1765 void AutofillDialogViews::OnMenuButtonClicked(views::View* source, |
1757 const gfx::Point& point) { | 1766 const gfx::Point& point) { |
1758 DCHECK_EQ(kSuggestedButtonClassName, source->GetClassName()); | 1767 DCHECK_EQ(kSuggestedButtonClassName, source->GetClassName()); |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1896 AddChildView(sign_in_web_view_); | 1905 AddChildView(sign_in_web_view_); |
1897 | 1906 |
1898 overlay_view_ = new OverlayView(delegate_); | 1907 overlay_view_ = new OverlayView(delegate_); |
1899 overlay_view_->SetVisible(false); | 1908 overlay_view_->SetVisible(false); |
1900 } | 1909 } |
1901 | 1910 |
1902 views::View* AutofillDialogViews::CreateDetailsContainer() { | 1911 views::View* AutofillDialogViews::CreateDetailsContainer() { |
1903 details_container_ = new DetailsContainerView( | 1912 details_container_ = new DetailsContainerView( |
1904 base::Bind(&AutofillDialogViews::DetailsContainerBoundsChanged, | 1913 base::Bind(&AutofillDialogViews::DetailsContainerBoundsChanged, |
1905 base::Unretained(this))); | 1914 base::Unretained(this))); |
| 1915 |
1906 // A box layout is used because it respects widget visibility. | 1916 // A box layout is used because it respects widget visibility. |
1907 details_container_->SetLayoutManager( | 1917 details_container_->SetLayoutManager( |
1908 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); | 1918 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); |
1909 for (DetailGroupMap::iterator iter = detail_groups_.begin(); | 1919 for (DetailGroupMap::iterator iter = detail_groups_.begin(); |
1910 iter != detail_groups_.end(); ++iter) { | 1920 iter != detail_groups_.end(); ++iter) { |
1911 CreateDetailsSection(iter->second.section); | 1921 CreateDetailsSection(iter->second.section); |
1912 details_container_->AddChildView(iter->second.container); | 1922 details_container_->AddChildView(iter->second.container); |
1913 } | 1923 } |
1914 | 1924 |
1915 return details_container_; | 1925 return details_container_; |
(...skipping 12 matching lines...) Expand all Loading... |
1928 UpdateDetailsGroupState(*group); | 1938 UpdateDetailsGroupState(*group); |
1929 } | 1939 } |
1930 | 1940 |
1931 views::View* AutofillDialogViews::CreateInputsContainer(DialogSection section) { | 1941 views::View* AutofillDialogViews::CreateInputsContainer(DialogSection section) { |
1932 // The |info_view| holds |manual_inputs| and |suggested_info|, allowing the | 1942 // The |info_view| holds |manual_inputs| and |suggested_info|, allowing the |
1933 // dialog to toggle which is shown. | 1943 // dialog to toggle which is shown. |
1934 views::View* info_view = new views::View(); | 1944 views::View* info_view = new views::View(); |
1935 info_view->SetLayoutManager( | 1945 info_view->SetLayoutManager( |
1936 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); | 1946 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); |
1937 | 1947 |
1938 views::View* manual_inputs = InitInputsView(section); | 1948 DetailsGroup* group = GroupForSection(section); |
1939 info_view->AddChildView(manual_inputs); | 1949 group->manual_input = new views::View(); |
1940 SuggestionView* suggested_info = new SuggestionView(this); | 1950 InitInputsView(section); |
1941 info_view->AddChildView(suggested_info); | 1951 info_view->AddChildView(group->manual_input); |
1942 | 1952 |
1943 DetailsGroup* group = GroupForSection(section); | 1953 group->suggested_info = new SuggestionView(this); |
| 1954 info_view->AddChildView(group->suggested_info); |
| 1955 |
1944 // TODO(estade): It might be slightly more OO if this button were created | 1956 // TODO(estade): It might be slightly more OO if this button were created |
1945 // and listened to by the section container. | 1957 // and listened to by the section container. |
1946 group->suggested_button = new SuggestedButton(this); | 1958 group->suggested_button = new SuggestedButton(this); |
1947 group->manual_input = manual_inputs; | |
1948 group->suggested_info = suggested_info; | |
1949 | 1959 |
1950 return info_view; | 1960 return info_view; |
1951 } | 1961 } |
1952 | 1962 |
1953 // TODO(estade): we should be using Chrome-style constrained window padding | 1963 // TODO(estade): we should be using Chrome-style constrained window padding |
1954 // values. | 1964 // values. |
1955 views::View* AutofillDialogViews::InitInputsView(DialogSection section) { | 1965 void AutofillDialogViews::InitInputsView(DialogSection section) { |
1956 const DetailInputs& inputs = delegate_->RequestedFieldsForSection(section); | 1966 DetailsGroup* group = GroupForSection(section); |
1957 TextfieldMap* textfields = &GroupForSection(section)->textfields; | 1967 EraseInvalidViewsInGroup(group); |
1958 ComboboxMap* comboboxes = &GroupForSection(section)->comboboxes; | |
1959 | 1968 |
1960 views::View* view = new views::View(); | 1969 TextfieldMap* textfields = &group->textfields; |
| 1970 textfields->clear(); |
| 1971 |
| 1972 ComboboxMap* comboboxes = &group->comboboxes; |
| 1973 comboboxes->clear(); |
| 1974 |
| 1975 views::View* view = group->manual_input; |
| 1976 view->RemoveAllChildViews(true); |
| 1977 |
1961 views::GridLayout* layout = new views::GridLayout(view); | 1978 views::GridLayout* layout = new views::GridLayout(view); |
1962 view->SetLayoutManager(layout); | 1979 view->SetLayoutManager(layout); |
1963 | 1980 |
1964 int column_set_id = 0; | 1981 int column_set_id = 0; |
| 1982 const DetailInputs& inputs = delegate_->RequestedFieldsForSection(section); |
1965 for (DetailInputs::const_iterator it = inputs.begin(); | 1983 for (DetailInputs::const_iterator it = inputs.begin(); |
1966 it != inputs.end(); ++it) { | 1984 it != inputs.end(); ++it) { |
1967 const DetailInput& input = *it; | 1985 const DetailInput& input = *it; |
| 1986 |
1968 ui::ComboboxModel* input_model = | 1987 ui::ComboboxModel* input_model = |
1969 delegate_->ComboboxModelForAutofillType(input.type); | 1988 delegate_->ComboboxModelForAutofillType(input.type); |
1970 scoped_ptr<views::View> view_to_add; | 1989 scoped_ptr<views::View> view_to_add; |
1971 if (input_model) { | 1990 if (input_model) { |
1972 views::Combobox* combobox = new views::Combobox(input_model); | 1991 views::Combobox* combobox = new views::Combobox(input_model); |
1973 combobox->set_listener(this); | 1992 combobox->set_listener(this); |
1974 comboboxes->insert(std::make_pair(input.type, combobox)); | 1993 comboboxes->insert(std::make_pair(input.type, combobox)); |
1975 SelectComboboxValueOrSetToDefault(combobox, input.initial_value); | 1994 SelectComboboxValueOrSetToDefault(combobox, input.initial_value); |
1976 view_to_add.reset(combobox); | 1995 view_to_add.reset(combobox); |
1977 } else { | 1996 } else { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2020 views::GridLayout::FILL, views::GridLayout::FILL, | 2039 views::GridLayout::FILL, views::GridLayout::FILL, |
2021 1, 0); | 2040 1, 0); |
2022 | 2041 |
2023 if (input.length == DetailInput::LONG || | 2042 if (input.length == DetailInput::LONG || |
2024 input.length == DetailInput::SHORT_EOL) { | 2043 input.length == DetailInput::SHORT_EOL) { |
2025 ++column_set_id; | 2044 ++column_set_id; |
2026 } | 2045 } |
2027 } | 2046 } |
2028 | 2047 |
2029 SetIconsForSection(section); | 2048 SetIconsForSection(section); |
2030 | |
2031 return view; | |
2032 } | 2049 } |
2033 | 2050 |
2034 void AutofillDialogViews::ShowDialogInMode(DialogMode dialog_mode) { | 2051 void AutofillDialogViews::ShowDialogInMode(DialogMode dialog_mode) { |
2035 loading_shield_->SetVisible(dialog_mode == LOADING); | 2052 loading_shield_->SetVisible(dialog_mode == LOADING); |
2036 sign_in_web_view_->SetVisible(dialog_mode == SIGN_IN); | 2053 sign_in_web_view_->SetVisible(dialog_mode == SIGN_IN); |
2037 notification_area_->SetVisible(dialog_mode == DETAIL_INPUT); | 2054 notification_area_->SetVisible(dialog_mode == DETAIL_INPUT); |
2038 scrollable_area_->SetVisible(dialog_mode == DETAIL_INPUT); | 2055 scrollable_area_->SetVisible(dialog_mode == DETAIL_INPUT); |
2039 FocusInitialView(); | 2056 FocusInitialView(); |
2040 } | 2057 } |
2041 | 2058 |
2042 void AutofillDialogViews::UpdateSectionImpl( | 2059 void AutofillDialogViews::UpdateSectionImpl( |
2043 DialogSection section, | 2060 DialogSection section, |
2044 bool clobber_inputs) { | 2061 bool clobber_inputs) { |
2045 // Reset all validity marks for this section. | |
2046 if (clobber_inputs) | |
2047 MarkInputsInvalid(section, ValidityMessages(), true); | |
2048 | |
2049 const DetailInputs& updated_inputs = | |
2050 delegate_->RequestedFieldsForSection(section); | |
2051 DetailsGroup* group = GroupForSection(section); | 2062 DetailsGroup* group = GroupForSection(section); |
2052 | 2063 |
2053 for (DetailInputs::const_iterator iter = updated_inputs.begin(); | 2064 if (clobber_inputs) { |
2054 iter != updated_inputs.end(); ++iter) { | 2065 InitInputsView(section); |
2055 const DetailInput& input = *iter; | 2066 } else { |
2056 TextfieldMap::iterator text_mapping = group->textfields.find(input.type); | 2067 const DetailInputs& updated_inputs = |
| 2068 delegate_->RequestedFieldsForSection(section); |
2057 | 2069 |
2058 if (text_mapping != group->textfields.end()) { | 2070 for (DetailInputs::const_iterator iter = updated_inputs.begin(); |
2059 DecoratedTextfield* decorated = text_mapping->second; | 2071 iter != updated_inputs.end(); ++iter) { |
2060 if (decorated->text().empty() || clobber_inputs) | 2072 const DetailInput& input = *iter; |
2061 decorated->SetText(input.initial_value); | 2073 |
| 2074 TextfieldMap::iterator text_mapping = group->textfields.find(input.type); |
| 2075 if (text_mapping != group->textfields.end()) { |
| 2076 DecoratedTextfield* decorated = text_mapping->second; |
| 2077 if (decorated->text().empty()) |
| 2078 decorated->SetText(input.initial_value); |
| 2079 } |
| 2080 |
| 2081 ComboboxMap::iterator combo_mapping = group->comboboxes.find(input.type); |
| 2082 if (combo_mapping != group->comboboxes.end()) { |
| 2083 views::Combobox* combobox = combo_mapping->second; |
| 2084 if (combobox->selected_index() == combobox->model()->GetDefaultIndex()) |
| 2085 SelectComboboxValueOrSetToDefault(combobox, input.initial_value); |
| 2086 } |
2062 } | 2087 } |
2063 | 2088 |
2064 ComboboxMap::iterator combo_mapping = group->comboboxes.find(input.type); | 2089 SetIconsForSection(section); |
2065 if (combo_mapping != group->comboboxes.end()) { | |
2066 views::Combobox* combobox = combo_mapping->second; | |
2067 if (combobox->selected_index() == combobox->model()->GetDefaultIndex() || | |
2068 clobber_inputs) { | |
2069 SelectComboboxValueOrSetToDefault(combobox, input.initial_value); | |
2070 } | |
2071 } | |
2072 } | 2090 } |
2073 | 2091 |
2074 SetIconsForSection(section); | |
2075 SetEditabilityForSection(section); | 2092 SetEditabilityForSection(section); |
2076 UpdateDetailsGroupState(*group); | 2093 UpdateDetailsGroupState(*group); |
2077 } | 2094 } |
2078 | 2095 |
2079 void AutofillDialogViews::UpdateDetailsGroupState(const DetailsGroup& group) { | 2096 void AutofillDialogViews::UpdateDetailsGroupState(const DetailsGroup& group) { |
2080 const SuggestionState& suggestion_state = | 2097 const SuggestionState& suggestion_state = |
2081 delegate_->SuggestionStateForSection(group.section); | 2098 delegate_->SuggestionStateForSection(group.section); |
2082 group.suggested_info->SetState(suggestion_state); | 2099 group.suggested_info->SetState(suggestion_state); |
2083 group.manual_input->SetVisible(!suggestion_state.visible); | 2100 group.manual_input->SetVisible(!suggestion_state.visible); |
2084 | 2101 |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2174 SetValidityForInput(iter->second, message.text); | 2191 SetValidityForInput(iter->second, message.text); |
2175 } | 2192 } |
2176 for (ComboboxMap::const_iterator iter = group->comboboxes.begin(); | 2193 for (ComboboxMap::const_iterator iter = group->comboboxes.begin(); |
2177 iter != group->comboboxes.end(); ++iter) { | 2194 iter != group->comboboxes.end(); ++iter) { |
2178 const ValidityMessage& message = | 2195 const ValidityMessage& message = |
2179 messages.GetMessageOrDefault(iter->first); | 2196 messages.GetMessageOrDefault(iter->first); |
2180 if (overwrite_unsure || message.sure) | 2197 if (overwrite_unsure || message.sure) |
2181 SetValidityForInput(iter->second, message.text); | 2198 SetValidityForInput(iter->second, message.text); |
2182 } | 2199 } |
2183 } else { | 2200 } else { |
2184 // Purge invisible views from |validity_map_|. | 2201 EraseInvalidViewsInGroup(group); |
2185 std::map<views::View*, base::string16>::iterator it; | |
2186 for (it = validity_map_.begin(); it != validity_map_.end();) { | |
2187 DCHECK(GroupForView(it->first)); | |
2188 if (GroupForView(it->first) == group) | |
2189 validity_map_.erase(it++); | |
2190 else | |
2191 ++it; | |
2192 } | |
2193 | 2202 |
2194 if (section == GetCreditCardSection()) { | 2203 if (section == GetCreditCardSection()) { |
2195 // Special case CVC as it's not part of |group->manual_input|. | 2204 // Special case CVC as it's not part of |group->manual_input|. |
2196 const ValidityMessage& message = | 2205 const ValidityMessage& message = |
2197 messages.GetMessageOrDefault(CREDIT_CARD_VERIFICATION_CODE); | 2206 messages.GetMessageOrDefault(CREDIT_CARD_VERIFICATION_CODE); |
2198 if (overwrite_unsure || message.sure) { | 2207 if (overwrite_unsure || message.sure) { |
2199 SetValidityForInput(group->suggested_info->decorated_textfield(), | 2208 SetValidityForInput(group->suggested_info->decorated_textfield(), |
2200 message.text); | 2209 message.text); |
2201 } | 2210 } |
2202 } | 2211 } |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2364 // inputs instead of directly editable inputs. Those are accessed via | 2373 // inputs instead of directly editable inputs. Those are accessed via |
2365 // |suggested_info|. | 2374 // |suggested_info|. |
2366 if (decorated && | 2375 if (decorated && |
2367 decorated == group->suggested_info->decorated_textfield()) { | 2376 decorated == group->suggested_info->decorated_textfield()) { |
2368 return group; | 2377 return group; |
2369 } | 2378 } |
2370 } | 2379 } |
2371 return NULL; | 2380 return NULL; |
2372 } | 2381 } |
2373 | 2382 |
| 2383 void AutofillDialogViews::EraseInvalidViewsInGroup(const DetailsGroup* group) { |
| 2384 std::map<views::View*, base::string16>::iterator it = validity_map_.begin(); |
| 2385 while (it != validity_map_.end()) { |
| 2386 if (GroupForView(it->first) == group) |
| 2387 validity_map_.erase(it++); |
| 2388 else |
| 2389 ++it; |
| 2390 } |
| 2391 } |
| 2392 |
2374 views::Textfield* AutofillDialogViews::TextfieldForType( | 2393 views::Textfield* AutofillDialogViews::TextfieldForType( |
2375 ServerFieldType type) { | 2394 ServerFieldType type) { |
2376 for (DetailGroupMap::iterator iter = detail_groups_.begin(); | 2395 for (DetailGroupMap::iterator iter = detail_groups_.begin(); |
2377 iter != detail_groups_.end(); ++iter) { | 2396 iter != detail_groups_.end(); ++iter) { |
2378 const DetailsGroup& group = iter->second; | 2397 const DetailsGroup& group = iter->second; |
2379 TextfieldMap::const_iterator text_mapping = group.textfields.find(type); | 2398 TextfieldMap::const_iterator text_mapping = group.textfields.find(type); |
2380 if (text_mapping != group.textfields.end()) | 2399 if (text_mapping != group.textfields.end()) |
2381 return text_mapping->second; | 2400 return text_mapping->second; |
2382 } | 2401 } |
2383 | 2402 |
2384 return NULL; | 2403 return NULL; |
2385 } | 2404 } |
2386 | 2405 |
2387 views::Combobox* AutofillDialogViews::ComboboxForType( | 2406 views::Combobox* AutofillDialogViews::ComboboxForType( |
2388 ServerFieldType type) { | 2407 ServerFieldType type) { |
2389 for (DetailGroupMap::iterator iter = detail_groups_.begin(); | 2408 for (DetailGroupMap::iterator iter = detail_groups_.begin(); |
2390 iter != detail_groups_.end(); ++iter) { | 2409 iter != detail_groups_.end(); ++iter) { |
2391 const DetailsGroup& group = iter->second; | 2410 const DetailsGroup& group = iter->second; |
2392 ComboboxMap::const_iterator combo_mapping = group.comboboxes.find(type); | 2411 ComboboxMap::const_iterator combo_mapping = group.comboboxes.find(type); |
2393 if (combo_mapping != group.comboboxes.end()) | 2412 if (combo_mapping != group.comboboxes.end()) |
2394 return combo_mapping->second; | 2413 return combo_mapping->second; |
2395 } | 2414 } |
2396 | 2415 |
2397 return NULL; | 2416 return NULL; |
2398 } | 2417 } |
2399 | 2418 |
| 2419 ServerFieldType AutofillDialogViews::TypeForCombobox( |
| 2420 const views::Combobox* combobox) const { |
| 2421 for (DetailGroupMap::const_iterator it = detail_groups_.begin(); |
| 2422 it != detail_groups_.end(); ++it) { |
| 2423 const DetailsGroup& group = it->second; |
| 2424 for (ComboboxMap::const_iterator combo_it = group.comboboxes.begin(); |
| 2425 combo_it != group.comboboxes.end(); ++combo_it) { |
| 2426 if (combo_it->second == combobox) |
| 2427 return combo_it->first; |
| 2428 } |
| 2429 } |
| 2430 NOTREACHED(); |
| 2431 return UNKNOWN_TYPE; |
| 2432 } |
| 2433 |
2400 void AutofillDialogViews::DetailsContainerBoundsChanged() { | 2434 void AutofillDialogViews::DetailsContainerBoundsChanged() { |
2401 if (error_bubble_) | 2435 if (error_bubble_) |
2402 error_bubble_->UpdatePosition(); | 2436 error_bubble_->UpdatePosition(); |
2403 } | 2437 } |
2404 | 2438 |
2405 void AutofillDialogViews::SetIconsForSection(DialogSection section) { | 2439 void AutofillDialogViews::SetIconsForSection(DialogSection section) { |
2406 FieldValueMap user_input; | 2440 FieldValueMap user_input; |
2407 GetUserInput(section, &user_input); | 2441 GetUserInput(section, &user_input); |
2408 FieldIconMap field_icons = delegate_->IconsForFields(user_input); | 2442 FieldIconMap field_icons = delegate_->IconsForFields(user_input); |
2409 TextfieldMap* textfields = &GroupForSection(section)->textfields; | 2443 TextfieldMap* textfields = &GroupForSection(section)->textfields; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2448 AutofillDialogViews::DetailsGroup::DetailsGroup(DialogSection section) | 2482 AutofillDialogViews::DetailsGroup::DetailsGroup(DialogSection section) |
2449 : section(section), | 2483 : section(section), |
2450 container(NULL), | 2484 container(NULL), |
2451 manual_input(NULL), | 2485 manual_input(NULL), |
2452 suggested_info(NULL), | 2486 suggested_info(NULL), |
2453 suggested_button(NULL) {} | 2487 suggested_button(NULL) {} |
2454 | 2488 |
2455 AutofillDialogViews::DetailsGroup::~DetailsGroup() {} | 2489 AutofillDialogViews::DetailsGroup::~DetailsGroup() {} |
2456 | 2490 |
2457 } // namespace autofill | 2491 } // namespace autofill |
OLD | NEW |