OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "content/app/content_main.h" | 5 #include "content/app/content_main.h" |
6 | 6 |
7 #include "base/at_exit.h" | 7 #include "base/at_exit.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/debug/debugger.h" | 9 #include "base/debug/debugger.h" |
10 #include "base/i18n/icu_util.h" | 10 #include "base/i18n/icu_util.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/mac/scoped_nsautorelease_pool.h" | 12 #include "base/mac/scoped_nsautorelease_pool.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/metrics/stats_table.h" | 14 #include "base/metrics/stats_table.h" |
15 #include "base/process_util.h" | 15 #include "base/process_util.h" |
16 #include "base/stringprintf.h" | 16 #include "base/stringprintf.h" |
17 #include "base/string_number_conversions.h" | 17 #include "base/string_number_conversions.h" |
18 #include "content/app/content_main_delegate.h" | 18 #include "content/app/content_main_delegate.h" |
19 #include "content/app/startup_helper_win.h" | 19 #include "content/app/startup_helper_win.h" |
20 #include "content/browser/browser_main.h" | 20 #include "content/browser/browser_main.h" |
21 #include "content/common/content_client.h" | |
21 #include "content/common/content_constants.h" | 22 #include "content/common/content_constants.h" |
22 #include "content/common/content_paths.h" | 23 #include "content/common/content_paths.h" |
23 #include "content/common/main_function_params.h" | 24 #include "content/common/main_function_params.h" |
24 #include "content/common/sandbox_init_wrapper.h" | 25 #include "content/common/sandbox_init_wrapper.h" |
25 #include "content/common/set_process_title.h" | 26 #include "content/common/set_process_title.h" |
26 #include "content/public/common/content_switches.h" | 27 #include "content/public/common/content_switches.h" |
27 #include "crypto/nss_util.h" | 28 #include "crypto/nss_util.h" |
28 #include "ipc/ipc_switches.h" | 29 #include "ipc/ipc_switches.h" |
29 #include "ui/base/ui_base_switches.h" | 30 #include "ui/base/ui_base_switches.h" |
30 #include "ui/base/ui_base_paths.h" | 31 #include "ui/base/ui_base_paths.h" |
32 #include "webkit/glue/webkit_glue.h" | |
31 | 33 |
32 #if defined(OS_WIN) | 34 #if defined(OS_WIN) |
33 #include <atlbase.h> | 35 #include <atlbase.h> |
34 #include <atlapp.h> | 36 #include <atlapp.h> |
35 #include <malloc.h> | 37 #include <malloc.h> |
36 #elif defined(OS_MACOSX) | 38 #elif defined(OS_MACOSX) |
37 #include "base/mach_ipc_mac.h" | 39 #include "base/mach_ipc_mac.h" |
38 #include "base/system_monitor/system_monitor.h" | 40 #include "base/system_monitor/system_monitor.h" |
39 #include "content/browser/mach_broker_mac.h" | 41 #include "content/browser/mach_broker_mac.h" |
40 #endif // OS_WIN | 42 #endif // OS_WIN |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
196 // This function call can return multiple times, once per fork(). | 198 // This function call can return multiple times, once per fork(). |
197 if (!ZygoteMain(main_function_params, zygote_fork_delegate.get())) | 199 if (!ZygoteMain(main_function_params, zygote_fork_delegate.get())) |
198 return 1; | 200 return 1; |
199 | 201 |
200 if (delegate) delegate->ZygoteForked(); | 202 if (delegate) delegate->ZygoteForked(); |
201 | 203 |
202 // Zygote::HandleForkRequest may have reallocated the command | 204 // Zygote::HandleForkRequest may have reallocated the command |
203 // line so update it here with the new version. | 205 // line so update it here with the new version. |
204 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 206 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
205 | 207 |
208 // If a custom user agent was passed on the command line, we need | |
209 // to (re)set it now, rather than using the default one the zygote | |
210 // initialized. | |
211 bool custom = false; | |
212 std::string ua = content::GetContentClient()->GetUserAgent(&custom); | |
213 if (custom) { | |
jam
2011/10/15 01:32:04
nit: this file doesn't use brace brackets for sing
Dirk Pranke
2011/10/15 02:14:07
Will fix.
| |
214 webkit_glue::ResetUserAgent(ua, custom); | |
215 } | |
216 | |
206 // The StatsTable must be initialized in each process; we already | 217 // The StatsTable must be initialized in each process; we already |
207 // initialized for the browser process, now we need to initialize | 218 // initialized for the browser process, now we need to initialize |
208 // within the new processes as well. | 219 // within the new processes as well. |
209 pid_t browser_pid = base::GetParentProcessId( | 220 pid_t browser_pid = base::GetParentProcessId( |
210 base::GetParentProcessId(base::GetCurrentProcId())); | 221 base::GetParentProcessId(base::GetCurrentProcId())); |
211 InitializeStatsTable(browser_pid, command_line); | 222 InitializeStatsTable(browser_pid, command_line); |
212 | 223 |
213 MainFunctionParams main_params(command_line, | 224 MainFunctionParams main_params(command_line, |
214 main_function_params.sandbox_info_, | 225 main_function_params.sandbox_info_, |
215 main_function_params.autorelease_pool_); | 226 main_function_params.autorelease_pool_); |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
448 _CrtDumpMemoryLeaks(); | 459 _CrtDumpMemoryLeaks(); |
449 #endif // _CRTDBG_MAP_ALLOC | 460 #endif // _CRTDBG_MAP_ALLOC |
450 | 461 |
451 _Module.Term(); | 462 _Module.Term(); |
452 #endif // OS_WIN | 463 #endif // OS_WIN |
453 | 464 |
454 return exit_code; | 465 return exit_code; |
455 } | 466 } |
456 | 467 |
457 } // namespace content | 468 } // namespace content |
OLD | NEW |