| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_VIEW_LAYOUT_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_VIEW_LAYOUT_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_VIEW_LAYOUT_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_VIEW_LAYOUT_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/gtest_prod_util.h" | 10 #include "base/gtest_prod_util.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "ui/gfx/rect.h" | 12 #include "ui/gfx/rect.h" |
| 13 #include "ui/views/layout/layout_manager.h" | 13 #include "ui/views/layout/layout_manager.h" |
| 14 | 14 |
| 15 class BookmarkBarView; | 15 class BookmarkBarView; |
| 16 class Browser; | 16 class Browser; |
| 17 class BrowserView; | 17 class BrowserView; |
| 18 class BrowserViewLayoutDelegate; |
| 18 class ContentsContainer; | 19 class ContentsContainer; |
| 19 class DownloadShelfView; | 20 class ImmersiveModeController; |
| 20 class InfoBarContainerView; | 21 class InfoBarContainerView; |
| 21 class OverlayContainer; | 22 class OverlayContainer; |
| 22 class TabContentsContainer; | 23 class TabContentsContainer; |
| 23 class TabStrip; | 24 class TabStrip; |
| 24 class ToolbarView; | 25 class TopContainerView; |
| 25 class WebContentsModalDialogHost; | 26 class WebContentsModalDialogHost; |
| 26 | 27 |
| 27 namespace gfx { | 28 namespace gfx { |
| 28 class Point; | 29 class Point; |
| 29 class Size; | 30 class Size; |
| 30 } | 31 } |
| 31 | 32 |
| 32 namespace views { | 33 namespace views { |
| 33 class SingleSplitView; | 34 class SingleSplitView; |
| 34 } | 35 } |
| 35 | 36 |
| 36 // The layout manager used in chrome browser. | 37 // The layout manager used in chrome browser. |
| 37 class BrowserViewLayout : public views::LayoutManager { | 38 class BrowserViewLayout : public views::LayoutManager { |
| 38 public: | 39 public: |
| 39 // The vertical overlap between the TabStrip and the Toolbar. | 40 // The vertical overlap between the TabStrip and the Toolbar. |
| 40 static const int kToolbarTabStripVerticalOverlap; | 41 static const int kToolbarTabStripVerticalOverlap; |
| 41 | 42 |
| 42 BrowserViewLayout(); | 43 BrowserViewLayout(); |
| 43 virtual ~BrowserViewLayout(); | 44 virtual ~BrowserViewLayout(); |
| 44 | 45 |
| 45 // Sets all the views to be managed. Tests may inject stubs or NULL. | 46 // Sets all the views to be managed. Takes ownership of |delegate|. |
| 46 void Init(Browser* browser, | 47 // |browser_view| may be NULL in tests. |
| 48 void Init(BrowserViewLayoutDelegate* delegate, |
| 49 Browser* browser, |
| 47 BrowserView* browser_view, | 50 BrowserView* browser_view, |
| 51 views::View* top_container, |
| 52 TabStrip* tab_strip, |
| 53 views::View* toolbar, |
| 48 InfoBarContainerView* infobar_container, | 54 InfoBarContainerView* infobar_container, |
| 49 views::SingleSplitView* contents_split, | 55 views::View* contents_split, |
| 50 ContentsContainer* contents_container, | 56 ContentsContainer* contents_container, |
| 51 OverlayContainer* overlay_container); | 57 OverlayContainer* overlay_container, |
| 58 ImmersiveModeController* immersive_mode_controller); |
| 52 | 59 |
| 53 // Sets or updates views that are not available when |this| is initialized. | 60 // Sets or updates views that are not available when |this| is initialized. |
| 61 void set_window_switcher_button(views::View* button) { |
| 62 window_switcher_button_ = button; |
| 63 } |
| 64 void set_tab_strip(TabStrip* tab_strip) { |
| 65 tab_strip_ = tab_strip; |
| 66 } |
| 54 void set_bookmark_bar(BookmarkBarView* bookmark_bar) { | 67 void set_bookmark_bar(BookmarkBarView* bookmark_bar) { |
| 55 bookmark_bar_ = bookmark_bar; | 68 bookmark_bar_ = bookmark_bar; |
| 56 } | 69 } |
| 57 void set_download_shelf(DownloadShelfView* download_shelf) { | 70 void set_download_shelf(views::View* download_shelf) { |
| 58 download_shelf_ = download_shelf; | 71 download_shelf_ = download_shelf; |
| 59 } | 72 } |
| 60 | 73 |
| 61 WebContentsModalDialogHost* GetWebContentsModalDialogHost(); | 74 WebContentsModalDialogHost* GetWebContentsModalDialogHost(); |
| 62 | 75 |
| 63 // Returns the minimum size of the browser view. | 76 // Returns the minimum size of the browser view. |
| 64 gfx::Size GetMinimumSize(); | 77 gfx::Size GetMinimumSize(); |
| 65 | 78 |
| 66 // Returns the bounding box, in widget coordinates, for the find bar. | 79 // Returns the bounding box, in widget coordinates, for the find bar. |
| 67 gfx::Rect GetFindBarBoundingBox() const; | 80 gfx::Rect GetFindBarBoundingBox() const; |
| 68 | 81 |
| 69 // Returns true if the specified point(BrowserView coordinates) is in | 82 // Returns true if the specified point(BrowserView coordinates) is in |
| 70 // in the window caption area of the browser window. | 83 // in the window caption area of the browser window. |
| 71 bool IsPositionInWindowCaption(const gfx::Point& point); | 84 bool IsPositionInWindowCaption(const gfx::Point& point); |
| 72 | 85 |
| 73 // Tests to see if the specified |point| (in nonclient view's coordinates) | 86 // Tests to see if the specified |point| (in nonclient view's coordinates) |
| 74 // is within the views managed by the laymanager. Returns one of | 87 // is within the views managed by the laymanager. Returns one of |
| 75 // HitTestCompat enum defined in ui/base/hit_test.h. | 88 // HitTestCompat enum defined in ui/base/hit_test.h. |
| 76 // See also ClientView::NonClientHitTest. | 89 // See also ClientView::NonClientHitTest. |
| 77 int NonClientHitTest(const gfx::Point& point); | 90 int NonClientHitTest(const gfx::Point& point); |
| 78 | 91 |
| 79 // views::LayoutManager overrides: | 92 // views::LayoutManager overrides: |
| 80 virtual void Layout(views::View* host) OVERRIDE; | 93 virtual void Layout(views::View* host) OVERRIDE; |
| 81 virtual gfx::Size GetPreferredSize(views::View* host) OVERRIDE; | 94 virtual gfx::Size GetPreferredSize(views::View* host) OVERRIDE; |
| 82 | 95 |
| 83 private: | 96 private: |
| 84 FRIEND_TEST_ALL_PREFIXES(BrowserViewLayoutTest, BrowserViewLayout); | 97 FRIEND_TEST_ALL_PREFIXES(BrowserViewLayoutTest, BrowserViewLayout); |
| 85 FRIEND_TEST_ALL_PREFIXES(BrowserViewLayoutTest, Layout); | 98 FRIEND_TEST_ALL_PREFIXES(BrowserViewLayoutTest, Layout); |
| 99 FRIEND_TEST_ALL_PREFIXES(BrowserViewLayoutTest, LayoutDownloadShelf); |
| 86 class WebContentsModalDialogHostViews; | 100 class WebContentsModalDialogHostViews; |
| 87 | 101 |
| 88 enum InstantUIState { | 102 enum InstantUIState { |
| 89 // No instant suggestions are being shown. | 103 // No instant suggestions are being shown. |
| 90 kInstantUINone, | 104 kInstantUINone, |
| 91 // Instant suggestions are displayed in a overlay overlapping the tab | 105 // Instant suggestions are displayed in a overlay overlapping the tab |
| 92 // contents. | 106 // contents. |
| 93 kInstantUIOverlay, | 107 kInstantUIOverlay, |
| 94 // Instant suggestions are displayed in the main tab contents. | 108 // Instant suggestions are displayed in the main tab contents. |
| 95 kInstantUIFullPageResults, | 109 kInstantUIFullPageResults, |
| 96 }; | 110 }; |
| 97 | 111 |
| 98 Browser* browser() { return browser_; } | 112 Browser* browser() { return browser_; } |
| 99 | 113 |
| 100 // Layout the tab strip region, returns the coordinate of the bottom of the | 114 // Layout the tab strip region, returns the coordinate of the bottom of the |
| 101 // TabStrip, for laying out subsequent controls. | 115 // TabStrip, for laying out subsequent controls. |
| 102 int LayoutTabStripRegion(); | 116 int LayoutTabStripRegion(views::View* browser_view); |
| 103 | 117 |
| 104 // Layout the following controls, starting at |top|, returns the coordinate | 118 // Layout the following controls, starting at |top|, returns the coordinate |
| 105 // of the bottom of the control, for laying out the next control. | 119 // of the bottom of the control, for laying out the next control. |
| 106 int LayoutToolbar(int top); | 120 int LayoutToolbar(int top); |
| 107 int LayoutBookmarkAndInfoBars(int top); | 121 int LayoutBookmarkAndInfoBars(int top); |
| 108 int LayoutBookmarkBar(int top); | 122 int LayoutBookmarkBar(int top); |
| 109 int LayoutInfoBar(int top); | 123 int LayoutInfoBar(int top); |
| 110 | 124 |
| 111 // Layout the |contents_split_| view between the coordinates |top| and | 125 // Layout the |contents_split_| view between the coordinates |top| and |
| 112 // |bottom|. See browser_view.h for details of the relationship between | 126 // |bottom|. See browser_view.h for details of the relationship between |
| (...skipping 20 matching lines...) Expand all Loading... |
| 133 // Returns the state of instant extended suggestions. | 147 // Returns the state of instant extended suggestions. |
| 134 InstantUIState GetInstantUIState(); | 148 InstantUIState GetInstantUIState(); |
| 135 | 149 |
| 136 // Layout the Download Shelf, returns the coordinate of the top of the | 150 // Layout the Download Shelf, returns the coordinate of the top of the |
| 137 // control, for laying out the previous control. | 151 // control, for laying out the previous control. |
| 138 int LayoutDownloadShelf(int bottom); | 152 int LayoutDownloadShelf(int bottom); |
| 139 | 153 |
| 140 // Returns true if an infobar is showing. | 154 // Returns true if an infobar is showing. |
| 141 bool InfobarVisible() const; | 155 bool InfobarVisible() const; |
| 142 | 156 |
| 157 // The delegate interface. May be a mock in tests. |
| 158 scoped_ptr<BrowserViewLayoutDelegate> delegate_; |
| 159 |
| 143 // The browser from the owning BrowserView. | 160 // The browser from the owning BrowserView. |
| 144 Browser* browser_; | 161 Browser* browser_; |
| 145 | 162 |
| 146 // The owning BrowserView. May be NULL in tests. | 163 // The owning BrowserView. May be NULL in tests. |
| 164 // TODO(jamescook): Remove this, use the views::View passed in to Layout(). |
| 147 BrowserView* browser_view_; | 165 BrowserView* browser_view_; |
| 148 | 166 |
| 149 // Child views that the layout manager manages. | 167 // Child views that the layout manager manages. |
| 168 // NOTE: If you add a view, try to add it as a views::View, which makes |
| 169 // testing much easier. |
| 170 views::View* top_container_; |
| 171 TabStrip* tab_strip_; |
| 172 views::View* toolbar_; |
| 150 BookmarkBarView* bookmark_bar_; | 173 BookmarkBarView* bookmark_bar_; |
| 151 InfoBarContainerView* infobar_container_; | 174 InfoBarContainerView* infobar_container_; |
| 152 views::SingleSplitView* contents_split_; | 175 views::View* contents_split_; |
| 153 ContentsContainer* contents_container_; | 176 ContentsContainer* contents_container_; |
| 154 OverlayContainer* overlay_container_; | 177 OverlayContainer* overlay_container_; |
| 155 DownloadShelfView* download_shelf_; | 178 views::View* window_switcher_button_; |
| 179 views::View* download_shelf_; |
| 180 |
| 181 ImmersiveModeController* immersive_mode_controller_; |
| 156 | 182 |
| 157 // The bounds within which the vertically-stacked contents of the BrowserView | 183 // The bounds within which the vertically-stacked contents of the BrowserView |
| 158 // should be laid out within. This is just the local bounds of the | 184 // should be laid out within. This is just the local bounds of the |
| 159 // BrowserView. | 185 // BrowserView. |
| 160 // TODO(jamescook): Remove this and just use browser_view_->GetLocalBounds(). | 186 // TODO(jamescook): Remove this and just use browser_view_->GetLocalBounds(). |
| 161 gfx::Rect vertical_layout_rect_; | 187 gfx::Rect vertical_layout_rect_; |
| 162 | 188 |
| 163 // The host for use in positioning the web contents modal dialog. | 189 // The host for use in positioning the web contents modal dialog. |
| 164 scoped_ptr<WebContentsModalDialogHostViews> dialog_host_; | 190 scoped_ptr<WebContentsModalDialogHostViews> dialog_host_; |
| 165 | 191 |
| 166 // The distance the web contents modal dialog is from the top of the window, | 192 // The distance the web contents modal dialog is from the top of the window, |
| 167 // in pixels. | 193 // in pixels. |
| 168 int web_contents_modal_dialog_top_y_; | 194 int web_contents_modal_dialog_top_y_; |
| 169 | 195 |
| 170 DISALLOW_COPY_AND_ASSIGN(BrowserViewLayout); | 196 DISALLOW_COPY_AND_ASSIGN(BrowserViewLayout); |
| 171 }; | 197 }; |
| 172 | 198 |
| 173 #endif // CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_VIEW_LAYOUT_H_ | 199 #endif // CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_VIEW_LAYOUT_H_ |
| OLD | NEW |