Chromium Code Reviews| 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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 145 // It exists to circumvent shortcomings of GridLayout and BoxLayout (namely that | 145 // It exists to circumvent shortcomings of GridLayout and BoxLayout (namely that |
| 146 // the former doesn't fully respect child visibility, and that the latter won't | 146 // the former doesn't fully respect child visibility, and that the latter won't |
| 147 // expand a single child). | 147 // expand a single child). |
| 148 class SectionRowView : public views::View { | 148 class SectionRowView : public views::View { |
| 149 public: | 149 public: |
| 150 SectionRowView() {} | 150 SectionRowView() {} |
| 151 virtual ~SectionRowView() {} | 151 virtual ~SectionRowView() {} |
| 152 | 152 |
| 153 // views::View implementation: | 153 // views::View implementation: |
| 154 virtual gfx::Size GetPreferredSize() OVERRIDE { | 154 virtual gfx::Size GetPreferredSize() OVERRIDE { |
| 155 // Only the height matters anyway. | 155 int height = 0; |
| 156 return child_at(2)->GetPreferredSize(); | 156 int width = 0; |
| 157 for (int i = 0; i < child_count(); ++i) { | |
| 158 if (child_at(i)->visible()) { | |
| 159 if (width > 0) | |
| 160 width += kAroundTextPadding; | |
| 161 | |
| 162 gfx::Size size = child_at(i)->GetPreferredSize(); | |
| 163 height = std::max(height, size.height()); | |
| 164 width += size.width(); | |
| 165 } | |
| 166 } | |
| 167 | |
| 168 return gfx::Size(width, height); | |
| 157 } | 169 } |
| 158 | 170 |
| 159 virtual void Layout() OVERRIDE { | 171 virtual void Layout() OVERRIDE { |
| 160 const gfx::Rect bounds = GetContentsBounds(); | 172 const gfx::Rect bounds = GetContentsBounds(); |
| 161 | 173 |
| 162 // Icon is left aligned. | 174 // Icon is left aligned. |
| 163 int start_x = bounds.x(); | 175 int start_x = bounds.x(); |
| 164 views::View* icon = child_at(0); | 176 views::View* icon = child_at(0); |
| 165 if (icon->visible()) { | 177 if (icon->visible()) { |
| 166 icon->SizeToPreferredSize(); | 178 icon->SizeToPreferredSize(); |
| (...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 581 kOverlayTextInterlineSpacing)); | 593 kOverlayTextInterlineSpacing)); |
| 582 message_stack_->set_border(views::Border::CreateEmptyBorder( | 594 message_stack_->set_border(views::Border::CreateEmptyBorder( |
| 583 kDialogEdgePadding, kDialogEdgePadding, 0, kDialogEdgePadding)); | 595 kDialogEdgePadding, kDialogEdgePadding, 0, kDialogEdgePadding)); |
| 584 | 596 |
| 585 AddChildView(button_); | 597 AddChildView(button_); |
| 586 button_->set_focusable(true); | 598 button_->set_focusable(true); |
| 587 } | 599 } |
| 588 | 600 |
| 589 AutofillDialogViews::OverlayView::~OverlayView() {} | 601 AutofillDialogViews::OverlayView::~OverlayView() {} |
| 590 | 602 |
| 591 int AutofillDialogViews::OverlayView::GetHeightForContentsForWidth(int w) { | 603 int AutofillDialogViews::OverlayView::GetHeightForContentsForWidth(int width) { |
| 592 // In this case, 0 means "no preference". | 604 // In this case, 0 means "no preference". |
| 593 if (!message_stack_->visible()) | 605 if (!message_stack_->visible()) |
| 594 return 0; | 606 return 0; |
| 595 | 607 |
| 596 return kOverlayImageBottomMargin + | 608 return kOverlayImageBottomMargin + |
| 597 views::kButtonVEdgeMarginNew + | 609 views::kButtonVEdgeMarginNew + |
| 598 message_stack_->GetHeightForWidth(w) + | 610 message_stack_->GetHeightForWidth(w) + |
| 599 image_view_->GetHeightForWidth(w) + | 611 image_view_->GetHeightForWidth(w) + |
| 600 (button_->visible() ? button_->GetHeightForWidth(w) + | 612 (button_->visible() ? button_->GetHeightForWidth(w) + |
| 601 views::kButtonVEdgeMarginNew : 0); | 613 views::kButtonVEdgeMarginNew : 0); |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 979 ui::MouseEvent AutofillDialogViews::SectionContainer::ProxyEvent( | 991 ui::MouseEvent AutofillDialogViews::SectionContainer::ProxyEvent( |
| 980 const ui::MouseEvent& event) { | 992 const ui::MouseEvent& event) { |
| 981 ui::MouseEvent event_copy = event; | 993 ui::MouseEvent event_copy = event; |
| 982 event_copy.set_location(gfx::Point()); | 994 event_copy.set_location(gfx::Point()); |
| 983 return event_copy; | 995 return event_copy; |
| 984 } | 996 } |
| 985 | 997 |
| 986 // AutofilDialogViews::SuggestionView ------------------------------------------ | 998 // AutofilDialogViews::SuggestionView ------------------------------------------ |
| 987 | 999 |
| 988 AutofillDialogViews::SuggestionView::SuggestionView( | 1000 AutofillDialogViews::SuggestionView::SuggestionView( |
| 989 const base::string16& edit_label, | |
| 990 AutofillDialogViews* autofill_dialog) | 1001 AutofillDialogViews* autofill_dialog) |
| 991 : label_(new views::Label()), | 1002 : label_(new views::Label()), |
| 992 label_line_2_(new views::Label()), | 1003 label_line_2_(new views::Label()), |
| 993 icon_(new views::ImageView()), | 1004 icon_(new views::ImageView()), |
| 994 label_container_(new SectionRowView()), | |
| 995 decorated_( | 1005 decorated_( |
| 996 new DecoratedTextfield(base::string16(), | 1006 new DecoratedTextfield(base::string16(), |
| 997 base::string16(), | 1007 base::string16(), |
| 998 autofill_dialog)) { | 1008 autofill_dialog)) { |
| 999 // TODO(estade): Make this the correct color. | 1009 // TODO(estade): Make this the correct color. |
| 1000 set_border( | 1010 set_border( |
| 1001 views::Border::CreateSolidSidedBorder(1, 0, 0, 0, SK_ColorLTGRAY)); | 1011 views::Border::CreateSolidSidedBorder(1, 0, 0, 0, SK_ColorLTGRAY)); |
| 1002 | 1012 |
| 1013 SectionRowView* label_container = new SectionRowView(); | |
| 1014 AddChildView(label_container); | |
| 1015 | |
| 1003 // Label and icon. | 1016 // Label and icon. |
| 1017 label_container->AddChildView(icon_); | |
| 1004 label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 1018 label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 1005 label_container_->AddChildView(icon_); | 1019 label_container->AddChildView(label_); |
| 1006 label_container_->AddChildView(label_); | 1020 |
| 1007 label_container_->AddChildView(decorated_); | 1021 // TODO(estade): get the sizing and spacing right on this textfield. |
| 1008 decorated_->SetVisible(false); | 1022 decorated_->SetVisible(false); |
| 1009 // TODO(estade): get the sizing and spacing right on this textfield. | |
| 1010 decorated_->set_default_width_in_chars(10); | 1023 decorated_->set_default_width_in_chars(10); |
| 1011 AddChildView(label_container_); | 1024 label_container->AddChildView(decorated_); |
| 1012 | 1025 |
| 1026 // TODO(estade): need to get the line height right. | |
| 1013 label_line_2_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 1027 label_line_2_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 1014 label_line_2_->SetVisible(false); | 1028 label_line_2_->SetVisible(false); |
| 1015 label_line_2_->SetMultiLine(true); | 1029 label_line_2_->SetMultiLine(true); |
| 1016 AddChildView(label_line_2_); | 1030 AddChildView(label_line_2_); |
| 1017 | 1031 |
| 1018 // TODO(estade): do something about this '2'. | 1032 // TODO(estade): do something about this '2'. |
| 1019 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 2, 0)); | 1033 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 2, 0)); |
| 1020 } | 1034 } |
| 1021 | 1035 |
| 1022 AutofillDialogViews::SuggestionView::~SuggestionView() {} | 1036 AutofillDialogViews::SuggestionView::~SuggestionView() {} |
| 1023 | 1037 |
| 1024 void AutofillDialogViews::SuggestionView::SetSuggestionText( | 1038 gfx::Size AutofillDialogViews::SuggestionView::GetPreferredSize() { |
| 1025 const base::string16& text, | 1039 // There's no preferred width. The parent's layout should get the preferred |
| 1026 gfx::Font::FontStyle text_style) { | 1040 // height from GetHeightForWidth(). |
| 1027 label_->SetFont(ui::ResourceBundle::GetSharedInstance().GetFont( | 1041 return gfx::Size(); |
| 1028 ui::ResourceBundle::BaseFont).DeriveFont(0, text_style)); | 1042 } |
| 1029 | 1043 |
| 1044 int AutofillDialogViews::SuggestionView::GetHeightForWidth(int width) { | |
| 1045 int height = 0; | |
| 1046 CanUseVerticallyCompactText(width, &height); | |
| 1047 return height; | |
| 1048 } | |
| 1049 | |
| 1050 bool AutofillDialogViews::SuggestionView::CanUseVerticallyCompactText( | |
| 1051 int available_width, int* resulting_height) { | |
|
sky
2013/08/06 21:28:10
nit: when you wrap one param per line.
sky
2013/08/06 21:28:10
How many times if this called with varying widths
Evan Stade
2013/08/06 23:15:34
It's mostly called with the same width over and ov
Evan Stade
2013/08/06 23:15:34
Done.
| |
| 1052 // This calculation may be costly, avoid doing it more than once per width. | |
| 1053 if (!calculated_heights_.count(available_width)) { | |
| 1054 // Changing the state of |this| now will lead to extra layouts and | |
| 1055 // paints we don't want, so create another SuggestionView to calculate | |
| 1056 // which label we have room to show. | |
| 1057 SuggestionView sizing_view(NULL); | |
| 1058 sizing_view.SetLabelText(state_.vertically_compact_text); | |
| 1059 sizing_view.SetIcon(state_.icon); | |
| 1060 sizing_view.SetTextfield(state_.extra_text, state_.extra_icon); | |
| 1061 | |
| 1062 // Shortcut |sizing_view|'s GetHeightForWidth() to avoid an infinite loop. | |
| 1063 // Its BoxLayout must do these calculations for us. | |
| 1064 views::LayoutManager* layout = sizing_view.GetLayoutManager(); | |
| 1065 if (layout->GetPreferredSize(&sizing_view).width() <= available_width) { | |
| 1066 calculated_heights_[available_width] = std::make_pair( | |
| 1067 true, | |
| 1068 layout->GetPreferredHeightForWidth(&sizing_view, available_width)); | |
| 1069 } else { | |
| 1070 sizing_view.SetLabelText(state_.horizontally_compact_text); | |
| 1071 calculated_heights_[available_width] = std::make_pair( | |
| 1072 false, | |
| 1073 layout->GetPreferredHeightForWidth(&sizing_view, available_width)); | |
| 1074 } | |
| 1075 } | |
| 1076 | |
| 1077 std::pair<bool, int> values = calculated_heights_[available_width]; | |
|
sky
2013/08/06 21:28:10
const std::pair&
Evan Stade
2013/08/06 23:15:34
Done.
| |
| 1078 *resulting_height = values.second; | |
| 1079 return values.first; | |
| 1080 } | |
| 1081 | |
| 1082 void AutofillDialogViews::SuggestionView::OnBoundsChanged( | |
| 1083 const gfx::Rect& previous_bounds) { | |
| 1084 int unused; | |
| 1085 SetLabelText(CanUseVerticallyCompactText(width(), &unused) ? | |
| 1086 state_.vertically_compact_text : | |
| 1087 state_.horizontally_compact_text); | |
| 1088 } | |
| 1089 | |
| 1090 void AutofillDialogViews::SuggestionView::SetState( | |
| 1091 const SuggestionState& state) { | |
| 1092 calculated_heights_.clear(); | |
| 1093 state_ = state; | |
| 1094 SetVisible(state_.visible); | |
| 1095 // Set to the more compact text for now. |this| will optionally switch to | |
| 1096 // the more vertically expanded view when the bounds are set. | |
| 1097 SetLabelText(state_.vertically_compact_text); | |
| 1098 SetIcon(state_.icon); | |
| 1099 SetTextfield(state_.extra_text, state_.extra_icon); | |
| 1100 PreferredSizeChanged(); | |
| 1101 } | |
| 1102 | |
| 1103 void AutofillDialogViews::SuggestionView::SetLabelText( | |
| 1104 const base::string16& text) { | |
| 1030 // TODO(estade): does this localize well? | 1105 // TODO(estade): does this localize well? |
| 1031 base::string16 line_return(ASCIIToUTF16("\n")); | 1106 base::string16 line_return(ASCIIToUTF16("\n")); |
| 1032 size_t position = text.find(line_return); | 1107 size_t position = text.find(line_return); |
| 1033 if (position == base::string16::npos) { | 1108 if (position == base::string16::npos) { |
| 1034 label_->SetText(text); | 1109 label_->SetText(text); |
| 1035 label_line_2_->SetVisible(false); | 1110 label_line_2_->SetVisible(false); |
| 1036 } else { | 1111 } else { |
| 1037 label_->SetText(text.substr(0, position)); | 1112 label_->SetText(text.substr(0, position)); |
| 1038 label_line_2_->SetText(text.substr(position + line_return.length())); | 1113 label_line_2_->SetText(text.substr(position + line_return.length())); |
| 1039 label_line_2_->SetVisible(true); | 1114 label_line_2_->SetVisible(true); |
| 1040 } | 1115 } |
| 1041 } | 1116 } |
| 1042 | 1117 |
| 1043 void AutofillDialogViews::SuggestionView::SetSuggestionIcon( | 1118 void AutofillDialogViews::SuggestionView::SetIcon( |
| 1044 const gfx::Image& image) { | 1119 const gfx::Image& image) { |
| 1045 icon_->SetVisible(!image.IsEmpty()); | 1120 icon_->SetVisible(!image.IsEmpty()); |
| 1046 icon_->SetImage(image.AsImageSkia()); | 1121 icon_->SetImage(image.AsImageSkia()); |
| 1047 } | 1122 } |
| 1048 | 1123 |
| 1049 void AutofillDialogViews::SuggestionView::ShowTextfield( | 1124 void AutofillDialogViews::SuggestionView::SetTextfield( |
| 1050 const base::string16& placeholder_text, | 1125 const base::string16& placeholder_text, |
| 1051 const gfx::Image& icon) { | 1126 const gfx::Image& icon) { |
| 1052 decorated_->set_placeholder_text(placeholder_text); | 1127 decorated_->set_placeholder_text(placeholder_text); |
| 1053 decorated_->SetIcon(icon); | 1128 decorated_->SetIcon(icon); |
| 1054 decorated_->SetVisible(true); | 1129 decorated_->SetVisible(!placeholder_text.empty()); |
| 1055 // The textfield will increase the height of the first row and cause the | |
| 1056 // label to be aligned properly, so the border is not necessary. | |
| 1057 label_->set_border(NULL); | |
| 1058 } | 1130 } |
| 1059 | 1131 |
| 1060 // AutofillDialogViews::AutocheckoutStepsArea --------------------------------- | 1132 // AutofillDialogViews::AutocheckoutStepsArea --------------------------------- |
| 1061 | 1133 |
| 1062 AutofillDialogViews::AutocheckoutStepsArea::AutocheckoutStepsArea() { | 1134 AutofillDialogViews::AutocheckoutStepsArea::AutocheckoutStepsArea() { |
| 1063 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, | 1135 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, |
| 1064 kAutocheckoutStepsAreaPadding, | 1136 kAutocheckoutStepsAreaPadding, |
| 1065 0, | 1137 0, |
| 1066 kAutocheckoutStepInset)); | 1138 kAutocheckoutStepInset)); |
| 1067 } | 1139 } |
| (...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1457 | 1529 |
| 1458 void AutofillDialogViews::Layout() { | 1530 void AutofillDialogViews::Layout() { |
| 1459 gfx::Rect content_bounds = GetContentsBounds(); | 1531 gfx::Rect content_bounds = GetContentsBounds(); |
| 1460 if (sign_in_webview_->visible()) { | 1532 if (sign_in_webview_->visible()) { |
| 1461 sign_in_webview_->SetBoundsRect(content_bounds); | 1533 sign_in_webview_->SetBoundsRect(content_bounds); |
| 1462 return; | 1534 return; |
| 1463 } | 1535 } |
| 1464 | 1536 |
| 1465 const int x = content_bounds.x(); | 1537 const int x = content_bounds.x(); |
| 1466 const int y = content_bounds.y(); | 1538 const int y = content_bounds.y(); |
| 1467 const int w = content_bounds.width(); | 1539 const int width = content_bounds.width(); |
| 1468 // Layout notification area at top of dialog. | 1540 // Layout notification area at top of dialog. |
| 1469 int notification_height = notification_area_->GetHeightForWidth(w); | 1541 int notification_height = notification_area_->GetHeightForWidth(w); |
| 1470 notification_area_->SetBounds(x, y, w, notification_height); | 1542 notification_area_->SetBounds(x, y, width, notification_height); |
| 1471 | 1543 |
| 1472 // Layout Autocheckout steps at bottom of dialog. | 1544 // Layout Autocheckout steps at bottom of dialog. |
| 1473 int steps_height = autocheckout_steps_area_->GetHeightForWidth(w); | 1545 int steps_height = autocheckout_steps_area_->GetHeightForWidth(w); |
| 1474 autocheckout_steps_area_->SetBounds(x, content_bounds.bottom() - steps_height, | 1546 autocheckout_steps_area_->SetBounds(x, content_bounds.bottom() - steps_height, |
| 1475 w, steps_height); | 1547 width, steps_height); |
| 1476 | 1548 |
| 1477 // The rest (the |scrollable_area_|) takes up whatever's left. | 1549 // The rest (the |scrollable_area_|) takes up whatever's left. |
| 1478 if (scrollable_area_->visible()) { | 1550 if (scrollable_area_->visible()) { |
| 1479 int scroll_y = y; | 1551 int scroll_y = y; |
| 1480 if (notification_height > 0) | 1552 if (notification_height > 0) |
| 1481 scroll_y += notification_height + views::kRelatedControlVerticalSpacing; | 1553 scroll_y += notification_height + views::kRelatedControlVerticalSpacing; |
| 1482 | 1554 |
| 1483 int scroll_bottom = content_bounds.bottom(); | 1555 int scroll_bottom = content_bounds.bottom(); |
| 1484 if (steps_height > 0) | 1556 if (steps_height > 0) |
| 1485 scroll_bottom -= steps_height + views::kRelatedControlVerticalSpacing; | 1557 scroll_bottom -= steps_height + views::kRelatedControlVerticalSpacing; |
| 1486 | 1558 |
| 1487 scrollable_area_->contents()->SizeToPreferredSize(); | 1559 scrollable_area_->contents()->SizeToPreferredSize(); |
| 1488 scrollable_area_->SetBounds(x, scroll_y, w, scroll_bottom - scroll_y); | 1560 scrollable_area_->SetBounds(x, scroll_y, width, scroll_bottom - scroll_y); |
| 1489 } | 1561 } |
| 1490 | 1562 |
| 1491 if (loading_shield_->visible()) | 1563 if (loading_shield_->visible()) |
| 1492 loading_shield_->SetBoundsRect(bounds()); | 1564 loading_shield_->SetBoundsRect(bounds()); |
| 1493 | 1565 |
| 1494 if (error_bubble_) | 1566 if (error_bubble_) |
| 1495 error_bubble_->UpdatePosition(); | 1567 error_bubble_->UpdatePosition(); |
| 1496 } | 1568 } |
| 1497 | 1569 |
| 1498 void AutofillDialogViews::OnBoundsChanged(const gfx::Rect& previous_bounds) { | 1570 void AutofillDialogViews::OnBoundsChanged(const gfx::Rect& previous_bounds) { |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1788 | 1860 |
| 1789 views::View* AutofillDialogViews::CreateInputsContainer(DialogSection section) { | 1861 views::View* AutofillDialogViews::CreateInputsContainer(DialogSection section) { |
| 1790 // The |info_view| holds |manual_inputs| and |suggested_info|, allowing the | 1862 // The |info_view| holds |manual_inputs| and |suggested_info|, allowing the |
| 1791 // dialog to toggle which is shown. | 1863 // dialog to toggle which is shown. |
| 1792 views::View* info_view = new views::View(); | 1864 views::View* info_view = new views::View(); |
| 1793 info_view->SetLayoutManager( | 1865 info_view->SetLayoutManager( |
| 1794 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); | 1866 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); |
| 1795 | 1867 |
| 1796 views::View* manual_inputs = InitInputsView(section); | 1868 views::View* manual_inputs = InitInputsView(section); |
| 1797 info_view->AddChildView(manual_inputs); | 1869 info_view->AddChildView(manual_inputs); |
| 1798 SuggestionView* suggested_info = | 1870 SuggestionView* suggested_info = new SuggestionView(this); |
| 1799 new SuggestionView(controller_->EditSuggestionText(), this); | |
| 1800 info_view->AddChildView(suggested_info); | 1871 info_view->AddChildView(suggested_info); |
| 1801 | 1872 |
| 1802 // TODO(estade): It might be slightly more OO if this button were created | 1873 // TODO(estade): It might be slightly more OO if this button were created |
| 1803 // and listened to by the section container. | 1874 // and listened to by the section container. |
| 1804 views::ImageButton* menu_button = new views::ImageButton(this); | 1875 views::ImageButton* menu_button = new views::ImageButton(this); |
| 1805 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 1876 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 1806 menu_button->SetImage(views::Button::STATE_NORMAL, | 1877 menu_button->SetImage(views::Button::STATE_NORMAL, |
| 1807 rb.GetImageSkiaNamed(IDR_AUTOFILL_DIALOG_MENU_BUTTON)); | 1878 rb.GetImageSkiaNamed(IDR_AUTOFILL_DIALOG_MENU_BUTTON)); |
| 1808 menu_button->SetImage(views::Button::STATE_PRESSED, | 1879 menu_button->SetImage(views::Button::STATE_PRESSED, |
| 1809 rb.GetImageSkiaNamed(IDR_AUTOFILL_DIALOG_MENU_BUTTON_P)); | 1880 rb.GetImageSkiaNamed(IDR_AUTOFILL_DIALOG_MENU_BUTTON_P)); |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1945 } | 2016 } |
| 1946 } | 2017 } |
| 1947 } | 2018 } |
| 1948 | 2019 |
| 1949 UpdateDetailsGroupState(*group); | 2020 UpdateDetailsGroupState(*group); |
| 1950 } | 2021 } |
| 1951 | 2022 |
| 1952 void AutofillDialogViews::UpdateDetailsGroupState(const DetailsGroup& group) { | 2023 void AutofillDialogViews::UpdateDetailsGroupState(const DetailsGroup& group) { |
| 1953 const SuggestionState& suggestion_state = | 2024 const SuggestionState& suggestion_state = |
| 1954 controller_->SuggestionStateForSection(group.section); | 2025 controller_->SuggestionStateForSection(group.section); |
| 1955 bool show_suggestions = !suggestion_state.text.empty(); | 2026 group.suggested_info->SetState(suggestion_state); |
| 1956 group.suggested_info->SetVisible(show_suggestions); | 2027 group.manual_input->SetVisible(!suggestion_state.visible); |
| 1957 group.suggested_info->SetSuggestionText(suggestion_state.text, | |
| 1958 suggestion_state.text_style); | |
| 1959 group.suggested_info->SetSuggestionIcon(suggestion_state.icon); | |
| 1960 | |
| 1961 if (!suggestion_state.extra_text.empty()) { | |
| 1962 group.suggested_info->ShowTextfield( | |
| 1963 suggestion_state.extra_text, | |
| 1964 suggestion_state.extra_icon); | |
| 1965 } | |
| 1966 | |
| 1967 group.manual_input->SetVisible(!show_suggestions); | |
| 1968 | 2028 |
| 1969 UpdateButtonStripExtraView(); | 2029 UpdateButtonStripExtraView(); |
| 1970 | 2030 |
| 1971 const bool has_menu = !!controller_->MenuModelForSection(group.section); | 2031 const bool has_menu = !!controller_->MenuModelForSection(group.section); |
| 1972 | 2032 |
| 1973 if (group.suggested_button) | 2033 if (group.suggested_button) |
| 1974 group.suggested_button->SetVisible(has_menu); | 2034 group.suggested_button->SetVisible(has_menu); |
| 1975 | 2035 |
| 1976 if (group.container) { | 2036 if (group.container) { |
| 1977 group.container->SetForwardMouseEvents(has_menu && show_suggestions); | 2037 group.container->SetForwardMouseEvents( |
| 2038 has_menu && suggestion_state.visible); | |
| 1978 group.container->SetVisible(controller_->SectionIsActive(group.section)); | 2039 group.container->SetVisible(controller_->SectionIsActive(group.section)); |
| 1979 if (group.container->visible()) | 2040 if (group.container->visible()) |
| 1980 ValidateGroup(group, VALIDATE_EDIT); | 2041 ValidateGroup(group, VALIDATE_EDIT); |
| 1981 } | 2042 } |
| 1982 | 2043 |
| 1983 ContentsPreferredSizeChanged(); | 2044 ContentsPreferredSizeChanged(); |
| 1984 } | 2045 } |
| 1985 | 2046 |
| 1986 template<class T> | 2047 template<class T> |
| 1987 void AutofillDialogViews::SetValidityForInput( | 2048 void AutofillDialogViews::SetValidityForInput( |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2271 AutofillDialogViews::DetailsGroup::DetailsGroup(DialogSection section) | 2332 AutofillDialogViews::DetailsGroup::DetailsGroup(DialogSection section) |
| 2272 : section(section), | 2333 : section(section), |
| 2273 container(NULL), | 2334 container(NULL), |
| 2274 manual_input(NULL), | 2335 manual_input(NULL), |
| 2275 suggested_info(NULL), | 2336 suggested_info(NULL), |
| 2276 suggested_button(NULL) {} | 2337 suggested_button(NULL) {} |
| 2277 | 2338 |
| 2278 AutofillDialogViews::DetailsGroup::~DetailsGroup() {} | 2339 AutofillDialogViews::DetailsGroup::~DetailsGroup() {} |
| 2279 | 2340 |
| 2280 } // namespace autofill | 2341 } // namespace autofill |
| OLD | NEW |