browser_view_layout.cc revision 424c4d7b64af9d0d8fd9624f381f469654d5e3d2
1// Copyright 2012 The Chromium Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5#include "chrome/browser/ui/views/frame/browser_view_layout.h" 6 7#include "base/observer_list.h" 8#include "chrome/browser/profiles/profile.h" 9#include "chrome/browser/ui/browser.h" 10#include "chrome/browser/ui/browser_finder.h" 11#include "chrome/browser/ui/browser_window.h" 12#include "chrome/browser/ui/find_bar/find_bar.h" 13#include "chrome/browser/ui/find_bar/find_bar_controller.h" 14#include "chrome/browser/ui/search/search_model.h" 15#include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h" 16#include "chrome/browser/ui/views/download/download_shelf_view.h" 17#include "chrome/browser/ui/views/frame/browser_frame.h" 18#include "chrome/browser/ui/views/frame/browser_view.h" 19#include "chrome/browser/ui/views/frame/browser_view_layout_delegate.h" 20#include "chrome/browser/ui/views/frame/contents_container.h" 21#include "chrome/browser/ui/views/frame/immersive_mode_controller.h" 22#include "chrome/browser/ui/views/frame/top_container_view.h" 23#include "chrome/browser/ui/views/fullscreen_exit_bubble_views.h" 24#include "chrome/browser/ui/views/infobars/infobar_container_view.h" 25#include "chrome/browser/ui/views/tabs/tab_strip.h" 26#include "components/web_modal/web_contents_modal_dialog_host.h" 27#include "ui/base/hit_test.h" 28#include "ui/gfx/point.h" 29#include "ui/gfx/scrollbar_size.h" 30#include "ui/gfx/size.h" 31#include "ui/views/controls/webview/webview.h" 32 33using views::View; 34using web_modal::WebContentsModalDialogHost; 35using web_modal::WebContentsModalDialogHostObserver; 36 37namespace { 38 39// The visible height of the shadow above the tabs. Clicks in this area are 40// treated as clicks to the frame, rather than clicks to the tab. 41const int kTabShadowSize = 2; 42// The number of pixels the bookmark bar should overlap the spacer by if the 43// spacer is visible. 44const int kSpacerBookmarkBarOverlap = 1; 45// The number of pixels the metro switcher is offset from the right edge. 46const int kWindowSwitcherOffsetX = 7; 47// The number of pixels the constrained window should overlap the bottom 48// of the omnibox. 49const int kConstrainedWindowOverlap = 3; 50 51// Combines View::ConvertPointToTarget and View::HitTest for a given |point|. 52// Converts |point| from |src| to |dst| and hit tests it against |dst|. The 53// converted |point| can then be retrieved and used for additional tests. 54bool ConvertedHitTest(views::View* src, views::View* dst, gfx::Point* point) { 55 DCHECK(src); 56 DCHECK(dst); 57 DCHECK(point); 58 views::View::ConvertPointToTarget(src, dst, point); 59 return dst->HitTestPoint(*point); 60} 61 62} // namespace 63 64class BrowserViewLayout::WebContentsModalDialogHostViews 65 : public WebContentsModalDialogHost { 66 public: 67 explicit WebContentsModalDialogHostViews( 68 BrowserViewLayout* browser_view_layout) 69 : browser_view_layout_(browser_view_layout) { 70 } 71 72 virtual ~WebContentsModalDialogHostViews() { 73 FOR_EACH_OBSERVER(web_modal::WebContentsModalDialogHostObserver, 74 observer_list_, 75 OnHostDestroying()); 76 } 77 78 void NotifyPositionRequiresUpdate() { 79 FOR_EACH_OBSERVER(WebContentsModalDialogHostObserver, 80 observer_list_, 81 OnPositionRequiresUpdate()); 82 } 83 84 private: 85 virtual gfx::NativeView GetHostView() const OVERRIDE { 86 gfx::NativeWindow native_window = 87 browser_view_layout_->browser()->window()->GetNativeWindow(); 88 return views::Widget::GetWidgetForNativeWindow(native_window)-> 89 GetNativeView(); 90 } 91 92 // Center horizontally over the content area, with the top overlapping the 93 // browser chrome. 94 virtual gfx::Point GetDialogPosition(const gfx::Size& size) OVERRIDE { 95 int top_y = browser_view_layout_->web_contents_modal_dialog_top_y_; 96 gfx::Rect content_area = 97 browser_view_layout_->browser_view_->GetClientAreaBounds(); 98 int middle_x = content_area.x() + content_area.width() / 2; 99 return gfx::Point(middle_x - size.width() / 2, top_y); 100 } 101 102 // Add/remove observer. 103 virtual void AddObserver( 104 WebContentsModalDialogHostObserver* observer) OVERRIDE { 105 observer_list_.AddObserver(observer); 106 } 107 virtual void RemoveObserver( 108 WebContentsModalDialogHostObserver* observer) OVERRIDE { 109 observer_list_.RemoveObserver(observer); 110 } 111 112 BrowserViewLayout* const browser_view_layout_; 113 114 ObserverList<WebContentsModalDialogHostObserver> observer_list_; 115 116 DISALLOW_COPY_AND_ASSIGN(WebContentsModalDialogHostViews); 117}; 118 119// static 120const int BrowserViewLayout::kToolbarTabStripVerticalOverlap = 3; 121 122//////////////////////////////////////////////////////////////////////////////// 123// BrowserViewLayout, public: 124 125BrowserViewLayout::BrowserViewLayout() 126 : browser_(NULL), 127 browser_view_(NULL), 128 top_container_(NULL), 129 tab_strip_(NULL), 130 toolbar_(NULL), 131 bookmark_bar_(NULL), 132 infobar_container_(NULL), 133 contents_split_(NULL), 134 contents_container_(NULL), 135 download_shelf_(NULL), 136 immersive_mode_controller_(NULL), 137 dialog_host_(new WebContentsModalDialogHostViews(this)), 138 web_contents_modal_dialog_top_y_(-1) {} 139 140BrowserViewLayout::~BrowserViewLayout() { 141} 142 143void BrowserViewLayout::Init( 144 BrowserViewLayoutDelegate* delegate, 145 Browser* browser, 146 BrowserView* browser_view, 147 views::View* top_container, 148 TabStrip* tab_strip, 149 views::View* toolbar, 150 InfoBarContainerView* infobar_container, 151 views::View* contents_split, 152 ContentsContainer* contents_container, 153 ImmersiveModeController* immersive_mode_controller) { 154 delegate_.reset(delegate); 155 browser_ = browser; 156 browser_view_ = browser_view; 157 top_container_ = top_container; 158 tab_strip_ = tab_strip; 159 toolbar_ = toolbar; 160 infobar_container_ = infobar_container; 161 contents_split_ = contents_split; 162 contents_container_ = contents_container; 163 immersive_mode_controller_ = immersive_mode_controller; 164} 165 166WebContentsModalDialogHost* 167 BrowserViewLayout::GetWebContentsModalDialogHost() { 168 return dialog_host_.get(); 169} 170 171gfx::Size BrowserViewLayout::GetMinimumSize() { 172 gfx::Size tabstrip_size( 173 browser()->SupportsWindowFeature(Browser::FEATURE_TABSTRIP) ? 174 tab_strip_->GetMinimumSize() : gfx::Size()); 175 BrowserNonClientFrameView::TabStripInsets tab_strip_insets( 176 browser_view_->frame()->GetTabStripInsets(false)); 177 gfx::Size toolbar_size( 178 (browser()->SupportsWindowFeature(Browser::FEATURE_TOOLBAR) || 179 browser()->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR)) ? 180 toolbar_->GetMinimumSize() : gfx::Size()); 181 if (tabstrip_size.height() && toolbar_size.height()) 182 toolbar_size.Enlarge(0, -kToolbarTabStripVerticalOverlap); 183 gfx::Size bookmark_bar_size; 184 if (bookmark_bar_ && 185 bookmark_bar_->visible() && 186 browser()->SupportsWindowFeature(Browser::FEATURE_BOOKMARKBAR)) { 187 bookmark_bar_size = bookmark_bar_->GetMinimumSize(); 188 bookmark_bar_size.Enlarge(0, -bookmark_bar_->GetToolbarOverlap()); 189 } 190 // TODO: Adjust the minimum height for the find bar. 191 192 gfx::Size contents_size(contents_split_->GetMinimumSize()); 193 194 int min_height = tabstrip_size.height() + toolbar_size.height() + 195 bookmark_bar_size.height() + contents_size.height(); 196 int widths[] = { 197 tabstrip_size.width() + tab_strip_insets.left + tab_strip_insets.right, 198 toolbar_size.width(), 199 bookmark_bar_size.width(), 200 contents_size.width() }; 201 int min_width = *std::max_element(&widths[0], &widths[arraysize(widths)]); 202 return gfx::Size(min_width, min_height); 203} 204 205gfx::Rect BrowserViewLayout::GetFindBarBoundingBox() const { 206 // This function returns the area the Find Bar can be laid out within. This 207 // basically implies the "user-perceived content area" of the browser 208 // window excluding the vertical scrollbar. The "user-perceived content area" 209 // excludes the detached bookmark bar (in the New Tab case) and any infobars 210 // since they are not _visually_ connected to the Toolbar. 211 212 // First determine the bounding box of the content area in Widget 213 // coordinates. 214 gfx::Rect bounding_box = contents_container_->ConvertRectToWidget( 215 contents_container_->GetLocalBounds()); 216 217 gfx::Rect top_container_bounds = top_container_->ConvertRectToWidget( 218 top_container_->GetLocalBounds()); 219 220 int find_bar_y = 0; 221 if (immersive_mode_controller_->IsEnabled() && 222 !immersive_mode_controller_->IsRevealed()) { 223 // Position the find bar exactly below the top container. In immersive 224 // fullscreen, when the top-of-window views are not revealed, only the 225 // miniature immersive style tab strip is visible. Do not overlap the 226 // find bar and the tab strip. 227 find_bar_y = top_container_bounds.bottom(); 228 } else { 229 // Position the find bar 1 pixel above the bottom of the top container 230 // so that it occludes the border between the content area and the top 231 // container and looks connected to the top container. 232 find_bar_y = top_container_bounds.bottom() - 1; 233 } 234 235 // Grow the height of |bounding_box| by the height of any elements between 236 // the top container and |contents_container_| such as the detached bookmark 237 // bar and any infobars. 238 int height_delta = bounding_box.y() - find_bar_y; 239 bounding_box.set_y(find_bar_y); 240 bounding_box.set_height(std::max(0, bounding_box.height() + height_delta)); 241 242 // Finally decrease the width of the bounding box by the width of 243 // the vertical scroll bar. 244 int scrollbar_width = gfx::scrollbar_size(); 245 bounding_box.set_width(std::max(0, bounding_box.width() - scrollbar_width)); 246 if (base::i18n::IsRTL()) 247 bounding_box.set_x(bounding_box.x() + scrollbar_width); 248 249 return bounding_box; 250} 251 252int BrowserViewLayout::NonClientHitTest(const gfx::Point& point) { 253 // Since the TabStrip only renders in some parts of the top of the window, 254 // the un-obscured area is considered to be part of the non-client caption 255 // area of the window. So we need to treat hit-tests in these regions as 256 // hit-tests of the titlebar. 257 258 views::View* parent = browser_view_->parent(); 259 260 gfx::Point point_in_browser_view_coords(point); 261 views::View::ConvertPointToTarget( 262 parent, browser_view_, &point_in_browser_view_coords); 263 gfx::Point test_point(point); 264 265 // Determine if the TabStrip exists and is capable of being clicked on. We 266 // might be a popup window without a TabStrip. 267 if (browser_view_->IsTabStripVisible()) { 268 // See if the mouse pointer is within the bounds of the TabStrip. 269 if (ConvertedHitTest(parent, tab_strip_, &test_point)) { 270 if (tab_strip_->IsPositionInWindowCaption(test_point)) 271 return HTCAPTION; 272 return HTCLIENT; 273 } 274 275 // The top few pixels of the TabStrip are a drop-shadow - as we're pretty 276 // starved of dragable area, let's give it to window dragging (this also 277 // makes sense visually). 278 if (!(browser_view_->IsMaximized() || browser_view_->IsFullscreen()) && 279 (point_in_browser_view_coords.y() < 280 (tab_strip_->y() + kTabShadowSize))) { 281 // We return HTNOWHERE as this is a signal to our containing 282 // NonClientView that it should figure out what the correct hit-test 283 // code is given the mouse position... 284 return HTNOWHERE; 285 } 286 } 287 288 // If the point's y coordinate is below the top of the toolbar and otherwise 289 // within the bounds of this view, the point is considered to be within the 290 // client area. 291 gfx::Rect bv_bounds = browser_view_->bounds(); 292 bv_bounds.Offset(0, toolbar_->y()); 293 bv_bounds.set_height(bv_bounds.height() - toolbar_->y()); 294 if (bv_bounds.Contains(point)) 295 return HTCLIENT; 296 297 // If the point is within the bounds of the window switcher button, the point 298 // is considered to be within the client area. 299 views::View* window_switcher_button = delegate_->GetWindowSwitcherButton(); 300 if (window_switcher_button && window_switcher_button->visible()) { 301 gfx::Point window_switcher_point(point_in_browser_view_coords); 302 views::View::ConvertPointToTarget(browser_view_, window_switcher_button, 303 &window_switcher_point); 304 if (window_switcher_button->HitTestPoint(window_switcher_point)) 305 return HTCLIENT; 306 } 307 308 // If the point's y coordinate is above the top of the toolbar, but neither 309 // over the tabstrip nor over the window switcher button (per previous 310 // checking in this function), then we consider it in the window caption 311 // (e.g. the area to the right of the tabstrip underneath the window 312 // controls). However, note that we DO NOT return HTCAPTION here, because 313 // when the window is maximized the window controls will fall into this 314 // space (since the BrowserView is sized to entire size of the window at that 315 // point), and the HTCAPTION value will cause the window controls not to work. 316 // So we return HTNOWHERE so that the caller will hit-test the window controls 317 // before finally falling back to HTCAPTION. 318 bv_bounds = browser_view_->bounds(); 319 bv_bounds.set_height(toolbar_->y()); 320 if (bv_bounds.Contains(point)) 321 return HTNOWHERE; 322 323 // If the point is somewhere else, delegate to the default implementation. 324 return browser_view_->views::ClientView::NonClientHitTest(point); 325} 326 327////////////////////////////////////////////////////////////////////////////// 328// BrowserViewLayout, views::LayoutManager implementation: 329 330void BrowserViewLayout::Layout(views::View* browser_view) { 331 vertical_layout_rect_ = browser_view->GetLocalBounds(); 332 int top = LayoutTabStripRegion(browser_view); 333 if (delegate_->IsTabStripVisible()) { 334 int x = tab_strip_->GetMirroredX() + 335 browser_view_->GetMirroredX() + 336 browser_view_->frame()->GetThemeBackgroundXInset(); 337 tab_strip_->SetBackgroundOffset( 338 gfx::Point(x, browser_view_->frame()->GetTabStripInsets(false).top)); 339 } 340 top = LayoutToolbar(top); 341 342 top = LayoutBookmarkAndInfoBars(top, browser_view->y()); 343 344 // Top container requires updated toolbar and bookmark bar to compute bounds. 345 UpdateTopContainerBounds(); 346 347 int bottom = LayoutDownloadShelf(browser_view->height()); 348 // Treat a detached bookmark bar as if the web contents container is shifted 349 // upwards and overlaps it. 350 int active_top_margin = GetContentsOffsetForBookmarkBar(); 351 contents_container_->SetActiveTopMargin(active_top_margin); 352 top -= active_top_margin; 353 LayoutContentsSplitView(top, bottom); 354 355 // This must be done _after_ we lay out the WebContents since this 356 // code calls back into us to find the bounding box the find bar 357 // must be laid out within, and that code depends on the 358 // TabContentsContainer's bounds being up to date. 359 if (browser()->HasFindBarController()) { 360 browser()->GetFindBarController()->find_bar()->MoveWindowIfNecessary( 361 gfx::Rect(), true); 362 } 363 364 // Adjust the fullscreen exit bubble bounds for |top_container_|'s new bounds. 365 // This makes the fullscreen exit bubble look like it animates with 366 // |top_container_| in immersive fullscreen. 367 FullscreenExitBubbleViews* fullscreen_exit_bubble = 368 delegate_->GetFullscreenExitBubble(); 369 if (fullscreen_exit_bubble) 370 fullscreen_exit_bubble->RepositionIfVisible(); 371 372 // Adjust any web contents modal dialogs. 373 dialog_host_->NotifyPositionRequiresUpdate(); 374} 375 376// Return the preferred size which is the size required to give each 377// children their respective preferred size. 378gfx::Size BrowserViewLayout::GetPreferredSize(views::View* host) { 379 return gfx::Size(); 380} 381 382////////////////////////////////////////////////////////////////////////////// 383// BrowserViewLayout, private: 384 385int BrowserViewLayout::LayoutTabStripRegion(views::View* browser_view) { 386 if (!delegate_->IsTabStripVisible()) { 387 tab_strip_->SetVisible(false); 388 tab_strip_->SetBounds(0, 0, 0, 0); 389 return 0; 390 } 391 // This retrieves the bounds for the tab strip based on whether or not we show 392 // anything to the left of it, like the incognito avatar. 393 gfx::Rect tabstrip_bounds(delegate_->GetBoundsForTabStrip(tab_strip_)); 394 gfx::Point tabstrip_origin(tabstrip_bounds.origin()); 395 views::View::ConvertPointToTarget( 396 browser_view->parent(), browser_view, &tabstrip_origin); 397 tabstrip_bounds.set_origin(tabstrip_origin); 398 399 tab_strip_->SetVisible(true); 400 tab_strip_->SetBoundsRect(tabstrip_bounds); 401 int bottom = tabstrip_bounds.bottom(); 402 403 // The metro window switcher sits at the far right edge of the tabstrip 404 // a |kWindowSwitcherOffsetX| pixels from the right edge. 405 // Only visible if there is more than one type of window to switch between. 406 // TODO(mad): update this code when more window types than just incognito 407 // and regular are available. 408 views::View* switcher_button = delegate_->GetWindowSwitcherButton(); 409 if (switcher_button) { 410 if (browser()->profile()->HasOffTheRecordProfile() && 411 chrome::FindBrowserWithProfile( 412 browser()->profile()->GetOriginalProfile(), 413 browser()->host_desktop_type()) != NULL) { 414 switcher_button->SetVisible(true); 415 int width = browser_view->width(); 416 gfx::Size ps = switcher_button->GetPreferredSize(); 417 if (width > ps.width()) { 418 switcher_button->SetBounds(width - ps.width() - kWindowSwitcherOffsetX, 419 0, 420 ps.width(), 421 ps.height()); 422 } 423 } else { 424 // We hide the button if the incognito profile is not alive. 425 // Note that Layout() is not called to all browser windows automatically 426 // when a profile goes away but we rely in the metro_driver.dll to call 427 // ::SetWindowPos( , .. SWP_SHOWWINDOW) which causes this function to 428 // be called again. This works both in showing or hidding the button. 429 switcher_button->SetVisible(false); 430 } 431 } 432 433 return bottom; 434} 435 436int BrowserViewLayout::LayoutToolbar(int top) { 437 int browser_view_width = vertical_layout_rect_.width(); 438 bool toolbar_visible = delegate_->IsToolbarVisible(); 439 int y = top; 440 y -= (toolbar_visible && delegate_->IsTabStripVisible()) ? 441 kToolbarTabStripVerticalOverlap : 0; 442 int height = toolbar_visible ? toolbar_->GetPreferredSize().height() : 0; 443 toolbar_->SetVisible(toolbar_visible); 444 toolbar_->SetBounds(vertical_layout_rect_.x(), y, browser_view_width, height); 445 446 return y + height; 447} 448 449int BrowserViewLayout::LayoutBookmarkAndInfoBars(int top, int browser_view_y) { 450 web_contents_modal_dialog_top_y_ = 451 top + browser_view_y - kConstrainedWindowOverlap; 452 453 if (bookmark_bar_) { 454 // If we're showing the Bookmark bar in detached style, then we 455 // need to show any Info bar _above_ the Bookmark bar, since the 456 // Bookmark bar is styled to look like it's part of the page. 457 if (bookmark_bar_->IsDetached()) { 458 web_contents_modal_dialog_top_y_ = 459 top + browser_view_y - kConstrainedWindowOverlap; 460 return LayoutBookmarkBar(LayoutInfoBar(top)); 461 } 462 // Otherwise, Bookmark bar first, Info bar second. 463 top = std::max(toolbar_->bounds().bottom(), LayoutBookmarkBar(top)); 464 } 465 466 return LayoutInfoBar(top); 467} 468 469int BrowserViewLayout::LayoutBookmarkBar(int top) { 470 int y = top; 471 if (!delegate_->IsBookmarkBarVisible()) { 472 bookmark_bar_->SetVisible(false); 473 // TODO(jamescook): Don't change the bookmark bar height when it is 474 // invisible, so we can use its height for layout even in that state. 475 bookmark_bar_->SetBounds(0, y, browser_view_->width(), 0); 476 return y; 477 } 478 479 bookmark_bar_->set_infobar_visible(InfobarVisible()); 480 int bookmark_bar_height = bookmark_bar_->GetPreferredSize().height(); 481 y -= bookmark_bar_->GetToolbarOverlap(); 482 bookmark_bar_->SetBounds(vertical_layout_rect_.x(), 483 y, 484 vertical_layout_rect_.width(), 485 bookmark_bar_height); 486 // Set visibility after setting bounds, as the visibility update uses the 487 // bounds to determine if the mouse is hovering over a button. 488 bookmark_bar_->SetVisible(true); 489 return y + bookmark_bar_height; 490} 491 492int BrowserViewLayout::LayoutInfoBar(int top) { 493 // In immersive fullscreen, the infobar always starts near the top of the 494 // screen, just under the "light bar" rectangular stripes. 495 if (immersive_mode_controller_->IsEnabled()) { 496 top = immersive_mode_controller_->ShouldHideTabIndicators() 497 ? browser_view_->y() 498 : browser_view_->y() + TabStrip::GetImmersiveHeight(); 499 } 500 // Raise the |infobar_container_| by its vertical overlap. 501 infobar_container_->SetVisible(InfobarVisible()); 502 int height; 503 int overlapped_top = top - infobar_container_->GetVerticalOverlap(&height); 504 infobar_container_->SetBounds(vertical_layout_rect_.x(), 505 overlapped_top, 506 vertical_layout_rect_.width(), 507 height); 508 return overlapped_top + height; 509} 510 511void BrowserViewLayout::LayoutContentsSplitView(int top, int bottom) { 512 // |contents_split_| contains web page contents and devtools. 513 // See browser_view.h for details. 514 gfx::Rect contents_split_bounds(vertical_layout_rect_.x(), 515 top, 516 vertical_layout_rect_.width(), 517 std::max(0, bottom - top)); 518 contents_split_->SetBoundsRect(contents_split_bounds); 519} 520 521void BrowserViewLayout::UpdateTopContainerBounds() { 522 gfx::Rect top_container_bounds(top_container_->GetPreferredSize()); 523 524 // If the immersive mode controller is animating the top-of-window views, 525 // part of the top container may be offscreen. 526 top_container_bounds.set_y( 527 immersive_mode_controller_->GetTopContainerVerticalOffset( 528 top_container_bounds.size())); 529 top_container_->SetBoundsRect(top_container_bounds); 530} 531 532int BrowserViewLayout::GetContentsOffsetForBookmarkBar() { 533 // If the bookmark bar is hidden or attached to the omnibox the web contents 534 // will appear directly underneath it and does not need an offset. 535 if (!bookmark_bar_ || 536 !browser_view_->IsBookmarkBarVisible() || 537 !bookmark_bar_->IsDetached()) { 538 return 0; 539 } 540 541 // Dev tools. 542 if (contents_split_->child_at(1) && contents_split_->child_at(1)->visible()) 543 return 0; 544 545 // Offset for the detached bookmark bar. 546 return bookmark_bar_->height() - 547 bookmark_bar_->GetFullyDetachedToolbarOverlap(); 548} 549 550int BrowserViewLayout::LayoutDownloadShelf(int bottom) { 551 if (delegate_->DownloadShelfNeedsLayout()) { 552 bool visible = browser()->SupportsWindowFeature( 553 Browser::FEATURE_DOWNLOADSHELF); 554 DCHECK(download_shelf_); 555 int height = visible ? download_shelf_->GetPreferredSize().height() : 0; 556 download_shelf_->SetVisible(visible); 557 download_shelf_->SetBounds(vertical_layout_rect_.x(), bottom - height, 558 vertical_layout_rect_.width(), height); 559 download_shelf_->Layout(); 560 bottom -= height; 561 } 562 return bottom; 563} 564 565bool BrowserViewLayout::InfobarVisible() const { 566 // Cast to a views::View to access GetPreferredSize(). 567 views::View* infobar_container = infobar_container_; 568 // NOTE: Can't check if the size IsEmpty() since it's always 0-width. 569 return browser_->SupportsWindowFeature(Browser::FEATURE_INFOBAR) && 570 (infobar_container->GetPreferredSize().height() != 0); 571} 572