diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-17 22:24:43 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-17 22:24:43 +0000 |
commit | 490f79c179cc9df090dc68e36949ecc3458793da (patch) | |
tree | 1792cef02967fb6f8abe77e05d1f8ad015603ffb /content | |
parent | 3ffd3aec671a91b110860fc7c956f4d11a5be680 (diff) | |
download | chromium_src-490f79c179cc9df090dc68e36949ecc3458793da.zip chromium_src-490f79c179cc9df090dc68e36949ecc3458793da.tar.gz chromium_src-490f79c179cc9df090dc68e36949ecc3458793da.tar.bz2 |
Add separate ContentClient interfaces for gpu/plugin/renderer processes. Since we don't have a need for a chrome/gpu or chrome/plugin directory, their chrome implementations are in chrome/common. Use the renderer one for getting the sad plugin image.
Review URL: http://codereview.chromium.org/6708013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@78617 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r-- | content/browser/content_browser_client.h | 8 | ||||
-rw-r--r-- | content/browser/renderer_host/test_render_view_host.cc | 2 | ||||
-rw-r--r-- | content/browser/tab_contents/render_view_host_manager.cc | 3 | ||||
-rw-r--r-- | content/common/content_client.cc | 2 | ||||
-rw-r--r-- | content/common/content_client.h | 40 | ||||
-rw-r--r-- | content/content_gpu.gypi | 1 | ||||
-rw-r--r-- | content/content_plugin.gypi | 1 | ||||
-rw-r--r-- | content/content_renderer.gypi | 1 | ||||
-rw-r--r-- | content/gpu/content_gpu_client.h | 24 | ||||
-rw-r--r-- | content/gpu/gpu_thread.cc | 4 | ||||
-rw-r--r-- | content/plugin/content_plugin_client.h | 23 | ||||
-rw-r--r-- | content/plugin/plugin_thread.cc | 4 | ||||
-rw-r--r-- | content/renderer/content_renderer_client.h | 23 | ||||
-rw-r--r-- | content/renderer/webplugin_delegate_proxy.cc | 12 |
14 files changed, 110 insertions, 38 deletions
diff --git a/content/browser/content_browser_client.h b/content/browser/content_browser_client.h index 7d5e916..b916263 100644 --- a/content/browser/content_browser_client.h +++ b/content/browser/content_browser_client.h @@ -6,6 +6,8 @@ #define CONTENT_BROWSER_CONTENT_BROWSER_CLIENT_H_ #pragma once +#include "content/common/content_client.h" + class GURL; class Profile; class RenderViewHost; @@ -16,9 +18,9 @@ namespace content { class ContentBrowserClient { public: // Initialize a RenderViewHost before its CreateRenderView method is called. - virtual void OnRenderViewCreation(RenderViewHost* render_view_host, - Profile* profile, - const GURL& url) {} + virtual void PreCreateRenderView(RenderViewHost* render_view_host, + Profile* profile, + const GURL& url) {} }; } // namespace content diff --git a/content/browser/renderer_host/test_render_view_host.cc b/content/browser/renderer_host/test_render_view_host.cc index 5707937..d9e43f7 100644 --- a/content/browser/renderer_host/test_render_view_host.cc +++ b/content/browser/renderer_host/test_render_view_host.cc @@ -341,7 +341,7 @@ void RenderViewHostTestHarness::Reload() { void RenderViewHostTestHarness::SetUp() { // Initialize Chrome's ContentBrowserClient here, since we won't go through // BrowserMain. - content::GetContentClient()->set_browser_client(&browser_client_); + content::GetContentClient()->set_browser(&browser_client_); contents_.reset(CreateTestTabContents()); } diff --git a/content/browser/tab_contents/render_view_host_manager.cc b/content/browser/tab_contents/render_view_host_manager.cc index 51f5894..501a119 100644 --- a/content/browser/tab_contents/render_view_host_manager.cc +++ b/content/browser/tab_contents/render_view_host_manager.cc @@ -22,7 +22,6 @@ #include "content/browser/tab_contents/tab_contents_view.h" #include "content/browser/webui/web_ui.h" #include "content/browser/webui/web_ui_factory.h" -#include "content/common/content_client.h" #include "content/common/notification_service.h" #include "content/common/notification_type.h" @@ -488,7 +487,7 @@ bool RenderViewHostManager::InitRenderView(RenderViewHost* render_view_host, // Give the embedder a chance to initialize the render view. Profile* profile = delegate_->GetControllerForRenderManager().profile(); - content::GetContentClient()->browser_client()->OnRenderViewCreation( + content::GetContentClient()->browser()->PreCreateRenderView( render_view_host, profile, entry.url()); return delegate_->CreateRenderViewForRenderManager(render_view_host); diff --git a/content/common/content_client.cc b/content/common/content_client.cc index 421e781..79fe8cc 100644 --- a/content/common/content_client.cc +++ b/content/common/content_client.cc @@ -17,7 +17,7 @@ ContentClient* GetContentClient() { } ContentClient::ContentClient() : - browser_client_(NULL) { + browser_(NULL), gpu_(NULL), plugin_(NULL), renderer_(NULL) { } ContentClient::~ContentClient() { diff --git a/content/common/content_client.h b/content/common/content_client.h index 6ac6d54..8836a44 100644 --- a/content/common/content_client.h +++ b/content/common/content_client.h @@ -7,16 +7,17 @@ #pragma once #include "base/basictypes.h" -#include "base/scoped_ptr.h" -#include "base/string16.h" -class ContentBrowserClient; class GURL; -struct GPUInfo; namespace content { +class ContentBrowserClient; class ContentClient; +class ContentGpuClient; +class ContentPluginClient; +class ContentRendererClient; + // Setter and getter for the client. The client should be set early, before any // content code is called. void SetContentClient(ContentClient* client); @@ -28,27 +29,28 @@ class ContentClient { ContentClient(); ~ContentClient(); - // Gets or sets the embedder API for participating in browser logic. - // The client must be set early, before any content code is called. - ContentBrowserClient* browser_client() { - return browser_client_; - } - void set_browser_client(ContentBrowserClient* client) { - browser_client_ = client; - } + ContentBrowserClient* browser() { return browser_; } + void set_browser(ContentBrowserClient* c) { browser_ = c; } + ContentGpuClient* gpu() { return gpu_; } + void set_gpu(ContentGpuClient* g) { gpu_ = g; } + ContentPluginClient* plugin() { return plugin_; } + void set_plugin(ContentPluginClient* r) { plugin_ = r; } + ContentRendererClient* renderer() { return renderer_; } + void set_renderer(ContentRendererClient* r) { renderer_ = r; } // Sets the URL that is logged if the child process crashes. Use GURL() to // clear the URL. virtual void SetActiveURL(const GURL& url) {} - // Sets the data on the gpu to send along with crash reports. - virtual void SetGpuInfo(const GPUInfo& gpu_info) {} - - // Notifies that a plugin process has started. - virtual void PluginProcessStarted(const string16& plugin_name) {} - private: - ContentBrowserClient* browser_client_; + // The embedder API for participating in browser logic. + ContentBrowserClient* browser_; + // The embedder API for participating in gpu logic. + ContentGpuClient* gpu_; + // The embedder API for participating in plugin logic. + ContentPluginClient* plugin_; + // The embedder API for participating in renderer logic. + ContentRendererClient* renderer_; }; } // namespace content diff --git a/content/content_gpu.gypi b/content/content_gpu.gypi index ae65369..682eb51 100644 --- a/content/content_gpu.gypi +++ b/content/content_gpu.gypi @@ -19,6 +19,7 @@ '../skia/skia.gyp:skia', ], 'sources': [ + 'gpu/content_gpu_client.h', 'gpu/gpu_channel.cc', 'gpu/gpu_channel.h', 'gpu/gpu_command_buffer_stub.cc', diff --git a/content/content_plugin.gypi b/content/content_plugin.gypi index 8886a04..94b4dc80 100644 --- a/content/content_plugin.gypi +++ b/content/content_plugin.gypi @@ -20,6 +20,7 @@ 'sources': [ # All .cc, .h, .m, and .mm files under plugins except for tests and # mocks. + 'plugin/content_plugin_client.h', 'plugin/npobject_base.h', 'plugin/npobject_proxy.cc', 'plugin/npobject_proxy.h', diff --git a/content/content_renderer.gypi b/content/content_renderer.gypi index 239c922..7c3ad94 100644 --- a/content/content_renderer.gypi +++ b/content/content_renderer.gypi @@ -25,6 +25,7 @@ 'renderer/audio_device.h', 'renderer/audio_message_filter.cc', 'renderer/audio_message_filter.h', + 'renderer/content_renderer_client.h', 'renderer/cookie_message_filter.cc', 'renderer/cookie_message_filter.h', 'renderer/device_orientation_dispatcher.cc', diff --git a/content/gpu/content_gpu_client.h b/content/gpu/content_gpu_client.h new file mode 100644 index 0000000..e87f90b --- /dev/null +++ b/content/gpu/content_gpu_client.h @@ -0,0 +1,24 @@ +// 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_GPU_CONTENT_GPU_CLIENT_H_ +#define CONTENT_GPU_CONTENT_GPU_CLIENT_H_ +#pragma once + +#include "content/common/content_client.h" + +struct GPUInfo; + +namespace content { + +// Embedder API for participating in plugin logic. +class ContentGpuClient { + public: + // Sets the data on the gpu to send along with crash reports. + virtual void SetGpuInfo(const GPUInfo& gpu_info) {} +}; + +} // namespace content + +#endif // CONTENT_GPU_CONTENT_GPU_CLIENT_H_ diff --git a/content/gpu/gpu_thread.cc b/content/gpu/gpu_thread.cc index 3dc960e..d620747 100644 --- a/content/gpu/gpu_thread.cc +++ b/content/gpu/gpu_thread.cc @@ -14,9 +14,9 @@ #include "base/threading/worker_pool.h" #include "build/build_config.h" #include "content/common/child_process.h" -#include "content/common/content_client.h" #include "content/common/content_switches.h" #include "content/common/gpu_messages.h" +#include "content/gpu/content_gpu_client.h" #include "content/gpu/gpu_info_collector.h" #include "content/gpu/gpu_watchdog_thread.h" #include "ipc/ipc_channel_handle.h" @@ -132,7 +132,7 @@ void GpuThread::OnInitialize() { } gpu_info_collector::CollectGraphicsInfo(&gpu_info_); - content::GetContentClient()->SetGpuInfo(gpu_info_); + content::GetContentClient()->gpu()->SetGpuInfo(gpu_info_); LOG(INFO) << "gpu_info_collector::CollectGraphicsInfo complete"; // Record initialization only after collecting the GPU info because that can diff --git a/content/plugin/content_plugin_client.h b/content/plugin/content_plugin_client.h new file mode 100644 index 0000000..a8f3974 --- /dev/null +++ b/content/plugin/content_plugin_client.h @@ -0,0 +1,23 @@ +// 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_PLUGIN_CONTENT_PLUGIN_CLIENT_H_ +#define CONTENT_PLUGIN_CONTENT_PLUGIN_CLIENT_H_ +#pragma once + +#include "base/string16.h" +#include "content/common/content_client.h" + +namespace content { + +// Embedder API for participating in plugin logic. +class ContentPluginClient { + public: + // Notifies that a plugin process has started. + virtual void PluginProcessStarted(const string16& plugin_name) {} +}; + +} // namespace content + +#endif // CONTENT_PLUGIN_CONTENT_PLUGIN_CLIENT_H_ diff --git a/content/plugin/plugin_thread.cc b/content/plugin/plugin_thread.cc index c2ca935..1d14c22 100644 --- a/content/plugin/plugin_thread.cc +++ b/content/plugin/plugin_thread.cc @@ -20,10 +20,10 @@ #include "base/process_util.h" #include "base/threading/thread_local.h" #include "content/common/child_process.h" -#include "content/common/content_client.h" #include "content/common/content_switches.h" #include "content/common/child_process_messages.h" #include "content/common/plugin_messages.h" +#include "content/plugin/content_plugin_client.h" #include "content/plugin/npobject_util.h" #include "ipc/ipc_channel_handle.h" #include "net/base/net_errors.h" @@ -81,7 +81,7 @@ PluginThread::PluginThread() if (plugin.get()) plugin->NP_Initialize(); - content::GetContentClient()->PluginProcessStarted( + content::GetContentClient()->plugin()->PluginProcessStarted( plugin.get() ? plugin->plugin_info().name : string16()); // Certain plugins, such as flash, steal the unhandled exception filter diff --git a/content/renderer/content_renderer_client.h b/content/renderer/content_renderer_client.h new file mode 100644 index 0000000..4c94f31 --- /dev/null +++ b/content/renderer/content_renderer_client.h @@ -0,0 +1,23 @@ +// 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_RENDERER_CONTENT_RENDERER_CLIENT_H_ +#define CONTENT_RENDERER_CONTENT_RENDERER_CLIENT_H_ +#pragma once + +#include "content/common/content_client.h" + +class SkBitmap; + +namespace content { + +// Embedder API for participating in renderer logic. +class ContentRendererClient { + public: + virtual SkBitmap* GetSadPluginBitmap() { return NULL; } +}; + +} // namespace content + +#endif // CONTENT_RENDERER_CONTENT_RENDERER_CLIENT_H_ diff --git a/content/renderer/webplugin_delegate_proxy.cc b/content/renderer/webplugin_delegate_proxy.cc index e8ac928..0c018cd 100644 --- a/content/renderer/webplugin_delegate_proxy.cc +++ b/content/renderer/webplugin_delegate_proxy.cc @@ -29,8 +29,8 @@ #include "content/plugin/npobject_stub.h" #include "content/plugin/npobject_util.h" #include "content/renderer/command_buffer_proxy.h" +#include "content/renderer/content_renderer_client.h" #include "content/renderer/plugin_channel_host.h" -//#include "grit/renderer_resources.h" #include "ipc/ipc_channel_handle.h" #include "net/base/mime_util.h" #include "skia/ext/platform_canvas.h" @@ -40,7 +40,6 @@ #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" -#include "ui/base/resource/resource_bundle.h" #include "ui/gfx/blit.h" #include "ui/gfx/canvas_skia.h" #include "ui/gfx/native_widget_types.h" @@ -1151,12 +1150,9 @@ void WebPluginDelegateProxy::OnMissingPluginStatus(int status) { void WebPluginDelegateProxy::PaintSadPlugin(WebKit::WebCanvas* native_context, const gfx::Rect& rect) { // Lazily load the sad plugin image. - /* temporarily disabled by jam - if (!sad_plugin_) { - sad_plugin_ = ResourceBundle::GetSharedInstance().GetBitmapNamed( - IDR_SAD_PLUGIN); - } - */ + if (!sad_plugin_) + sad_plugin_ = content::GetContentClient()->renderer()->GetSadPluginBitmap(); + if (!sad_plugin_) return; |