diff options
author | viettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-19 16:59:20 +0000 |
---|---|---|
committer | viettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-19 16:59:20 +0000 |
commit | e55b88a050a41eb515a56ee086472b8631f50ad7 (patch) | |
tree | 4a486632d787fb23d00e464d2f8a7b6c66f96e10 /ppapi | |
parent | 8b7576347ef991a7e144947638b51d286099273e (diff) | |
download | chromium_src-e55b88a050a41eb515a56ee086472b8631f50ad7.zip chromium_src-e55b88a050a41eb515a56ee086472b8631f50ad7.tar.gz chromium_src-e55b88a050a41eb515a56ee086472b8631f50ad7.tar.bz2 |
PPAPI: Add a (trivial) C++ wrapper for PPB_CursorControl_Dev.
Review URL: https://codereview.chromium.org/11183075
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@163009 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rw-r--r-- | ppapi/cpp/dev/cursor_control_dev.cc | 67 | ||||
-rw-r--r-- | ppapi/cpp/dev/cursor_control_dev.h | 36 | ||||
-rw-r--r-- | ppapi/ppapi_sources.gypi | 2 |
3 files changed, 105 insertions, 0 deletions
diff --git a/ppapi/cpp/dev/cursor_control_dev.cc b/ppapi/cpp/dev/cursor_control_dev.cc new file mode 100644 index 0000000..6df0107 --- /dev/null +++ b/ppapi/cpp/dev/cursor_control_dev.cc @@ -0,0 +1,67 @@ +// 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. + +#include "ppapi/cpp/dev/cursor_control_dev.h" + +#include "ppapi/cpp/image_data.h" +#include "ppapi/cpp/instance_handle.h" +#include "ppapi/cpp/module.h" +#include "ppapi/cpp/module_impl.h" +#include "ppapi/cpp/point.h" + +namespace pp { + +namespace { + +template <> const char* interface_name<PPB_CursorControl_Dev_0_4>() { + return PPB_CURSOR_CONTROL_DEV_INTERFACE_0_4; +} + +} // namespace + +bool CursorControl_Dev::SetCursor(const InstanceHandle& instance, + PP_CursorType_Dev type, + const ImageData& custom_image, + const Point& hot_spot) { + if (has_interface<PPB_CursorControl_Dev_0_4>()) { + return PP_ToBool(get_interface<PPB_CursorControl_Dev_0_4>()->SetCursor( + instance.pp_instance(), type, custom_image.pp_resource(), + &hot_spot.pp_point())); + } + return false; +} + +bool LockCursor(const InstanceHandle& instance) { + if (has_interface<PPB_CursorControl_Dev_0_4>()) { + return PP_ToBool(get_interface<PPB_CursorControl_Dev_0_4>()->LockCursor( + instance.pp_instance())); + } + return false; +} + +bool UnlockCursor(const InstanceHandle& instance) { + if (has_interface<PPB_CursorControl_Dev_0_4>()) { + return PP_ToBool(get_interface<PPB_CursorControl_Dev_0_4>()->UnlockCursor( + instance.pp_instance())); + } + return false; +} + +bool HasCursorLock(const InstanceHandle& instance) { + if (has_interface<PPB_CursorControl_Dev_0_4>()) { + return PP_ToBool(get_interface<PPB_CursorControl_Dev_0_4>()->HasCursorLock( + instance.pp_instance())); + } + return false; +} + +bool CanLockCursor(const InstanceHandle& instance) { + if (has_interface<PPB_CursorControl_Dev_0_4>()) { + return PP_ToBool(get_interface<PPB_CursorControl_Dev_0_4>()->CanLockCursor( + instance.pp_instance())); + } + return false; +} + +} // namespace pp diff --git a/ppapi/cpp/dev/cursor_control_dev.h b/ppapi/cpp/dev/cursor_control_dev.h new file mode 100644 index 0000000..0ad9748 --- /dev/null +++ b/ppapi/cpp/dev/cursor_control_dev.h @@ -0,0 +1,36 @@ +// 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. + +#ifndef PPAPI_CPP_DEV_CURSOR_CONTROL_DEV_H_ +#define PPAPI_CPP_DEV_CURSOR_CONTROL_DEV_H_ + +#include "ppapi/c/dev/ppb_cursor_control_dev.h" + +/// @file +/// This file defines APIs for controlling the cursor. + +namespace pp { + +class ImageData; +class InstanceHandle; +class Point; + +/// APIs for controlling the cursor. +class CursorControl_Dev { + public: + CursorControl_Dev() {} + + bool SetCursor(const InstanceHandle& instance, + PP_CursorType_Dev type, + const ImageData& custom_image, + const Point& hot_spot); + bool LockCursor(const InstanceHandle& instance); + bool UnlockCursor(const InstanceHandle& instance); + bool HasCursorLock(const InstanceHandle& instance); + bool CanLockCursor(const InstanceHandle& instance); +}; + +} // namespace pp + +#endif // PPAPI_CPP_DEV_CURSOR_CONTROL_DEV_H_ diff --git a/ppapi/ppapi_sources.gypi b/ppapi/ppapi_sources.gypi index 541cfbd..fbb8d09 100644 --- a/ppapi/ppapi_sources.gypi +++ b/ppapi/ppapi_sources.gypi @@ -203,6 +203,8 @@ 'cpp/dev/buffer_dev.h', 'cpp/dev/crypto_dev.cc', 'cpp/dev/crypto_dev.h', + 'cpp/dev/cursor_control_dev.cc', + 'cpp/dev/cursor_control_dev.h', 'cpp/dev/device_ref_dev.cc', 'cpp/dev/device_ref_dev.h', 'cpp/dev/directory_entry_dev.cc', |