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 virtual ~TestBrowserWindowOwner() {
26 BrowserList::RemoveObserver(this);
30 // Overridden from BrowserListObserver:
31 virtual void OnBrowserRemoved(Browser* browser) OVERRIDE {
32 if (browser->window() == window_.get())
36 scoped_ptr<TestBrowserWindow> window_;
38 DISALLOW_COPY_AND_ASSIGN(TestBrowserWindowOwner);
43 Browser* CreateBrowserWithTestWindowForParams(Browser::CreateParams* params) {
44 TestBrowserWindow* window = new TestBrowserWindow;
45 new TestBrowserWindowOwner(window);
46 params->window = window;
47 return new Browser(*params);
53 // TestBrowserWindow::TestLocationBar -----------------------------------------
55 GURL TestBrowserWindow::TestLocationBar::GetDestinationURL() const {
60 TestBrowserWindow::TestLocationBar::GetWindowOpenDisposition() const {
65 TestBrowserWindow::TestLocationBar::GetPageTransition() const {
66 return ui::PAGE_TRANSITION_LINK;
69 bool TestBrowserWindow::TestLocationBar::ShowPageActionPopup(
70 const extensions::Extension* extension, bool grant_active_tab) {
74 const OmniboxView* TestBrowserWindow::TestLocationBar::GetOmniboxView() const {
78 OmniboxView* TestBrowserWindow::TestLocationBar::GetOmniboxView() {
83 TestBrowserWindow::TestLocationBar::GetLocationBarForTesting() {
88 // TestBrowserWindow ----------------------------------------------------------
90 TestBrowserWindow::TestBrowserWindow() {}
92 TestBrowserWindow::~TestBrowserWindow() {}
94 bool TestBrowserWindow::IsActive() const {
98 bool TestBrowserWindow::IsAlwaysOnTop() const {
102 gfx::NativeWindow TestBrowserWindow::GetNativeWindow() {
106 BrowserWindowTesting* TestBrowserWindow::GetBrowserWindowTesting() {
110 StatusBubble* TestBrowserWindow::GetStatusBubble() {
114 gfx::Rect TestBrowserWindow::GetRestoredBounds() const {
118 ui::WindowShowState TestBrowserWindow::GetRestoredState() const {
119 return ui::SHOW_STATE_DEFAULT;
122 gfx::Rect TestBrowserWindow::GetBounds() const {
126 bool TestBrowserWindow::IsMaximized() const {
130 bool TestBrowserWindow::IsMinimized() const {
134 bool TestBrowserWindow::ShouldHideUIForFullscreen() const {
138 bool TestBrowserWindow::IsFullscreen() const {
143 bool TestBrowserWindow::IsInMetroSnapMode() const {
148 bool TestBrowserWindow::IsFullscreenBubbleVisible() const {
152 LocationBar* TestBrowserWindow::GetLocationBar() const {
153 return const_cast<TestLocationBar*>(&location_bar_);
156 bool TestBrowserWindow::PreHandleKeyboardEvent(
157 const content::NativeWebKeyboardEvent& event,
158 bool* is_keyboard_shortcut) {
162 bool TestBrowserWindow::IsBookmarkBarVisible() const {
166 bool TestBrowserWindow::IsBookmarkBarAnimating() const {
170 bool TestBrowserWindow::IsTabStripEditable() const {
174 bool TestBrowserWindow::IsToolbarVisible() const {
178 gfx::Rect TestBrowserWindow::GetRootWindowResizerRect() const {
182 bool TestBrowserWindow::IsDownloadShelfVisible() const {
186 DownloadShelf* TestBrowserWindow::GetDownloadShelf() {
187 return &download_shelf_;
190 int TestBrowserWindow::GetExtraRenderViewHeight() const {
194 #if defined(OS_MACOSX)
195 bool TestBrowserWindow::IsFullscreenWithChrome() {
199 bool TestBrowserWindow::IsFullscreenWithoutChrome() {
204 WindowOpenDisposition TestBrowserWindow::GetDispositionForPopupBounds(
205 const gfx::Rect& bounds) {
209 FindBar* TestBrowserWindow::CreateFindBar() {
213 web_modal::WebContentsModalDialogHost*
214 TestBrowserWindow::GetWebContentsModalDialogHost() {
219 TestBrowserWindow::GetRenderViewHeightInsetWithDetachedBookmarkBar() {
223 void TestBrowserWindow::ExecuteExtensionCommand(
224 const extensions::Extension* extension,
225 const extensions::Command& command) {}