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 "ui/views/examples/content_client/examples_main_delegate.h" | 5 #include "ui/views/examples/content_client/examples_main_delegate.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/path_service.h" | 12 #include "base/path_service.h" |
13 #include "content/public/common/content_switches.h" | 13 #include "content/public/common/content_switches.h" |
14 #include "content/shell/shell_content_plugin_client.h" | |
15 #include "content/shell/shell_content_renderer_client.h" | |
16 #include "content/shell/shell_content_utility_client.h" | |
17 #include "ui/base/resource/resource_bundle.h" | 14 #include "ui/base/resource/resource_bundle.h" |
18 #include "ui/base/ui_base_paths.h" | 15 #include "ui/base/ui_base_paths.h" |
19 #include "ui/views/examples/content_client/examples_content_browser_client.h" | 16 #include "ui/views/examples/content_client/examples_content_browser_client.h" |
20 | 17 |
21 #if defined(OS_WIN) | 18 #if defined(OS_WIN) |
22 #include "base/logging_win.h" | 19 #include "base/logging_win.h" |
23 #endif | 20 #endif |
24 | 21 |
25 namespace views { | 22 namespace views { |
26 namespace examples { | 23 namespace examples { |
(...skipping 13 matching lines...) Expand all Loading... |
40 | 37 |
41 ExamplesMainDelegate::~ExamplesMainDelegate() { | 38 ExamplesMainDelegate::~ExamplesMainDelegate() { |
42 } | 39 } |
43 | 40 |
44 bool ExamplesMainDelegate::BasicStartupComplete(int* exit_code) { | 41 bool ExamplesMainDelegate::BasicStartupComplete(int* exit_code) { |
45 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 42 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
46 std::string process_type = | 43 std::string process_type = |
47 command_line.GetSwitchValueASCII(switches::kProcessType); | 44 command_line.GetSwitchValueASCII(switches::kProcessType); |
48 | 45 |
49 content::SetContentClient(&content_client_); | 46 content::SetContentClient(&content_client_); |
50 InitializeShellContentClient(process_type); | |
51 | 47 |
52 bool success = logging::InitLogging(NULL, | 48 bool success = logging::InitLogging(NULL, |
53 logging::LOG_ONLY_TO_SYSTEM_DEBUG_LOG, | 49 logging::LOG_ONLY_TO_SYSTEM_DEBUG_LOG, |
54 logging::LOCK_LOG_FILE, | 50 logging::LOCK_LOG_FILE, |
55 logging::DELETE_OLD_LOG_FILE, | 51 logging::DELETE_OLD_LOG_FILE, |
56 logging::DISABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS); | 52 logging::DISABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS); |
57 CHECK(success); | 53 CHECK(success); |
58 #if defined(OS_WIN) | 54 #if defined(OS_WIN) |
59 logging::LogEventProvider::Initialize(kViewsExamplesProviderName); | 55 logging::LogEventProvider::Initialize(kViewsExamplesProviderName); |
60 #endif | 56 #endif |
61 | 57 |
62 return false; | 58 return false; |
63 } | 59 } |
64 | 60 |
65 void ExamplesMainDelegate::PreSandboxStartup() { | 61 void ExamplesMainDelegate::PreSandboxStartup() { |
66 InitializeResourceBundle(); | 62 InitializeResourceBundle(); |
67 } | 63 } |
68 | 64 |
69 #if defined(OS_POSIX) | 65 content::ContentBrowserClient* |
70 void ExamplesMainDelegate::ZygoteForked() { | 66 ExamplesMainDelegate::CreateContentBrowserClient() { |
71 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 67 browser_client_.reset(new ExamplesContentBrowserClient); |
72 std::string process_type = | 68 return browser_client_.get(); |
73 command_line.GetSwitchValueASCII(switches::kProcessType); | |
74 InitializeShellContentClient(process_type); | |
75 } | |
76 #endif | |
77 | |
78 void ExamplesMainDelegate::InitializeShellContentClient( | |
79 const std::string& process_type) { | |
80 if (process_type.empty()) { | |
81 browser_client_.reset(new ExamplesContentBrowserClient); | |
82 content::GetContentClient()->set_browser(browser_client_.get()); | |
83 } else if (process_type == switches::kRendererProcess) { | |
84 renderer_client_.reset(new content::ShellContentRendererClient); | |
85 content::GetContentClient()->set_renderer(renderer_client_.get()); | |
86 } else if (process_type == switches::kPluginProcess) { | |
87 plugin_client_.reset(new content::ShellContentPluginClient); | |
88 content::GetContentClient()->set_plugin(plugin_client_.get()); | |
89 } else if (process_type == switches::kUtilityProcess) { | |
90 utility_client_.reset(new content::ShellContentUtilityClient); | |
91 content::GetContentClient()->set_utility(utility_client_.get()); | |
92 } | |
93 } | 69 } |
94 | 70 |
95 void ExamplesMainDelegate::InitializeResourceBundle() { | 71 void ExamplesMainDelegate::InitializeResourceBundle() { |
96 ui::ResourceBundle::InitSharedInstanceWithLocale("en-US", NULL); | 72 ui::ResourceBundle::InitSharedInstanceWithLocale("en-US", NULL); |
97 } | 73 } |
98 | 74 |
99 } // namespace examples | 75 } // namespace examples |
100 } // namespace views | 76 } // namespace views |
OLD | NEW |