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

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: Address msw@'s comments. 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/aura/window.h"
msw 2015/07/08 01:14:00 nit: this isn't needed, given the include in the h
xdai1 2015/07/08 21:34:21 Sorry missed this one. Removed it.
9 #include "ui/gfx/geometry/rect.h" 10 #include "ui/gfx/geometry/rect.h"
10 11
11
12 // Helpers -------------------------------------------------------------------- 12 // Helpers --------------------------------------------------------------------
13 13
14 namespace chrome { 14 namespace chrome {
15 15
16 namespace { 16 namespace {
17 17
18 // Handles destroying a TestBrowserWindow when the Browser it is attached to is 18 // Handles destroying a TestBrowserWindow when the Browser it is attached to is
19 // destroyed. 19 // destroyed.
20 class TestBrowserWindowOwner : public chrome::BrowserListObserver { 20 class TestBrowserWindowOwner : public chrome::BrowserListObserver {
21 public: 21 public:
(...skipping 16 matching lines...) Expand all
38 38
39 } // namespace 39 } // namespace
40 40
41 Browser* CreateBrowserWithTestWindowForParams(Browser::CreateParams* params) { 41 Browser* CreateBrowserWithTestWindowForParams(Browser::CreateParams* params) {
42 TestBrowserWindow* window = new TestBrowserWindow; 42 TestBrowserWindow* window = new TestBrowserWindow;
43 new TestBrowserWindowOwner(window); 43 new TestBrowserWindowOwner(window);
44 params->window = window; 44 params->window = window;
45 return new Browser(*params); 45 return new Browser(*params);
46 } 46 }
47 47
48 #if defined(USE_AURA)
49 Browser* CreateBrowserWithAuraTestWindowForParams(
50 const Browser::CreateParams& params) {
51 aura::Window* window = new aura::Window(nullptr);
msw 2015/07/08 01:14:00 nit: make |window| a scoped_ptr and pass into the
xdai1 2015/07/08 21:34:21 Done.
52 window->set_id(0);
53 window->SetType(ui::wm::WINDOW_TYPE_NORMAL);
54 window->Init(ui::LAYER_TEXTURED);
55 window->Show();
56
57 TestBrowserWindowAura* browser_window = new TestBrowserWindowAura(window);
58 browser_window->CreateBrowser(params);
59 new TestBrowserWindowOwner(browser_window);
60
61 return browser_window->browser();
62 }
63 #endif // defined(USE_AURA)
64
48 } // namespace chrome 65 } // namespace chrome
49 66
50 67
51 // TestBrowserWindow::TestLocationBar ----------------------------------------- 68 // TestBrowserWindow::TestLocationBar -----------------------------------------
52 69
53 GURL TestBrowserWindow::TestLocationBar::GetDestinationURL() const { 70 GURL TestBrowserWindow::TestLocationBar::GetDestinationURL() const {
54 return GURL(); 71 return GURL();
55 } 72 }
56 73
57 WindowOpenDisposition 74 WindowOpenDisposition
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 return 0; 241 return 0;
225 } 242 }
226 243
227 void TestBrowserWindow::ExecuteExtensionCommand( 244 void TestBrowserWindow::ExecuteExtensionCommand(
228 const extensions::Extension* extension, 245 const extensions::Extension* extension,
229 const extensions::Command& command) {} 246 const extensions::Command& command) {}
230 247
231 ExclusiveAccessContext* TestBrowserWindow::GetExclusiveAccessContext() { 248 ExclusiveAccessContext* TestBrowserWindow::GetExclusiveAccessContext() {
232 return nullptr; 249 return nullptr;
233 } 250 }
251
252 #if defined(USE_AURA)
253
254 // TestBrowserWindowAura -------------------------------------------------------
255
256 TestBrowserWindowAura::TestBrowserWindowAura(aura::Window* native_window)
257 : native_window_(native_window) {
258 }
259
260 TestBrowserWindowAura::~TestBrowserWindowAura() {
261 }
262
263 gfx::NativeWindow TestBrowserWindowAura::GetNativeWindow() const {
264 return native_window_.get();
265 }
266
267 void TestBrowserWindowAura::Show() {
268 native_window_->Show();
269 }
270
271 void TestBrowserWindowAura::Hide() {
272 native_window_->Hide();
273 }
274
275 gfx::Rect TestBrowserWindowAura::GetBounds() const {
276 return native_window_->bounds();
277 }
278
279 Browser* TestBrowserWindowAura::browser() {
280 return browser_;
281 }
282
283 void TestBrowserWindowAura::CreateBrowser(const Browser::CreateParams& params) {
284 Browser::CreateParams create_params = params;
285 create_params.window = this;
286 browser_ = new Browser(create_params);
287 }
288
289 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698