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/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 BrowserWindowTesting
* TestBrowserWindow::GetBrowserWindowTesting() {
108 StatusBubble
* TestBrowserWindow::GetStatusBubble() {
112 gfx::Rect
TestBrowserWindow::GetRestoredBounds() const {
116 ui::WindowShowState
TestBrowserWindow::GetRestoredState() const {
117 return ui::SHOW_STATE_DEFAULT
;
120 gfx::Rect
TestBrowserWindow::GetBounds() const {
124 bool TestBrowserWindow::IsMaximized() const {
128 bool TestBrowserWindow::IsMinimized() const {
132 bool TestBrowserWindow::ShouldHideUIForFullscreen() const {
136 bool TestBrowserWindow::IsFullscreen() const {
141 bool TestBrowserWindow::IsInMetroSnapMode() const {
146 bool TestBrowserWindow::IsFullscreenBubbleVisible() const {
150 LocationBar
* TestBrowserWindow::GetLocationBar() const {
151 return const_cast<TestLocationBar
*>(&location_bar_
);
154 bool TestBrowserWindow::PreHandleKeyboardEvent(
155 const content::NativeWebKeyboardEvent
& event
,
156 bool* is_keyboard_shortcut
) {
160 bool TestBrowserWindow::IsBookmarkBarVisible() const {
164 bool TestBrowserWindow::IsBookmarkBarAnimating() const {
168 bool TestBrowserWindow::IsTabStripEditable() const {
172 bool TestBrowserWindow::IsToolbarVisible() const {
176 gfx::Rect
TestBrowserWindow::GetRootWindowResizerRect() const {
180 bool TestBrowserWindow::IsDownloadShelfVisible() const {
184 DownloadShelf
* TestBrowserWindow::GetDownloadShelf() {
185 return &download_shelf_
;
188 int TestBrowserWindow::GetExtraRenderViewHeight() const {
192 #if defined(OS_MACOSX)
193 bool TestBrowserWindow::IsFullscreenWithChrome() {
197 bool TestBrowserWindow::IsFullscreenWithoutChrome() {
202 WindowOpenDisposition
TestBrowserWindow::GetDispositionForPopupBounds(
203 const gfx::Rect
& bounds
) {
207 FindBar
* TestBrowserWindow::CreateFindBar() {
211 web_modal::WebContentsModalDialogHost
*
212 TestBrowserWindow::GetWebContentsModalDialogHost() {
217 TestBrowserWindow::GetRenderViewHeightInsetWithDetachedBookmarkBar() {
221 void TestBrowserWindow::ExecuteExtensionCommand(
222 const extensions::Extension
* extension
,
223 const extensions::Command
& command
) {}