| 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/browser/headless_content_browser_client.h" | 5 #include "headless/lib/browser/headless_content_browser_client.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <unordered_set> | 8 #include <unordered_set> |
| 9 | 9 |
| 10 #include "base/base_switches.h" | 10 #include "base/base_switches.h" |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/json/json_reader.h" | 13 #include "base/json/json_reader.h" |
| 14 #include "base/memory/ptr_util.h" | 14 #include "base/memory/ptr_util.h" |
| 15 #include "base/path_service.h" | 15 #include "base/path_service.h" |
| 16 #include "content/public/browser/browser_context.h" | 16 #include "content/public/browser/browser_context.h" |
| 17 #include "content/public/browser/browser_thread.h" | 17 #include "content/public/browser/browser_thread.h" |
| 18 #include "content/public/browser/render_process_host.h" | 18 #include "content/public/browser/render_process_host.h" |
| 19 #include "content/public/browser/render_view_host.h" | 19 #include "content/public/browser/render_view_host.h" |
| 20 #include "content/public/browser/storage_partition.h" | 20 #include "content/public/browser/storage_partition.h" |
| 21 #include "content/public/common/content_switches.h" | 21 #include "content/public/common/content_switches.h" |
| 22 #include "content/public/common/service_names.mojom.h" | 22 #include "content/public/common/service_names.mojom.h" |
| 23 #include "headless/app/headless_shell_switches.h" |
| 23 #include "headless/grit/headless_lib_resources.h" | 24 #include "headless/grit/headless_lib_resources.h" |
| 24 #include "headless/lib/browser/headless_browser_context_impl.h" | 25 #include "headless/lib/browser/headless_browser_context_impl.h" |
| 25 #include "headless/lib/browser/headless_browser_impl.h" | 26 #include "headless/lib/browser/headless_browser_impl.h" |
| 26 #include "headless/lib/browser/headless_browser_main_parts.h" | 27 #include "headless/lib/browser/headless_browser_main_parts.h" |
| 27 #include "headless/lib/browser/headless_devtools_manager_delegate.h" | 28 #include "headless/lib/browser/headless_devtools_manager_delegate.h" |
| 28 #include "headless/lib/headless_macros.h" | 29 #include "headless/lib/headless_macros.h" |
| 29 #include "storage/browser/quota/quota_settings.h" | 30 #include "storage/browser/quota/quota_settings.h" |
| 30 #include "ui/base/resource/resource_bundle.h" | 31 #include "ui/base/resource/resource_bundle.h" |
| 31 #include "ui/gfx/switches.h" | 32 #include "ui/gfx/switches.h" |
| 32 | 33 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 return crash_handler; | 71 return crash_handler; |
| 71 } | 72 } |
| 72 } | 73 } |
| 73 | 74 |
| 74 int GetCrashSignalFD(const base::CommandLine& command_line, | 75 int GetCrashSignalFD(const base::CommandLine& command_line, |
| 75 const HeadlessBrowser::Options& options) { | 76 const HeadlessBrowser::Options& options) { |
| 76 if (!breakpad::IsCrashReporterEnabled()) | 77 if (!breakpad::IsCrashReporterEnabled()) |
| 77 return -1; | 78 return -1; |
| 78 | 79 |
| 79 std::string process_type = | 80 std::string process_type = |
| 80 command_line.GetSwitchValueASCII(switches::kProcessType); | 81 command_line.GetSwitchValueASCII(::switches::kProcessType); |
| 81 | 82 |
| 82 if (process_type == switches::kRendererProcess) { | 83 if (process_type == ::switches::kRendererProcess) { |
| 83 static breakpad::CrashHandlerHostLinux* crash_handler = | 84 static breakpad::CrashHandlerHostLinux* crash_handler = |
| 84 CreateCrashHandlerHost(process_type, options); | 85 CreateCrashHandlerHost(process_type, options); |
| 85 return crash_handler->GetDeathSignalSocket(); | 86 return crash_handler->GetDeathSignalSocket(); |
| 86 } | 87 } |
| 87 | 88 |
| 88 if (process_type == switches::kPpapiPluginProcess) { | 89 if (process_type == ::switches::kPpapiPluginProcess) { |
| 89 static breakpad::CrashHandlerHostLinux* crash_handler = | 90 static breakpad::CrashHandlerHostLinux* crash_handler = |
| 90 CreateCrashHandlerHost(process_type, options); | 91 CreateCrashHandlerHost(process_type, options); |
| 91 return crash_handler->GetDeathSignalSocket(); | 92 return crash_handler->GetDeathSignalSocket(); |
| 92 } | 93 } |
| 93 | 94 |
| 94 if (process_type == switches::kGpuProcess) { | 95 if (process_type == ::switches::kGpuProcess) { |
| 95 static breakpad::CrashHandlerHostLinux* crash_handler = | 96 static breakpad::CrashHandlerHostLinux* crash_handler = |
| 96 CreateCrashHandlerHost(process_type, options); | 97 CreateCrashHandlerHost(process_type, options); |
| 97 return crash_handler->GetDeathSignalSocket(); | 98 return crash_handler->GetDeathSignalSocket(); |
| 98 } | 99 } |
| 99 | 100 |
| 100 return -1; | 101 return -1; |
| 101 } | 102 } |
| 102 #endif // defined(HEADLESS_USE_BREAKPAD) | 103 #endif // defined(HEADLESS_USE_BREAKPAD) |
| 103 | 104 |
| 104 } // namespace | 105 } // namespace |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 int crash_signal_fd = GetCrashSignalFD(command_line, *browser_->options()); | 181 int crash_signal_fd = GetCrashSignalFD(command_line, *browser_->options()); |
| 181 if (crash_signal_fd >= 0) | 182 if (crash_signal_fd >= 0) |
| 182 mappings->Share(kCrashDumpSignal, crash_signal_fd); | 183 mappings->Share(kCrashDumpSignal, crash_signal_fd); |
| 183 #endif // defined(HEADLESS_USE_BREAKPAD) | 184 #endif // defined(HEADLESS_USE_BREAKPAD) |
| 184 } | 185 } |
| 185 #endif // defined(OS_POSIX) && !defined(OS_MACOSX) | 186 #endif // defined(OS_POSIX) && !defined(OS_MACOSX) |
| 186 | 187 |
| 187 void HeadlessContentBrowserClient::AppendExtraCommandLineSwitches( | 188 void HeadlessContentBrowserClient::AppendExtraCommandLineSwitches( |
| 188 base::CommandLine* command_line, | 189 base::CommandLine* command_line, |
| 189 int child_process_id) { | 190 int child_process_id) { |
| 190 command_line->AppendSwitch(switches::kHeadless); | 191 command_line->AppendSwitch(::switches::kHeadless); |
| 192 const base::CommandLine& old_command_line( |
| 193 *base::CommandLine::ForCurrentProcess()); |
| 194 if (old_command_line.HasSwitch(switches::kUserAgent)) { |
| 195 command_line->AppendSwitchNative( |
| 196 switches::kUserAgent, |
| 197 old_command_line.GetSwitchValueNative(switches::kUserAgent)); |
| 198 } |
| 191 #if defined(HEADLESS_USE_BREAKPAD) | 199 #if defined(HEADLESS_USE_BREAKPAD) |
| 192 // This flag tells child processes to also turn on crash reporting. | 200 // This flag tells child processes to also turn on crash reporting. |
| 193 if (breakpad::IsCrashReporterEnabled()) | 201 if (breakpad::IsCrashReporterEnabled()) |
| 194 command_line->AppendSwitch(switches::kEnableCrashReporter); | 202 command_line->AppendSwitch(::switches::kEnableCrashReporter); |
| 195 #endif // defined(HEADLESS_USE_BREAKPAD) | 203 #endif // defined(HEADLESS_USE_BREAKPAD) |
| 196 } | 204 } |
| 197 | 205 |
| 198 } // namespace headless | 206 } // namespace headless |
| OLD | NEW |