summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/common/pepper_plugin_registry.cc2
-rw-r--r--content/browser/plugin_service.cc2
-rw-r--r--content/browser/ppapi_plugin_process_host.cc8
-rw-r--r--content/browser/ppapi_plugin_process_host.h6
-rw-r--r--content/renderer/pepper_plugin_delegate_impl.cc11
-rw-r--r--content/renderer/pepper_plugin_delegate_impl.h2
-rw-r--r--content/renderer/webplugin_delegate_proxy.cc36
-rw-r--r--webkit/glue/webkit_glue.gypi2
-rw-r--r--webkit/plugins/ppapi/mock_plugin_delegate.cc7
-rw-r--r--webkit/plugins/ppapi/mock_plugin_delegate.h2
-rw-r--r--webkit/plugins/ppapi/plugin_delegate.h10
-rw-r--r--webkit/plugins/ppapi/plugin_module.cc2
-rw-r--r--webkit/plugins/ppapi/plugin_module.h8
-rw-r--r--webkit/plugins/ppapi/ppapi_plugin_instance.cc15
-rw-r--r--webkit/plugins/ppapi/ppapi_plugin_instance.h3
-rw-r--r--webkit/plugins/ppapi/ppapi_unittest.cc2
-rw-r--r--webkit/plugins/sad_plugin.cc49
-rw-r--r--webkit/plugins/sad_plugin.h26
18 files changed, 149 insertions, 44 deletions
diff --git a/chrome/common/pepper_plugin_registry.cc b/chrome/common/pepper_plugin_registry.cc
index ff312a2..e70933e 100644
--- a/chrome/common/pepper_plugin_registry.cc
+++ b/chrome/common/pepper_plugin_registry.cc
@@ -310,7 +310,7 @@ PepperPluginRegistry::PepperPluginRegistry() {
continue; // Out of process plugins need no special pre-initialization.
scoped_refptr<webkit::ppapi::PluginModule> module =
- new webkit::ppapi::PluginModule(current.name, this);
+ new webkit::ppapi::PluginModule(current.name, current.path, this);
AddLiveModule(current.path, module);
if (current.is_internal) {
if (!module->InitAsInternalPlugin(current.internal_entry_points)) {
diff --git a/content/browser/plugin_service.cc b/content/browser/plugin_service.cc
index b43774a..46230c1 100644
--- a/content/browser/plugin_service.cc
+++ b/content/browser/plugin_service.cc
@@ -281,7 +281,7 @@ PpapiPluginProcessHost* PluginService::FindOrStartPpapiPluginProcess(
// This plugin isn't loaded by any plugin process, so create a new process.
scoped_ptr<PpapiPluginProcessHost> new_host(new PpapiPluginProcessHost);
- if (!new_host->Init(plugin_path)) {
+ if (!new_host->Init(*info)) {
NOTREACHED(); // Init is not expected to fail.
return NULL;
}
diff --git a/content/browser/ppapi_plugin_process_host.cc b/content/browser/ppapi_plugin_process_host.cc
index def01b7d..a4505a9 100644
--- a/content/browser/ppapi_plugin_process_host.cc
+++ b/content/browser/ppapi_plugin_process_host.cc
@@ -7,7 +7,9 @@
#include "base/command_line.h"
#include "base/file_path.h"
#include "base/process_util.h"
+#include "base/utf_string_conversions.h"
#include "chrome/common/chrome_switches.h"
+#include "chrome/common/pepper_plugin_registry.h"
#include "chrome/common/render_messages.h"
#include "content/browser/plugin_service.h"
#include "content/browser/renderer_host/render_message_filter.h"
@@ -24,8 +26,10 @@ PpapiPluginProcessHost::~PpapiPluginProcessHost() {
CancelRequests();
}
-bool PpapiPluginProcessHost::Init(const FilePath& path) {
- plugin_path_ = path;
+bool PpapiPluginProcessHost::Init(const PepperPluginInfo& info) {
+ plugin_path_ = info.path;
+ set_name(UTF8ToWide(info.name));
+ set_version(UTF8ToWide(info.version));
if (!CreateChannel())
return false;
diff --git a/content/browser/ppapi_plugin_process_host.h b/content/browser/ppapi_plugin_process_host.h
index baeaf3b..aa6bc47 100644
--- a/content/browser/ppapi_plugin_process_host.h
+++ b/content/browser/ppapi_plugin_process_host.h
@@ -12,6 +12,8 @@
#include "base/file_path.h"
#include "content/browser/browser_child_process_host.h"
+struct PepperPluginInfo;
+
class PpapiPluginProcessHost : public BrowserChildProcessHost {
public:
class Client {
@@ -32,9 +34,9 @@ class PpapiPluginProcessHost : public BrowserChildProcessHost {
explicit PpapiPluginProcessHost();
virtual ~PpapiPluginProcessHost();
- // Actually launches the process with the given plugin path. Returns true
+ // Actually launches the process with the given plugin info. Returns true
// on success (the process was spawned).
- bool Init(const FilePath& path);
+ bool Init(const PepperPluginInfo& info);
// Opens a new channel to the plugin. The client will be notified when the
// channel is ready or if there's an error.
diff --git a/content/renderer/pepper_plugin_delegate_impl.cc b/content/renderer/pepper_plugin_delegate_impl.cc
index 2a916a6..2acad4d 100644
--- a/content/renderer/pepper_plugin_delegate_impl.cc
+++ b/content/renderer/pepper_plugin_delegate_impl.cc
@@ -454,7 +454,7 @@ PepperPluginDelegateImpl::CreatePepperPlugin(const FilePath& path) {
// Create a new HostDispatcher for the proxying, and hook it to a new
// PluginModule. Note that AddLiveModule must be called before any early
// returns since the module's destructor will remove itself.
- module = new webkit::ppapi::PluginModule(info->name,
+ module = new webkit::ppapi::PluginModule(info->name, path,
PepperPluginRegistry::GetInstance());
PepperPluginRegistry::GetInstance()->AddLiveModule(path, module);
scoped_ptr<DispatcherWrapper> dispatcher(new DispatcherWrapper);
@@ -523,6 +523,11 @@ PepperPluginDelegateImpl::GetBitmapForOptimizedPluginPaint(
return NULL;
}
+void PepperPluginDelegateImpl::PluginCrashed(
+ webkit::ppapi::PluginInstance* instance) {
+ render_view_->PluginCrashed(instance->module()->path());
+}
+
void PepperPluginDelegateImpl::InstanceCreated(
webkit::ppapi::PluginInstance* instance) {
active_instances_.insert(instance);
@@ -536,6 +541,10 @@ void PepperPluginDelegateImpl::InstanceDeleted(
active_instances_.erase(instance);
}
+SkBitmap* PepperPluginDelegateImpl::GetSadPluginBitmap() {
+ return content::GetContentClient()->renderer()->GetSadPluginBitmap();
+}
+
webkit::ppapi::PluginDelegate::PlatformImage2D*
PepperPluginDelegateImpl::CreateImage2D(int width, int height) {
uint32 buffer_size = width * height * 4;
diff --git a/content/renderer/pepper_plugin_delegate_impl.h b/content/renderer/pepper_plugin_delegate_impl.h
index 5def533..274bbf1 100644
--- a/content/renderer/pepper_plugin_delegate_impl.h
+++ b/content/renderer/pepper_plugin_delegate_impl.h
@@ -76,10 +76,12 @@ class PepperPluginDelegateImpl
void OnSetFocus(bool has_focus);
// PluginDelegate implementation.
+ virtual void PluginCrashed(webkit::ppapi::PluginInstance* instance);
virtual void InstanceCreated(
webkit::ppapi::PluginInstance* instance);
virtual void InstanceDeleted(
webkit::ppapi::PluginInstance* instance);
+ virtual SkBitmap* GetSadPluginBitmap();
virtual PlatformAudio* CreateAudio(
uint32_t sample_rate,
uint32_t sample_count,
diff --git a/content/renderer/webplugin_delegate_proxy.cc b/content/renderer/webplugin_delegate_proxy.cc
index 1571295..35b171f8 100644
--- a/content/renderer/webplugin_delegate_proxy.cc
+++ b/content/renderer/webplugin_delegate_proxy.cc
@@ -45,6 +45,7 @@
#include "ui/gfx/native_widget_types.h"
#include "ui/gfx/size.h"
#include "webkit/plugins/npapi/webplugin.h"
+#include "webkit/plugins/sad_plugin.h"
#include "webkit/glue/webkit_glue.h"
#if defined(OS_POSIX)
@@ -1152,39 +1153,8 @@ void WebPluginDelegateProxy::PaintSadPlugin(WebKit::WebCanvas* native_context,
// Lazily load the sad plugin image.
if (!sad_plugin_)
sad_plugin_ = content::GetContentClient()->renderer()->GetSadPluginBitmap();
-
- if (!sad_plugin_)
- return;
-
- // Make a temporary canvas for the background image.
- const int width = plugin_rect_.width();
- const int height = plugin_rect_.height();
- gfx::CanvasSkia canvas(width, height, false);
-#if defined(OS_MACOSX)
- // Flip the canvas, since the context expects flipped data.
- canvas.translate(0, height);
- canvas.scale(1, -1);
-#endif
- SkPaint paint;
-
- paint.setStyle(SkPaint::kFill_Style);
- paint.setColor(SK_ColorBLACK);
- canvas.drawRectCoords(0, 0, SkIntToScalar(width), SkIntToScalar(height),
- paint);
- canvas.DrawBitmapInt(*sad_plugin_,
- std::max(0, (width - sad_plugin_->width())/2),
- std::max(0, (height - sad_plugin_->height())/2));
-
- // It's slightly less code to make a big SkBitmap of the sad tab image and
- // then copy that to the screen than to use the native APIs. The small speed
- // penalty is not important when drawing crashed plugins.
-#if WEBKIT_USING_SKIA
- gfx::NativeDrawingContext context = native_context->beginPlatformPaint();
- BlitCanvasToContext(context, plugin_rect_, &canvas, gfx::Point(0, 0));
- native_context->endPlatformPaint();
-#elif WEBKIT_USING_CG
- BlitCanvasToContext(native_context, plugin_rect_, &canvas, gfx::Point(0, 0));
-#endif
+ if (sad_plugin_)
+ webkit::PaintSadPlugin(native_context, plugin_rect_, *sad_plugin_);
}
void WebPluginDelegateProxy::CopyFromTransportToBacking(const gfx::Rect& rect) {
diff --git a/webkit/glue/webkit_glue.gypi b/webkit/glue/webkit_glue.gypi
index 8c87826..9a4117a 100644
--- a/webkit/glue/webkit_glue.gypi
+++ b/webkit/glue/webkit_glue.gypi
@@ -356,6 +356,8 @@
'../plugins/ppapi/var.h',
'../plugins/ppapi/var_object_class.cc',
'../plugins/ppapi/var_object_class.h',
+ '../plugins/sad_plugin.cc',
+ '../plugins/sad_plugin.h',
'media/audio_decoder.cc',
'media/audio_decoder.h',
'media/buffered_data_source.cc',
diff --git a/webkit/plugins/ppapi/mock_plugin_delegate.cc b/webkit/plugins/ppapi/mock_plugin_delegate.cc
index 930b681..77b66ac 100644
--- a/webkit/plugins/ppapi/mock_plugin_delegate.cc
+++ b/webkit/plugins/ppapi/mock_plugin_delegate.cc
@@ -16,12 +16,19 @@ MockPluginDelegate::MockPluginDelegate() {
MockPluginDelegate::~MockPluginDelegate() {
}
+void MockPluginDelegate::PluginCrashed(PluginInstance* instance) {
+}
+
void MockPluginDelegate::InstanceCreated(PluginInstance* instance) {
}
void MockPluginDelegate::InstanceDeleted(PluginInstance* instance) {
}
+SkBitmap* MockPluginDelegate::GetSadPluginBitmap() {
+ 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 7980918..9a4113f 100644
--- a/webkit/plugins/ppapi/mock_plugin_delegate.h
+++ b/webkit/plugins/ppapi/mock_plugin_delegate.h
@@ -15,8 +15,10 @@ class MockPluginDelegate : public PluginDelegate {
MockPluginDelegate();
~MockPluginDelegate();
+ virtual void PluginCrashed(PluginInstance* instance);
virtual void InstanceCreated(PluginInstance* instance);
virtual void InstanceDeleted(PluginInstance* instance);
+ virtual SkBitmap* GetSadPluginBitmap();
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 1effed1..e2b3759 100644
--- a/webkit/plugins/ppapi/plugin_delegate.h
+++ b/webkit/plugins/ppapi/plugin_delegate.h
@@ -24,6 +24,7 @@
class AudioMessageFilter;
class GURL;
class P2PSocketDispatcher;
+class SkBitmap;
namespace base {
class MessageLoopProxy;
@@ -208,6 +209,11 @@ class PluginDelegate {
PP_VideoUncompressedDataBuffer_Dev& buffer) = 0;
};
+ // Notification that the given plugin has crashed. When a plugin crashes, all
+ // instances associated with that plugin will notify that they've crashed via
+ // this function.
+ virtual void PluginCrashed(PluginInstance* instance) = 0;
+
// Indicates that the given instance has been created.
virtual void InstanceCreated(PluginInstance* instance) = 0;
@@ -216,6 +222,10 @@ class PluginDelegate {
// from this call.
virtual void InstanceDeleted(PluginInstance* instance) = 0;
+ // Returns a pointer (ownership not transferred) to the bitmap to paint the
+ // sad plugin screen with. Returns NULL on failure.
+ virtual SkBitmap* GetSadPluginBitmap() = 0;
+
// The caller will own the pointer returned from this.
virtual PlatformImage2D* CreateImage2D(int width, int height) = 0;
diff --git a/webkit/plugins/ppapi/plugin_module.cc b/webkit/plugins/ppapi/plugin_module.cc
index 02d1276..638f113 100644
--- a/webkit/plugins/ppapi/plugin_module.cc
+++ b/webkit/plugins/ppapi/plugin_module.cc
@@ -381,12 +381,14 @@ PluginModule::EntryPoints::EntryPoints()
// PluginModule ----------------------------------------------------------------
PluginModule::PluginModule(const std::string& name,
+ const FilePath& path,
PluginDelegate::ModuleLifetime* lifetime_delegate)
: lifetime_delegate_(lifetime_delegate),
callback_tracker_(new CallbackTracker),
is_crashed_(false),
library_(NULL),
name_(name),
+ path_(path),
reserve_instance_id_(NULL) {
pp_module_ = ResourceTracker::Get()->AddModule(this);
GetMainThreadMessageLoop(); // Initialize the main thread message loop.
diff --git a/webkit/plugins/ppapi/plugin_module.h b/webkit/plugins/ppapi/plugin_module.h
index 45545c9..6107430 100644
--- a/webkit/plugins/ppapi/plugin_module.h
+++ b/webkit/plugins/ppapi/plugin_module.h
@@ -10,6 +10,7 @@
#include <string>
#include "base/basictypes.h"
+#include "base/file_path.h"
#include "base/native_library.h"
#include "base/process.h"
#include "base/ref_counted.h"
@@ -75,6 +76,7 @@ class PluginModule : public base::RefCounted<PluginModule>,
// all plugin modules. In practice it will be a global singleton that
// tracks which modules are alive.
PluginModule(const std::string& name,
+ const FilePath& path,
PluginDelegate::ModuleLifetime* lifetime_delegate);
~PluginModule();
@@ -103,6 +105,7 @@ class PluginModule : public base::RefCounted<PluginModule>,
PP_Module pp_module() const { return pp_module_; }
const std::string& name() const { return name_; }
+ const FilePath& path() const { return path_; }
PluginInstance* CreateInstance(PluginDelegate* delegate);
@@ -128,6 +131,8 @@ class PluginModule : public base::RefCounted<PluginModule>,
// release relevant resources and update all affected instances.
void PluginCrashed();
+ bool is_crashed() const { return is_crashed_; }
+
// Reserves the given instance is unique within the plugin, checking for
// collisions. See PPB_Proxy_Private for more information.
//
@@ -173,8 +178,9 @@ class PluginModule : public base::RefCounted<PluginModule>,
// presence of the out_of_process_proxy_ value.
EntryPoints entry_points_;
- // The name of the module.
+ // The name and file location of the module.
const std::string name_;
+ const FilePath path_;
// Non-owning pointers to all instances associated with this module. When
// there are no more instances, this object should be deleted.
diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.cc b/webkit/plugins/ppapi/ppapi_plugin_instance.cc
index 1b4d0be..fd234bf 100644
--- a/webkit/plugins/ppapi/ppapi_plugin_instance.cc
+++ b/webkit/plugins/ppapi/ppapi_plugin_instance.cc
@@ -53,6 +53,7 @@
#include "webkit/plugins/ppapi/ppp_pdf.h"
#include "webkit/plugins/ppapi/string.h"
#include "webkit/plugins/ppapi/var.h"
+#include "webkit/plugins/sad_plugin.h"
#if defined(OS_POSIX)
#include "printing/native_metafile.h"
@@ -335,7 +336,8 @@ PluginInstance::PluginInstance(PluginDelegate* delegate,
plugin_graphics_3d_interface_(NULL),
always_on_top_(false),
fullscreen_container_(NULL),
- fullscreen_(false) {
+ fullscreen_(false),
+ sad_plugin_(NULL) {
pp_instance_ = ResourceTracker::Get()->AddInstance(this);
memset(&current_print_settings_, 0, sizeof(current_print_settings_));
@@ -394,6 +396,15 @@ const PPB_Zoom_Dev* PluginInstance::GetZoomInterface() {
void PluginInstance::Paint(WebCanvas* canvas,
const gfx::Rect& plugin_rect,
const gfx::Rect& paint_rect) {
+ if (module()->is_crashed()) {
+ // Crashed plugin painting.
+ if (!sad_plugin_) // Lazily initialize bitmap.
+ sad_plugin_ = delegate_->GetSadPluginBitmap();
+ if (sad_plugin_)
+ webkit::PaintSadPlugin(canvas, plugin_rect, *sad_plugin_);
+ return;
+ }
+
if (bound_graphics_2d())
bound_graphics_2d()->Paint(canvas, plugin_rect, paint_rect);
}
@@ -451,7 +462,7 @@ void PluginInstance::InstanceCrashed() {
bound_graphics_ = NULL;
InvalidateRect(gfx::Rect());
- // TODO(brettw) show a crashed plugin screen.
+ delegate()->PluginCrashed(this);
}
PP_Var PluginInstance::GetWindowObject() {
diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.h b/webkit/plugins/ppapi/ppapi_plugin_instance.h
index b847c36..a8bba47 100644
--- a/webkit/plugins/ppapi/ppapi_plugin_instance.h
+++ b/webkit/plugins/ppapi/ppapi_plugin_instance.h
@@ -363,6 +363,9 @@ class PluginInstance : public base::RefCounted<PluginInstance> {
// True if we are in fullscreen mode. Note: it is false during the transition.
bool fullscreen_;
+ // Bitmap for crashed plugin. Lazily initialized, non-owning pointer.
+ SkBitmap* sad_plugin_;
+
typedef std::set<PluginObject*> PluginObjectSet;
PluginObjectSet live_plugin_objects_;
diff --git a/webkit/plugins/ppapi/ppapi_unittest.cc b/webkit/plugins/ppapi/ppapi_unittest.cc
index 56464e6..b5e4b5f 100644
--- a/webkit/plugins/ppapi/ppapi_unittest.cc
+++ b/webkit/plugins/ppapi/ppapi_unittest.cc
@@ -87,7 +87,7 @@ void PpapiUnittest::SetUp() {
delegate_.reset(new MockPluginDelegate);
// Initialize the mock module.
- module_ = new PluginModule("Mock plugin", this);
+ module_ = new PluginModule("Mock plugin", FilePath(), this);
PluginModule::EntryPoints entry_points;
entry_points.get_interface = &MockGetInterface;
entry_points.initialize_module = &MockInitializeModule;
diff --git a/webkit/plugins/sad_plugin.cc b/webkit/plugins/sad_plugin.cc
new file mode 100644
index 0000000..7512b4b
--- /dev/null
+++ b/webkit/plugins/sad_plugin.cc
@@ -0,0 +1,49 @@
+// 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 "webkit/plugins/sad_plugin.h"
+
+#include "third_party/skia/include/core/SkPaint.h"
+#include "third_party/skia/include/core/SkScalar.h"
+#include "ui/gfx/blit.h"
+#include "ui/gfx/canvas_skia.h"
+#include "ui/gfx/rect.h"
+
+namespace webkit {
+
+void PaintSadPlugin(WebKit::WebCanvas* webcanvas,
+ const gfx::Rect& plugin_rect,
+ const SkBitmap& sad_plugin_bitmap) {
+ // Make a temporary canvas for the background image.
+ const int width = plugin_rect.width();
+ const int height = plugin_rect.height();
+ gfx::CanvasSkia canvas(width, height, false);
+#if defined(OS_MACOSX)
+ // Flip the canvas, since the context expects flipped data.
+ canvas.translate(0, height);
+ canvas.scale(1, -1);
+#endif
+ SkPaint paint;
+
+ paint.setStyle(SkPaint::kFill_Style);
+ paint.setColor(SK_ColorBLACK);
+ canvas.drawRectCoords(0, 0, SkIntToScalar(width), SkIntToScalar(height),
+ paint);
+ canvas.DrawBitmapInt(sad_plugin_bitmap,
+ std::max(0, (width - sad_plugin_bitmap.width()) / 2),
+ std::max(0, (height - sad_plugin_bitmap.height()) / 2));
+
+ // It's slightly less code to make a big SkBitmap of the sad tab image and
+ // then copy that to the screen than to use the native APIs. The small speed
+ // penalty is not important when drawing crashed plugins.
+#if WEBKIT_USING_SKIA
+ gfx::NativeDrawingContext context = webcanvas->beginPlatformPaint();
+ BlitCanvasToContext(context, plugin_rect, &canvas, gfx::Point(0, 0));
+ webcanvas->endPlatformPaint();
+#elif WEBKIT_USING_CG
+ BlitCanvasToContext(webcanvas, plugin_rect, &canvas, gfx::Point(0, 0));
+#endif
+}
+
+} // namespace webkit
diff --git a/webkit/plugins/sad_plugin.h b/webkit/plugins/sad_plugin.h
new file mode 100644
index 0000000..63b0d7f
--- /dev/null
+++ b/webkit/plugins/sad_plugin.h
@@ -0,0 +1,26 @@
+// 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 WEBKIT_PLUGINS_SAD_PLUGIN_H_
+#define WEBKIT_PLUGINS_SAD_PLUGIN_H_
+
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebCanvas.h"
+
+class SkBitmap;
+
+namespace gfx {
+class Rect;
+}
+
+namespace webkit {
+
+// Paints the sad plugin to the given canvas for the given plugin bounds. This
+// is used by both the NPAPI and the PPAPI out-of-process plugin impls.
+void PaintSadPlugin(WebKit::WebCanvas* canvas,
+ const gfx::Rect& plugin_rect,
+ const SkBitmap& sad_plugin_bitmap);
+
+} // namespace
+
+#endif // WEBKIT_PLUGINS_SAD_PLUGIN_H_