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 --------------------------------------------------------------------
16 scoped_ptr
<Browser
> CreateBrowserWithTestWindowForParams(
17 Browser::CreateParams
* params
) {
18 TestBrowserWindow
* window
= new TestBrowserWindow
;
19 new TestBrowserWindowOwner(window
);
20 params
->window
= window
;
21 return make_scoped_ptr(new Browser(*params
));
27 // TestBrowserWindow::TestLocationBar -----------------------------------------
29 GURL
TestBrowserWindow::TestLocationBar::GetDestinationURL() const {
34 TestBrowserWindow::TestLocationBar::GetWindowOpenDisposition() const {
39 TestBrowserWindow::TestLocationBar::GetPageTransition() const {
40 return ui::PAGE_TRANSITION_LINK
;
43 bool TestBrowserWindow::TestLocationBar::ShowPageActionPopup(
44 const extensions::Extension
* extension
, bool grant_active_tab
) {
48 const OmniboxView
* TestBrowserWindow::TestLocationBar::GetOmniboxView() const {
52 OmniboxView
* TestBrowserWindow::TestLocationBar::GetOmniboxView() {
57 TestBrowserWindow::TestLocationBar::GetLocationBarForTesting() {
62 // TestBrowserWindow ----------------------------------------------------------
64 TestBrowserWindow::TestBrowserWindow() {}
66 TestBrowserWindow::~TestBrowserWindow() {}
68 bool TestBrowserWindow::IsActive() const {
72 bool TestBrowserWindow::IsAlwaysOnTop() const {
76 gfx::NativeWindow
TestBrowserWindow::GetNativeWindow() const {
80 StatusBubble
* TestBrowserWindow::GetStatusBubble() {
84 gfx::Rect
TestBrowserWindow::GetRestoredBounds() const {
88 ui::WindowShowState
TestBrowserWindow::GetRestoredState() const {
89 return ui::SHOW_STATE_DEFAULT
;
92 gfx::Rect
TestBrowserWindow::GetBounds() const {
96 bool TestBrowserWindow::IsMaximized() const {
100 bool TestBrowserWindow::IsMinimized() const {
104 bool TestBrowserWindow::ShouldHideUIForFullscreen() const {
108 bool TestBrowserWindow::IsFullscreen() const {
112 bool TestBrowserWindow::IsFullscreenBubbleVisible() const {
116 bool TestBrowserWindow::SupportsFullscreenWithToolbar() const {
120 void TestBrowserWindow::UpdateFullscreenWithToolbar(bool with_toolbar
) {
123 bool TestBrowserWindow::IsFullscreenWithToolbar() const {
128 bool TestBrowserWindow::IsInMetroSnapMode() const {
133 LocationBar
* TestBrowserWindow::GetLocationBar() const {
134 return const_cast<TestLocationBar
*>(&location_bar_
);
137 ToolbarActionsBar
* TestBrowserWindow::GetToolbarActionsBar() {
141 bool TestBrowserWindow::PreHandleKeyboardEvent(
142 const content::NativeWebKeyboardEvent
& event
,
143 bool* is_keyboard_shortcut
) {
147 bool TestBrowserWindow::IsBookmarkBarVisible() const {
151 bool TestBrowserWindow::IsBookmarkBarAnimating() const {
155 bool TestBrowserWindow::IsTabStripEditable() const {
159 bool TestBrowserWindow::IsToolbarVisible() const {
163 gfx::Rect
TestBrowserWindow::GetRootWindowResizerRect() const {
167 bool TestBrowserWindow::ShowSessionCrashedBubble() {
171 bool TestBrowserWindow::IsProfileResetBubbleSupported() const {
175 GlobalErrorBubbleViewBase
* TestBrowserWindow::ShowProfileResetBubble(
176 const base::WeakPtr
<ProfileResetGlobalError
>& global_error
) {
180 bool TestBrowserWindow::IsDownloadShelfVisible() const {
184 DownloadShelf
* TestBrowserWindow::GetDownloadShelf() {
185 return &download_shelf_
;
188 WindowOpenDisposition
TestBrowserWindow::GetDispositionForPopupBounds(
189 const gfx::Rect
& bounds
) {
193 FindBar
* TestBrowserWindow::CreateFindBar() {
197 web_modal::WebContentsModalDialogHost
*
198 TestBrowserWindow::GetWebContentsModalDialogHost() {
202 int TestBrowserWindow::GetRenderViewHeightInsetWithDetachedBookmarkBar() {
206 void TestBrowserWindow::ExecuteExtensionCommand(
207 const extensions::Extension
* extension
,
208 const extensions::Command
& command
) {}
210 ExclusiveAccessContext
* TestBrowserWindow::GetExclusiveAccessContext() {
214 // TestBrowserWindowOwner -----------------------------------------------------
216 TestBrowserWindowOwner::TestBrowserWindowOwner(TestBrowserWindow
* window
)
218 BrowserList::AddObserver(this);
221 TestBrowserWindowOwner::~TestBrowserWindowOwner() {
222 BrowserList::RemoveObserver(this);
225 void TestBrowserWindowOwner::OnBrowserRemoved(Browser
* browser
) {
226 if (browser
->window() == window_
.get())