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" |
54 | 55 |
55 #if defined(USE_TCMALLOC) | 56 #if defined(USE_TCMALLOC) |
56 #include "third_party/tcmalloc/chromium/src/gperftools/malloc_extension.h" | 57 #include "third_party/tcmalloc/chromium/src/gperftools/malloc_extension.h" |
57 #if defined(TYPE_PROFILING) | 58 #if defined(TYPE_PROFILING) |
58 #include "base/allocator/type_profiler.h" | 59 #include "base/allocator/type_profiler.h" |
59 #include "base/allocator/type_profiler_tcmalloc.h" | 60 #include "base/allocator/type_profiler_tcmalloc.h" |
60 #endif | 61 #endif |
61 #endif | 62 #endif |
62 | 63 |
63 #if !defined(OS_IOS) | 64 #if !defined(OS_IOS) |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 | 373 |
373 if (delegate) delegate->ZygoteForked(); | 374 if (delegate) delegate->ZygoteForked(); |
374 | 375 |
375 // Zygote::HandleForkRequest may have reallocated the command | 376 // Zygote::HandleForkRequest may have reallocated the command |
376 // line so update it here with the new version. | 377 // line so update it here with the new version. |
377 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 378 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
378 std::string process_type = | 379 std::string process_type = |
379 command_line.GetSwitchValueASCII(switches::kProcessType); | 380 command_line.GetSwitchValueASCII(switches::kProcessType); |
380 ContentClientInitializer::Set(process_type, delegate); | 381 ContentClientInitializer::Set(process_type, delegate); |
381 | 382 |
| 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 |
382 // The StatsTable must be initialized in each process; we already | 391 // The StatsTable must be initialized in each process; we already |
383 // initialized for the browser process, now we need to initialize | 392 // initialized for the browser process, now we need to initialize |
384 // within the new processes as well. | 393 // within the new processes as well. |
385 InitializeStatsTable(command_line); | 394 InitializeStatsTable(command_line); |
386 | 395 |
387 MainFunctionParams main_params(command_line); | 396 MainFunctionParams main_params(command_line); |
388 | 397 |
389 for (size_t i = 0; i < arraysize(kMainFunctions); ++i) { | 398 for (size_t i = 0; i < arraysize(kMainFunctions); ++i) { |
390 if (process_type == kMainFunctions[i].name) | 399 if (process_type == kMainFunctions[i].name) |
391 return kMainFunctions[i].function(main_params); | 400 return kMainFunctions[i].function(main_params); |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
731 RegisterPathProvider(); | 740 RegisterPathProvider(); |
732 RegisterContentSchemes(true); | 741 RegisterContentSchemes(true); |
733 | 742 |
734 CHECK(base::i18n::InitializeICU()); | 743 CHECK(base::i18n::InitializeICU()); |
735 | 744 |
736 InitializeStatsTable(command_line); | 745 InitializeStatsTable(command_line); |
737 | 746 |
738 if (delegate_) | 747 if (delegate_) |
739 delegate_->PreSandboxStartup(); | 748 delegate_->PreSandboxStartup(); |
740 | 749 |
| 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 |
741 if (!process_type.empty()) | 758 if (!process_type.empty()) |
742 CommonSubprocessInit(process_type); | 759 CommonSubprocessInit(process_type); |
743 | 760 |
744 #if defined(OS_WIN) | 761 #if defined(OS_WIN) |
745 CHECK(InitializeSandbox(params.sandbox_info)); | 762 CHECK(InitializeSandbox(params.sandbox_info)); |
746 #elif defined(OS_MACOSX) && !defined(OS_IOS) | 763 #elif defined(OS_MACOSX) && !defined(OS_IOS) |
747 if (process_type == switches::kRendererProcess || | 764 if (process_type == switches::kRendererProcess || |
748 process_type == switches::kPpapiPluginProcess || | 765 process_type == switches::kPpapiPluginProcess || |
749 (delegate_ && delegate_->DelaySandboxInitialization(process_type))) { | 766 (delegate_ && delegate_->DelaySandboxInitialization(process_type))) { |
750 // On OS X the renderer sandbox needs to be initialized later in the | 767 // 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... |
837 | 854 |
838 DISALLOW_COPY_AND_ASSIGN(ContentMainRunnerImpl); | 855 DISALLOW_COPY_AND_ASSIGN(ContentMainRunnerImpl); |
839 }; | 856 }; |
840 | 857 |
841 // static | 858 // static |
842 ContentMainRunner* ContentMainRunner::Create() { | 859 ContentMainRunner* ContentMainRunner::Create() { |
843 return new ContentMainRunnerImpl(); | 860 return new ContentMainRunnerImpl(); |
844 } | 861 } |
845 | 862 |
846 } // namespace content | 863 } // namespace content |
OLD | NEW |