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

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

Issue 10692195: Consolidate Browser Creation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « chrome/test/base/test_browser_window.h ('k') | no next file » | 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"
8 #include "chrome/browser/ui/browser_list_observer.h"
7 #include "ui/gfx/rect.h" 9 #include "ui/gfx/rect.h"
8 10
9 using content::NativeWebKeyboardEvent; 11 using content::NativeWebKeyboardEvent;
10 12
11 TestBrowserWindow::TestBrowserWindow(Browser* browser) {} 13 TestBrowserWindow::TestBrowserWindow() {}
12 14
13 TestBrowserWindow::~TestBrowserWindow() {} 15 TestBrowserWindow::~TestBrowserWindow() {}
14 16
15 bool TestBrowserWindow::IsActive() const { 17 bool TestBrowserWindow::IsActive() const {
16 return false; 18 return false;
17 } 19 }
18 20
19 bool TestBrowserWindow::IsAlwaysOnTop() const { 21 bool TestBrowserWindow::IsAlwaysOnTop() const {
20 return false; 22 return false;
21 } 23 }
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 } 125 }
124 126
125 WindowOpenDisposition TestBrowserWindow::GetDispositionForPopupBounds( 127 WindowOpenDisposition TestBrowserWindow::GetDispositionForPopupBounds(
126 const gfx::Rect& bounds) { 128 const gfx::Rect& bounds) {
127 return NEW_POPUP; 129 return NEW_POPUP;
128 } 130 }
129 131
130 FindBar* TestBrowserWindow::CreateFindBar() { 132 FindBar* TestBrowserWindow::CreateFindBar() {
131 return NULL; 133 return NULL;
132 } 134 }
135
136 namespace chrome {
137
138 namespace {
139
140 // Handles destroying a TestBrowserWindow when the Browser it is attached to is
141 // destroyed.
142 class TestBrowserWindowOwner : public chrome::BrowserListObserver {
143 public:
144 explicit TestBrowserWindowOwner(TestBrowserWindow* window) : window_(window) {
145 BrowserList::AddObserver(this);
146 }
147 virtual ~TestBrowserWindowOwner() {
148 BrowserList::RemoveObserver(this);
149 }
150
151 private:
152 // Overridden from BrowserListObserver:
153 virtual void OnBrowserRemoved(Browser* browser) OVERRIDE {
154 if (browser->window() == window_.get())
155 delete this;
156 }
157
158 scoped_ptr<TestBrowserWindow> window_;
159
160 DISALLOW_COPY_AND_ASSIGN(TestBrowserWindowOwner);
161 };
162
163 } // namespace
164
165 Browser* CreateBrowserWithTestWindowForProfile(Profile* profile) {
166 Browser::CreateParams params(profile);
167 return CreateBrowserWithTestWindowForParams(&params);
168 }
169
170 Browser* CreateBrowserWithTestWindowForParams(Browser::CreateParams* params) {
171 TestBrowserWindow* window = new TestBrowserWindow;
172 new TestBrowserWindowOwner(window);
173 params->window = window;
174 return new Browser(*params);
175 }
176
177 } // namespace chrome
OLDNEW
« no previous file with comments | « 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