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

Side by Side Diff: headless/lib/browser/headless_browser_impl.cc

Issue 2624343002: Get headless_shell building on Windows. (Closed)
Patch Set: Created 3 years, 11 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "headless/lib/browser/headless_browser_impl.h" 5 #include "headless/lib/browser/headless_browser_impl.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/memory/ptr_util.h" 12 #include "base/memory/ptr_util.h"
13 #include "base/threading/thread_task_runner_handle.h" 13 #include "base/threading/thread_task_runner_handle.h"
14 #include "content/public/app/content_main.h" 14 #include "content/public/app/content_main.h"
15 #include "content/public/browser/browser_thread.h" 15 #include "content/public/browser/browser_thread.h"
16 #include "content/public/browser/web_contents.h" 16 #include "content/public/browser/web_contents.h"
17 #include "content/public/common/content_switches.h" 17 #include "content/public/common/content_switches.h"
18 #include "headless/lib/browser/headless_browser_context_impl.h" 18 #include "headless/lib/browser/headless_browser_context_impl.h"
19 #include "headless/lib/browser/headless_browser_main_parts.h" 19 #include "headless/lib/browser/headless_browser_main_parts.h"
20 #include "headless/lib/browser/headless_web_contents_impl.h" 20 #include "headless/lib/browser/headless_web_contents_impl.h"
21 #include "headless/lib/browser/headless_window_parenting_client.h" 21 #include "headless/lib/browser/headless_window_parenting_client.h"
22 #include "headless/lib/browser/headless_window_tree_host.h" 22 #include "headless/lib/browser/headless_window_tree_host.h"
23 #include "headless/lib/headless_content_main_delegate.h" 23 #include "headless/lib/headless_content_main_delegate.h"
24 #include "ui/aura/env.h" 24 #include "ui/aura/env.h"
25 #include "ui/aura/window.h" 25 #include "ui/aura/window.h"
26 #include "ui/events/devices/device_data_manager.h" 26 #include "ui/events/devices/device_data_manager.h"
27 #include "ui/gfx/geometry/size.h" 27 #include "ui/gfx/geometry/size.h"
28 28
29 #if defined(OS_WIN)
30 #include "content/public/app/sandbox_helper_win.h"
31 #include "sandbox/win/src/sandbox_types.h"
32 #endif
33
29 namespace headless { 34 namespace headless {
30 namespace { 35 namespace {
31 36
32 int RunContentMain( 37 int RunContentMain(
33 HeadlessBrowser::Options options, 38 HeadlessBrowser::Options options,
34 const base::Callback<void(HeadlessBrowser*)>& on_browser_start_callback) { 39 const base::Callback<void(HeadlessBrowser*)>& on_browser_start_callback) {
35 content::ContentMainParams params(nullptr); 40 content::ContentMainParams params(nullptr);
36 params.argc = options.argc; 41 sandbox::SandboxInterfaceInfo sandbox_info = {0};
dvallet 2017/02/13 03:20:24 Please change to: #if defined(OS_WIN) sandbox::S
37 params.argv = options.argv; 42 content::InitializeSandboxInfo(&sandbox_info);
43
44 params.sandbox_info = &sandbox_info;
38 45
39 // TODO(skyostil): Implement custom message pumps. 46 // TODO(skyostil): Implement custom message pumps.
40 DCHECK(!options.message_pump); 47 DCHECK(!options.message_pump);
41 48
42 std::unique_ptr<HeadlessBrowserImpl> browser( 49 std::unique_ptr<HeadlessBrowserImpl> browser(
43 new HeadlessBrowserImpl(on_browser_start_callback, std::move(options))); 50 new HeadlessBrowserImpl(on_browser_start_callback, std::move(options)));
44 headless::HeadlessContentMainDelegate delegate(std::move(browser)); 51 headless::HeadlessContentMainDelegate delegate(std::move(browser));
45 params.delegate = &delegate; 52 params.delegate = &delegate;
46 return content::ContentMain(params); 53 return content::ContentMain(params);
47 } 54 }
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 189
183 HeadlessBrowserContext* HeadlessBrowserImpl::GetBrowserContextForId( 190 HeadlessBrowserContext* HeadlessBrowserImpl::GetBrowserContextForId(
184 const std::string& id) { 191 const std::string& id) {
185 auto find_it = browser_contexts_.find(id); 192 auto find_it = browser_contexts_.find(id);
186 if (find_it == browser_contexts_.end()) 193 if (find_it == browser_contexts_.end())
187 return nullptr; 194 return nullptr;
188 return find_it->second.get(); 195 return find_it->second.get();
189 } 196 }
190 197
191 void RunChildProcessIfNeeded(int argc, const char** argv) { 198 void RunChildProcessIfNeeded(int argc, const char** argv) {
192 base::CommandLine command_line(argc, argv); 199 base::CommandLine command_line(0, nullptr);
dvallet 2017/02/13 03:20:24 Revert thes changes.
193 if (!command_line.HasSwitch(switches::kProcessType)) 200 if (!command_line.HasSwitch(switches::kProcessType))
194 return; 201 return;
195 202
196 HeadlessBrowser::Options::Builder builder(argc, argv); 203 HeadlessBrowser::Options::Builder builder(0, nullptr);
dvallet 2017/02/13 03:20:24 ditto, revert this
197 exit(RunContentMain(builder.Build(), 204 exit(RunContentMain(builder.Build(),
198 base::Callback<void(HeadlessBrowser*)>())); 205 base::Callback<void(HeadlessBrowser*)>()));
199 } 206 }
200 207
201 int HeadlessBrowserMain( 208 int HeadlessBrowserMain(
202 HeadlessBrowser::Options options, 209 HeadlessBrowser::Options options,
203 const base::Callback<void(HeadlessBrowser*)>& on_browser_start_callback) { 210 const base::Callback<void(HeadlessBrowser*)>& on_browser_start_callback) {
204 DCHECK(!on_browser_start_callback.is_null()); 211 DCHECK(!on_browser_start_callback.is_null());
205 #if DCHECK_IS_ON() 212 #if DCHECK_IS_ON()
206 // The browser can only be initialized once. 213 // The browser can only be initialized once.
207 static bool browser_was_initialized; 214 static bool browser_was_initialized;
208 DCHECK(!browser_was_initialized); 215 DCHECK(!browser_was_initialized);
209 browser_was_initialized = true; 216 browser_was_initialized = true;
210 217
211 // Child processes should not end up here. 218 // Child processes should not end up here.
212 base::CommandLine command_line(options.argc, options.argv); 219 base::CommandLine command_line(options.argc, options.argv);
213 DCHECK(!command_line.HasSwitch(switches::kProcessType)); 220 DCHECK(!command_line.HasSwitch(switches::kProcessType));
214 #endif 221 #endif
215 return RunContentMain(std::move(options), 222 return RunContentMain(std::move(options),
216 std::move(on_browser_start_callback)); 223 std::move(on_browser_start_callback));
217 } 224 }
218 225
219 } // namespace headless 226 } // namespace headless
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698