diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-08 20:28:43 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-08 20:28:43 +0000 |
commit | 33ec505631bcc1cc6709248b97b468fbdf3d5f0a (patch) | |
tree | 4963e5e21af0f8173c5b6353c34209993b5da852 /ppapi/shared_impl | |
parent | 41c3696d8ebb37c0b2e0afd0361f0b40bc369483 (diff) | |
download | chromium_src-33ec505631bcc1cc6709248b97b468fbdf3d5f0a.zip chromium_src-33ec505631bcc1cc6709248b97b468fbdf3d5f0a.tar.gz chromium_src-33ec505631bcc1cc6709248b97b468fbdf3d5f0a.tar.bz2 |
Add new MouseCursor interface for setting the mouse cursor.
Remove most of the old cursor control interface. This keeps backwards compat for CursorControl.SetCursor (which just redirects to the new function) to kepe existing users running. None of the other functions on cursor control were implemented, so I removed all the proxying and stuff for them.
BUG=
TEST=
Review URL: https://chromiumcodereview.appspot.com/9814015
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@131314 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/shared_impl')
-rw-r--r-- | ppapi/shared_impl/ppb_instance_shared.cc | 43 | ||||
-rw-r--r-- | ppapi/shared_impl/ppb_instance_shared.h | 4 |
2 files changed, 47 insertions, 0 deletions
diff --git a/ppapi/shared_impl/ppb_instance_shared.cc b/ppapi/shared_impl/ppb_instance_shared.cc index 7e931c3..255a92e 100644 --- a/ppapi/shared_impl/ppb_instance_shared.cc +++ b/ppapi/shared_impl/ppb_instance_shared.cc @@ -9,7 +9,10 @@ #include "ppapi/c/pp_errors.h" #include "ppapi/c/ppb_input_event.h" #include "ppapi/shared_impl/ppapi_globals.h" +#include "ppapi/shared_impl/ppb_image_data_shared.h" #include "ppapi/shared_impl/var.h" +#include "ppapi/thunk/enter.h" +#include "ppapi/thunk/ppb_image_data_api.h" namespace ppapi { @@ -52,4 +55,44 @@ int32_t PPB_Instance_Shared::ValidateRequestInputEvents( return PP_OK; } +bool PPB_Instance_Shared::ValidateSetCursorParams(PP_MouseCursor_Type type, + PP_Resource image,
+ const PP_Point* hot_spot) {
+ if (static_cast<int>(type) < static_cast<int>(PP_MOUSECURSOR_TYPE_CUSTOM) || + static_cast<int>(type) > static_cast<int>(PP_MOUSECURSOR_TYPE_GRABBING)) + return false; // Cursor type out of range. + if (type != PP_MOUSECURSOR_TYPE_CUSTOM) { + // The image must not be specified if the type isn't custom. However, we + // don't require that the hot spot be null since the C++ wrappers and proxy + // pass the point by reference and it will normally be specified. + return image == 0; + } + + if (!hot_spot) + return false; // Hot spot must be specified for custom cursor. + + thunk::EnterResourceNoLock<thunk::PPB_ImageData_API> enter(image, true); + if (enter.failed()) + return false; // Invalid image resource. + + // Validate the image size. A giant cursor can arbitrarily overwrite parts + // of the screen resulting in potential spoofing attacks. So we force the + // cursor to be a reasonably-sized image. + PP_ImageDataDesc desc; + if (!PP_ToBool(enter.object()->Describe(&desc))) + return false; + if (desc.size.width > 32 || desc.size.height > 32) + return false; + + // Validate image format. + if (desc.format != PPB_ImageData_Shared::GetNativeImageDataFormat()) + return false; + + // Validate the hot spot location. + if (hot_spot->x < 0 || hot_spot->x >= desc.size.width || + hot_spot->y < 0 || hot_spot->y >= desc.size.height) + return false; + return true; +} + } // namespace ppapi diff --git a/ppapi/shared_impl/ppb_instance_shared.h b/ppapi/shared_impl/ppb_instance_shared.h index 2842160..8260a78 100644 --- a/ppapi/shared_impl/ppb_instance_shared.h +++ b/ppapi/shared_impl/ppb_instance_shared.h @@ -29,6 +29,10 @@ class PPAPI_SHARED_EXPORT PPB_Instance_Shared // Error checks the given resquest to Request[Filtering]InputEvents. Returns // PP_OK if the given classes are all valid, PP_ERROR_NOTSUPPORTED if not. int32_t ValidateRequestInputEvents(bool is_filtering, uint32_t event_classes); + + bool ValidateSetCursorParams(PP_MouseCursor_Type type, + PP_Resource image,
+ const PP_Point* hot_spot);
}; } // namespace ppapi |