OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "content/shell/shell_main_delegate.h" |
| 6 |
| 7 #include "base/command_line.h" |
| 8 #include "content/common/content_switches.h" |
| 9 #include "content/shell/shell_content_browser_client.h" |
| 10 #include "content/shell/shell_content_plugin_client.h" |
| 11 #include "content/shell/shell_content_renderer_client.h" |
| 12 #include "content/shell/shell_content_utility_client.h" |
| 13 |
| 14 ShellMainDelegate::ShellMainDelegate() { |
| 15 } |
| 16 |
| 17 ShellMainDelegate::~ShellMainDelegate() { |
| 18 } |
| 19 |
| 20 void ShellMainDelegate::PreSandboxStartup() { |
| 21 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 22 std::string process_type = |
| 23 command_line.GetSwitchValueASCII(switches::kProcessType); |
| 24 |
| 25 content::SetContentClient(&content_client_); |
| 26 InitializeShellContentClient(process_type); |
| 27 } |
| 28 |
| 29 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
| 30 void ShellMainDelegate::ZygoteForked() { |
| 31 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 32 std::string process_type = |
| 33 command_line.GetSwitchValueASCII(switches::kProcessType); |
| 34 InitializeShellContentClient(process_type); |
| 35 } |
| 36 #endif |
| 37 |
| 38 void ShellMainDelegate::InitializeShellContentClient( |
| 39 const std::string& process_type) { |
| 40 if (process_type.empty()) { |
| 41 browser_client_.reset(new content::ShellContentBrowserClient); |
| 42 content::GetContentClient()->set_browser(browser_client_.get()); |
| 43 } else if (process_type == switches::kRendererProcess) { |
| 44 renderer_client_.reset(new content::ShellContentRendererClient); |
| 45 content::GetContentClient()->set_renderer(renderer_client_.get()); |
| 46 } else if (process_type == switches::kPluginProcess) { |
| 47 plugin_client_.reset(new content::ShellContentPluginClient); |
| 48 content::GetContentClient()->set_plugin(plugin_client_.get()); |
| 49 } else if (process_type == switches::kUtilityProcess) { |
| 50 utility_client_.reset(new content::ShellContentUtilityClient); |
| 51 content::GetContentClient()->set_utility(utility_client_.get()); |
| 52 } |
| 53 } |
OLD | NEW |