OLD | NEW |
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/headless_content_main_delegate.h" | 5 #include "headless/lib/headless_content_main_delegate.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/base_switches.h" | 9 #include "base/base_switches.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/environment.h" | 11 #include "base/environment.h" |
12 #include "base/files/file_util.h" | 12 #include "base/files/file_util.h" |
13 #include "base/lazy_instance.h" | 13 #include "base/lazy_instance.h" |
14 #include "base/path_service.h" | 14 #include "base/path_service.h" |
15 #include "base/run_loop.h" | 15 #include "base/run_loop.h" |
16 #include "base/strings/string_number_conversions.h" | 16 #include "base/strings/string_number_conversions.h" |
17 #include "base/trace_event/trace_event.h" | 17 #include "base/trace_event/trace_event.h" |
18 #include "components/crash/content/app/breakpad_linux.h" | 18 #include "components/crash/content/app/breakpad_linux.h" |
19 #include "content/public/browser/browser_main_runner.h" | 19 #include "content/public/browser/browser_main_runner.h" |
20 #include "content/public/common/content_switches.h" | 20 #include "content/public/common/content_switches.h" |
21 #include "headless/lib/browser/headless_browser_impl.h" | 21 #include "headless/lib/browser/headless_browser_impl.h" |
22 #include "headless/lib/browser/headless_content_browser_client.h" | 22 #include "headless/lib/browser/headless_content_browser_client.h" |
23 #include "headless/lib/headless_crash_reporter_client.h" | 23 #include "headless/lib/headless_crash_reporter_client.h" |
24 #include "headless/lib/headless_macros.h" | 24 #include "headless/lib/headless_macros.h" |
| 25 #include "headless/lib/renderer/headless_content_renderer_client.h" |
25 #include "ui/base/resource/resource_bundle.h" | 26 #include "ui/base/resource/resource_bundle.h" |
26 #include "ui/base/ui_base_switches.h" | 27 #include "ui/base/ui_base_switches.h" |
27 #include "ui/gfx/switches.h" | 28 #include "ui/gfx/switches.h" |
28 #include "ui/gl/gl_switches.h" | 29 #include "ui/gl/gl_switches.h" |
29 #include "ui/ozone/public/ozone_switches.h" | 30 #include "ui/ozone/public/ozone_switches.h" |
30 | 31 |
31 #ifdef HEADLESS_USE_EMBEDDED_RESOURCES | 32 #ifdef HEADLESS_USE_EMBEDDED_RESOURCES |
32 #include "headless/embedded_resource_pak.h" | 33 #include "headless/embedded_resource_pak.h" |
33 #endif | 34 #endif |
34 | 35 |
35 #if !defined(CHROME_MULTIPLE_DLL_BROWSER) | |
36 #include "headless/lib/renderer/headless_content_renderer_client.h" | |
37 #endif | |
38 | |
39 #if defined(OS_MACOSX) | 36 #if defined(OS_MACOSX) |
40 #include "components/crash/content/app/crashpad.h" | 37 #include "components/crash/content/app/crashpad.h" |
41 #endif | 38 #endif |
42 | 39 |
43 namespace headless { | 40 namespace headless { |
44 namespace { | 41 namespace { |
45 // Keep in sync with content/common/content_constants_internal.h. | 42 // Keep in sync with content/common/content_constants_internal.h. |
46 // TODO(skyostil): Add a tracing test for this. | 43 // TODO(skyostil): Add a tracing test for this. |
47 const int kTraceEventBrowserProcessSortIndex = -6; | 44 const int kTraceEventBrowserProcessSortIndex = -6; |
48 | 45 |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 void HeadlessContentMainDelegate::PreSandboxStartup() { | 179 void HeadlessContentMainDelegate::PreSandboxStartup() { |
183 const base::CommandLine& command_line( | 180 const base::CommandLine& command_line( |
184 *base::CommandLine::ForCurrentProcess()); | 181 *base::CommandLine::ForCurrentProcess()); |
185 #if defined(OS_WIN) | 182 #if defined(OS_WIN) |
186 // Windows always needs to initialize logging, otherwise you get a renderer | 183 // Windows always needs to initialize logging, otherwise you get a renderer |
187 // crash. | 184 // crash. |
188 InitLogging(command_line); | 185 InitLogging(command_line); |
189 #else | 186 #else |
190 if (command_line.HasSwitch(switches::kEnableLogging)) | 187 if (command_line.HasSwitch(switches::kEnableLogging)) |
191 InitLogging(command_line); | 188 InitLogging(command_line); |
| 189 #endif |
| 190 #if !defined(OS_MACOSX) |
| 191 InitCrashReporter(command_line); |
192 #endif // defined(OS_WIN) | 192 #endif // defined(OS_WIN) |
193 InitCrashReporter(command_line); | |
194 InitializeResourceBundle(); | 193 InitializeResourceBundle(); |
195 } | 194 } |
196 | 195 |
197 int HeadlessContentMainDelegate::RunProcess( | 196 int HeadlessContentMainDelegate::RunProcess( |
198 const std::string& process_type, | 197 const std::string& process_type, |
199 const content::MainFunctionParams& main_function_params) { | 198 const content::MainFunctionParams& main_function_params) { |
200 if (!process_type.empty()) | 199 if (!process_type.empty()) |
201 return -1; | 200 return -1; |
202 | 201 |
203 base::trace_event::TraceLog::GetInstance()->SetProcessName("HeadlessBrowser"); | 202 base::trace_event::TraceLog::GetInstance()->SetProcessName("HeadlessBrowser"); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 if (!base::PathExists(pak_file)) | 270 if (!base::PathExists(pak_file)) |
272 pak_file = dir_module.Append(FILE_PATH_LITERAL("Resources/resources.pak")); | 271 pak_file = dir_module.Append(FILE_PATH_LITERAL("Resources/resources.pak")); |
273 #endif | 272 #endif |
274 ResourceBundle::GetSharedInstance().AddDataPackFromPath( | 273 ResourceBundle::GetSharedInstance().AddDataPackFromPath( |
275 pak_file, ui::SCALE_FACTOR_NONE); | 274 pak_file, ui::SCALE_FACTOR_NONE); |
276 #endif | 275 #endif |
277 } | 276 } |
278 | 277 |
279 content::ContentBrowserClient* | 278 content::ContentBrowserClient* |
280 HeadlessContentMainDelegate::CreateContentBrowserClient() { | 279 HeadlessContentMainDelegate::CreateContentBrowserClient() { |
281 #if defined(CHROME_MULTIPLE_DLL_CHILD) | |
282 return nullptr; | |
283 #else | |
284 browser_client_ = | 280 browser_client_ = |
285 base::MakeUnique<HeadlessContentBrowserClient>(browser_.get()); | 281 base::MakeUnique<HeadlessContentBrowserClient>(browser_.get()); |
286 return browser_client_.get(); | 282 return browser_client_.get(); |
287 #endif | |
288 } | 283 } |
289 | 284 |
290 content::ContentRendererClient* | 285 content::ContentRendererClient* |
291 HeadlessContentMainDelegate::CreateContentRendererClient() { | 286 HeadlessContentMainDelegate::CreateContentRendererClient() { |
292 #if defined(CHROME_MULTIPLE_DLL_BROWSER) | |
293 return nullptr; | |
294 #else | |
295 renderer_client_ = base::MakeUnique<HeadlessContentRendererClient>(); | 287 renderer_client_ = base::MakeUnique<HeadlessContentRendererClient>(); |
296 return renderer_client_.get(); | 288 return renderer_client_.get(); |
297 #endif | |
298 } | 289 } |
299 | 290 |
300 } // namespace headless | 291 } // namespace headless |
OLD | NEW |