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