android_webview
apps
ash
base
build
build_overrides
buildtools
cc
chrome
chromecast
chromeos
clank
codelabs
components
content
crypto
dbus
device
docs
extensions
fuchsia_web
gin
google_apis
google_update
gpu
headless
infra
internal
ios
ios_internal
ipc
media
mojo
native_client
native_client_sdk
net
pdf
ppapi
api
buildflags
c
cpp
dev
documentation
private
trusted
BUILD.gn
DEPS
array_output.cc
array_output.h
audio.cc
audio.h
audio_buffer.cc
audio_buffer.h
audio_config.cc
audio_config.h
completion_callback.h
core.cc
core.h
directory_entry.cc
directory_entry.h
file_io.cc
file_io.h
file_ref.cc
file_ref.h
file_system.cc
file_system.h
fullscreen.cc
fullscreen.h
graphics_2d.cc
graphics_2d.h
graphics_3d.cc
graphics_3d.h
graphics_3d_client.cc
graphics_3d_client.h
host_resolver.cc
host_resolver.h
image_data.cc
image_data.h
input_event.cc
input_event.h
input_event_interface_name.h
instance.cc
instance.h
instance_handle.cc
instance_handle.h
logging.h
media_stream_audio_track.cc
media_stream_audio_track.h
media_stream_video_track.cc
media_stream_video_track.h
message_handler.h
message_loop.cc
message_loop.h
module.cc
module.h
module_embedder.h
module_impl.h
mouse_cursor.cc
mouse_cursor.h
mouse_lock.cc
mouse_lock.h
net_address.cc
net_address.h
network_list.cc
network_list.h
network_monitor.cc
network_monitor.h
network_proxy.cc
network_proxy.h
output_traits.h
pass_ref.h
point.h
ppp_entrypoints.cc
rect.cc
rect.h
resource.cc
resource.h
size.h
tcp_socket.cc
tcp_socket.h
text_input_controller.cc
text_input_controller.h
touch_point.h
udp_socket.cc
udp_socket.h
url_loader.cc
url_loader.h
url_request_info.cc
url_request_info.h
url_response_info.cc
url_response_info.h
var.cc
var.h
var_array.cc
var_array.h
var_array_buffer.cc
var_array_buffer.h
var_dictionary.cc
var_dictionary.h
video_decoder.cc
video_decoder.h
video_encoder.cc
video_encoder.h
video_frame.cc
video_frame.h
view.cc
view.h
vpn_provider.cc
vpn_provider.h
websocket.cc
websocket.h
examples
generators
host
lib
nacl_irt
native_client
proxy
shared_impl
tests
thunk
tools
utility
BUILD.gn
DEPS
DIR_METADATA
LICENSE
OWNERS
PRESUBMIT.py
generate_ppapi_include_tests.py
generate_ppapi_size_checks.py
printing
remoting
rlz
sandbox
services
signing_keys
skia
sql
storage
styleguide
testing
third_party
tools
ui
url
v8
webkit
.clang-format
.clang-tidy
.clangd
.eslintrc.js
.git-blame-ignore-revs
.gitallowed
.gitattributes
.gitignore
.gitmodules
.gn
.mailmap
.rustfmt.toml
.vpython3
.yapfignore
ATL_OWNERS
AUTHORS
BUILD.gn
CODE_OF_CONDUCT.md
CPPLINT.cfg
CRYPTO_OWNERS
DEPS
DIR_METADATA
LICENSE
LICENSE.chromium_os
OWNERS
PRESUBMIT.py
PRESUBMIT_test.py
PRESUBMIT_test_mocks.py
README.md
WATCHLISTS
codereview.settings

The methodology used to generate this CL is documented in https://crbug.com/1098010#c95. No-Try: true Bug: 1098010 Change-Id: I6ae92e5d7ccbf73b176588124b2f8b4067f805b3 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3900575 Reviewed-by: Mark Mentovai <mark@chromium.org> Owners-Override: Avi Drissman <avi@chromium.org> Commit-Queue: Avi Drissman <avi@chromium.org> Auto-Submit: Avi Drissman <avi@chromium.org> Cr-Commit-Position: refs/heads/main@{#1047628}
65 lines
1.7 KiB
C++
65 lines
1.7 KiB
C++
// Copyright 2012 The Chromium Authors
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#include "ppapi/cpp/mouse_lock.h"
|
|
|
|
#include "ppapi/c/ppb_mouse_lock.h"
|
|
#include "ppapi/c/ppp_mouse_lock.h"
|
|
#include "ppapi/cpp/completion_callback.h"
|
|
#include "ppapi/cpp/instance.h"
|
|
#include "ppapi/cpp/instance_handle.h"
|
|
#include "ppapi/cpp/module.h"
|
|
#include "ppapi/cpp/module_impl.h"
|
|
|
|
namespace pp {
|
|
|
|
namespace {
|
|
|
|
static const char kPPPMouseLockInterface[] = PPP_MOUSELOCK_INTERFACE;
|
|
|
|
void MouseLockLost(PP_Instance instance) {
|
|
void* object =
|
|
Instance::GetPerInstanceObject(instance, kPPPMouseLockInterface);
|
|
if (!object)
|
|
return;
|
|
static_cast<MouseLock*>(object)->MouseLockLost();
|
|
}
|
|
|
|
const PPP_MouseLock ppp_mouse_lock = {
|
|
&MouseLockLost
|
|
};
|
|
|
|
template <> const char* interface_name<PPB_MouseLock_1_0>() {
|
|
return PPB_MOUSELOCK_INTERFACE_1_0;
|
|
}
|
|
|
|
} // namespace
|
|
|
|
MouseLock::MouseLock(Instance* instance)
|
|
: associated_instance_(instance) {
|
|
Module::Get()->AddPluginInterface(kPPPMouseLockInterface, &ppp_mouse_lock);
|
|
instance->AddPerInstanceObject(kPPPMouseLockInterface, this);
|
|
}
|
|
|
|
MouseLock::~MouseLock() {
|
|
Instance::RemovePerInstanceObject(associated_instance_,
|
|
kPPPMouseLockInterface, this);
|
|
}
|
|
|
|
int32_t MouseLock::LockMouse(const CompletionCallback& cc) {
|
|
if (!has_interface<PPB_MouseLock_1_0>())
|
|
return cc.MayForce(PP_ERROR_NOINTERFACE);
|
|
return get_interface<PPB_MouseLock_1_0>()->LockMouse(
|
|
associated_instance_.pp_instance(), cc.pp_completion_callback());
|
|
}
|
|
|
|
void MouseLock::UnlockMouse() {
|
|
if (has_interface<PPB_MouseLock_1_0>()) {
|
|
get_interface<PPB_MouseLock_1_0>()->UnlockMouse(
|
|
associated_instance_.pp_instance());
|
|
}
|
|
}
|
|
|
|
} // namespace pp
|