Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(68)

Side by Side Diff: chrome/test/base/test_browser_window.cc

Issue 1198313003: Fix the browser match rules. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revert back to use Browesr raw pointer as the return type for CreateBrowserWithTestWindowForParams Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/test/base/test_browser_window.h" 5 #include "chrome/test/base/test_browser_window.h"
6 6
7 #include "chrome/browser/ui/browser_list.h" 7 #include "chrome/browser/ui/browser_list.h"
8 #include "chrome/browser/ui/browser_list_observer.h" 8 #include "chrome/browser/ui/browser_list_observer.h"
9 #include "ui/gfx/geometry/rect.h" 9 #include "ui/gfx/geometry/rect.h"
10 10
11
12 // Helpers -------------------------------------------------------------------- 11 // Helpers --------------------------------------------------------------------
13 12
14 namespace chrome { 13 namespace chrome {
15 14
16 namespace { 15 namespace {
17 16
18 // Handles destroying a TestBrowserWindow when the Browser it is attached to is 17 // Handles destroying a TestBrowserWindow when the Browser it is attached to is
19 // destroyed. 18 // destroyed.
20 class TestBrowserWindowOwner : public chrome::BrowserListObserver { 19 class TestBrowserWindowOwner : public chrome::BrowserListObserver {
21 public: 20 public:
(...skipping 16 matching lines...) Expand all
38 37
39 } // namespace 38 } // namespace
40 39
41 Browser* CreateBrowserWithTestWindowForParams(Browser::CreateParams* params) { 40 Browser* CreateBrowserWithTestWindowForParams(Browser::CreateParams* params) {
42 TestBrowserWindow* window = new TestBrowserWindow; 41 TestBrowserWindow* window = new TestBrowserWindow;
43 new TestBrowserWindowOwner(window); 42 new TestBrowserWindowOwner(window);
44 params->window = window; 43 params->window = window;
45 return new Browser(*params); 44 return new Browser(*params);
46 } 45 }
47 46
47 #if defined(USE_AURA)
48 Browser* CreateBrowserWithAuraTestWindowForParams(
49 const Browser::CreateParams& params) {
50 scoped_ptr<aura::Window> window(new aura::Window(nullptr));
51 window->set_id(0);
52 window->SetType(ui::wm::WINDOW_TYPE_NORMAL);
53 window->Init(ui::LAYER_TEXTURED);
54 window->Show();
55
56 TestBrowserWindowAura* browser_window =
msw 2015/07/08 23:58:00 nit: if we keep this function, make it just call C
57 new TestBrowserWindowAura(window.Pass());
58 new TestBrowserWindowOwner(browser_window);
59 return browser_window->CreateBrowser(params);
60 }
61
62 Browser* CreateBrowserForAuraTestWindowAndParams(
63 scoped_ptr<aura::Window> window,
64 const Browser::CreateParams& params) {
msw 2015/07/08 23:58:00 Should these functions take a params pointer, like
65 TestBrowserWindowAura* browser_window =
66 new TestBrowserWindowAura(window.Pass());
67 new TestBrowserWindowOwner(browser_window);
68 return browser_window->CreateBrowser(params);
69 }
70
71 #endif // defined(USE_AURA)
72
48 } // namespace chrome 73 } // namespace chrome
49 74
50 75
51 // TestBrowserWindow::TestLocationBar ----------------------------------------- 76 // TestBrowserWindow::TestLocationBar -----------------------------------------
52 77
53 GURL TestBrowserWindow::TestLocationBar::GetDestinationURL() const { 78 GURL TestBrowserWindow::TestLocationBar::GetDestinationURL() const {
54 return GURL(); 79 return GURL();
55 } 80 }
56 81
57 WindowOpenDisposition 82 WindowOpenDisposition
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 return 0; 249 return 0;
225 } 250 }
226 251
227 void TestBrowserWindow::ExecuteExtensionCommand( 252 void TestBrowserWindow::ExecuteExtensionCommand(
228 const extensions::Extension* extension, 253 const extensions::Extension* extension,
229 const extensions::Command& command) {} 254 const extensions::Command& command) {}
230 255
231 ExclusiveAccessContext* TestBrowserWindow::GetExclusiveAccessContext() { 256 ExclusiveAccessContext* TestBrowserWindow::GetExclusiveAccessContext() {
232 return nullptr; 257 return nullptr;
233 } 258 }
259
260 #if defined(USE_AURA)
261
262 // TestBrowserWindowAura -------------------------------------------------------
263
264 TestBrowserWindowAura::TestBrowserWindowAura(
265 scoped_ptr<aura::Window> native_window)
266 : native_window_(native_window.Pass()) {
267 }
268
269 TestBrowserWindowAura::~TestBrowserWindowAura() {
270 }
271
272 gfx::NativeWindow TestBrowserWindowAura::GetNativeWindow() const {
273 return native_window_.get();
274 }
275
276 void TestBrowserWindowAura::Show() {
277 native_window_->Show();
278 }
279
280 void TestBrowserWindowAura::Hide() {
281 native_window_->Hide();
282 }
283
284 gfx::Rect TestBrowserWindowAura::GetBounds() const {
285 return native_window_->bounds();
286 }
287
288 Browser* TestBrowserWindowAura::CreateBrowser(
289 const Browser::CreateParams& params) {
290 Browser::CreateParams create_params = params;
291 create_params.window = this;
292 browser_ = new Browser(create_params);
293 return browser_;
294 }
295
296 #endif
OLDNEW
« chrome/test/base/test_browser_window.h ('K') | « chrome/test/base/test_browser_window.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698