| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/public/app/content_main_runner.h" | 5 #include "content/public/app/content_main_runner.h" |
| 6 | 6 |
| 7 #include <stdlib.h> | 7 #include <stdlib.h> |
| 8 | 8 |
| 9 #include "base/allocator/allocator_extension.h" | 9 #include "base/allocator/allocator_extension.h" |
| 10 #include "base/at_exit.h" | 10 #include "base/at_exit.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 #include "content/public/common/sandbox_init.h" | 43 #include "content/public/common/sandbox_init.h" |
| 44 #include "content/renderer/in_process_renderer_thread.h" | 44 #include "content/renderer/in_process_renderer_thread.h" |
| 45 #include "content/utility/in_process_utility_thread.h" | 45 #include "content/utility/in_process_utility_thread.h" |
| 46 #include "crypto/nss_util.h" | 46 #include "crypto/nss_util.h" |
| 47 #include "ipc/ipc_switches.h" | 47 #include "ipc/ipc_switches.h" |
| 48 #include "media/base/media.h" | 48 #include "media/base/media.h" |
| 49 #include "sandbox/win/src/sandbox_types.h" | 49 #include "sandbox/win/src/sandbox_types.h" |
| 50 #include "ui/base/ui_base_paths.h" | 50 #include "ui/base/ui_base_paths.h" |
| 51 #include "ui/base/ui_base_switches.h" | 51 #include "ui/base/ui_base_switches.h" |
| 52 #include "ui/gfx/win/dpi.h" | 52 #include "ui/gfx/win/dpi.h" |
| 53 #include "webkit/common/user_agent/user_agent.h" | |
| 54 | 53 |
| 55 #if defined(USE_TCMALLOC) | 54 #if defined(USE_TCMALLOC) |
| 56 #include "third_party/tcmalloc/chromium/src/gperftools/malloc_extension.h" | 55 #include "third_party/tcmalloc/chromium/src/gperftools/malloc_extension.h" |
| 57 #if defined(TYPE_PROFILING) | 56 #if defined(TYPE_PROFILING) |
| 58 #include "base/allocator/type_profiler.h" | 57 #include "base/allocator/type_profiler.h" |
| 59 #include "base/allocator/type_profiler_tcmalloc.h" | 58 #include "base/allocator/type_profiler_tcmalloc.h" |
| 60 #endif | 59 #endif |
| 61 #endif | 60 #endif |
| 62 | 61 |
| 63 #if !defined(OS_IOS) | 62 #if !defined(OS_IOS) |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 | 371 |
| 373 if (delegate) delegate->ZygoteForked(); | 372 if (delegate) delegate->ZygoteForked(); |
| 374 | 373 |
| 375 // Zygote::HandleForkRequest may have reallocated the command | 374 // Zygote::HandleForkRequest may have reallocated the command |
| 376 // line so update it here with the new version. | 375 // line so update it here with the new version. |
| 377 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 376 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 378 std::string process_type = | 377 std::string process_type = |
| 379 command_line.GetSwitchValueASCII(switches::kProcessType); | 378 command_line.GetSwitchValueASCII(switches::kProcessType); |
| 380 ContentClientInitializer::Set(process_type, delegate); | 379 ContentClientInitializer::Set(process_type, delegate); |
| 381 | 380 |
| 382 // If a custom user agent was passed on the command line, we need | |
| 383 // to (re)set it now, rather than using the default one the zygote | |
| 384 // initialized. | |
| 385 if (command_line.HasSwitch(switches::kUserAgent)) { | |
| 386 webkit_glue::SetUserAgent( | |
| 387 command_line.GetSwitchValueASCII(switches::kUserAgent), true); | |
| 388 } | |
| 389 | |
| 390 // The StatsTable must be initialized in each process; we already | 381 // The StatsTable must be initialized in each process; we already |
| 391 // initialized for the browser process, now we need to initialize | 382 // initialized for the browser process, now we need to initialize |
| 392 // within the new processes as well. | 383 // within the new processes as well. |
| 393 InitializeStatsTable(command_line); | 384 InitializeStatsTable(command_line); |
| 394 | 385 |
| 395 MainFunctionParams main_params(command_line); | 386 MainFunctionParams main_params(command_line); |
| 396 | 387 |
| 397 for (size_t i = 0; i < arraysize(kMainFunctions); ++i) { | 388 for (size_t i = 0; i < arraysize(kMainFunctions); ++i) { |
| 398 if (process_type == kMainFunctions[i].name) | 389 if (process_type == kMainFunctions[i].name) |
| 399 return kMainFunctions[i].function(main_params); | 390 return kMainFunctions[i].function(main_params); |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 734 RegisterPathProvider(); | 725 RegisterPathProvider(); |
| 735 RegisterContentSchemes(true); | 726 RegisterContentSchemes(true); |
| 736 | 727 |
| 737 CHECK(base::i18n::InitializeICU()); | 728 CHECK(base::i18n::InitializeICU()); |
| 738 | 729 |
| 739 InitializeStatsTable(command_line); | 730 InitializeStatsTable(command_line); |
| 740 | 731 |
| 741 if (delegate) | 732 if (delegate) |
| 742 delegate->PreSandboxStartup(); | 733 delegate->PreSandboxStartup(); |
| 743 | 734 |
| 744 // Set any custom user agent passed on the command line now so the string | |
| 745 // doesn't change between calls to webkit_glue::GetUserAgent(), otherwise it | |
| 746 // defaults to the user agent set during SetContentClient(). | |
| 747 if (command_line.HasSwitch(switches::kUserAgent)) { | |
| 748 webkit_glue::SetUserAgent( | |
| 749 command_line.GetSwitchValueASCII(switches::kUserAgent), true); | |
| 750 } | |
| 751 | |
| 752 if (!process_type.empty()) | 735 if (!process_type.empty()) |
| 753 CommonSubprocessInit(process_type); | 736 CommonSubprocessInit(process_type); |
| 754 | 737 |
| 755 #if defined(OS_WIN) | 738 #if defined(OS_WIN) |
| 756 CHECK(InitializeSandbox(sandbox_info)); | 739 CHECK(InitializeSandbox(sandbox_info)); |
| 757 #elif defined(OS_MACOSX) && !defined(OS_IOS) | 740 #elif defined(OS_MACOSX) && !defined(OS_IOS) |
| 758 if (process_type == switches::kRendererProcess || | 741 if (process_type == switches::kRendererProcess || |
| 759 process_type == switches::kPpapiPluginProcess || | 742 process_type == switches::kPpapiPluginProcess || |
| 760 (delegate && delegate->DelaySandboxInitialization(process_type))) { | 743 (delegate && delegate->DelaySandboxInitialization(process_type))) { |
| 761 // On OS X the renderer sandbox needs to be initialized later in the | 744 // On OS X the renderer sandbox needs to be initialized later in the |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 852 | 835 |
| 853 DISALLOW_COPY_AND_ASSIGN(ContentMainRunnerImpl); | 836 DISALLOW_COPY_AND_ASSIGN(ContentMainRunnerImpl); |
| 854 }; | 837 }; |
| 855 | 838 |
| 856 // static | 839 // static |
| 857 ContentMainRunner* ContentMainRunner::Create() { | 840 ContentMainRunner* ContentMainRunner::Create() { |
| 858 return new ContentMainRunnerImpl(); | 841 return new ContentMainRunnerImpl(); |
| 859 } | 842 } |
| 860 | 843 |
| 861 } // namespace content | 844 } // namespace content |
| OLD | NEW |