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 bool TestBrowserWindow::PreHandleKeyboardEvent(
138 const content::NativeWebKeyboardEvent
& event
,
139 bool* is_keyboard_shortcut
) {
143 bool TestBrowserWindow::IsBookmarkBarVisible() const {
147 bool TestBrowserWindow::IsBookmarkBarAnimating() const {
151 bool TestBrowserWindow::IsTabStripEditable() const {
155 bool TestBrowserWindow::IsToolbarVisible() const {
159 gfx::Rect
TestBrowserWindow::GetRootWindowResizerRect() const {
163 bool TestBrowserWindow::ShowSessionCrashedBubble() {
167 bool TestBrowserWindow::IsProfileResetBubbleSupported() const {
171 GlobalErrorBubbleViewBase
* TestBrowserWindow::ShowProfileResetBubble(
172 const base::WeakPtr
<ProfileResetGlobalError
>& global_error
) {
176 bool TestBrowserWindow::IsDownloadShelfVisible() const {
180 DownloadShelf
* TestBrowserWindow::GetDownloadShelf() {
181 return &download_shelf_
;
184 WindowOpenDisposition
TestBrowserWindow::GetDispositionForPopupBounds(
185 const gfx::Rect
& bounds
) {
189 FindBar
* TestBrowserWindow::CreateFindBar() {
193 web_modal::WebContentsModalDialogHost
*
194 TestBrowserWindow::GetWebContentsModalDialogHost() {
198 int TestBrowserWindow::GetRenderViewHeightInsetWithDetachedBookmarkBar() {
202 void TestBrowserWindow::ExecuteExtensionCommand(
203 const extensions::Extension
* extension
,
204 const extensions::Command
& command
) {}
206 ExclusiveAccessContext
* TestBrowserWindow::GetExclusiveAccessContext() {
210 // TestBrowserWindowOwner -----------------------------------------------------
212 TestBrowserWindowOwner::TestBrowserWindowOwner(TestBrowserWindow
* window
)
214 BrowserList::AddObserver(this);
217 TestBrowserWindowOwner::~TestBrowserWindowOwner() {
218 BrowserList::RemoveObserver(this);
221 void TestBrowserWindowOwner::OnBrowserRemoved(Browser
* browser
) {
222 if (browser
->window() == window_
.get())