| 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/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 1661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1672 views::View* focused_before, | 1672 views::View* focused_before, |
| 1673 views::View* focused_now) { | 1673 views::View* focused_now) { |
| 1674 // If user leaves an edit-field, revalidate the group it belongs to. | 1674 // If user leaves an edit-field, revalidate the group it belongs to. |
| 1675 if (focused_before) { | 1675 if (focused_before) { |
| 1676 DetailsGroup* group = GroupForView(focused_before); | 1676 DetailsGroup* group = GroupForView(focused_before); |
| 1677 if (group && group->container->visible()) | 1677 if (group && group->container->visible()) |
| 1678 ValidateGroup(*group, VALIDATE_EDIT); | 1678 ValidateGroup(*group, VALIDATE_EDIT); |
| 1679 } | 1679 } |
| 1680 | 1680 |
| 1681 // Show an error bubble when the user focuses the input. | 1681 // Show an error bubble when the user focuses the input. |
| 1682 if (focused_now) | 1682 if (focused_now) { |
| 1683 focused_now->ScrollRectToVisible(focused_now->GetLocalBounds()); |
| 1683 ShowErrorBubbleForViewIfNecessary(focused_now); | 1684 ShowErrorBubbleForViewIfNecessary(focused_now); |
| 1685 } |
| 1684 } | 1686 } |
| 1685 | 1687 |
| 1686 void AutofillDialogViews::OnSelectedIndexChanged(views::Combobox* combobox) { | 1688 void AutofillDialogViews::OnSelectedIndexChanged(views::Combobox* combobox) { |
| 1687 DetailsGroup* group = GroupForView(combobox); | 1689 DetailsGroup* group = GroupForView(combobox); |
| 1688 ValidateGroup(*group, VALIDATE_EDIT); | 1690 ValidateGroup(*group, VALIDATE_EDIT); |
| 1689 } | 1691 } |
| 1690 | 1692 |
| 1691 void AutofillDialogViews::StyledLabelLinkClicked(const ui::Range& range, | 1693 void AutofillDialogViews::StyledLabelLinkClicked(const ui::Range& range, |
| 1692 int event_flags) { | 1694 int event_flags) { |
| 1693 delegate_->LegalDocumentLinkClicked(range); | 1695 delegate_->LegalDocumentLinkClicked(range); |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2008 validity_map_.erase(input); | 2010 validity_map_.erase(input); |
| 2009 error_bubble_.reset(); | 2011 error_bubble_.reset(); |
| 2010 } | 2012 } |
| 2011 } | 2013 } |
| 2012 } | 2014 } |
| 2013 | 2015 |
| 2014 void AutofillDialogViews::ShowErrorBubbleForViewIfNecessary(views::View* view) { | 2016 void AutofillDialogViews::ShowErrorBubbleForViewIfNecessary(views::View* view) { |
| 2015 if (!view->GetWidget()) | 2017 if (!view->GetWidget()) |
| 2016 return; | 2018 return; |
| 2017 | 2019 |
| 2018 if (error_bubble_ && error_bubble_->anchor() == view) | |
| 2019 return; | |
| 2020 | |
| 2021 std::map<views::View*, base::string16>::iterator error_message = | 2020 std::map<views::View*, base::string16>::iterator error_message = |
| 2022 validity_map_.find(view); | 2021 validity_map_.find(view); |
| 2023 if (error_message != validity_map_.end()) { | 2022 if (error_message != validity_map_.end()) { |
| 2024 view->ScrollRectToVisible(view->GetLocalBounds()); | 2023 view->ScrollRectToVisible(view->GetLocalBounds()); |
| 2025 error_bubble_.reset(new ErrorBubble(view, error_message->second)); | 2024 |
| 2025 if (!error_bubble_ || error_bubble_->anchor() != view) |
| 2026 error_bubble_.reset(new ErrorBubble(view, error_message->second)); |
| 2026 } | 2027 } |
| 2027 } | 2028 } |
| 2028 | 2029 |
| 2029 void AutofillDialogViews::MarkInputsInvalid(DialogSection section, | 2030 void AutofillDialogViews::MarkInputsInvalid(DialogSection section, |
| 2030 const ValidityData& validity_data) { | 2031 const ValidityData& validity_data) { |
| 2031 DetailsGroup* group = GroupForSection(section); | 2032 DetailsGroup* group = GroupForSection(section); |
| 2032 DCHECK(group->container->visible()); | 2033 DCHECK(group->container->visible()); |
| 2033 | 2034 |
| 2034 typedef std::map<ServerFieldType, | 2035 typedef std::map<ServerFieldType, |
| 2035 base::Callback<void(const base::string16&)> > FieldMap; | 2036 base::Callback<void(const base::string16&)> > FieldMap; |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2280 AutofillDialogViews::DetailsGroup::DetailsGroup(DialogSection section) | 2281 AutofillDialogViews::DetailsGroup::DetailsGroup(DialogSection section) |
| 2281 : section(section), | 2282 : section(section), |
| 2282 container(NULL), | 2283 container(NULL), |
| 2283 manual_input(NULL), | 2284 manual_input(NULL), |
| 2284 suggested_info(NULL), | 2285 suggested_info(NULL), |
| 2285 suggested_button(NULL) {} | 2286 suggested_button(NULL) {} |
| 2286 | 2287 |
| 2287 AutofillDialogViews::DetailsGroup::~DetailsGroup() {} | 2288 AutofillDialogViews::DetailsGroup::~DetailsGroup() {} |
| 2288 | 2289 |
| 2289 } // namespace autofill | 2290 } // namespace autofill |
| OLD | NEW |