• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
14 namespace chrome {
15 
16 namespace {
17 
18 // Handles destroying a TestBrowserWindow when the Browser it is attached to is
19 // destroyed.
20 class TestBrowserWindowOwner : public chrome::BrowserListObserver {
21  public:
TestBrowserWindowOwner(TestBrowserWindow * window)22   explicit TestBrowserWindowOwner(TestBrowserWindow* window) : window_(window) {
23     BrowserList::AddObserver(this);
24   }
~TestBrowserWindowOwner()25   virtual ~TestBrowserWindowOwner() {
26     BrowserList::RemoveObserver(this);
27   }
28 
29  private:
30   // Overridden from BrowserListObserver:
OnBrowserRemoved(Browser * browser)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 
CreateBrowserWithTestWindowForParams(Browser::CreateParams * params)43 Browser* 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 
GetDestinationURL() const55 GURL TestBrowserWindow::TestLocationBar::GetDestinationURL() const {
56   return GURL();
57 }
58 
59 WindowOpenDisposition
GetWindowOpenDisposition() const60     TestBrowserWindow::TestLocationBar::GetWindowOpenDisposition() const {
61   return CURRENT_TAB;
62 }
63 
64 ui::PageTransition
GetPageTransition() const65     TestBrowserWindow::TestLocationBar::GetPageTransition() const {
66   return ui::PAGE_TRANSITION_LINK;
67 }
68 
ShowPageActionPopup(const extensions::Extension * extension,bool grant_active_tab)69 bool TestBrowserWindow::TestLocationBar::ShowPageActionPopup(
70     const extensions::Extension* extension, bool grant_active_tab) {
71   return false;
72 }
73 
GetOmniboxView() const74 const OmniboxView* TestBrowserWindow::TestLocationBar::GetOmniboxView() const {
75   return NULL;
76 }
77 
GetOmniboxView()78 OmniboxView* TestBrowserWindow::TestLocationBar::GetOmniboxView() {
79   return NULL;
80 }
81 
82 LocationBarTesting*
GetLocationBarForTesting()83     TestBrowserWindow::TestLocationBar::GetLocationBarForTesting() {
84   return NULL;
85 }
86 
87 
88 // TestBrowserWindow ----------------------------------------------------------
89 
TestBrowserWindow()90 TestBrowserWindow::TestBrowserWindow() {}
91 
~TestBrowserWindow()92 TestBrowserWindow::~TestBrowserWindow() {}
93 
IsActive() const94 bool TestBrowserWindow::IsActive() const {
95   return false;
96 }
97 
IsAlwaysOnTop() const98 bool TestBrowserWindow::IsAlwaysOnTop() const {
99   return false;
100 }
101 
GetNativeWindow()102 gfx::NativeWindow TestBrowserWindow::GetNativeWindow() {
103   return NULL;
104 }
105 
GetBrowserWindowTesting()106 BrowserWindowTesting* TestBrowserWindow::GetBrowserWindowTesting() {
107   return NULL;
108 }
109 
GetStatusBubble()110 StatusBubble* TestBrowserWindow::GetStatusBubble() {
111   return NULL;
112 }
113 
GetRestoredBounds() const114 gfx::Rect TestBrowserWindow::GetRestoredBounds() const {
115   return gfx::Rect();
116 }
117 
GetRestoredState() const118 ui::WindowShowState TestBrowserWindow::GetRestoredState() const {
119   return ui::SHOW_STATE_DEFAULT;
120 }
121 
GetBounds() const122 gfx::Rect TestBrowserWindow::GetBounds() const {
123   return gfx::Rect();
124 }
125 
IsMaximized() const126 bool TestBrowserWindow::IsMaximized() const {
127   return false;
128 }
129 
IsMinimized() const130 bool TestBrowserWindow::IsMinimized() const {
131   return false;
132 }
133 
ShouldHideUIForFullscreen() const134 bool TestBrowserWindow::ShouldHideUIForFullscreen() const {
135   return false;
136 }
137 
IsFullscreen() const138 bool TestBrowserWindow::IsFullscreen() const {
139   return false;
140 }
141 
142 #if defined(OS_WIN)
IsInMetroSnapMode() const143 bool TestBrowserWindow::IsInMetroSnapMode() const {
144   return false;
145 }
146 #endif
147 
IsFullscreenBubbleVisible() const148 bool TestBrowserWindow::IsFullscreenBubbleVisible() const {
149   return false;
150 }
151 
GetLocationBar() const152 LocationBar* TestBrowserWindow::GetLocationBar() const {
153   return const_cast<TestLocationBar*>(&location_bar_);
154 }
155 
PreHandleKeyboardEvent(const content::NativeWebKeyboardEvent & event,bool * is_keyboard_shortcut)156 bool TestBrowserWindow::PreHandleKeyboardEvent(
157     const content::NativeWebKeyboardEvent& event,
158     bool* is_keyboard_shortcut) {
159   return false;
160 }
161 
IsBookmarkBarVisible() const162 bool TestBrowserWindow::IsBookmarkBarVisible() const {
163   return false;
164 }
165 
IsBookmarkBarAnimating() const166 bool TestBrowserWindow::IsBookmarkBarAnimating() const {
167   return false;
168 }
169 
IsTabStripEditable() const170 bool TestBrowserWindow::IsTabStripEditable() const {
171   return false;
172 }
173 
IsToolbarVisible() const174 bool TestBrowserWindow::IsToolbarVisible() const {
175   return false;
176 }
177 
GetRootWindowResizerRect() const178 gfx::Rect TestBrowserWindow::GetRootWindowResizerRect() const {
179   return gfx::Rect();
180 }
181 
IsDownloadShelfVisible() const182 bool TestBrowserWindow::IsDownloadShelfVisible() const {
183   return false;
184 }
185 
GetDownloadShelf()186 DownloadShelf* TestBrowserWindow::GetDownloadShelf() {
187   return &download_shelf_;
188 }
189 
GetExtraRenderViewHeight() const190 int TestBrowserWindow::GetExtraRenderViewHeight() const {
191   return 0;
192 }
193 
194 #if defined(OS_MACOSX)
IsFullscreenWithChrome()195 bool TestBrowserWindow::IsFullscreenWithChrome() {
196   return false;
197 }
198 
IsFullscreenWithoutChrome()199 bool TestBrowserWindow::IsFullscreenWithoutChrome() {
200   return false;
201 }
202 #endif
203 
GetDispositionForPopupBounds(const gfx::Rect & bounds)204 WindowOpenDisposition TestBrowserWindow::GetDispositionForPopupBounds(
205     const gfx::Rect& bounds) {
206   return NEW_POPUP;
207 }
208 
CreateFindBar()209 FindBar* TestBrowserWindow::CreateFindBar() {
210   return NULL;
211 }
212 
213 web_modal::WebContentsModalDialogHost*
GetWebContentsModalDialogHost()214     TestBrowserWindow::GetWebContentsModalDialogHost() {
215   return NULL;
216 }
217 
218 int
GetRenderViewHeightInsetWithDetachedBookmarkBar()219 TestBrowserWindow::GetRenderViewHeightInsetWithDetachedBookmarkBar() {
220   return 0;
221 }
222 
ExecuteExtensionCommand(const extensions::Extension * extension,const extensions::Command & command)223 void TestBrowserWindow::ExecuteExtensionCommand(
224     const extensions::Extension* extension,
225     const extensions::Command& command) {}
226