summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-23 02:32:55 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-23 02:32:55 +0000
commiteaacd1f30dce47cbd261c950af3aa9588c753799 (patch)
tree460f6e5954276215d4bb0bf1c7ede5006df3513e
parentd48989178865e7285b6c2aa4649752e5c240c5ca (diff)
downloadchromium_src-eaacd1f30dce47cbd261c950af3aa9588c753799.zip
chromium_src-eaacd1f30dce47cbd261c950af3aa9588c753799.tar.gz
chromium_src-eaacd1f30dce47cbd261c950af3aa9588c753799.tar.bz2
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
-rw-r--r--chrome/renderer/chrome_content_renderer_client.cc19
-rw-r--r--chrome/renderer/chrome_content_renderer_client.h7
-rw-r--r--content/renderer/content_renderer_client.h10
-rw-r--r--content/renderer/mock_content_renderer_client.cc7
-rw-r--r--content/renderer/mock_content_renderer_client.h5
-rw-r--r--content/renderer/render_view.cc9
-rw-r--r--content/shell/shell_content_renderer_client.cc8
-rw-r--r--content/shell/shell_content_renderer_client.h5
8 files changed, 39 insertions, 31 deletions
diff --git a/chrome/renderer/chrome_content_renderer_client.cc b/chrome/renderer/chrome_content_renderer_client.cc
index a533ca3..a21c82a 100644
--- a/chrome/renderer/chrome_content_renderer_client.cc
+++ b/chrome/renderer/chrome_content_renderer_client.cc
@@ -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,
diff --git a/chrome/renderer/chrome_content_renderer_client.h b/chrome/renderer/chrome_content_renderer_client.h
index 54676b1..8123831 100644
--- a/chrome/renderer/chrome_content_renderer_client.h
+++ b/chrome/renderer/chrome_content_renderer_client.h
@@ -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,
diff --git a/content/renderer/content_renderer_client.h b/content/renderer/content_renderer_client.h
index 59223c1..931d65a 100644
--- a/content/renderer/content_renderer_client.h
+++ b/content/renderer/content_renderer_client.h
@@ -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,
diff --git a/content/renderer/mock_content_renderer_client.cc b/content/renderer/mock_content_renderer_client.cc
index ed2b8b0..843561e 100644
--- a/content/renderer/mock_content_renderer_client.cc
+++ b/content/renderer/mock_content_renderer_client.cc
@@ -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,
diff --git a/content/renderer/mock_content_renderer_client.h b/content/renderer/mock_content_renderer_client.h
index 374fb78..1abda3b 100644
--- a/content/renderer/mock_content_renderer_client.h
+++ b/content/renderer/mock_content_renderer_client.h
@@ -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;
diff --git a/content/renderer/render_view.cc b/content/renderer/render_view.cc
index 4ca44e1..c5aab5d 100644
--- a/content/renderer/render_view.cc
+++ b/content/renderer/render_view.cc
@@ -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) {
diff --git a/content/shell/shell_content_renderer_client.cc b/content/shell/shell_content_renderer_client.cc
index 32da65a..735197a 100644
--- a/content/shell/shell_content_renderer_client.cc
+++ b/content/shell/shell_content_renderer_client.cc
@@ -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,
diff --git a/content/shell/shell_content_renderer_client.h b/content/shell/shell_content_renderer_client.h
index b9ba912..b498106 100644
--- a/content/shell/shell_content_renderer_client.h
+++ b/content/shell/shell_content_renderer_client.h
@@ -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;