diff options
Diffstat (limited to 'webkit/plugins/ppapi')
-rw-r--r-- | webkit/plugins/ppapi/mock_plugin_delegate.cc | 7 | ||||
-rw-r--r-- | webkit/plugins/ppapi/mock_plugin_delegate.h | 2 | ||||
-rw-r--r-- | webkit/plugins/ppapi/plugin_delegate.h | 10 | ||||
-rw-r--r-- | webkit/plugins/ppapi/plugin_module.cc | 2 | ||||
-rw-r--r-- | webkit/plugins/ppapi/plugin_module.h | 8 | ||||
-rw-r--r-- | webkit/plugins/ppapi/ppapi_plugin_instance.cc | 15 | ||||
-rw-r--r-- | webkit/plugins/ppapi/ppapi_plugin_instance.h | 3 | ||||
-rw-r--r-- | webkit/plugins/ppapi/ppapi_unittest.cc | 2 |
8 files changed, 45 insertions, 4 deletions
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(¤t_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; |