diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-05 14:43:01 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-05 14:43:01 +0000 |
commit | c6681f35e68c7689fdfd8794e0b1ec4cb92059e0 (patch) | |
tree | 9bc947f0a938e736e3660507ba47e7e6bac97a00 /content/shell | |
parent | c36a9e1dd2f21fce9ac430bd896b9f76e9a8eb73 (diff) | |
download | chromium_src-c6681f35e68c7689fdfd8794e0b1ec4cb92059e0.zip chromium_src-c6681f35e68c7689fdfd8794e0b1ec4cb92059e0.tar.gz chromium_src-c6681f35e68c7689fdfd8794e0b1ec4cb92059e0.tar.bz2 |
Simplify how Content*Client interfaces are created. Instead of depending on the embedder to know when to create and set them and to handle special cases like zygote/single-process, directly ask the embedder to create an instance of a specific type. Also, if the embedder doesn't return an instance create the empty version.
Remove MockContentRendererClient since it existed before ContentRendererClient had an implementation and has no need anymore. Rename MockContentBrowserClient to TestContentBrowserClient to better reflect how it's used.
BUG=98716
Review URL: https://chromiumcodereview.appspot.com/10479023
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@140524 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/shell')
-rw-r--r-- | content/shell/shell_content_plugin_client.cc | 12 | ||||
-rw-r--r-- | content/shell/shell_content_plugin_client.h | 21 | ||||
-rw-r--r-- | content/shell/shell_content_utility_client.cc | 19 | ||||
-rw-r--r-- | content/shell/shell_content_utility_client.h | 23 | ||||
-rw-r--r-- | content/shell/shell_main_delegate.cc | 47 | ||||
-rw-r--r-- | content/shell/shell_main_delegate.h | 12 |
6 files changed, 15 insertions, 119 deletions
diff --git a/content/shell/shell_content_plugin_client.cc b/content/shell/shell_content_plugin_client.cc deleted file mode 100644 index b2b6c7d..0000000 --- a/content/shell/shell_content_plugin_client.cc +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "content/shell/shell_content_plugin_client.h" - -namespace content { - -ShellContentPluginClient::~ShellContentPluginClient() { -} - -} // namespace content diff --git a/content/shell/shell_content_plugin_client.h b/content/shell/shell_content_plugin_client.h deleted file mode 100644 index f35937a..0000000 --- a/content/shell/shell_content_plugin_client.h +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CONTENT_SHELL_SHELL_CONTENT_PLUGIN_CLIENT_H_ -#define CONTENT_SHELL_SHELL_CONTENT_PLUGIN_CLIENT_H_ -#pragma once - -#include "base/compiler_specific.h" -#include "content/public/plugin/content_plugin_client.h" - -namespace content { - -class ShellContentPluginClient : public ContentPluginClient { - public: - virtual ~ShellContentPluginClient(); -}; - -} // namespace content - -#endif // CONTENT_SHELL_SHELL_CONTENT_PLUGIN_CLIENT_H_ diff --git a/content/shell/shell_content_utility_client.cc b/content/shell/shell_content_utility_client.cc deleted file mode 100644 index fb2a285..0000000 --- a/content/shell/shell_content_utility_client.cc +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "content/shell/shell_content_utility_client.h" - -namespace content { - -ShellContentUtilityClient::~ShellContentUtilityClient() { -} - -void ShellContentUtilityClient::UtilityThreadStarted() { -} - -bool ShellContentUtilityClient::OnMessageReceived(const IPC::Message& message) { - return false; -} - -} // namespace content diff --git a/content/shell/shell_content_utility_client.h b/content/shell/shell_content_utility_client.h deleted file mode 100644 index 051298a..0000000 --- a/content/shell/shell_content_utility_client.h +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CONTENT_SHELL_SHELL_CONTENT_UTILITY_CLIENT_H_ -#define CONTENT_SHELL_SHELL_CONTENT_UTILITY_CLIENT_H_ -#pragma once - -#include "base/compiler_specific.h" -#include "content/public/utility/content_utility_client.h" - -namespace content { - - class ShellContentUtilityClient : public ContentUtilityClient { - public: - virtual ~ShellContentUtilityClient(); - virtual void UtilityThreadStarted() OVERRIDE; - virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; -}; - -} // namespace content - -#endif // CONTENT_SHELL_SHELL_CONTENT_UTILITY_CLIENT_H_ diff --git a/content/shell/shell_main_delegate.cc b/content/shell/shell_main_delegate.cc index 469e779..f2ae251 100644 --- a/content/shell/shell_main_delegate.cc +++ b/content/shell/shell_main_delegate.cc @@ -11,9 +11,7 @@ #include "content/public/common/url_constants.h" #include "content/shell/shell_browser_main.h" #include "content/shell/shell_content_browser_client.h" -#include "content/shell/shell_content_plugin_client.h" #include "content/shell/shell_content_renderer_client.h" -#include "content/shell/shell_content_utility_client.h" #include "ui/base/resource/resource_bundle.h" #include "ui/base/ui_base_paths.h" @@ -34,12 +32,7 @@ bool ShellMainDelegate::BasicStartupComplete(int* exit_code) { #if defined(OS_MACOSX) OverrideFrameworkBundlePath(); #endif - const CommandLine& command_line = *CommandLine::ForCurrentProcess(); - std::string process_type = - command_line.GetSwitchValueASCII(switches::kProcessType); content::SetContentClient(&content_client_); - InitializeShellContentClient(process_type); - return false; } @@ -59,35 +52,6 @@ int ShellMainDelegate::RunProcess( return ShellBrowserMain(main_function_params); } -#if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) -void ShellMainDelegate::ZygoteForked() { - const CommandLine& command_line = *CommandLine::ForCurrentProcess(); - std::string process_type = - command_line.GetSwitchValueASCII(switches::kProcessType); - InitializeShellContentClient(process_type); -} -#endif - -void ShellMainDelegate::InitializeShellContentClient( - const std::string& process_type) { - if (process_type.empty()) { - browser_client_.reset(new content::ShellContentBrowserClient); - content::GetContentClient()->set_browser(browser_client_.get()); - } - - if (process_type == switches::kRendererProcess || - CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess)) { - renderer_client_.reset(new content::ShellContentRendererClient); - content::GetContentClient()->set_renderer(renderer_client_.get()); - } else if (process_type == switches::kPluginProcess) { - plugin_client_.reset(new content::ShellContentPluginClient); - content::GetContentClient()->set_plugin(plugin_client_.get()); - } else if (process_type == switches::kUtilityProcess) { - utility_client_.reset(new content::ShellContentUtilityClient); - content::GetContentClient()->set_utility(utility_client_.get()); - } -} - void ShellMainDelegate::InitializeResourceBundle() { FilePath pak_file; #if defined(OS_MACOSX) @@ -106,3 +70,14 @@ void ShellMainDelegate::InitializeResourceBundle() { #endif ui::ResourceBundle::InitSharedInstanceWithPakFile(pak_file); } + +content::ContentBrowserClient* ShellMainDelegate::CreateContentBrowserClient() { + browser_client_.reset(new content::ShellContentBrowserClient); + return browser_client_.get(); +} + +content::ContentRendererClient* + ShellMainDelegate::CreateContentRendererClient() { + renderer_client_.reset(new content::ShellContentRendererClient); + return renderer_client_.get(); +} diff --git a/content/shell/shell_main_delegate.h b/content/shell/shell_main_delegate.h index d3b07d4..a36dbcc 100644 --- a/content/shell/shell_main_delegate.h +++ b/content/shell/shell_main_delegate.h @@ -14,8 +14,6 @@ namespace content { class ShellContentBrowserClient; class ShellContentRendererClient; -class ShellContentPluginClient; -class ShellContentUtilityClient; } // namespace content class ShellMainDelegate : public content::ContentMainDelegate { @@ -23,23 +21,21 @@ class ShellMainDelegate : public content::ContentMainDelegate { ShellMainDelegate(); virtual ~ShellMainDelegate(); + // content::ContentMainDelegate implementation: virtual bool BasicStartupComplete(int* exit_code) OVERRIDE; virtual void PreSandboxStartup() OVERRIDE; virtual int RunProcess( const std::string& process_type, const content::MainFunctionParams& main_function_params) OVERRIDE; -#if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) - virtual void ZygoteForked() OVERRIDE; -#endif + virtual content::ContentBrowserClient* CreateContentBrowserClient() OVERRIDE; + virtual content::ContentRendererClient* + CreateContentRendererClient() OVERRIDE; private: - void InitializeShellContentClient(const std::string& process_type); void InitializeResourceBundle(); scoped_ptr<content::ShellContentBrowserClient> browser_client_; scoped_ptr<content::ShellContentRendererClient> renderer_client_; - scoped_ptr<content::ShellContentPluginClient> plugin_client_; - scoped_ptr<content::ShellContentUtilityClient> utility_client_; content::ShellContentClient content_client_; DISALLOW_COPY_AND_ASSIGN(ShellMainDelegate); |