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
3 // found in the LICENSE file.
5 #include "chrome/test/base/test_browser_window.h"
7 #include "chrome/browser/ui/browser_list.h"
8 #include "chrome/browser/ui/browser_list_observer.h"
9 #include "ui/gfx/geometry/rect.h"
12 // Helpers --------------------------------------------------------------------
18 // Handles destroying a TestBrowserWindow when the Browser it is attached to is
20 class TestBrowserWindowOwner
: public chrome::BrowserListObserver
{
22 explicit TestBrowserWindowOwner(TestBrowserWindow
* window
) : window_(window
) {
23 BrowserList::AddObserver(this);
25 ~TestBrowserWindowOwner() override
{ BrowserList::RemoveObserver(this); }
28 // Overridden from BrowserListObserver:
29 void OnBrowserRemoved(Browser
* browser
) override
{
30 if (browser
->window() == window_
.get())
34 scoped_ptr
<TestBrowserWindow
> window_
;
36 DISALLOW_COPY_AND_ASSIGN(TestBrowserWindowOwner
);
41 Browser
* CreateBrowserWithTestWindowForParams(Browser::CreateParams
* params
) {
42 TestBrowserWindow
* window
= new TestBrowserWindow
;
43 new TestBrowserWindowOwner(window
);
44 params
->window
= window
;
45 return new Browser(*params
);
51 // TestBrowserWindow::TestLocationBar -----------------------------------------
53 GURL
TestBrowserWindow::TestLocationBar::GetDestinationURL() const {
58 TestBrowserWindow::TestLocationBar::GetWindowOpenDisposition() const {
63 TestBrowserWindow::TestLocationBar::GetPageTransition() const {
64 return ui::PAGE_TRANSITION_LINK
;
67 bool TestBrowserWindow::TestLocationBar::ShowPageActionPopup(
68 const extensions::Extension
* extension
, bool grant_active_tab
) {
72 const OmniboxView
* TestBrowserWindow::TestLocationBar::GetOmniboxView() const {
76 OmniboxView
* TestBrowserWindow::TestLocationBar::GetOmniboxView() {
81 TestBrowserWindow::TestLocationBar::GetLocationBarForTesting() {
86 // TestBrowserWindow ----------------------------------------------------------
88 TestBrowserWindow::TestBrowserWindow() {}
90 TestBrowserWindow::~TestBrowserWindow() {}
92 bool TestBrowserWindow::IsActive() const {
96 bool TestBrowserWindow::IsAlwaysOnTop() const {
100 gfx::NativeWindow
TestBrowserWindow::GetNativeWindow() const {
104 StatusBubble
* TestBrowserWindow::GetStatusBubble() {
108 gfx::Rect
TestBrowserWindow::GetRestoredBounds() const {
112 ui::WindowShowState
TestBrowserWindow::GetRestoredState() const {
113 return ui::SHOW_STATE_DEFAULT
;
116 gfx::Rect
TestBrowserWindow::GetBounds() const {
120 bool TestBrowserWindow::IsMaximized() const {
124 bool TestBrowserWindow::IsMinimized() const {
128 bool TestBrowserWindow::ShouldHideUIForFullscreen() const {
132 bool TestBrowserWindow::IsFullscreen() const {
136 bool TestBrowserWindow::IsFullscreenBubbleVisible() const {
140 bool TestBrowserWindow::SupportsFullscreenWithToolbar() const {
144 void TestBrowserWindow::UpdateFullscreenWithToolbar(bool with_toolbar
) {
147 bool TestBrowserWindow::IsFullscreenWithToolbar() const {
152 bool TestBrowserWindow::IsInMetroSnapMode() const {
157 LocationBar
* TestBrowserWindow::GetLocationBar() const {
158 return const_cast<TestLocationBar
*>(&location_bar_
);
161 bool TestBrowserWindow::PreHandleKeyboardEvent(
162 const content::NativeWebKeyboardEvent
& event
,
163 bool* is_keyboard_shortcut
) {
167 bool TestBrowserWindow::IsBookmarkBarVisible() const {
171 bool TestBrowserWindow::IsBookmarkBarAnimating() const {
175 bool TestBrowserWindow::IsTabStripEditable() const {
179 bool TestBrowserWindow::IsToolbarVisible() const {
183 gfx::Rect
TestBrowserWindow::GetRootWindowResizerRect() const {
187 bool TestBrowserWindow::ShowSessionCrashedBubble() {
191 bool TestBrowserWindow::IsProfileResetBubbleSupported() const {
195 GlobalErrorBubbleViewBase
* TestBrowserWindow::ShowProfileResetBubble(
196 const base::WeakPtr
<ProfileResetGlobalError
>& global_error
) {
200 bool TestBrowserWindow::IsDownloadShelfVisible() const {
204 DownloadShelf
* TestBrowserWindow::GetDownloadShelf() {
205 return &download_shelf_
;
208 int TestBrowserWindow::GetExtraRenderViewHeight() const {
212 WindowOpenDisposition
TestBrowserWindow::GetDispositionForPopupBounds(
213 const gfx::Rect
& bounds
) {
217 FindBar
* TestBrowserWindow::CreateFindBar() {
221 web_modal::WebContentsModalDialogHost
*
222 TestBrowserWindow::GetWebContentsModalDialogHost() {
227 TestBrowserWindow::GetRenderViewHeightInsetWithDetachedBookmarkBar() {
231 void TestBrowserWindow::ExecuteExtensionCommand(
232 const extensions::Extension
* extension
,
233 const extensions::Command
& command
) {}