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

Side by Side Diff: ash/shell/content_client/shell_main_delegate.cc

Issue 10479023: Simplify how Content*Client interfaces are created. Instead of depending on the embedder to know wh… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: remove unused function declaration Created 8 years, 6 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
OLDNEW
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 "ash/shell/content_client/shell_main_delegate.h" 5 #include "ash/shell/content_client/shell_main_delegate.h"
6 6
7 #include "ash/shell/content_client/shell_content_browser_client.h" 7 #include "ash/shell/content_client/shell_content_browser_client.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/file_path.h" 9 #include "base/file_path.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
11 #include "content/public/common/content_switches.h" 11 #include "content/public/common/content_switches.h"
12 #include "content/shell/shell_content_plugin_client.h"
13 #include "content/shell/shell_content_renderer_client.h"
14 #include "content/shell/shell_content_utility_client.h"
15 #include "ui/base/resource/resource_bundle.h" 12 #include "ui/base/resource/resource_bundle.h"
16 #include "ui/base/ui_base_paths.h" 13 #include "ui/base/ui_base_paths.h"
17 14
18 namespace ash { 15 namespace ash {
19 namespace shell { 16 namespace shell {
20 17
21 ShellMainDelegate::ShellMainDelegate() { 18 ShellMainDelegate::ShellMainDelegate() {
22 } 19 }
23 20
24 ShellMainDelegate::~ShellMainDelegate() { 21 ShellMainDelegate::~ShellMainDelegate() {
25 } 22 }
26 23
27 bool ShellMainDelegate::BasicStartupComplete(int* exit_code) { 24 bool ShellMainDelegate::BasicStartupComplete(int* exit_code) {
28 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 25 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
29 std::string process_type = 26 std::string process_type =
30 command_line.GetSwitchValueASCII(switches::kProcessType); 27 command_line.GetSwitchValueASCII(switches::kProcessType);
31 28
32 content::SetContentClient(&content_client_); 29 content::SetContentClient(&content_client_);
33 InitializeShellContentClient(process_type);
34 30
35 return false; 31 return false;
36 } 32 }
37 33
38 void ShellMainDelegate::PreSandboxStartup() { 34 void ShellMainDelegate::PreSandboxStartup() {
39 InitializeResourceBundle(); 35 InitializeResourceBundle();
40 } 36 }
41 37
42 #if defined(OS_POSIX) 38 content::ContentBrowserClient* ShellMainDelegate::CreateContentBrowserClient() {
43 39 browser_client_.reset(new ShellContentBrowserClient);
44 void ShellMainDelegate::ZygoteForked() { 40 return browser_client_.get();
45 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
46 std::string process_type =
47 command_line.GetSwitchValueASCII(switches::kProcessType);
48 InitializeShellContentClient(process_type);
49 }
50 #endif
51
52 void ShellMainDelegate::InitializeShellContentClient(
53 const std::string& process_type) {
54 if (process_type.empty()) {
55 browser_client_.reset(new ShellContentBrowserClient);
56 content::GetContentClient()->set_browser(browser_client_.get());
57 } else if (process_type == switches::kRendererProcess) {
58 renderer_client_.reset(new content::ShellContentRendererClient);
59 content::GetContentClient()->set_renderer(renderer_client_.get());
60 } else if (process_type == switches::kPluginProcess) {
61 plugin_client_.reset(new content::ShellContentPluginClient);
62 content::GetContentClient()->set_plugin(plugin_client_.get());
63 } else if (process_type == switches::kUtilityProcess) {
64 utility_client_.reset(new content::ShellContentUtilityClient);
65 content::GetContentClient()->set_utility(utility_client_.get());
66 }
67 } 41 }
68 42
69 void ShellMainDelegate::InitializeResourceBundle() { 43 void ShellMainDelegate::InitializeResourceBundle() {
70 ui::ResourceBundle::InitSharedInstanceWithLocale("en-US", NULL); 44 ui::ResourceBundle::InitSharedInstanceWithLocale("en-US", NULL);
71 } 45 }
72 46
73 } // namespace shell 47 } // namespace shell
74 } // namespace ash 48 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698