OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ppapi/cpp/mouse_lock.h" | 5 #include "ppapi/cpp/mouse_lock.h" |
6 | 6 |
7 #include "ppapi/c/ppb_mouse_lock.h" | 7 #include "ppapi/c/ppb_mouse_lock.h" |
8 #include "ppapi/c/ppp_mouse_lock.h" | 8 #include "ppapi/c/ppp_mouse_lock.h" |
9 #include "ppapi/cpp/completion_callback.h" | 9 #include "ppapi/cpp/completion_callback.h" |
10 #include "ppapi/cpp/instance.h" | 10 #include "ppapi/cpp/instance.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 const PPP_MouseLock ppp_mouse_lock = { | 29 const PPP_MouseLock ppp_mouse_lock = { |
30 &MouseLockLost | 30 &MouseLockLost |
31 }; | 31 }; |
32 | 32 |
33 template <> const char* interface_name<PPB_MouseLock>() { | 33 template <> const char* interface_name<PPB_MouseLock>() { |
34 return PPB_MOUSELOCK_INTERFACE; | 34 return PPB_MOUSELOCK_INTERFACE; |
35 } | 35 } |
36 | 36 |
37 } // namespace | 37 } // namespace |
38 | 38 |
39 MouseLock::MouseLock(const InstanceHandle& instance) | 39 MouseLock::MouseLock(Instance* instance) |
40 : associated_instance_(instance) { | 40 : associated_instance_(instance) { |
41 Module::Get()->AddPluginInterface(kPPPMouseLockInterface, &ppp_mouse_lock); | 41 Module::Get()->AddPluginInterface(kPPPMouseLockInterface, &ppp_mouse_lock); |
42 Instance::AddPerInstanceObject(instance, kPPPMouseLockInterface, this); | 42 instance->AddPerInstanceObject(kPPPMouseLockInterface, this); |
43 } | 43 } |
44 | 44 |
45 MouseLock::~MouseLock() { | 45 MouseLock::~MouseLock() { |
46 Instance::RemovePerInstanceObject(associated_instance_, | 46 Instance::RemovePerInstanceObject(associated_instance_, |
47 kPPPMouseLockInterface, this); | 47 kPPPMouseLockInterface, this); |
48 } | 48 } |
49 | 49 |
50 int32_t MouseLock::LockMouse(const CompletionCallback& cc) { | 50 int32_t MouseLock::LockMouse(const CompletionCallback& cc) { |
51 if (!has_interface<PPB_MouseLock>()) | 51 if (!has_interface<PPB_MouseLock>()) |
52 return cc.MayForce(PP_ERROR_NOINTERFACE); | 52 return cc.MayForce(PP_ERROR_NOINTERFACE); |
53 return get_interface<PPB_MouseLock>()->LockMouse( | 53 return get_interface<PPB_MouseLock>()->LockMouse( |
54 associated_instance_.pp_instance(), cc.pp_completion_callback()); | 54 associated_instance_.pp_instance(), cc.pp_completion_callback()); |
55 } | 55 } |
56 | 56 |
57 void MouseLock::UnlockMouse() { | 57 void MouseLock::UnlockMouse() { |
58 if (has_interface<PPB_MouseLock>()) { | 58 if (has_interface<PPB_MouseLock>()) { |
59 get_interface<PPB_MouseLock>()->UnlockMouse( | 59 get_interface<PPB_MouseLock>()->UnlockMouse( |
60 associated_instance_.pp_instance()); | 60 associated_instance_.pp_instance()); |
61 } | 61 } |
62 } | 62 } |
63 | 63 |
64 } // namespace pp | 64 } // namespace pp |
OLD | NEW |