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

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 sky@'s comment. 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
« no previous file with comments | « chrome/test/base/test_browser_window.h ('k') | chrome/test/base/test_browser_window_aura.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 11
12 // Helpers -------------------------------------------------------------------- 12 // Helpers --------------------------------------------------------------------
13 13
14 namespace chrome { 14 namespace chrome {
15 15
16 namespace { 16 scoped_ptr<Browser> CreateBrowserWithTestWindowForParams(
17 17 Browser::CreateParams* params) {
18 // Handles destroying a TestBrowserWindow when the Browser it is attached to is
19 // destroyed.
20 class TestBrowserWindowOwner : public chrome::BrowserListObserver {
21 public:
22 explicit TestBrowserWindowOwner(TestBrowserWindow* window) : window_(window) {
23 BrowserList::AddObserver(this);
24 }
25 ~TestBrowserWindowOwner() override { BrowserList::RemoveObserver(this); }
26
27 private:
28 // Overridden from BrowserListObserver:
29 void OnBrowserRemoved(Browser* browser) override {
30 if (browser->window() == window_.get())
31 delete this;
32 }
33
34 scoped_ptr<TestBrowserWindow> window_;
35
36 DISALLOW_COPY_AND_ASSIGN(TestBrowserWindowOwner);
37 };
38
39 } // namespace
40
41 Browser* CreateBrowserWithTestWindowForParams(Browser::CreateParams* params) {
42 TestBrowserWindow* window = new TestBrowserWindow; 18 TestBrowserWindow* window = new TestBrowserWindow;
43 new TestBrowserWindowOwner(window); 19 new TestBrowserWindowOwner(window);
44 params->window = window; 20 params->window = window;
45 return new Browser(*params); 21 return make_scoped_ptr(new Browser(*params));
46 } 22 }
47 23
48 } // namespace chrome 24 } // namespace chrome
49 25
50 26
51 // TestBrowserWindow::TestLocationBar ----------------------------------------- 27 // TestBrowserWindow::TestLocationBar -----------------------------------------
52 28
53 GURL TestBrowserWindow::TestLocationBar::GetDestinationURL() const { 29 GURL TestBrowserWindow::TestLocationBar::GetDestinationURL() const {
54 return GURL(); 30 return GURL();
55 } 31 }
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 188
213 FindBar* TestBrowserWindow::CreateFindBar() { 189 FindBar* TestBrowserWindow::CreateFindBar() {
214 return NULL; 190 return NULL;
215 } 191 }
216 192
217 web_modal::WebContentsModalDialogHost* 193 web_modal::WebContentsModalDialogHost*
218 TestBrowserWindow::GetWebContentsModalDialogHost() { 194 TestBrowserWindow::GetWebContentsModalDialogHost() {
219 return NULL; 195 return NULL;
220 } 196 }
221 197
222 int 198 int TestBrowserWindow::GetRenderViewHeightInsetWithDetachedBookmarkBar() {
223 TestBrowserWindow::GetRenderViewHeightInsetWithDetachedBookmarkBar() {
224 return 0; 199 return 0;
225 } 200 }
226 201
227 void TestBrowserWindow::ExecuteExtensionCommand( 202 void TestBrowserWindow::ExecuteExtensionCommand(
228 const extensions::Extension* extension, 203 const extensions::Extension* extension,
229 const extensions::Command& command) {} 204 const extensions::Command& command) {}
230 205
231 ExclusiveAccessContext* TestBrowserWindow::GetExclusiveAccessContext() { 206 ExclusiveAccessContext* TestBrowserWindow::GetExclusiveAccessContext() {
232 return nullptr; 207 return nullptr;
233 } 208 }
209
210 // TestBrowserWindowOwner -----------------------------------------------------
211
212 TestBrowserWindowOwner::TestBrowserWindowOwner(TestBrowserWindow* window)
213 : window_(window) {
214 BrowserList::AddObserver(this);
215 }
216
217 TestBrowserWindowOwner::~TestBrowserWindowOwner() {
218 BrowserList::RemoveObserver(this);
219 }
220
221 void TestBrowserWindowOwner::OnBrowserRemoved(Browser* browser) {
222 if (browser->window() == window_.get())
223 delete this;
224 }
OLDNEW
« no previous file with comments | « chrome/test/base/test_browser_window.h ('k') | chrome/test/base/test_browser_window_aura.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698