Chromium Code Reviews| Index: chrome/browser/ui/views/location_bar/location_bar_view.cc |
| diff --git a/chrome/browser/ui/views/location_bar/location_bar_view.cc b/chrome/browser/ui/views/location_bar/location_bar_view.cc |
| index 82d54b9e7dbf59efae0ea0a717de7f63a6a05a01..8d87f155575e1538f932b561a443a8ed2fd1b718 100644 |
| --- a/chrome/browser/ui/views/location_bar/location_bar_view.cc |
| +++ b/chrome/browser/ui/views/location_bar/location_bar_view.cc |
| @@ -105,6 +105,11 @@ using views::View; |
| namespace { |
| +// The search button images are made to look as if they overlay the normal edge |
| +// images, but to align things, the search button needs to be inset horizontally |
| +// by 1 px. |
| +const int kSearchButtonInset = 1; |
|
Greg Billock
2014/05/12 23:09:44
Would it make sense to shift the images to include
Peter Kasting
2014/05/13 00:55:33
I think that's reasonable. I'd rather do it separ
|
| + |
| #if !defined(OS_CHROMEOS) |
| Browser* GetBrowserFromDelegate(LocationBarView::Delegate* delegate) { |
| WebContents* web_contents = delegate->GetWebContents(); |
| @@ -698,17 +703,53 @@ void LocationBarView::GetAccessibleState(ui::AXViewState* state) { |
| } |
| gfx::Size LocationBarView::GetPreferredSize() { |
|
Greg Billock
2014/05/12 23:09:44
I was expecting to see this in a new GetMinimumSiz
Peter Kasting
2014/05/13 00:55:33
Yeah, there's no such thing as a "preferred size"
|
| - gfx::Size background_min_size(border_painter_->GetMinimumSize()); |
| + // Compute minimum height. |
| + gfx::Size min_size(border_painter_->GetMinimumSize()); |
| if (!IsInitialized()) |
| - return background_min_size; |
| - |
| - gfx::Size origin_chip_view_min_size(origin_chip_view_->GetMinimumSize()); |
| + return min_size; |
| gfx::Size search_button_min_size(search_button_->GetMinimumSize()); |
| - gfx::Size min_size(background_min_size); |
| min_size.SetToMax(search_button_min_size); |
| - min_size.set_width(origin_chip_view_min_size.width() + |
| - background_min_size.width() + |
| - search_button_min_size.width()); |
| + |
| + // Compute width of omnibox-leading content. |
| + const int horizontal_edge_thickness = GetHorizontalEdgeThickness(); |
| + int leading_width = horizontal_edge_thickness; |
| + if (origin_chip_view_->ShouldShow()) |
|
Greg Billock
2014/05/12 23:09:44
This is origin_chip_view_->visible() in the Layout
Peter Kasting
2014/05/13 00:55:33
Layout() sets |origin_chip_view_| to be visible ba
|
| + leading_width += origin_chip_view_->GetMinimumSize().width(); |
| + if (!omnibox_view_->model()->keyword().empty() && |
| + !omnibox_view_->model()->is_keyword_hint()) { |
| + // The selected keyword view can collapse completely. |
| + } else if (!toolbar_origin_chip_view_ && |
| + !chrome::ShouldDisplayOriginChipV2() && |
| + (GetToolbarModel()->GetSecurityLevel(false) == ToolbarModel::EV_SECURE)) { |
| + leading_width += kBubblePadding + |
| + ev_bubble_view_->GetMinimumSizeForLabelText( |
| + GetToolbarModel()->GetEVCertName()).width(); |
|
Greg Billock
2014/05/12 23:09:44
I remember the GetEVCertName being sensitive to in
Peter Kasting
2014/05/13 00:55:33
I don't think I understand what you're referencing
Greg Billock
2014/05/13 16:08:15
I think IsInitialized will do it -- basically I re
Peter Kasting
2014/05/13 20:50:14
I think I recall the problem you're referencing, a
|
| + } else if (!origin_chip_view_->visible()) { |
| + leading_width += |
| + kItemPadding + location_icon_view_->GetMinimumSize().width(); |
| + } |
|
Greg Billock
2014/05/12 23:09:44
I'm not sure I'd be willing to swear this is all t
Peter Kasting
2014/05/13 00:55:33
Better state accessors for what? I don't know wha
Greg Billock
2014/05/13 16:08:15
Basically a way to collapse these multi-clause con
Peter Kasting
2014/05/13 20:50:14
Ah. Sure, that's reasonable. Done.
It's unfortu
|
| + leading_width += kItemPadding - (base::i18n::IsRTL() ? 1 : 0); |
|
Greg Billock
2014/05/12 23:09:44
Maybe bump kEditLeadingInternalSpace out of Layout
Peter Kasting
2014/05/13 00:55:33
Yeah, that seems like a good idea. Done.
|
| + |
| + // Compute width of omnibox-trailing content. |
| + int trailing_width = search_button_->visible() ? |
| + (search_button_->GetMinimumSize().width() + kSearchButtonInset) : |
| + horizontal_edge_thickness; |
| + trailing_width += IncrementalMinimumWidth(star_view_) + |
|
Greg Billock
2014/05/12 23:09:44
Should this be delegated to a LocationBarLayout me
Peter Kasting
2014/05/13 00:55:33
That won't help (it will make code strictly longer
|
| + IncrementalMinimumWidth(translate_icon_view_) + |
| + IncrementalMinimumWidth(open_pdf_in_reader_view_) + |
| + IncrementalMinimumWidth(manage_passwords_icon_view_) + |
| + IncrementalMinimumWidth(zoom_view_) + |
| + IncrementalMinimumWidth(generated_credit_card_view_) + |
| + IncrementalMinimumWidth(mic_search_view_) + kItemPadding; |
| + for (PageActionViews::const_iterator i(page_action_views_.begin()); |
| + i != page_action_views_.end(); ++i) |
| + trailing_width += IncrementalMinimumWidth((*i)); |
| + for (ContentSettingViews::const_iterator i(content_setting_views_.begin()); |
| + i != content_setting_views_.end(); ++i) |
| + trailing_width += IncrementalMinimumWidth((*i)); |
|
Greg Billock
2014/05/12 23:09:44
Need the keyword hint view here? Or since that's o
Peter Kasting
2014/05/13 00:55:33
Shouldn't be included since it auto-collapses and
|
| + |
| + const int kMinimumOmniboxWidth = 150; |
| + min_size.set_width(leading_width + kMinimumOmniboxWidth + trailing_width); |
| return min_size; |
| } |
| @@ -880,10 +921,6 @@ void LocationBarView::Layout() { |
| const int horizontal_edge_thickness = GetHorizontalEdgeThickness(); |
| int full_width = width() - horizontal_edge_thickness - origin_chip_width; |
| - // The search button images are made to look as if they overlay the normal |
| - // edge images, but to align things, the search button needs to be inset |
| - // horizontally by 1 px. |
| - const int kSearchButtonInset = 1; |
| const gfx::Size search_button_size(search_button_->GetPreferredSize()); |
| const int search_button_reserved_width = |
| search_button_size.width() + kSearchButtonInset; |
| @@ -1043,6 +1080,11 @@ WebContents* LocationBarView::GetWebContents() { |
| //////////////////////////////////////////////////////////////////////////////// |
| // LocationBarView, private: |
| +// static |
| +int LocationBarView::IncrementalMinimumWidth(views::View* view) { |
|
Greg Billock
2014/05/12 23:09:44
MinimumWidthIncludingPadding ?
Peter Kasting
2014/05/13 00:55:33
I would agree if this returned the value unconditi
|
| + return view->visible() ? (kItemPadding + view->GetMinimumSize().width()) : 0; |
| +} |
| + |
| int LocationBarView::GetHorizontalEdgeThickness() const { |
| // In maximized popup mode, there isn't any edge. |
| return (is_popup_mode_ && browser_ && browser_->window() && |