Commit eaacd1f3 authored by jam@chromium.org's avatar jam@chromium.org

Don't depend on the embedder creating a plugin. That way embedders can always...

Don't depend on the embedder creating a plugin. That way embedders can always provide an empty ContentRendererClient interface and still have functional rendering.
Review URL: http://codereview.chromium.org/7972018

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@102427 0039d316-1c4b-4281-b951-d872f2087c98
parent d4898917
......@@ -265,23 +265,20 @@ std::string ChromeContentRendererClient::GetDefaultEncoding() {
return l10n_util::GetStringUTF8(IDS_DEFAULT_ENCODING);
}
WebPlugin* ChromeContentRendererClient::CreatePlugin(
bool ChromeContentRendererClient::OverrideCreatePlugin(
RenderView* render_view,
WebFrame* frame,
const WebPluginParams& original_params) {
const WebPluginParams& params,
WebKit::WebPlugin** plugin) {
bool is_default_plugin;
WebPlugin* plugin = CreatePluginImpl(render_view,
frame,
original_params,
&is_default_plugin);
if (!plugin || is_default_plugin)
*plugin = CreatePlugin(render_view, frame, params, &is_default_plugin);
if (!*plugin || is_default_plugin)
MissingPluginReporter::GetInstance()->ReportPluginMissing(
original_params.mimeType.utf8(),
original_params.url);
return plugin;
params.mimeType.utf8(), params.url);
return true;
}
WebPlugin* ChromeContentRendererClient::CreatePluginImpl(
WebPlugin* ChromeContentRendererClient::CreatePlugin(
RenderView* render_view,
WebFrame* frame,
const WebPluginParams& original_params,
......
......@@ -42,10 +42,11 @@ class ChromeContentRendererClient : public content::ContentRendererClient {
virtual void SetNumberOfViews(int number_of_views) OVERRIDE;
virtual SkBitmap* GetSadPluginBitmap() OVERRIDE;
virtual std::string GetDefaultEncoding() OVERRIDE;
virtual WebKit::WebPlugin* CreatePlugin(
virtual bool OverrideCreatePlugin(
RenderView* render_view,
WebKit::WebFrame* frame,
const WebKit::WebPluginParams& params) OVERRIDE;
const WebKit::WebPluginParams& params,
WebKit::WebPlugin** plugin) OVERRIDE;
virtual void ShowErrorPage(RenderView* render_view,
WebKit::WebFrame* frame,
int http_status_code) OVERRIDE;
......@@ -93,7 +94,7 @@ class ChromeContentRendererClient : public content::ContentRendererClient {
void OnPurgeMemory();
private:
WebKit::WebPlugin* CreatePluginImpl(
WebKit::WebPlugin* CreatePlugin(
RenderView* render_view,
WebKit::WebFrame* frame,
const WebKit::WebPluginParams& params,
......
......@@ -53,12 +53,14 @@ class ContentRendererClient {
// Returns the default text encoding.
virtual std::string GetDefaultEncoding() = 0;
// Create a plugin in the given frame. Can return NULL, in which case
// RenderView will create a plugin itself.
virtual WebKit::WebPlugin* CreatePlugin(
// Allows the embedder to override creating a plugin. If it returns true, then
// |plugin| will contain the created plugin, although it could be NULL. If it
// returns false, the content layer will create the plugin.
virtual bool OverrideCreatePlugin(
RenderView* render_view,
WebKit::WebFrame* frame,
const WebKit::WebPluginParams& params) = 0;
const WebKit::WebPluginParams& params,
WebKit::WebPlugin** plugin) = 0;
// Give the embedder the ability to set an error page.
virtual void ShowErrorPage(RenderView* render_view,
......
......@@ -29,11 +29,12 @@ std::string MockContentRendererClient::GetDefaultEncoding() {
return std::string();
}
WebKit::WebPlugin* MockContentRendererClient::CreatePlugin(
bool MockContentRendererClient::OverrideCreatePlugin(
RenderView* render_view,
WebKit::WebFrame* frame,
const WebKit::WebPluginParams& params) {
return NULL;
const WebKit::WebPluginParams& params,
WebKit::WebPlugin** plugin) {
return false;
}
void MockContentRendererClient::ShowErrorPage(RenderView* render_view,
......
......@@ -22,10 +22,11 @@ class MockContentRendererClient : public ContentRendererClient {
virtual void SetNumberOfViews(int number_of_views) OVERRIDE;
virtual SkBitmap* GetSadPluginBitmap() OVERRIDE;
virtual std::string GetDefaultEncoding() OVERRIDE;
virtual WebKit::WebPlugin* CreatePlugin(
virtual bool OverrideCreatePlugin(
RenderView* render_view,
WebKit::WebFrame* frame,
const WebKit::WebPluginParams& params) OVERRIDE;
const WebKit::WebPluginParams& params,
WebKit::WebPlugin** plugin) OVERRIDE;
virtual void ShowErrorPage(RenderView* render_view,
WebKit::WebFrame* frame,
int http_status_code) OVERRIDE;
......
......@@ -1969,8 +1969,13 @@ void RenderView::runModal() {
WebPlugin* RenderView::createPlugin(WebFrame* frame,
const WebPluginParams& params) {
return content::GetContentClient()->renderer()->CreatePlugin(
this, frame, params);
WebPlugin* plugin = NULL;
if (content::GetContentClient()->renderer()->OverrideCreatePlugin(
this, frame, params, &plugin)) {
return plugin;
}
return CreatePluginNoCheck(frame, params);
}
WebWorker* RenderView::createWorker(WebFrame* frame, WebWorkerClient* client) {
......
......@@ -4,7 +4,6 @@
#include "content/shell/shell_content_renderer_client.h"
#include "content/renderer/render_view.h"
#include "v8/include/v8.h"
namespace content {
......@@ -29,11 +28,12 @@ std::string ShellContentRendererClient::GetDefaultEncoding() {
return std::string();
}
WebKit::WebPlugin* ShellContentRendererClient::CreatePlugin(
bool ShellContentRendererClient::OverrideCreatePlugin(
RenderView* render_view,
WebKit::WebFrame* frame,
const WebKit::WebPluginParams& params) {
return render_view->CreatePluginNoCheck(frame, params);
const WebKit::WebPluginParams& params,
WebKit::WebPlugin** plugin) {
return false;
}
void ShellContentRendererClient::ShowErrorPage(RenderView* render_view,
......
......@@ -19,10 +19,11 @@ class ShellContentRendererClient : public ContentRendererClient {
virtual void SetNumberOfViews(int number_of_views) OVERRIDE;
virtual SkBitmap* GetSadPluginBitmap() OVERRIDE;
virtual std::string GetDefaultEncoding() OVERRIDE;
virtual WebKit::WebPlugin* CreatePlugin(
virtual bool OverrideCreatePlugin(
RenderView* render_view,
WebKit::WebFrame* frame,
const WebKit::WebPluginParams& params) OVERRIDE;
const WebKit::WebPluginParams& params,
WebKit::WebPlugin** plugin) OVERRIDE;
virtual void ShowErrorPage(RenderView* render_view,
WebKit::WebFrame* frame,
int http_status_code) OVERRIDE;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment