summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authorbauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-30 22:37:20 +0000
committerbauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-30 22:37:20 +0000
commit7459e417a82c6cd5a2c4d594404e7574040baaff (patch)
treedf4102a8b9f57cda26db71132fe9fe436f9a7fa4 /webkit
parentbdf3948b4606f1ebc1680a778fadc5fac7ce8d4f (diff)
downloadchromium_src-7459e417a82c6cd5a2c4d594404e7574040baaff.zip
chromium_src-7459e417a82c6cd5a2c4d594404e7574040baaff.tar.gz
chromium_src-7459e417a82c6cd5a2c4d594404e7574040baaff.tar.bz2
Show a replacement plug-in for loading errors.
This allows us to show a nicer placeholder when loading a plug-in fails then the one coming from WebKit. BUG=123580 TEST=manual Review URL: http://codereview.chromium.org/10093011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@134620 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/plugins/npapi/webplugin_impl.cc13
-rw-r--r--webkit/plugins/npapi/webplugin_page_delegate.h7
-rw-r--r--webkit/plugins/ppapi/mock_plugin_delegate.cc5
-rw-r--r--webkit/plugins/ppapi/mock_plugin_delegate.h1
-rw-r--r--webkit/plugins/ppapi/plugin_delegate.h10
-rw-r--r--webkit/plugins/ppapi/ppapi_webplugin_impl.cc11
-rw-r--r--webkit/support/test_webplugin_page_delegate.cc7
-rw-r--r--webkit/support/test_webplugin_page_delegate.h4
-rw-r--r--webkit/tools/test_shell/test_webview_delegate.cc5
-rw-r--r--webkit/tools/test_shell/test_webview_delegate.h2
10 files changed, 55 insertions, 10 deletions
diff --git a/webkit/plugins/npapi/webplugin_impl.cc b/webkit/plugins/npapi/webplugin_impl.cc
index f776559..595f5c9 100644
--- a/webkit/plugins/npapi/webplugin_impl.cc
+++ b/webkit/plugins/npapi/webplugin_impl.cc
@@ -256,10 +256,8 @@ bool WebPluginImpl::initialize(WebPluginContainer* container) {
WebPluginDelegate* plugin_delegate = page_delegate_->CreatePluginDelegate(
file_path_, mime_type_);
- if (!plugin_delegate) {
- LOG(ERROR) << "Couldn't create plug-in delegate";
+ if (!plugin_delegate)
return false;
- }
// Set the container before Initialize because the plugin may
// synchronously call NPN_GetValue to get its container during its
@@ -270,7 +268,14 @@ bool WebPluginImpl::initialize(WebPluginContainer* container) {
if (!ok) {
LOG(ERROR) << "Couldn't initialize plug-in";
plugin_delegate->PluginDestroyed();
- return false;
+
+ WebKit::WebPlugin* replacement_plugin =
+ page_delegate_->CreatePluginReplacement(file_path_);
+ if (!replacement_plugin->initialize(container))
+ return false;
+
+ container->setPlugin(replacement_plugin);
+ return true;
}
delegate_ = plugin_delegate;
diff --git a/webkit/plugins/npapi/webplugin_page_delegate.h b/webkit/plugins/npapi/webplugin_page_delegate.h
index 3176ccd..496bd6f 100644
--- a/webkit/plugins/npapi/webplugin_page_delegate.h
+++ b/webkit/plugins/npapi/webplugin_page_delegate.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 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.
@@ -13,6 +13,7 @@ class FilePath;
namespace WebKit {
class WebCookieJar;
+class WebPlugin;
}
namespace webkit {
@@ -31,6 +32,10 @@ class WebPluginPageDelegate {
const FilePath& file_path,
const std::string& mime_type) = 0;
+ // Caled to create a replacement plug-in when loading a plug-in failed.
+ virtual WebKit::WebPlugin* CreatePluginReplacement(
+ const FilePath& file_path) = 0;
+
// Called when a windowed plugin is created.
// Lets the view delegate create anything it is using to wrap the plugin.
virtual void CreatedPluginWindow(
diff --git a/webkit/plugins/ppapi/mock_plugin_delegate.cc b/webkit/plugins/ppapi/mock_plugin_delegate.cc
index 12fe0e7..7944ac2 100644
--- a/webkit/plugins/ppapi/mock_plugin_delegate.cc
+++ b/webkit/plugins/ppapi/mock_plugin_delegate.cc
@@ -50,6 +50,11 @@ SkBitmap* MockPluginDelegate::GetSadPluginBitmap() {
return NULL;
}
+WebKit::WebPlugin* MockPluginDelegate::CreatePluginReplacement(
+ const FilePath& file_path) {
+ return NULL;
+}
+
MockPluginDelegate::PlatformImage2D* MockPluginDelegate::CreateImage2D(
int width,
int height) {
diff --git a/webkit/plugins/ppapi/mock_plugin_delegate.h b/webkit/plugins/ppapi/mock_plugin_delegate.h
index e62ecc0..93d14a9 100644
--- a/webkit/plugins/ppapi/mock_plugin_delegate.h
+++ b/webkit/plugins/ppapi/mock_plugin_delegate.h
@@ -28,6 +28,7 @@ class MockPluginDelegate : public PluginDelegate {
virtual void InstanceCreated(PluginInstance* instance);
virtual void InstanceDeleted(PluginInstance* instance);
virtual SkBitmap* GetSadPluginBitmap();
+ virtual WebKit::WebPlugin* CreatePluginReplacement(const FilePath& file_path);
virtual PlatformImage2D* CreateImage2D(int width, int height);
virtual PlatformContext3D* CreateContext3D();
virtual PlatformVideoDecoder* CreateVideoDecoder(
diff --git a/webkit/plugins/ppapi/plugin_delegate.h b/webkit/plugins/ppapi/plugin_delegate.h
index 1514a96..96a9681 100644
--- a/webkit/plugins/ppapi/plugin_delegate.h
+++ b/webkit/plugins/ppapi/plugin_delegate.h
@@ -32,10 +32,10 @@
#include "webkit/quota/quota_types.h"
class GURL;
-struct PP_HostResolver_Private_Hint;
-struct PP_NetAddress_Private;
class SkBitmap;
class TransportDIB;
+struct PP_HostResolver_Private_Hint;
+struct PP_NetAddress_Private;
namespace base {
class MessageLoopProxy;
@@ -69,6 +69,7 @@ class PlatformCanvas;
namespace WebKit {
class WebFileChooserCompletion;
class WebGamepads;
+class WebPlugin;
struct WebCursorInfo;
struct WebFileChooserParams;
}
@@ -333,6 +334,11 @@ class PluginDelegate {
// sad plugin screen with. Returns NULL on failure.
virtual SkBitmap* GetSadPluginBitmap() = 0;
+ // Creates a replacement plug-in that is shown when the plug-in at |file_path|
+ // couldn't be loaded.
+ virtual WebKit::WebPlugin* CreatePluginReplacement(
+ const FilePath& file_path) = 0;
+
// The caller will own the pointer returned from this.
virtual PlatformImage2D* CreateImage2D(int width, int height) = 0;
diff --git a/webkit/plugins/ppapi/ppapi_webplugin_impl.cc b/webkit/plugins/ppapi/ppapi_webplugin_impl.cc
index fb01662..1c2fe51 100644
--- a/webkit/plugins/ppapi/ppapi_webplugin_impl.cc
+++ b/webkit/plugins/ppapi/ppapi_webplugin_impl.cc
@@ -27,6 +27,7 @@
using ppapi::NPObjectVar;
using WebKit::WebCanvas;
+using WebKit::WebPlugin;
using WebKit::WebPluginContainer;
using WebKit::WebPluginParams;
using WebKit::WebPoint;
@@ -84,7 +85,15 @@ bool WebPluginImpl::initialize(WebPluginContainer* container) {
if (!success) {
instance_->Delete();
instance_ = NULL;
- return false;
+
+ WebKit::WebPlugin* replacement_plugin =
+ init_data_->delegate->CreatePluginReplacement(
+ init_data_->module->path());
+ if (!replacement_plugin->initialize(container))
+ return false;
+
+ container->setPlugin(replacement_plugin);
+ return true;
}
init_data_.reset();
diff --git a/webkit/support/test_webplugin_page_delegate.cc b/webkit/support/test_webplugin_page_delegate.cc
index 0c54097..9ec4346 100644
--- a/webkit/support/test_webplugin_page_delegate.cc
+++ b/webkit/support/test_webplugin_page_delegate.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 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.
@@ -19,6 +19,11 @@ TestWebPluginPageDelegate::CreatePluginDelegate(
file_path, mime_type, 0);
}
+WebKit::WebPlugin* TestWebPluginPageDelegate::CreatePluginReplacement(
+ const FilePath& file_path) {
+ return NULL;
+}
+
WebKit::WebCookieJar* TestWebPluginPageDelegate::GetCookieJar() {
return WebKit::webKitPlatformSupport()->cookieJar();
}
diff --git a/webkit/support/test_webplugin_page_delegate.h b/webkit/support/test_webplugin_page_delegate.h
index 27d8ba3..3949af7 100644
--- a/webkit/support/test_webplugin_page_delegate.h
+++ b/webkit/support/test_webplugin_page_delegate.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 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.
@@ -20,6 +20,8 @@ class TestWebPluginPageDelegate : public webkit::npapi::WebPluginPageDelegate {
virtual webkit::npapi::WebPluginDelegate* CreatePluginDelegate(
const FilePath& file_path,
const std::string& mime_type) OVERRIDE;
+ virtual WebKit::WebPlugin* CreatePluginReplacement(
+ const FilePath& file_path) OVERRIDE;
virtual void CreatedPluginWindow(gfx::PluginWindowHandle handle) OVERRIDE {}
virtual void WillDestroyPluginWindow(
gfx::PluginWindowHandle handle) OVERRIDE {}
diff --git a/webkit/tools/test_shell/test_webview_delegate.cc b/webkit/tools/test_shell/test_webview_delegate.cc
index 9c5d4f9..70fae86 100644
--- a/webkit/tools/test_shell/test_webview_delegate.cc
+++ b/webkit/tools/test_shell/test_webview_delegate.cc
@@ -944,6 +944,11 @@ void TestWebViewDelegate::openFileSystem(
// WebPluginPageDelegate -----------------------------------------------------
+WebKit::WebPlugin* TestWebViewDelegate::CreatePluginReplacement(
+ const FilePath& file_path) {
+ return NULL;
+}
+
WebCookieJar* TestWebViewDelegate::GetCookieJar() {
return WebKit::webKitPlatformSupport()->cookieJar();
}
diff --git a/webkit/tools/test_shell/test_webview_delegate.h b/webkit/tools/test_shell/test_webview_delegate.h
index 8a87db3..435830a 100644
--- a/webkit/tools/test_shell/test_webview_delegate.h
+++ b/webkit/tools/test_shell/test_webview_delegate.h
@@ -241,6 +241,8 @@ class TestWebViewDelegate : public WebKit::WebViewClient,
virtual webkit::npapi::WebPluginDelegate* CreatePluginDelegate(
const FilePath& url,
const std::string& mime_type) OVERRIDE;
+ virtual WebKit::WebPlugin* CreatePluginReplacement(
+ const FilePath& file_path) OVERRIDE;
virtual void CreatedPluginWindow(
gfx::PluginWindowHandle handle) OVERRIDE;
virtual void WillDestroyPluginWindow(