Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(78)

Side by Side Diff: chrome/browser/ui/views/frame/browser_view_layout.h

Issue 14348011: Add a unit test for BrowserViewLayout (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
11 #include "ui/gfx/rect.h" 12 #include "ui/gfx/rect.h"
12 #include "ui/views/layout/layout_manager.h" 13 #include "ui/views/layout/layout_manager.h"
13 14
14 class BookmarkBarView; 15 class BookmarkBarView;
15 class Browser; 16 class Browser;
16 class BrowserView; 17 class BrowserView;
17 class ContentsContainer; 18 class ContentsContainer;
18 class DownloadShelfView; 19 class DownloadShelfView;
19 class TabContentsContainer; 20 class TabContentsContainer;
20 class TabStrip; 21 class TabStrip;
21 class ToolbarView; 22 class ToolbarView;
22 class WebContentsModalDialogHost; 23 class WebContentsModalDialogHost;
23 24
24 namespace gfx { 25 namespace gfx {
25 class Point; 26 class Point;
26 class Size; 27 class Size;
27 } 28 }
28 29
29 namespace views { 30 namespace views {
30 class SingleSplitView; 31 class SingleSplitView;
31 } 32 }
32 33
33 // The layout manager used in chrome browser. 34 // The layout manager used in chrome browser.
34 class BrowserViewLayout : public views::LayoutManager { 35 class BrowserViewLayout : public views::LayoutManager {
35 public: 36 public:
36 // The vertical overlap between the TabStrip and the Toolbar. 37 // The vertical overlap between the TabStrip and the Toolbar.
37 static const int kToolbarTabStripVerticalOverlap; 38 static const int kToolbarTabStripVerticalOverlap;
38 39
39 BrowserViewLayout(); 40 explicit BrowserViewLayout(Browser* browser);
40 virtual ~BrowserViewLayout(); 41 virtual ~BrowserViewLayout();
41 42
42 WebContentsModalDialogHost* GetWebContentsModalDialogHost(); 43 WebContentsModalDialogHost* GetWebContentsModalDialogHost();
43 44
44 // Returns the minimum size of the browser view. 45 // Returns the minimum size of the browser view.
45 gfx::Size GetMinimumSize(); 46 gfx::Size GetMinimumSize();
46 47
47 // Returns the bounding box for the find bar. 48 // Returns the bounding box for the find bar.
48 gfx::Rect GetFindBarBoundingBox() const; 49 gfx::Rect GetFindBarBoundingBox() const;
49 50
50 // Returns true if the specified point(BrowserView coordinates) is in 51 // Returns true if the specified point(BrowserView coordinates) is in
51 // in the window caption area of the browser window. 52 // in the window caption area of the browser window.
52 bool IsPositionInWindowCaption(const gfx::Point& point); 53 bool IsPositionInWindowCaption(const gfx::Point& point);
53 54
54 // Tests to see if the specified |point| (in nonclient view's coordinates) 55 // Tests to see if the specified |point| (in nonclient view's coordinates)
55 // is within the views managed by the laymanager. Returns one of 56 // is within the views managed by the laymanager. Returns one of
56 // HitTestCompat enum defined in ui/base/hit_test.h. 57 // HitTestCompat enum defined in ui/base/hit_test.h.
57 // See also ClientView::NonClientHitTest. 58 // See also ClientView::NonClientHitTest.
58 int NonClientHitTest(const gfx::Point& point); 59 int NonClientHitTest(const gfx::Point& point);
59 60
60 // views::LayoutManager overrides: 61 // views::LayoutManager overrides:
61 virtual void Installed(views::View* host) OVERRIDE; 62 virtual void Installed(views::View* host) OVERRIDE;
62 virtual void Uninstalled(views::View* host) OVERRIDE; 63 virtual void Uninstalled(views::View* host) OVERRIDE;
63 virtual void ViewAdded(views::View* host, views::View* view) OVERRIDE; 64 virtual void ViewAdded(views::View* host, views::View* view) OVERRIDE;
64 virtual void Layout(views::View* host) OVERRIDE; 65 virtual void Layout(views::View* host) OVERRIDE;
65 virtual gfx::Size GetPreferredSize(views::View* host) OVERRIDE; 66 virtual gfx::Size GetPreferredSize(views::View* host) OVERRIDE;
66 67
67 private: 68 private:
69 FRIEND_TEST_ALL_PREFIXES(BrowserViewLayoutTest, BrowserViewLayout);
70 FRIEND_TEST_ALL_PREFIXES(BrowserViewLayoutTest, Layout);
68 class WebContentsModalDialogHostViews; 71 class WebContentsModalDialogHostViews;
69 72
70 enum InstantUIState { 73 enum InstantUIState {
71 // No instant suggestions are being shown. 74 // No instant suggestions are being shown.
72 kInstantUINone, 75 kInstantUINone,
73 // Instant suggestions are displayed in a overlay overlapping the tab 76 // Instant suggestions are displayed in a overlay overlapping the tab
74 // contents. 77 // contents.
75 kInstantUIOverlay, 78 kInstantUIOverlay,
76 // Instant suggestions are displayed in the main tab contents. 79 // Instant suggestions are displayed in the main tab contents.
77 kInstantUIFullPageResults, 80 kInstantUIFullPageResults,
78 }; 81 };
79 82
80 Browser* browser(); 83 Browser* browser() { return browser_; }
81 const Browser* browser() const;
82 84
83 // Layout the tab strip region, returns the coordinate of the bottom of the 85 // Layout the tab strip region, returns the coordinate of the bottom of the
84 // TabStrip, for laying out subsequent controls. 86 // TabStrip, for laying out subsequent controls.
85 int LayoutTabStripRegion(); 87 int LayoutTabStripRegion();
86 88
87 // Layout the following controls, starting at |top|, returns the coordinate 89 // Layout the following controls, starting at |top|, returns the coordinate
88 // of the bottom of the control, for laying out the next control. 90 // of the bottom of the control, for laying out the next control.
89 int LayoutToolbar(int top); 91 int LayoutToolbar(int top);
90 int LayoutBookmarkAndInfoBars(int top); 92 int LayoutBookmarkAndInfoBars(int top);
91 int LayoutBookmarkBar(int top); 93 int LayoutBookmarkBar(int top);
(...skipping 26 matching lines...) Expand all
118 // Returns the state of instant extended suggestions. 120 // Returns the state of instant extended suggestions.
119 InstantUIState GetInstantUIState(); 121 InstantUIState GetInstantUIState();
120 122
121 // Layout the Download Shelf, returns the coordinate of the top of the 123 // Layout the Download Shelf, returns the coordinate of the top of the
122 // control, for laying out the previous control. 124 // control, for laying out the previous control.
123 int LayoutDownloadShelf(int bottom); 125 int LayoutDownloadShelf(int bottom);
124 126
125 // Returns true if an infobar is showing. 127 // Returns true if an infobar is showing.
126 bool InfobarVisible() const; 128 bool InfobarVisible() const;
127 129
130 // The browser from the owning BrowserView.
131 Browser* browser_;
132
128 // Child views that the layout manager manages. 133 // Child views that the layout manager manages.
129 views::SingleSplitView* contents_split_; 134 views::SingleSplitView* contents_split_;
130 ContentsContainer* contents_container_; 135 ContentsContainer* contents_container_;
131 DownloadShelfView* download_shelf_; 136 DownloadShelfView* download_shelf_;
132 137
133 BrowserView* browser_view_; 138 BrowserView* browser_view_;
134 139
135 // The bounds within which the vertically-stacked contents of the BrowserView 140 // The bounds within which the vertically-stacked contents of the BrowserView
136 // should be laid out within. This is just the local bounds of the 141 // should be laid out within. This is just the local bounds of the
137 // BrowserView. 142 // BrowserView.
138 // TODO(jamescook): Remove this and just use browser_view_->GetLocalBounds(). 143 // TODO(jamescook): Remove this and just use browser_view_->GetLocalBounds().
139 gfx::Rect vertical_layout_rect_; 144 gfx::Rect vertical_layout_rect_;
140 145
141 // The distance the FindBar is from the top of the window, in pixels. 146 // The distance the FindBar is from the top of the window, in pixels.
142 int find_bar_y_; 147 int find_bar_y_;
143 148
144 // The host for use in positioning the web contents modal dialog. 149 // The host for use in positioning the web contents modal dialog.
145 scoped_ptr<WebContentsModalDialogHostViews> dialog_host_; 150 scoped_ptr<WebContentsModalDialogHostViews> dialog_host_;
146 151
147 // The distance the web contents modal dialog is from the top of the window, 152 // The distance the web contents modal dialog is from the top of the window,
148 // in pixels. 153 // in pixels.
149 int web_contents_modal_dialog_top_y_; 154 int web_contents_modal_dialog_top_y_;
150 155
151 DISALLOW_COPY_AND_ASSIGN(BrowserViewLayout); 156 DISALLOW_COPY_AND_ASSIGN(BrowserViewLayout);
152 }; 157 };
153 158
154 #endif // CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_VIEW_LAYOUT_H_ 159 #endif // CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_VIEW_LAYOUT_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/frame/browser_view.cc ('k') | chrome/browser/ui/views/frame/browser_view_layout.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698