Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(49)

Side by Side Diff: content/shell/shell_main.cc

Issue 8137012: Make an empty content browser test work. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/content_tests.gypi ('k') | content/shell/shell_main_delegate.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 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/app/content_main.h" 5 #include "content/app/content_main.h"
6 6
7 #include "base/command_line.h" 7 #include "content/shell/shell_main_delegate.h"
8 #include "base/memory/scoped_ptr.h"
9 #include "content/app/content_main_delegate.h"
10 #include "content/common/content_switches.h"
11 #include "content/shell/shell_content_browser_client.h"
12 #include "content/shell/shell_content_client.h"
13 #include "content/shell/shell_content_plugin_client.h"
14 #include "content/shell/shell_content_renderer_client.h"
15 #include "content/shell/shell_content_utility_client.h"
16 #include "sandbox/src/sandbox_types.h" 8 #include "sandbox/src/sandbox_types.h"
17 9
18 #if defined(OS_WIN) 10 #if defined(OS_WIN)
19 #include "content/app/startup_helper_win.h" 11 #include "content/app/startup_helper_win.h"
20 #endif 12 #endif
21 13
22 namespace {
23
24 class ShellMainDelegate : public content::ContentMainDelegate {
25 public:
26 virtual void PreSandboxStartup() OVERRIDE {
27 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
28 std::string process_type =
29 command_line.GetSwitchValueASCII(switches::kProcessType);
30
31 content::SetContentClient(&content_client_);
32 InitializeShellContentClient(process_type);
33 }
34
35 #if defined(OS_POSIX) && !defined(OS_MACOSX)
36 virtual void ZygoteForked() OVERRIDE {
37 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
38 std::string process_type =
39 command_line.GetSwitchValueASCII(switches::kProcessType);
40 InitializeShellContentClient(process_type);
41 }
42 #endif
43
44 private:
45 void InitializeShellContentClient(const std::string& process_type) {
46 if (process_type.empty()) {
47 browser_client_.reset(new content::ShellContentBrowserClient);
48 content::GetContentClient()->set_browser(browser_client_.get());
49 } else if (process_type == switches::kRendererProcess) {
50 renderer_client_.reset(new content::ShellContentRendererClient);
51 content::GetContentClient()->set_renderer(renderer_client_.get());
52 } else if (process_type == switches::kPluginProcess) {
53 plugin_client_.reset(new content::ShellContentPluginClient);
54 content::GetContentClient()->set_plugin(plugin_client_.get());
55 } else if (process_type == switches::kUtilityProcess) {
56 utility_client_.reset(new content::ShellContentUtilityClient);
57 content::GetContentClient()->set_utility(utility_client_.get());
58 }
59 }
60
61 scoped_ptr<content::ShellContentBrowserClient> browser_client_;
62 scoped_ptr<content::ShellContentRendererClient> renderer_client_;
63 scoped_ptr<content::ShellContentPluginClient> plugin_client_;
64 scoped_ptr<content::ShellContentUtilityClient> utility_client_;
65 content::ShellContentClient content_client_;
66 };
67
68 } // namespace
69
70 #if defined(OS_WIN) 14 #if defined(OS_WIN)
71 15
72 int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t*, int) { 16 int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t*, int) {
73 sandbox::SandboxInterfaceInfo sandbox_info = {0}; 17 sandbox::SandboxInterfaceInfo sandbox_info = {0};
74 content::InitializeSandboxInfo(&sandbox_info); 18 content::InitializeSandboxInfo(&sandbox_info);
75 ShellMainDelegate delegate; 19 ShellMainDelegate delegate;
76 return content::ContentMain(instance, &sandbox_info, &delegate); 20 return content::ContentMain(instance, &sandbox_info, &delegate);
77 } 21 }
78 #endif 22 #endif
79 23
80 #if defined(OS_POSIX) 24 #if defined(OS_POSIX)
81 25
82 #if defined(OS_MACOSX) 26 #if defined(OS_MACOSX)
83 __attribute__((visibility("default"))) 27 __attribute__((visibility("default")))
84 int main(int argc, const char* argv[]) { 28 int main(int argc, const char* argv[]) {
85 #else 29 #else
86 int main(int argc, const char** argv) { 30 int main(int argc, const char** argv) {
87 #endif // OS_MACOSX 31 #endif // OS_MACOSX
88 32
89 ShellMainDelegate delegate; 33 ShellMainDelegate delegate;
90 return content::ContentMain(argc, argv, &delegate); 34 return content::ContentMain(argc, argv, &delegate);
91 } 35 }
92 36
93 #endif // OS_POSIX 37 #endif // OS_POSIX
OLDNEW
« no previous file with comments | « content/content_tests.gypi ('k') | content/shell/shell_main_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698