diff options
author | yzshen@chromium.org <yzshen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-08 16:56:34 +0000 |
---|---|---|
committer | yzshen@chromium.org <yzshen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-08 16:56:34 +0000 |
commit | 18d871ff3cc3d59c58d479dbe82373a1f0a232b5 (patch) | |
tree | 30eea5317dcfea1cc965792c1e9691767b30f485 /webkit | |
parent | 25bd71ae5f7770990ac30c5ad5ca8745a952e1c0 (diff) | |
download | chromium_src-18d871ff3cc3d59c58d479dbe82373a1f0a232b5.zip chromium_src-18d871ff3cc3d59c58d479dbe82373a1f0a232b5.tar.gz chromium_src-18d871ff3cc3d59c58d479dbe82373a1f0a232b5.tar.bz2 |
Introduce a new Pepper interface: PPB/PPP_MouseLock.
BUG=None
TEST=None
Review URL: http://codereview.chromium.org/7828019
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@100166 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/plugins/ppapi/plugin_module.cc | 3 | ||||
-rw-r--r-- | webkit/plugins/ppapi/ppapi_plugin_instance.cc | 57 | ||||
-rw-r--r-- | webkit/plugins/ppapi/ppapi_plugin_instance.h | 12 |
3 files changed, 71 insertions, 1 deletions
diff --git a/webkit/plugins/ppapi/plugin_module.cc b/webkit/plugins/ppapi/plugin_module.cc index 8bee4b2..aa20704 100644 --- a/webkit/plugins/ppapi/plugin_module.cc +++ b/webkit/plugins/ppapi/plugin_module.cc @@ -27,6 +27,7 @@ #include "ppapi/c/dev/ppb_gles_chromium_texture_mapping_dev.h" #include "ppapi/c/dev/ppb_layer_compositor_dev.h" #include "ppapi/c/dev/ppb_memory_dev.h" +#include "ppapi/c/dev/ppb_mouse_lock_dev.h" #include "ppapi/c/dev/ppb_query_policy_dev.h" #include "ppapi/c/dev/ppb_scrollbar_dev.h" #include "ppapi/c/dev/ppb_surface_3d_dev.h" @@ -305,6 +306,8 @@ const void* GetInterface(const char* name) { return ::ppapi::thunk::GetPPB_MouseInputEvent_1_0_Thunk(); if (strcmp(name, PPB_MOUSE_INPUT_EVENT_INTERFACE_1_1) == 0) return ::ppapi::thunk::GetPPB_MouseInputEvent_1_1_Thunk(); + if (strcmp(name, PPB_MOUSELOCK_DEV_INTERFACE) == 0) + return ::ppapi::thunk::GetPPB_MouseLock_Thunk(); if (strcmp(name, PPB_PROXY_PRIVATE_INTERFACE) == 0) return PPB_Proxy_Impl::GetInterface(); if (strcmp(name, PPB_QUERY_POLICY_DEV_INTERFACE_0_1) == 0) diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.cc b/webkit/plugins/ppapi/ppapi_plugin_instance.cc index a896e06..b18df2c 100644 --- a/webkit/plugins/ppapi/ppapi_plugin_instance.cc +++ b/webkit/plugins/ppapi/ppapi_plugin_instance.cc @@ -14,6 +14,7 @@ #include "ppapi/c/dev/ppb_memory_dev.h" #include "ppapi/c/dev/ppb_zoom_dev.h" #include "ppapi/c/dev/ppp_find_dev.h" +#include "ppapi/c/dev/ppp_mouse_lock_dev.h" #include "ppapi/c/dev/ppp_policy_update_dev.h" #include "ppapi/c/dev/ppp_selection_dev.h" #include "ppapi/c/dev/ppp_zoom_dev.h" @@ -223,6 +224,7 @@ PluginInstance::PluginInstance( find_identifier_(-1), plugin_find_interface_(NULL), plugin_messaging_interface_(NULL), + plugin_mouse_lock_interface_(NULL), plugin_input_event_interface_(NULL), plugin_private_interface_(NULL), plugin_pdf_interface_(NULL), @@ -239,7 +241,8 @@ PluginInstance::PluginInstance( message_channel_(NULL), sad_plugin_(NULL), input_event_mask_(0), - filtered_input_event_mask_(0) { + filtered_input_event_mask_(0), + lock_mouse_callback_(PP_BlockUntilComplete()) { pp_instance_ = ResourceTracker::Get()->AddInstance(this); memset(¤t_print_settings_, 0, sizeof(current_print_settings_)); @@ -261,6 +264,9 @@ PluginInstance::~PluginInstance() { i != plugin_object_copy.end(); ++i) delete *i; + if (lock_mouse_callback_.func) + PP_RunAndClearCompletionCallback(&lock_mouse_callback_, PP_ERROR_ABORTED); + delegate_->InstanceDeleted(this); module_->InstanceDeleted(this); @@ -709,6 +715,16 @@ bool PluginInstance::LoadMessagingInterface() { return !!plugin_messaging_interface_; } +bool PluginInstance::LoadMouseLockInterface() { + if (!plugin_mouse_lock_interface_) { + plugin_mouse_lock_interface_ = + static_cast<const PPP_MouseLock_Dev*>(module_->GetPluginInterface( + PPP_MOUSELOCK_DEV_INTERFACE)); + } + + return !!plugin_mouse_lock_interface_; +} + bool PluginInstance::LoadPdfInterface() { if (!plugin_pdf_interface_) { plugin_pdf_interface_ = @@ -1272,6 +1288,20 @@ bool PluginInstance::IsFullPagePlugin() const { return frame->view()->mainFrame()->document().isPluginDocument(); } +void PluginInstance::OnLockMouseACK(int32_t result) { + if (!lock_mouse_callback_.func) { + NOTREACHED(); + return; + } + + PP_RunAndClearCompletionCallback(&lock_mouse_callback_, result); +} + +void PluginInstance::OnMouseLockLost() { + if (LoadMouseLockInterface()) + plugin_mouse_lock_interface_->MouseLockLost(pp_instance()); +} + PPB_Instance_FunctionAPI* PluginInstance::AsPPB_Instance_FunctionAPI() { return this; } @@ -1481,6 +1511,31 @@ void PluginInstance::PostMessage(PP_Instance instance, PP_Var message) { message_channel_->PostMessageToJavaScript(message); } +int32_t PluginInstance::LockMouse(PP_Instance instance, + PP_CompletionCallback callback) { + if (!callback.func) { + // Don't support synchronous call. + return PP_ERROR_BADARGUMENT; + } + if (lock_mouse_callback_.func) + return PP_ERROR_INPROGRESS; + + // TODO(yzshen): Uncomment the following lines after adding implementation in + // the delegate. + // lock_mouse_callback_ = callback; + // We will be notified on completion via OnLockMouseACK(), either + // synchronously or asynchronously. + // delegate()->LockMouse(this); + // return PP_OK_COMPLETIONPENDING; + return PP_ERROR_FAILED; +} + +void PluginInstance::UnlockMouse(PP_Instance instance) { + // TODO(yzshen): Uncomment the following after adding implementation in the + // delegate. + // delegate()->UnlockMouse(this); +} + void PluginInstance::SubscribeToPolicyUpdates(PP_Instance instance) { delegate()->SubscribeToPolicyUpdates(this); } diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.h b/webkit/plugins/ppapi/ppapi_plugin_instance.h index 4857bdf..48f9019 100644 --- a/webkit/plugins/ppapi/ppapi_plugin_instance.h +++ b/webkit/plugins/ppapi/ppapi_plugin_instance.h @@ -18,6 +18,7 @@ #include "googleurl/src/gurl.h" #include "ppapi/c/dev/pp_cursor_type_dev.h" #include "ppapi/c/dev/ppp_printing_dev.h" +#include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_var.h" @@ -38,6 +39,7 @@ struct PPP_Find_Dev; struct PPP_InputEvent; struct PPP_Instance_Private; struct PPP_Messaging; +struct PPP_MouseLock_Dev; struct PPP_Pdf; struct PPP_PolicyUpdate_Dev; struct PPP_Selection_Dev; @@ -246,6 +248,9 @@ class PluginInstance : public base::RefCounted<PluginInstance>, return fullscreen_container_; } + void OnLockMouseACK(int32_t result); + void OnMouseLockLost(); + // FunctionGroupBase overrides. virtual ::ppapi::thunk::PPB_Instance_FunctionAPI* AsPPB_Instance_FunctionAPI() OVERRIDE; @@ -274,6 +279,9 @@ class PluginInstance : public base::RefCounted<PluginInstance>, double minimum_factor, double maximium_factor) OVERRIDE; virtual void PostMessage(PP_Instance instance, PP_Var message) OVERRIDE; + virtual int32_t LockMouse(PP_Instance instance, + PP_CompletionCallback callback) OVERRIDE; + virtual void UnlockMouse(PP_Instance instance) OVERRIDE; virtual void SubscribeToPolicyUpdates(PP_Instance instance) OVERRIDE; private: @@ -288,6 +296,7 @@ class PluginInstance : public base::RefCounted<PluginInstance>, bool LoadFindInterface(); bool LoadInputEventInterface(); bool LoadMessagingInterface(); + bool LoadMouseLockInterface(); bool LoadPdfInterface(); bool LoadPolicyUpdateInterface(); bool LoadPrintInterface(); @@ -392,6 +401,7 @@ class PluginInstance : public base::RefCounted<PluginInstance>, // The plugin-provided interfaces. const PPP_Find_Dev* plugin_find_interface_; const PPP_Messaging* plugin_messaging_interface_; + const PPP_MouseLock_Dev* plugin_mouse_lock_interface_; const PPP_InputEvent* plugin_input_event_interface_; const PPP_Instance_Private* plugin_private_interface_; const PPP_Pdf* plugin_pdf_interface_; @@ -464,6 +474,8 @@ class PluginInstance : public base::RefCounted<PluginInstance>, uint32_t input_event_mask_; uint32_t filtered_input_event_mask_; + PP_CompletionCallback lock_mouse_callback_; + DISALLOW_COPY_AND_ASSIGN(PluginInstance); }; |