browser_view_layout.cc revision a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7
12a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Copyright 2012 The Chromium Authors. All rights reserved. 25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file. 45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/ui/views/frame/browser_view_layout.h" 65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 7c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "base/observer_list.h" 82a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "chrome/browser/profiles/profile.h" 9a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#include "chrome/browser/ui/browser.h" 105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/ui/browser_finder.h" 11a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#include "chrome/browser/ui/browser_window.h" 125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/ui/find_bar/find_bar.h" 135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/ui/find_bar/find_bar_controller.h" 145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/ui/search/search_model.h" 155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h" 165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/ui/views/download/download_shelf_view.h" 1790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include "chrome/browser/ui/views/frame/browser_view_layout_delegate.h" 185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/ui/views/frame/contents_container.h" 192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "chrome/browser/ui/views/frame/immersive_mode_controller.h" 202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "chrome/browser/ui/views/frame/top_container_view.h" 217dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch#include "chrome/browser/ui/views/fullscreen_exit_bubble_views.h" 225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/ui/views/infobars/infobar_container_view.h" 235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/ui/views/tabs/tab_strip.h" 2490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include "components/web_modal/web_contents_modal_dialog_host.h" 255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ui/base/hit_test.h" 265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ui/gfx/point.h" 275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ui/gfx/scrollbar_size.h" 285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ui/gfx/size.h" 295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ui/views/controls/webview/webview.h" 30f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)#include "ui/views/widget/widget.h" 31f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)#include "ui/views/window/client_view.h" 325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 33c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)using views::View; 3490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)using web_modal::WebContentsModalDialogHost; 354e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)using web_modal::ModalDialogHostObserver; 36c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace { 385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// The visible height of the shadow above the tabs. Clicks in this area are 405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// treated as clicks to the frame, rather than clicks to the tab. 415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)const int kTabShadowSize = 2; 425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// The number of pixels the metro switcher is offset from the right edge. 435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)const int kWindowSwitcherOffsetX = 7; 445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// The number of pixels the constrained window should overlap the bottom 455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// of the omnibox. 465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)const int kConstrainedWindowOverlap = 3; 475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Combines View::ConvertPointToTarget and View::HitTest for a given |point|. 495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Converts |point| from |src| to |dst| and hit tests it against |dst|. The 505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// converted |point| can then be retrieved and used for additional tests. 515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)bool ConvertedHitTest(views::View* src, views::View* dst, gfx::Point* point) { 525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) DCHECK(src); 535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) DCHECK(dst); 545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) DCHECK(point); 555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) views::View::ConvertPointToTarget(src, dst, point); 565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return dst->HitTestPoint(*point); 575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} // namespace 605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 61c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)class BrowserViewLayout::WebContentsModalDialogHostViews 62c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) : public WebContentsModalDialogHost { 63c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) public: 64c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) explicit WebContentsModalDialogHostViews( 65c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) BrowserViewLayout* browser_view_layout) 66c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) : browser_view_layout_(browser_view_layout) { 67c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) } 68c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 693551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) virtual ~WebContentsModalDialogHostViews() { 704e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) FOR_EACH_OBSERVER(web_modal::ModalDialogHostObserver, 713551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) observer_list_, 723551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) OnHostDestroying()); 733551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) } 743551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) 75c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) void NotifyPositionRequiresUpdate() { 764e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) FOR_EACH_OBSERVER(ModalDialogHostObserver, 77c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) observer_list_, 78c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) OnPositionRequiresUpdate()); 79c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) } 80c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 81c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // Center horizontally over the content area, with the top overlapping the 82c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // browser chrome. 83c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) virtual gfx::Point GetDialogPosition(const gfx::Size& size) OVERRIDE { 84c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) int top_y = browser_view_layout_->web_contents_modal_dialog_top_y_; 85f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) ContentsContainer* contents_container = 86f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) browser_view_layout_->contents_container_; 87f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) gfx::Rect contents_container_bounds_in_widget = 88f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) contents_container->ConvertRectToWidget( 89f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) contents_container->GetLocalBounds()); 90f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) int middle_x = contents_container_bounds_in_widget.x() + 91f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) contents_container_bounds_in_widget.width() / 2; 92c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) return gfx::Point(middle_x - size.width() / 2, top_y); 93c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) } 94c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 95a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) private: 96a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) virtual gfx::NativeView GetHostView() const OVERRIDE { 97a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) gfx::NativeWindow native_window = 98a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) browser_view_layout_->browser()->window()->GetNativeWindow(); 99a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) return views::Widget::GetWidgetForNativeWindow(native_window)-> 100a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) GetNativeView(); 101a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) } 102a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 10358537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) virtual gfx::Size GetMaximumDialogSize() OVERRIDE { 10458537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) gfx::Rect content_area = 10558537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) browser_view_layout_->contents_container_->ConvertRectToWidget( 10658537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) browser_view_layout_->contents_container_->GetLocalBounds()); 10758537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) 10858537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) gfx::Size max_dialog_size = content_area.size(); 10958537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) // Adjust for difference in alignment between the dialog top and the top of 11058537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) // the content area. 11158537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) int height_offset = content_area.y() - 11258537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) browser_view_layout_->web_contents_modal_dialog_top_y_; 11358537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) max_dialog_size.Enlarge(0, height_offset); 11458537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) return max_dialog_size; 11558537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) } 11658537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) 117c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // Add/remove observer. 118c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) virtual void AddObserver( 1194e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) ModalDialogHostObserver* observer) OVERRIDE { 120c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) observer_list_.AddObserver(observer); 121c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) } 122c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) virtual void RemoveObserver( 1234e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) ModalDialogHostObserver* observer) OVERRIDE { 124c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) observer_list_.RemoveObserver(observer); 125c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) } 126c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 127a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) BrowserViewLayout* const browser_view_layout_; 128c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 1294e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) ObserverList<ModalDialogHostObserver> observer_list_; 130c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 131c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(WebContentsModalDialogHostViews); 132c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)}; 133c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 134c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// static 135c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)const int BrowserViewLayout::kToolbarTabStripVerticalOverlap = 3; 136c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 1375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//////////////////////////////////////////////////////////////////////////////// 1385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// BrowserViewLayout, public: 1395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)BrowserViewLayout::BrowserViewLayout() 1417d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) : browser_(NULL), 142c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) browser_view_(NULL), 14390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) top_container_(NULL), 14490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) tab_strip_(NULL), 14590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) toolbar_(NULL), 146c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) bookmark_bar_(NULL), 147c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) infobar_container_(NULL), 148c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) contents_split_(NULL), 1495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) contents_container_(NULL), 1505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) download_shelf_(NULL), 15190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) immersive_mode_controller_(NULL), 152c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) dialog_host_(new WebContentsModalDialogHostViews(this)), 1537d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) web_contents_modal_dialog_top_y_(-1) {} 1545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)BrowserViewLayout::~BrowserViewLayout() { 1565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 1575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 15890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)void BrowserViewLayout::Init( 15990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) BrowserViewLayoutDelegate* delegate, 16090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) Browser* browser, 161f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) views::ClientView* browser_view, 16290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) views::View* top_container, 16390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) TabStrip* tab_strip, 16490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) views::View* toolbar, 16590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) InfoBarContainerView* infobar_container, 16690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) views::View* contents_split, 16790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) ContentsContainer* contents_container, 16890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) ImmersiveModeController* immersive_mode_controller) { 16990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) delegate_.reset(delegate); 170c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) browser_ = browser; 171c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) browser_view_ = browser_view; 17290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) top_container_ = top_container; 17390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) tab_strip_ = tab_strip; 17490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) toolbar_ = toolbar; 175c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) infobar_container_ = infobar_container; 176c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) contents_split_ = contents_split; 177c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) contents_container_ = contents_container; 17890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) immersive_mode_controller_ = immersive_mode_controller; 179c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)} 180c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 181c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)WebContentsModalDialogHost* 182c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) BrowserViewLayout::GetWebContentsModalDialogHost() { 183c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) return dialog_host_.get(); 1845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 1855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)gfx::Size BrowserViewLayout::GetMinimumSize() { 1875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Size tabstrip_size( 1885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) browser()->SupportsWindowFeature(Browser::FEATURE_TABSTRIP) ? 18990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) tab_strip_->GetMinimumSize() : gfx::Size()); 1905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Size toolbar_size( 1915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) (browser()->SupportsWindowFeature(Browser::FEATURE_TOOLBAR) || 1925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) browser()->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR)) ? 19390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) toolbar_->GetMinimumSize() : gfx::Size()); 1945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (tabstrip_size.height() && toolbar_size.height()) 1955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) toolbar_size.Enlarge(0, -kToolbarTabStripVerticalOverlap); 1965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Size bookmark_bar_size; 197c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) if (bookmark_bar_ && 198c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) bookmark_bar_->visible() && 1995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) browser()->SupportsWindowFeature(Browser::FEATURE_BOOKMARKBAR)) { 200c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) bookmark_bar_size = bookmark_bar_->GetMinimumSize(); 201eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch bookmark_bar_size.Enlarge(0, -bookmark_bar_->GetToolbarOverlap()); 2025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 203a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) gfx::Size infobar_container_size(infobar_container_->GetMinimumSize()); 204c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // TODO: Adjust the minimum height for the find bar. 205c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 2065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Size contents_size(contents_split_->GetMinimumSize()); 2075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 208a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) int min_height = delegate_->GetTopInsetInBrowserView() + 209a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) tabstrip_size.height() + toolbar_size.height() + 210a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) bookmark_bar_size.height() + infobar_container_size.height() + 211a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) contents_size.height(); 2125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int widths[] = { 213f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) tabstrip_size.width(), 2145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) toolbar_size.width(), 2155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bookmark_bar_size.width(), 216a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) infobar_container_size.width(), 2175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) contents_size.width() }; 2185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int min_width = *std::max_element(&widths[0], &widths[arraysize(widths)]); 2195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return gfx::Size(min_width, min_height); 2205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 2215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)gfx::Rect BrowserViewLayout::GetFindBarBoundingBox() const { 223c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // This function returns the area the Find Bar can be laid out within. This 224c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // basically implies the "user-perceived content area" of the browser 225c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // window excluding the vertical scrollbar. The "user-perceived content area" 226c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // excludes the detached bookmark bar (in the New Tab case) and any infobars 227c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // since they are not _visually_ connected to the Toolbar. 2285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // First determine the bounding box of the content area in Widget 2305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // coordinates. 2315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Rect bounding_box = contents_container_->ConvertRectToWidget( 2325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) contents_container_->GetLocalBounds()); 2335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 23490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) gfx::Rect top_container_bounds = top_container_->ConvertRectToWidget( 23590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) top_container_->GetLocalBounds()); 236c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 2377d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) int find_bar_y = 0; 2387d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) if (immersive_mode_controller_->IsEnabled() && 2397d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) !immersive_mode_controller_->IsRevealed()) { 2407d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) // Position the find bar exactly below the top container. In immersive 2417d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) // fullscreen, when the top-of-window views are not revealed, only the 2427d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) // miniature immersive style tab strip is visible. Do not overlap the 2437d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) // find bar and the tab strip. 2447d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) find_bar_y = top_container_bounds.bottom(); 2457d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) } else { 2467d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) // Position the find bar 1 pixel above the bottom of the top container 2477d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) // so that it occludes the border between the content area and the top 2487d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) // container and looks connected to the top container. 2497d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) find_bar_y = top_container_bounds.bottom() - 1; 2507d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) } 251c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 252c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // Grow the height of |bounding_box| by the height of any elements between 253c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // the top container and |contents_container_| such as the detached bookmark 254c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // bar and any infobars. 255c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) int height_delta = bounding_box.y() - find_bar_y; 256c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) bounding_box.set_y(find_bar_y); 2575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bounding_box.set_height(std::max(0, bounding_box.height() + height_delta)); 2585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Finally decrease the width of the bounding box by the width of 2605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // the vertical scroll bar. 2615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int scrollbar_width = gfx::scrollbar_size(); 2625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bounding_box.set_width(std::max(0, bounding_box.width() - scrollbar_width)); 2635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (base::i18n::IsRTL()) 2645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bounding_box.set_x(bounding_box.x() + scrollbar_width); 2655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return bounding_box; 2675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 2685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 269bbcdd45c55eb7c4641ab97aef9889b0fc828e7d3Ben Murdochint BrowserViewLayout::NonClientHitTest(const gfx::Point& point) { 2705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Since the TabStrip only renders in some parts of the top of the window, 2715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // the un-obscured area is considered to be part of the non-client caption 2725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // area of the window. So we need to treat hit-tests in these regions as 2735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // hit-tests of the titlebar. 2745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) views::View* parent = browser_view_->parent(); 2765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Point point_in_browser_view_coords(point); 2785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) views::View::ConvertPointToTarget( 2795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) parent, browser_view_, &point_in_browser_view_coords); 2805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Point test_point(point); 2815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Determine if the TabStrip exists and is capable of being clicked on. We 2835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // might be a popup window without a TabStrip. 284f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) if (delegate_->IsTabStripVisible()) { 2855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // See if the mouse pointer is within the bounds of the TabStrip. 28690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) if (ConvertedHitTest(parent, tab_strip_, &test_point)) { 28790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) if (tab_strip_->IsPositionInWindowCaption(test_point)) 2885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return HTCAPTION; 2895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return HTCLIENT; 2905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 2915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The top few pixels of the TabStrip are a drop-shadow - as we're pretty 2935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // starved of dragable area, let's give it to window dragging (this also 2945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // makes sense visually). 295f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) views::Widget* widget = browser_view_->GetWidget(); 296f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) if (!(widget->IsMaximized() || widget->IsFullscreen()) && 2975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) (point_in_browser_view_coords.y() < 29890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) (tab_strip_->y() + kTabShadowSize))) { 2995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // We return HTNOWHERE as this is a signal to our containing 3005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // NonClientView that it should figure out what the correct hit-test 3015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // code is given the mouse position... 3025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return HTNOWHERE; 3035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 3045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 3055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // If the point's y coordinate is below the top of the toolbar and otherwise 3075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // within the bounds of this view, the point is considered to be within the 3085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // client area. 3095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Rect bv_bounds = browser_view_->bounds(); 31090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) bv_bounds.Offset(0, toolbar_->y()); 31190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) bv_bounds.set_height(bv_bounds.height() - toolbar_->y()); 3125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (bv_bounds.Contains(point)) 3135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return HTCLIENT; 3145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 315bbcdd45c55eb7c4641ab97aef9889b0fc828e7d3Ben Murdoch // If the point is within the bounds of the window switcher button, the point 316bbcdd45c55eb7c4641ab97aef9889b0fc828e7d3Ben Murdoch // is considered to be within the client area. 317bbcdd45c55eb7c4641ab97aef9889b0fc828e7d3Ben Murdoch views::View* window_switcher_button = delegate_->GetWindowSwitcherButton(); 318bbcdd45c55eb7c4641ab97aef9889b0fc828e7d3Ben Murdoch if (window_switcher_button && window_switcher_button->visible()) { 319bbcdd45c55eb7c4641ab97aef9889b0fc828e7d3Ben Murdoch gfx::Point window_switcher_point(point_in_browser_view_coords); 320bbcdd45c55eb7c4641ab97aef9889b0fc828e7d3Ben Murdoch views::View::ConvertPointToTarget(browser_view_, window_switcher_button, 321bbcdd45c55eb7c4641ab97aef9889b0fc828e7d3Ben Murdoch &window_switcher_point); 322bbcdd45c55eb7c4641ab97aef9889b0fc828e7d3Ben Murdoch if (window_switcher_button->HitTestPoint(window_switcher_point)) 323bbcdd45c55eb7c4641ab97aef9889b0fc828e7d3Ben Murdoch return HTCLIENT; 324bbcdd45c55eb7c4641ab97aef9889b0fc828e7d3Ben Murdoch } 325bbcdd45c55eb7c4641ab97aef9889b0fc828e7d3Ben Murdoch 326bbcdd45c55eb7c4641ab97aef9889b0fc828e7d3Ben Murdoch // If the point's y coordinate is above the top of the toolbar, but neither 327bbcdd45c55eb7c4641ab97aef9889b0fc828e7d3Ben Murdoch // over the tabstrip nor over the window switcher button (per previous 328bbcdd45c55eb7c4641ab97aef9889b0fc828e7d3Ben Murdoch // checking in this function), then we consider it in the window caption 329bbcdd45c55eb7c4641ab97aef9889b0fc828e7d3Ben Murdoch // (e.g. the area to the right of the tabstrip underneath the window 330bbcdd45c55eb7c4641ab97aef9889b0fc828e7d3Ben Murdoch // controls). However, note that we DO NOT return HTCAPTION here, because 331bbcdd45c55eb7c4641ab97aef9889b0fc828e7d3Ben Murdoch // when the window is maximized the window controls will fall into this 332bbcdd45c55eb7c4641ab97aef9889b0fc828e7d3Ben Murdoch // space (since the BrowserView is sized to entire size of the window at that 333bbcdd45c55eb7c4641ab97aef9889b0fc828e7d3Ben Murdoch // point), and the HTCAPTION value will cause the window controls not to work. 334bbcdd45c55eb7c4641ab97aef9889b0fc828e7d3Ben Murdoch // So we return HTNOWHERE so that the caller will hit-test the window controls 335bbcdd45c55eb7c4641ab97aef9889b0fc828e7d3Ben Murdoch // before finally falling back to HTCAPTION. 3365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bv_bounds = browser_view_->bounds(); 33790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) bv_bounds.set_height(toolbar_->y()); 3385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (bv_bounds.Contains(point)) 3395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return HTNOWHERE; 3405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // If the point is somewhere else, delegate to the default implementation. 3425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return browser_view_->views::ClientView::NonClientHitTest(point); 3435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 3445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)////////////////////////////////////////////////////////////////////////////// 3465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// BrowserViewLayout, views::LayoutManager implementation: 3475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 34890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)void BrowserViewLayout::Layout(views::View* browser_view) { 34990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) vertical_layout_rect_ = browser_view->GetLocalBounds(); 350f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) int top = delegate_->GetTopInsetInBrowserView(); 351f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) top = LayoutTabStripRegion(top); 35290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) if (delegate_->IsTabStripVisible()) { 35390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) int x = tab_strip_->GetMirroredX() + 3542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) browser_view_->GetMirroredX() + 355f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) delegate_->GetThemeBackgroundXInset(); 356f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) int y = browser_view_->y() + delegate_->GetTopInsetInBrowserView(); 357f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) tab_strip_->SetBackgroundOffset(gfx::Point(x, y)); 3585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 3595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) top = LayoutToolbar(top); 360a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 36190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) top = LayoutBookmarkAndInfoBars(top, browser_view->y()); 362c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 363868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // Top container requires updated toolbar and bookmark bar to compute bounds. 364868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) UpdateTopContainerBounds(); 3652a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 36690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) int bottom = LayoutDownloadShelf(browser_view->height()); 367c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // Treat a detached bookmark bar as if the web contents container is shifted 368c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // upwards and overlaps it. 369ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch int active_top_margin = GetContentsOffsetForBookmarkBar(); 370ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch contents_container_->SetActiveTopMargin(active_top_margin); 371ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch top -= active_top_margin; 372c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) LayoutContentsSplitView(top, bottom); 373c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 3745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // This must be done _after_ we lay out the WebContents since this 3755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // code calls back into us to find the bounding box the find bar 3765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // must be laid out within, and that code depends on the 3775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // TabContentsContainer's bounds being up to date. 3785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (browser()->HasFindBarController()) { 3795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) browser()->GetFindBarController()->find_bar()->MoveWindowIfNecessary( 3805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Rect(), true); 3815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 382c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 3837dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch // Adjust the fullscreen exit bubble bounds for |top_container_|'s new bounds. 3847dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch // This makes the fullscreen exit bubble look like it animates with 3857dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch // |top_container_| in immersive fullscreen. 3867dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch FullscreenExitBubbleViews* fullscreen_exit_bubble = 3877dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch delegate_->GetFullscreenExitBubble(); 3887dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch if (fullscreen_exit_bubble) 3897dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch fullscreen_exit_bubble->RepositionIfVisible(); 3907dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch 391a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) // Adjust any hosted dialogs if the browser's dialog positioning has changed. 392a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) if (dialog_host_->GetDialogPosition(gfx::Size()) != latest_dialog_position_) { 393a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) latest_dialog_position_ = dialog_host_->GetDialogPosition(gfx::Size()); 394a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) dialog_host_->NotifyPositionRequiresUpdate(); 395a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) } 3965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 3975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Return the preferred size which is the size required to give each 3995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// children their respective preferred size. 4005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)gfx::Size BrowserViewLayout::GetPreferredSize(views::View* host) { 4015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return gfx::Size(); 4025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 4035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)////////////////////////////////////////////////////////////////////////////// 4055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// BrowserViewLayout, private: 4065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 407f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)int BrowserViewLayout::LayoutTabStripRegion(int top) { 40890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) if (!delegate_->IsTabStripVisible()) { 40990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) tab_strip_->SetVisible(false); 41090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) tab_strip_->SetBounds(0, 0, 0, 0); 411f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) return top; 4125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 4135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // This retrieves the bounds for the tab strip based on whether or not we show 4145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // anything to the left of it, like the incognito avatar. 415f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) gfx::Rect tabstrip_bounds(delegate_->GetBoundsForTabStripInBrowserView()); 4165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 41790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) tab_strip_->SetVisible(true); 41890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) tab_strip_->SetBoundsRect(tabstrip_bounds); 4195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int bottom = tabstrip_bounds.bottom(); 4205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The metro window switcher sits at the far right edge of the tabstrip 4225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // a |kWindowSwitcherOffsetX| pixels from the right edge. 4235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Only visible if there is more than one type of window to switch between. 4245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // TODO(mad): update this code when more window types than just incognito 4255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // and regular are available. 42690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) views::View* switcher_button = delegate_->GetWindowSwitcherButton(); 4275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (switcher_button) { 4285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (browser()->profile()->HasOffTheRecordProfile() && 4292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) chrome::FindBrowserWithProfile( 4305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) browser()->profile()->GetOriginalProfile(), 4315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) browser()->host_desktop_type()) != NULL) { 4325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) switcher_button->SetVisible(true); 433f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) int width = browser_view_->width(); 4345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Size ps = switcher_button->GetPreferredSize(); 4355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (width > ps.width()) { 4365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) switcher_button->SetBounds(width - ps.width() - kWindowSwitcherOffsetX, 4375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 0, 4385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ps.width(), 4395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ps.height()); 4405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 4415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } else { 4425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // We hide the button if the incognito profile is not alive. 4435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Note that Layout() is not called to all browser windows automatically 4445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // when a profile goes away but we rely in the metro_driver.dll to call 4455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // ::SetWindowPos( , .. SWP_SHOWWINDOW) which causes this function to 4465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // be called again. This works both in showing or hidding the button. 4475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) switcher_button->SetVisible(false); 4485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 4495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 4505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return bottom; 4525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 4535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)int BrowserViewLayout::LayoutToolbar(int top) { 4555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int browser_view_width = vertical_layout_rect_.width(); 45690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) bool toolbar_visible = delegate_->IsToolbarVisible(); 4575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int y = top; 45890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) y -= (toolbar_visible && delegate_->IsTabStripVisible()) ? 4595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) kToolbarTabStripVerticalOverlap : 0; 46090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) int height = toolbar_visible ? toolbar_->GetPreferredSize().height() : 0; 46190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) toolbar_->SetVisible(toolbar_visible); 46290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) toolbar_->SetBounds(vertical_layout_rect_.x(), y, browser_view_width, height); 4635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return y + height; 4655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 4665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 46790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)int BrowserViewLayout::LayoutBookmarkAndInfoBars(int top, int browser_view_y) { 468424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) web_contents_modal_dialog_top_y_ = 469424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) top + browser_view_y - kConstrainedWindowOverlap; 470424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) 471c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) if (bookmark_bar_) { 4722a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // If we're showing the Bookmark bar in detached style, then we 4732a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // need to show any Info bar _above_ the Bookmark bar, since the 4742a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Bookmark bar is styled to look like it's part of the page. 47590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) if (bookmark_bar_->IsDetached()) { 47690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) web_contents_modal_dialog_top_y_ = 47790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) top + browser_view_y - kConstrainedWindowOverlap; 4782a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) return LayoutBookmarkBar(LayoutInfoBar(top)); 47990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) } 4805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Otherwise, Bookmark bar first, Info bar second. 48190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) top = std::max(toolbar_->bounds().bottom(), LayoutBookmarkBar(top)); 4825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 48390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 4845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return LayoutInfoBar(top); 4855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 4865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4872a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)int BrowserViewLayout::LayoutBookmarkBar(int top) { 4885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int y = top; 48990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) if (!delegate_->IsBookmarkBarVisible()) { 490c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) bookmark_bar_->SetVisible(false); 491c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // TODO(jamescook): Don't change the bookmark bar height when it is 492c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // invisible, so we can use its height for layout even in that state. 493c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) bookmark_bar_->SetBounds(0, y, browser_view_->width(), 0); 4945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return y; 4955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 4965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 497c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) bookmark_bar_->set_infobar_visible(InfobarVisible()); 498c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) int bookmark_bar_height = bookmark_bar_->GetPreferredSize().height(); 499eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch y -= bookmark_bar_->GetToolbarOverlap(); 50090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) bookmark_bar_->SetBounds(vertical_layout_rect_.x(), 50190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) y, 50290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) vertical_layout_rect_.width(), 50390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) bookmark_bar_height); 50490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // Set visibility after setting bounds, as the visibility update uses the 50590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // bounds to determine if the mouse is hovering over a button. 506c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) bookmark_bar_->SetVisible(true); 5075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return y + bookmark_bar_height; 5085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 5095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)int BrowserViewLayout::LayoutInfoBar(int top) { 511c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // In immersive fullscreen, the infobar always starts near the top of the 512c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // screen, just under the "light bar" rectangular stripes. 51390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) if (immersive_mode_controller_->IsEnabled()) { 51490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) top = immersive_mode_controller_->ShouldHideTabIndicators() 51590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) ? browser_view_->y() 51690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) : browser_view_->y() + TabStrip::GetImmersiveHeight(); 517c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) } 51890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // Raise the |infobar_container_| by its vertical overlap. 51990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) infobar_container_->SetVisible(InfobarVisible()); 5205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int height; 52190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) int overlapped_top = top - infobar_container_->GetVerticalOverlap(&height); 52290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) infobar_container_->SetBounds(vertical_layout_rect_.x(), 52390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) overlapped_top, 52490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) vertical_layout_rect_.width(), 52590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) height); 5265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return overlapped_top + height; 5275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 5285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 529c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)void BrowserViewLayout::LayoutContentsSplitView(int top, int bottom) { 530c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // |contents_split_| contains web page contents and devtools. 531c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // See browser_view.h for details. 532c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) gfx::Rect contents_split_bounds(vertical_layout_rect_.x(), 533c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) top, 5345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) vertical_layout_rect_.width(), 5355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) std::max(0, bottom - top)); 5365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) contents_split_->SetBoundsRect(contents_split_bounds); 5375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 5385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 539868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)void BrowserViewLayout::UpdateTopContainerBounds() { 540868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) gfx::Rect top_container_bounds(top_container_->GetPreferredSize()); 541868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 542a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) // If the immersive mode controller is animating the top container, it may be 543a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) // partly offscreen. The top container is positioned relative to the top of 544a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) // the client view instead of relative to GetTopInsetInBrowserView() because 545a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) // the top container paints parts of the frame (title, window controls) during 546a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) // an immersive reveal. 547868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) top_container_bounds.set_y( 548868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) immersive_mode_controller_->GetTopContainerVerticalOffset( 549868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) top_container_bounds.size())); 550868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) top_container_->SetBoundsRect(top_container_bounds); 551868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)} 552868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 553c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)int BrowserViewLayout::GetContentsOffsetForBookmarkBar() { 554c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // If the bookmark bar is hidden or attached to the omnibox the web contents 555c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // will appear directly underneath it and does not need an offset. 556c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) if (!bookmark_bar_ || 557f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) !delegate_->IsBookmarkBarVisible() || 558c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) !bookmark_bar_->IsDetached()) { 5595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return 0; 5605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 5615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 562c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // Dev tools. 5635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (contents_split_->child_at(1) && contents_split_->child_at(1)->visible()) 5645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return 0; 5655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 566c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // Offset for the detached bookmark bar. 567c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) return bookmark_bar_->height() - 568eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch bookmark_bar_->GetFullyDetachedToolbarOverlap(); 5695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 5705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)int BrowserViewLayout::LayoutDownloadShelf(int bottom) { 57290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) if (delegate_->DownloadShelfNeedsLayout()) { 5735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool visible = browser()->SupportsWindowFeature( 5745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) Browser::FEATURE_DOWNLOADSHELF); 5755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) DCHECK(download_shelf_); 5765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int height = visible ? download_shelf_->GetPreferredSize().height() : 0; 5775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) download_shelf_->SetVisible(visible); 5785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) download_shelf_->SetBounds(vertical_layout_rect_.x(), bottom - height, 5795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) vertical_layout_rect_.width(), height); 5805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) download_shelf_->Layout(); 5815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bottom -= height; 5825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 5835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return bottom; 5845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 5855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)bool BrowserViewLayout::InfobarVisible() const { 587c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // Cast to a views::View to access GetPreferredSize(). 588c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) views::View* infobar_container = infobar_container_; 5895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // NOTE: Can't check if the size IsEmpty() since it's always 0-width. 590c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) return browser_->SupportsWindowFeature(Browser::FEATURE_INFOBAR) && 5912a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) (infobar_container->GetPreferredSize().height() != 0); 5925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 593