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. 4 5#include "chrome/test/base/test_browser_window.h" 6 7#include "chrome/browser/ui/browser_list.h" 8#include "chrome/browser/ui/browser_list_observer.h" 9#include "ui/gfx/rect.h" 10 11 12// Helpers -------------------------------------------------------------------- 13 14namespace chrome { 15 16namespace { 17 18// Handles destroying a TestBrowserWindow when the Browser it is attached to is 19// destroyed. 20class TestBrowserWindowOwner : public chrome::BrowserListObserver { 21 public: 22 explicit TestBrowserWindowOwner(TestBrowserWindow* window) : window_(window) { 23 BrowserList::AddObserver(this); 24 } 25 virtual ~TestBrowserWindowOwner() { 26 BrowserList::RemoveObserver(this); 27 } 28 29 private: 30 // Overridden from BrowserListObserver: 31 virtual void OnBrowserRemoved(Browser* browser) OVERRIDE { 32 if (browser->window() == window_.get()) 33 delete this; 34 } 35 36 scoped_ptr<TestBrowserWindow> window_; 37 38 DISALLOW_COPY_AND_ASSIGN(TestBrowserWindowOwner); 39}; 40 41} // namespace 42 43Browser* CreateBrowserWithTestWindowForParams(Browser::CreateParams* params) { 44 TestBrowserWindow* window = new TestBrowserWindow; 45 new TestBrowserWindowOwner(window); 46 params->window = window; 47 return new Browser(*params); 48} 49 50} // namespace chrome 51 52 53// TestBrowserWindow::TestLocationBar ----------------------------------------- 54 55GURL TestBrowserWindow::TestLocationBar::GetDestinationURL() const { 56 return GURL(); 57} 58 59WindowOpenDisposition 60 TestBrowserWindow::TestLocationBar::GetWindowOpenDisposition() const { 61 return CURRENT_TAB; 62} 63 64ui::PageTransition 65 TestBrowserWindow::TestLocationBar::GetPageTransition() const { 66 return ui::PAGE_TRANSITION_LINK; 67} 68 69bool TestBrowserWindow::TestLocationBar::ShowPageActionPopup( 70 const extensions::Extension* extension, bool grant_active_tab) { 71 return false; 72} 73 74const OmniboxView* TestBrowserWindow::TestLocationBar::GetOmniboxView() const { 75 return NULL; 76} 77 78OmniboxView* TestBrowserWindow::TestLocationBar::GetOmniboxView() { 79 return NULL; 80} 81 82LocationBarTesting* 83 TestBrowserWindow::TestLocationBar::GetLocationBarForTesting() { 84 return NULL; 85} 86 87 88// TestBrowserWindow ---------------------------------------------------------- 89 90TestBrowserWindow::TestBrowserWindow() {} 91 92TestBrowserWindow::~TestBrowserWindow() {} 93 94bool TestBrowserWindow::IsActive() const { 95 return false; 96} 97 98bool TestBrowserWindow::IsAlwaysOnTop() const { 99 return false; 100} 101 102gfx::NativeWindow TestBrowserWindow::GetNativeWindow() { 103 return NULL; 104} 105 106BrowserWindowTesting* TestBrowserWindow::GetBrowserWindowTesting() { 107 return NULL; 108} 109 110StatusBubble* TestBrowserWindow::GetStatusBubble() { 111 return NULL; 112} 113 114gfx::Rect TestBrowserWindow::GetRestoredBounds() const { 115 return gfx::Rect(); 116} 117 118ui::WindowShowState TestBrowserWindow::GetRestoredState() const { 119 return ui::SHOW_STATE_DEFAULT; 120} 121 122gfx::Rect TestBrowserWindow::GetBounds() const { 123 return gfx::Rect(); 124} 125 126bool TestBrowserWindow::IsMaximized() const { 127 return false; 128} 129 130bool TestBrowserWindow::IsMinimized() const { 131 return false; 132} 133 134bool TestBrowserWindow::ShouldHideUIForFullscreen() const { 135 return false; 136} 137 138bool TestBrowserWindow::IsFullscreen() const { 139 return false; 140} 141 142#if defined(OS_WIN) 143bool TestBrowserWindow::IsInMetroSnapMode() const { 144 return false; 145} 146#endif 147 148bool TestBrowserWindow::IsFullscreenBubbleVisible() const { 149 return false; 150} 151 152LocationBar* TestBrowserWindow::GetLocationBar() const { 153 return const_cast<TestLocationBar*>(&location_bar_); 154} 155 156bool TestBrowserWindow::PreHandleKeyboardEvent( 157 const content::NativeWebKeyboardEvent& event, 158 bool* is_keyboard_shortcut) { 159 return false; 160} 161 162bool TestBrowserWindow::IsBookmarkBarVisible() const { 163 return false; 164} 165 166bool TestBrowserWindow::IsBookmarkBarAnimating() const { 167 return false; 168} 169 170bool TestBrowserWindow::IsTabStripEditable() const { 171 return false; 172} 173 174bool TestBrowserWindow::IsToolbarVisible() const { 175 return false; 176} 177 178gfx::Rect TestBrowserWindow::GetRootWindowResizerRect() const { 179 return gfx::Rect(); 180} 181 182bool TestBrowserWindow::IsDownloadShelfVisible() const { 183 return false; 184} 185 186DownloadShelf* TestBrowserWindow::GetDownloadShelf() { 187 return &download_shelf_; 188} 189 190int TestBrowserWindow::GetExtraRenderViewHeight() const { 191 return 0; 192} 193 194#if defined(OS_MACOSX) 195bool TestBrowserWindow::IsFullscreenWithChrome() { 196 return false; 197} 198 199bool TestBrowserWindow::IsFullscreenWithoutChrome() { 200 return false; 201} 202#endif 203 204WindowOpenDisposition TestBrowserWindow::GetDispositionForPopupBounds( 205 const gfx::Rect& bounds) { 206 return NEW_POPUP; 207} 208 209FindBar* TestBrowserWindow::CreateFindBar() { 210 return NULL; 211} 212 213web_modal::WebContentsModalDialogHost* 214 TestBrowserWindow::GetWebContentsModalDialogHost() { 215 return NULL; 216} 217 218int 219TestBrowserWindow::GetRenderViewHeightInsetWithDetachedBookmarkBar() { 220 return 0; 221} 222 223void TestBrowserWindow::ExecuteExtensionCommand( 224 const extensions::Extension* extension, 225 const extensions::Command& command) {} 226