OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/browser/apps/app_browsertest_util.h" | 5 #include "chrome/browser/apps/app_browsertest_util.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
9 #include "chrome/browser/extensions/api/tabs/tabs_api.h" | 9 #include "chrome/browser/extensions/api/tabs/tabs_api.h" |
10 #include "chrome/browser/extensions/extension_function_test_utils.h" | 10 #include "chrome/browser/extensions/extension_function_test_utils.h" |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 return AppWindowRegistry::Get(browser()->profile())->app_windows().size(); | 187 return AppWindowRegistry::Get(browser()->profile())->app_windows().size(); |
188 } | 188 } |
189 | 189 |
190 size_t PlatformAppBrowserTest::GetAppWindowCountForApp( | 190 size_t PlatformAppBrowserTest::GetAppWindowCountForApp( |
191 const std::string& app_id) { | 191 const std::string& app_id) { |
192 return AppWindowRegistry::Get(browser()->profile()) | 192 return AppWindowRegistry::Get(browser()->profile()) |
193 ->GetAppWindowsForApp(app_id) | 193 ->GetAppWindowsForApp(app_id) |
194 .size(); | 194 .size(); |
195 } | 195 } |
196 | 196 |
197 AppWindow* PlatformAppBrowserTest::CreateAppWindow(const Extension* extension) { | 197 AppWindow* PlatformAppBrowserTest::CreateAppWindow( |
198 return CreateAppWindowFromParams(extension, AppWindow::CreateParams()); | 198 content::BrowserContext* context, |
| 199 const Extension* extension) { |
| 200 return CreateAppWindowFromParams(context, extension, |
| 201 AppWindow::CreateParams()); |
199 } | 202 } |
200 | 203 |
201 AppWindow* PlatformAppBrowserTest::CreateAppWindowFromParams( | 204 AppWindow* PlatformAppBrowserTest::CreateAppWindowFromParams( |
| 205 content::BrowserContext* context, |
202 const Extension* extension, | 206 const Extension* extension, |
203 const AppWindow::CreateParams& params) { | 207 const AppWindow::CreateParams& params) { |
204 AppWindow* window = new AppWindow(browser()->profile(), | 208 AppWindow* window = new AppWindow(browser()->profile(), |
205 new ChromeAppDelegate(true), extension); | 209 new ChromeAppDelegate(true), extension); |
206 window->Init(GURL(std::string()), new AppWindowContentsImpl(window), params); | 210 ProcessManager* process_manager = ProcessManager::Get(context); |
| 211 ExtensionHost* background_host = |
| 212 process_manager->GetBackgroundHostForExtension(extension->id()); |
| 213 window->Init(GURL(std::string()), new AppWindowContentsImpl(window), |
| 214 background_host->host_contents()->GetMainFrame(), params); |
207 return window; | 215 return window; |
208 } | 216 } |
209 | 217 |
210 void PlatformAppBrowserTest::CloseAppWindow(AppWindow* window) { | 218 void PlatformAppBrowserTest::CloseAppWindow(AppWindow* window) { |
211 content::WebContentsDestroyedWatcher destroyed_watcher( | 219 content::WebContentsDestroyedWatcher destroyed_watcher( |
212 window->web_contents()); | 220 window->web_contents()); |
213 window->GetBaseWindow()->Close(); | 221 window->GetBaseWindow()->Close(); |
214 destroyed_watcher.Wait(); | 222 destroyed_watcher.Wait(); |
215 } | 223 } |
216 | 224 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 return app_window; | 258 return app_window; |
251 } | 259 } |
252 | 260 |
253 void ExperimentalPlatformAppBrowserTest::SetUpCommandLine( | 261 void ExperimentalPlatformAppBrowserTest::SetUpCommandLine( |
254 base::CommandLine* command_line) { | 262 base::CommandLine* command_line) { |
255 PlatformAppBrowserTest::SetUpCommandLine(command_line); | 263 PlatformAppBrowserTest::SetUpCommandLine(command_line); |
256 command_line->AppendSwitch(switches::kEnableExperimentalExtensionApis); | 264 command_line->AppendSwitch(switches::kEnableExperimentalExtensionApis); |
257 } | 265 } |
258 | 266 |
259 } // namespace extensions | 267 } // namespace extensions |
OLD | NEW |