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

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: Use scoped_ptr<Browser> instead. 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:
22 explicit TestBrowserWindowOwner(TestBrowserWindow* window) : window_(window) { 21 explicit TestBrowserWindowOwner(TestBrowserWindow* window) : window_(window) {
23 BrowserList::AddObserver(this); 22 BrowserList::AddObserver(this);
24 } 23 }
25 ~TestBrowserWindowOwner() override { BrowserList::RemoveObserver(this); } 24 ~TestBrowserWindowOwner() override { BrowserList::RemoveObserver(this); }
26 25
27 private: 26 private:
28 // Overridden from BrowserListObserver: 27 // Overridden from BrowserListObserver:
29 void OnBrowserRemoved(Browser* browser) override { 28 void OnBrowserRemoved(Browser* browser) override {
30 if (browser->window() == window_.get()) 29 if (browser->window() == window_.get())
31 delete this; 30 delete this;
32 } 31 }
33 32
34 scoped_ptr<TestBrowserWindow> window_; 33 scoped_ptr<TestBrowserWindow> window_;
35 34
36 DISALLOW_COPY_AND_ASSIGN(TestBrowserWindowOwner); 35 DISALLOW_COPY_AND_ASSIGN(TestBrowserWindowOwner);
37 }; 36 };
38 37
39 } // namespace 38 } // namespace
40 39
41 Browser* CreateBrowserWithTestWindowForParams(Browser::CreateParams* params) { 40 scoped_ptr<Browser> CreateBrowserWithTestWindowForParams(
41 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 make_scoped_ptr(new Browser(*params));
46 } 46 }
47 47
48 #if defined(USE_AURA)
49 scoped_ptr<Browser> CreateBrowserWithAuraTestWindowForParams(
50 scoped_ptr<aura::Window> window,
51 Browser::CreateParams* params) {
52 if (window.get() == nullptr) {
53 window.reset(new aura::Window(nullptr));
54 window->set_id(0);
55 window->SetType(ui::wm::WINDOW_TYPE_NORMAL);
56 window->Init(ui::LAYER_TEXTURED);
57 window->Show();
58 }
59
60 TestBrowserWindowAura* browser_window =
61 new TestBrowserWindowAura(window.Pass());
62 new TestBrowserWindowOwner(browser_window);
63 return browser_window->CreateBrowser(params);
64 }
65 #endif // defined(USE_AURA)
66
48 } // namespace chrome 67 } // namespace chrome
49 68
50 69
51 // TestBrowserWindow::TestLocationBar ----------------------------------------- 70 // TestBrowserWindow::TestLocationBar -----------------------------------------
52 71
53 GURL TestBrowserWindow::TestLocationBar::GetDestinationURL() const { 72 GURL TestBrowserWindow::TestLocationBar::GetDestinationURL() const {
54 return GURL(); 73 return GURL();
55 } 74 }
56 75
57 WindowOpenDisposition 76 WindowOpenDisposition
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 return 0; 243 return 0;
225 } 244 }
226 245
227 void TestBrowserWindow::ExecuteExtensionCommand( 246 void TestBrowserWindow::ExecuteExtensionCommand(
228 const extensions::Extension* extension, 247 const extensions::Extension* extension,
229 const extensions::Command& command) {} 248 const extensions::Command& command) {}
230 249
231 ExclusiveAccessContext* TestBrowserWindow::GetExclusiveAccessContext() { 250 ExclusiveAccessContext* TestBrowserWindow::GetExclusiveAccessContext() {
232 return nullptr; 251 return nullptr;
233 } 252 }
253
254 #if defined(USE_AURA)
255
256 // TestBrowserWindowAura -------------------------------------------------------
257
258 TestBrowserWindowAura::TestBrowserWindowAura(
259 scoped_ptr<aura::Window> native_window)
260 : native_window_(native_window.Pass()) {
261 }
262
263 TestBrowserWindowAura::~TestBrowserWindowAura() {
264 }
265
266 gfx::NativeWindow TestBrowserWindowAura::GetNativeWindow() const {
267 return native_window_.get();
268 }
269
270 void TestBrowserWindowAura::Show() {
271 native_window_->Show();
272 }
273
274 void TestBrowserWindowAura::Hide() {
275 native_window_->Hide();
276 }
277
278 gfx::Rect TestBrowserWindowAura::GetBounds() const {
279 return native_window_->bounds();
280 }
281
282 scoped_ptr<Browser> TestBrowserWindowAura::CreateBrowser(
283 Browser::CreateParams* params) {
284 params->window = this;
285 browser_ = new Browser(*params);
286 return make_scoped_ptr(browser_);
287 }
288
289 #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