Chromium Code Reviews| Index: chrome/browser/ui/views/extensions/extension_install_dialog_view.cc |
| diff --git a/chrome/browser/ui/views/extensions/extension_install_dialog_view.cc b/chrome/browser/ui/views/extensions/extension_install_dialog_view.cc |
| index 0491b93eab4ea97b5151cc758cd0f2444d79703f..c02b2192d8c0bf866e1b915664c4610757c526f2 100644 |
| --- a/chrome/browser/ui/views/extensions/extension_install_dialog_view.cc |
| +++ b/chrome/browser/ui/views/extensions/extension_install_dialog_view.cc |
| @@ -665,6 +665,16 @@ gfx::Size ExpandableContainerView::DetailsView::GetPreferredSize() const { |
| return gfx::Size(size.width(), size.height() * state_); |
| } |
| +// This is necessary for a subtle reason: views::BoxLayout only honors the |
| +// preferred size of subviews when using horizontal layout; in vertical layout, |
| +// it computes the width it should be, then calls |GetHeightForWidth()| on each |
| +// of the subviews to size them vertically. Without this override, the logic in |
| +// |GetPreferredSize()| to animate show/hide ends up ignored when this View is |
| +// inside a BoxLayout. |
| +int ExpandableContainerView::DetailsView::GetHeightForWidth(int width) const { |
| + return views::View::GetHeightForWidth(width) * state_; |
| +} |
| + |
| void ExpandableContainerView::DetailsView::AnimateToState(double state) { |
| state_ = state; |
| PreferredSizeChanged(); |
| @@ -680,64 +690,27 @@ ExpandableContainerView::ExpandableContainerView( |
| : details_view_(NULL), |
| slide_animation_(this), |
| more_details_(NULL), |
| - arrow_toggle_(NULL), |
| expanded_(false) { |
| - views::GridLayout* layout = new views::GridLayout(this); |
| + views::BoxLayout* layout = |
| + new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0); |
| + layout->set_main_axis_alignment(views::BoxLayout::MAIN_AXIS_ALIGNMENT_START); |
|
Devlin
2017/04/25 22:11:50
This is the default, isn't it?
Elly Fong-Jones
2017/04/26 15:24:33
So it is, well spotted.
|
| + layout->set_cross_axis_alignment( |
| + views::BoxLayout::CROSS_AXIS_ALIGNMENT_START); |
| SetLayoutManager(layout); |
| - int column_set_id = 0; |
| - views::ColumnSet* column_set = layout->AddColumnSet(column_set_id); |
| - column_set->AddColumn(views::GridLayout::LEADING, views::GridLayout::LEADING, |
| - 0, views::GridLayout::USE_PREF, 0, 0); |
| if (details.empty()) |
| return; |
| details_view_ = new DetailsView(horizontal_space, parent_bulleted); |
| - |
| - layout->StartRow(0, column_set_id); |
| - layout->AddView(details_view_); |
| - |
| for (size_t i = 0; i < details.size(); ++i) |
| details_view_->AddDetail(details[i]); |
| + AddChildView(details_view_); |
| - // Make sure the link width column is as wide as needed for both Show and |
| - // Hide details, so that the arrow doesn't shift horizontally when we toggle. |
| - views::Link* link = new views::Link( |
| - l10n_util::GetStringUTF16(IDS_EXTENSIONS_HIDE_DETAILS)); |
| - int link_col_width = link->GetPreferredSize().width(); |
| - link->SetText(l10n_util::GetStringUTF16(IDS_EXTENSIONS_SHOW_DETAILS)); |
| - link_col_width = std::max(link_col_width, link->GetPreferredSize().width()); |
| - |
| - column_set = layout->AddColumnSet(++column_set_id); |
| - // Padding to the left of the More Details column. |
| - column_set->AddPaddingColumn(0, |
| - GetLeftPaddingForBulletedItems(parent_bulleted)); |
| - // The More Details column. |
| - column_set->AddColumn(views::GridLayout::LEADING, |
| - views::GridLayout::LEADING, |
| - 0, |
| - views::GridLayout::FIXED, |
| - link_col_width, |
| - link_col_width); |
| - // The Up/Down arrow column. |
| - column_set->AddColumn(views::GridLayout::LEADING, |
| - views::GridLayout::TRAILING, |
| - 0, |
| - views::GridLayout::USE_PREF, |
| - 0, |
| - 0); |
| - |
| - // Add the More Details link. |
| - layout->StartRow(0, column_set_id); |
| - more_details_ = link; |
| + more_details_ = |
| + new views::Link(l10n_util::GetStringUTF16(IDS_EXTENSIONS_SHOW_DETAILS)); |
| more_details_->set_listener(this); |
| more_details_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| - layout->AddView(more_details_); |
| - |
| - // Add the arrow after the More Details link. |
| - arrow_toggle_ = new views::ImageButton(this); |
| - UpdateArrowToggle(false); |
| - layout->AddView(arrow_toggle_); |
| + AddChildView(more_details_); |
| } |
| ExpandableContainerView::~ExpandableContainerView() { |
| @@ -761,8 +734,6 @@ void ExpandableContainerView::AnimationProgressed( |
| } |
| void ExpandableContainerView::AnimationEnded(const gfx::Animation* animation) { |
| - if (arrow_toggle_) |
| - UpdateArrowToggle(animation->GetCurrentValue() != 0.0); |
| if (more_details_) { |
| more_details_->SetText(expanded_ ? |
| l10n_util::GetStringUTF16(IDS_EXTENSIONS_HIDE_DETAILS) : |
| @@ -783,12 +754,6 @@ void ExpandableContainerView::ToggleDetailLevel() { |
| slide_animation_.Show(); |
| } |
| -void ExpandableContainerView::UpdateArrowToggle(bool expanded) { |
| - gfx::ImageSkia icon = gfx::CreateVectorIcon( |
| - expanded ? kCaretUpIcon : kCaretDownIcon, gfx::kChromeIconGrey); |
| - arrow_toggle_->SetImage(views::Button::STATE_NORMAL, &icon); |
| -} |
| - |
| // static |
| ExtensionInstallPrompt::ShowDialogCallback |
| ExtensionInstallPrompt::GetViewsShowDialogCallback() { |