Avi Drissman | db497b3 | 2022-09-15 19:47:28 | [diff] [blame] | 1 | // Copyright 2012 The Chromium Authors |
[email protected] | 4c2e935 | 2010-11-05 22:13:02 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef PPAPI_PROXY_PPB_INSTANCE_PROXY_H_ |
| 6 | #define PPAPI_PROXY_PPB_INSTANCE_PROXY_H_ |
| 7 | |
avi | e029c413 | 2015-12-23 06:45:22 | [diff] [blame] | 8 | #include <stdint.h> |
| 9 | |
[email protected] | 98ad978 | 2012-08-22 04:06:22 | [diff] [blame] | 10 | #include <string> |
jrummell | 1e9a7b1 | 2014-09-08 00:38:31 | [diff] [blame] | 11 | #include <vector> |
[email protected] | 98ad978 | 2012-08-22 04:06:22 | [diff] [blame] | 12 | |
avi | e029c413 | 2015-12-23 06:45:22 | [diff] [blame] | 13 | #include "build/build_config.h" |
[email protected] | 4c2e935 | 2010-11-05 22:13:02 | [diff] [blame] | 14 | #include "ppapi/c/pp_instance.h" |
| 15 | #include "ppapi/c/pp_resource.h" |
| 16 | #include "ppapi/c/pp_var.h" |
| 17 | #include "ppapi/proxy/interface_proxy.h" |
[email protected] | 47a961c | 2012-07-13 19:18:52 | [diff] [blame] | 18 | #include "ppapi/proxy/proxy_completion_callback_factory.h" |
[email protected] | be0a84b | 2011-08-13 04:18:44 | [diff] [blame] | 19 | #include "ppapi/shared_impl/host_resource.h" |
[email protected] | 9a57839 | 2011-12-07 18:59:27 | [diff] [blame] | 20 | #include "ppapi/shared_impl/ppb_instance_shared.h" |
[email protected] | 109dcfb | 2012-11-29 17:59:19 | [diff] [blame] | 21 | #include "ppapi/shared_impl/singleton_resource_id.h" |
[email protected] | ceadc39 | 2011-06-15 23:04:24 | [diff] [blame] | 22 | #include "ppapi/thunk/ppb_instance_api.h" |
[email protected] | ae5ff9ae | 2012-01-06 22:50:33 | [diff] [blame] | 23 | #include "ppapi/utility/completion_callback_factory.h" |
[email protected] | 4c2e935 | 2010-11-05 22:13:02 | [diff] [blame] | 24 | |
[email protected] | 0f41c01 | 2011-10-21 19:49:20 | [diff] [blame] | 25 | // Windows headers interfere with this file. |
| 26 | #ifdef PostMessage |
| 27 | #undef PostMessage |
| 28 | #endif |
| 29 | |
[email protected] | 4d2efd2 | 2011-08-18 21:58:02 | [diff] [blame] | 30 | namespace ppapi { |
[email protected] | 4c2e935 | 2010-11-05 22:13:02 | [diff] [blame] | 31 | namespace proxy { |
| 32 | |
| 33 | class SerializedVarReceiveInput; |
| 34 | class SerializedVarOutParam; |
| 35 | class SerializedVarReturnValue; |
| 36 | |
[email protected] | ceadc39 | 2011-06-15 23:04:24 | [diff] [blame] | 37 | class PPB_Instance_Proxy : public InterfaceProxy, |
[email protected] | a9b16dd | 2012-01-31 05:00:26 | [diff] [blame] | 38 | public PPB_Instance_Shared { |
[email protected] | 4c2e935 | 2010-11-05 22:13:02 | [diff] [blame] | 39 | public: |
[email protected] | 5c96602 | 2011-09-13 18:09:37 | [diff] [blame] | 40 | PPB_Instance_Proxy(Dispatcher* dispatcher); |
jvoung | bd2e01dd | 2015-01-21 20:35:39 | [diff] [blame] | 41 | ~PPB_Instance_Proxy() override; |
[email protected] | 4c2e935 | 2010-11-05 22:13:02 | [diff] [blame] | 42 | |
[email protected] | 4c2e935 | 2010-11-05 22:13:02 | [diff] [blame] | 43 | // InterfaceProxy implementation. |
jvoung | bd2e01dd | 2015-01-21 20:35:39 | [diff] [blame] | 44 | bool OnMessageReceived(const IPC::Message& msg) override; |
[email protected] | 4c2e935 | 2010-11-05 22:13:02 | [diff] [blame] | 45 | |
[email protected] | 4f200612 | 2012-04-30 05:13:17 | [diff] [blame] | 46 | // PPB_Instance_API implementation. |
jvoung | bd2e01dd | 2015-01-21 20:35:39 | [diff] [blame] | 47 | PP_Bool BindGraphics(PP_Instance instance, PP_Resource device) override; |
| 48 | PP_Bool IsFullFrame(PP_Instance instance) override; |
| 49 | const ViewData* GetViewData(PP_Instance instance) override; |
jvoung | bd2e01dd | 2015-01-21 20:35:39 | [diff] [blame] | 50 | PP_Var GetWindowObject(PP_Instance instance) override; |
| 51 | PP_Var GetOwnerElementObject(PP_Instance instance) override; |
| 52 | PP_Var ExecuteScript(PP_Instance instance, |
| 53 | PP_Var script, |
| 54 | PP_Var* exception) override; |
| 55 | uint32_t GetAudioHardwareOutputSampleRate(PP_Instance instance) override; |
| 56 | uint32_t GetAudioHardwareOutputBufferSize(PP_Instance instance) override; |
| 57 | PP_Var GetDefaultCharSet(PP_Instance instance) override; |
jvoung | bd2e01dd | 2015-01-21 20:35:39 | [diff] [blame] | 58 | PP_Bool IsFullscreen(PP_Instance instance) override; |
| 59 | PP_Bool SetFullscreen(PP_Instance instance, PP_Bool fullscreen) override; |
| 60 | PP_Bool GetScreenSize(PP_Instance instance, PP_Size* size) override; |
| 61 | Resource* GetSingletonResource(PP_Instance instance, |
| 62 | SingletonResourceID id) override; |
| 63 | int32_t RequestInputEvents(PP_Instance instance, |
| 64 | uint32_t event_classes) override; |
| 65 | int32_t RequestFilteringInputEvents(PP_Instance instance, |
mostynb | 699af3c | 2014-10-06 18:03:34 | [diff] [blame] | 66 | uint32_t event_classes) override; |
jvoung | bd2e01dd | 2015-01-21 20:35:39 | [diff] [blame] | 67 | void ClearInputEventRequest(PP_Instance instance, |
| 68 | uint32_t event_classes) override; |
jvoung | bd2e01dd | 2015-01-21 20:35:39 | [diff] [blame] | 69 | void PostMessage(PP_Instance instance, PP_Var message) override; |
| 70 | int32_t RegisterMessageHandler(PP_Instance instance, |
| 71 | void* user_data, |
| 72 | const PPP_MessageHandler_0_2* handler, |
| 73 | PP_Resource message_loop) override; |
jvoung | bd2e01dd | 2015-01-21 20:35:39 | [diff] [blame] | 74 | void UnregisterMessageHandler(PP_Instance instance) override; |
| 75 | PP_Bool SetCursor(PP_Instance instance, |
| 76 | PP_MouseCursor_Type type, |
| 77 | PP_Resource image, |
| 78 | const PP_Point* hot_spot) override; |
| 79 | int32_t LockMouse(PP_Instance instance, |
| 80 | scoped_refptr<TrackedCallback> callback) override; |
| 81 | void UnlockMouse(PP_Instance instance) override; |
| 82 | void SetTextInputType(PP_Instance instance, PP_TextInput_Type type) override; |
| 83 | void UpdateCaretPosition(PP_Instance instance, |
| 84 | const PP_Rect& caret, |
| 85 | const PP_Rect& bounding_box) override; |
| 86 | void CancelCompositionText(PP_Instance instance) override; |
| 87 | void SelectionChanged(PP_Instance instance) override; |
| 88 | void UpdateSurroundingText(PP_Instance instance, |
| 89 | const char* text, |
| 90 | uint32_t caret, |
| 91 | uint32_t anchor) override; |
| 92 | PP_Var GetDocumentURL(PP_Instance instance, |
| 93 | PP_URLComponents_Dev* components) override; |
Xiaohan Wang | 0fd6e56a | 2022-01-13 20:26:11 | [diff] [blame] | 94 | #if !BUILDFLAG(IS_NACL) |
jvoung | bd2e01dd | 2015-01-21 20:35:39 | [diff] [blame] | 95 | PP_Var ResolveRelativeToDocument(PP_Instance instance, |
| 96 | PP_Var relative, |
| 97 | PP_URLComponents_Dev* components) override; |
| 98 | PP_Bool DocumentCanRequest(PP_Instance instance, PP_Var url) override; |
| 99 | PP_Bool DocumentCanAccessDocument(PP_Instance instance, |
| 100 | PP_Instance target) override; |
| 101 | PP_Var GetPluginInstanceURL(PP_Instance instance, |
| 102 | PP_URLComponents_Dev* components) override; |
| 103 | PP_Var GetPluginReferrerURL(PP_Instance instance, |
| 104 | PP_URLComponents_Dev* components) override; |
Xiaohan Wang | 0fd6e56a | 2022-01-13 20:26:11 | [diff] [blame] | 105 | #endif // !BUILDFLAG(IS_NACL) |
[email protected] | ceadc39 | 2011-06-15 23:04:24 | [diff] [blame] | 106 | |
[email protected] | ac4b54d | 2011-10-20 23:09:28 | [diff] [blame] | 107 | static const ApiID kApiID = API_ID_PPB_INSTANCE; |
[email protected] | 5c96602 | 2011-09-13 18:09:37 | [diff] [blame] | 108 | |
[email protected] | 4c2e935 | 2010-11-05 22:13:02 | [diff] [blame] | 109 | private: |
[email protected] | 0f41c01 | 2011-10-21 19:49:20 | [diff] [blame] | 110 | // Plugin -> Host message handlers. |
[email protected] | e8f07ac | 2012-01-03 17:43:36 | [diff] [blame] | 111 | void OnHostMsgGetWindowObject(PP_Instance instance, |
| 112 | SerializedVarReturnValue result); |
| 113 | void OnHostMsgGetOwnerElementObject(PP_Instance instance, |
[email protected] | 0346023 | 2011-10-10 17:23:57 | [diff] [blame] | 114 | SerializedVarReturnValue result); |
[email protected] | e8f07ac | 2012-01-03 17:43:36 | [diff] [blame] | 115 | void OnHostMsgBindGraphics(PP_Instance instance, |
[email protected] | 473ef7d | 2012-12-03 23:39:05 | [diff] [blame] | 116 | PP_Resource device); |
[email protected] | e8f07ac | 2012-01-03 17:43:36 | [diff] [blame] | 117 | void OnHostMsgIsFullFrame(PP_Instance instance, PP_Bool* result); |
| 118 | void OnHostMsgExecuteScript(PP_Instance instance, |
| 119 | SerializedVarReceiveInput script, |
| 120 | SerializedVarOutParam out_exception, |
| 121 | SerializedVarReturnValue result); |
[email protected] | c59ed589 | 2012-02-18 01:10:19 | [diff] [blame] | 122 | void OnHostMsgGetAudioHardwareOutputSampleRate(PP_Instance instance, |
| 123 | uint32_t *result); |
| 124 | void OnHostMsgGetAudioHardwareOutputBufferSize(PP_Instance instance, |
| 125 | uint32_t *result); |
[email protected] | e8f07ac | 2012-01-03 17:43:36 | [diff] [blame] | 126 | void OnHostMsgGetDefaultCharSet(PP_Instance instance, |
| 127 | SerializedVarReturnValue result); |
[email protected] | e8f07ac | 2012-01-03 17:43:36 | [diff] [blame] | 128 | void OnHostMsgSetFullscreen(PP_Instance instance, |
| 129 | PP_Bool fullscreen, |
| 130 | PP_Bool* result); |
| 131 | void OnHostMsgGetScreenSize(PP_Instance instance, |
| 132 | PP_Bool* result, |
| 133 | PP_Size* size); |
[email protected] | e8f07ac | 2012-01-03 17:43:36 | [diff] [blame] | 134 | void OnHostMsgRequestInputEvents(PP_Instance instance, |
| 135 | bool is_filtering, |
| 136 | uint32_t event_classes); |
| 137 | void OnHostMsgClearInputEvents(PP_Instance instance, |
| 138 | uint32_t event_classes); |
| 139 | void OnHostMsgPostMessage(PP_Instance instance, |
| 140 | SerializedVarReceiveInput message); |
| 141 | void OnHostMsgLockMouse(PP_Instance instance); |
| 142 | void OnHostMsgUnlockMouse(PP_Instance instance); |
[email protected] | c962f86 | 2012-04-12 00:02:04 | [diff] [blame] | 143 | void OnHostMsgSetCursor(PP_Instance instance, |
| 144 | int32_t type, |
| 145 | const ppapi::HostResource& custom_image, |
| 146 | const PP_Point& hot_spot); |
[email protected] | 4c44183a | 2012-04-27 16:52:23 | [diff] [blame] | 147 | void OnHostMsgSetTextInputType(PP_Instance instance, PP_TextInput_Type type); |
| 148 | void OnHostMsgUpdateCaretPosition(PP_Instance instance, |
| 149 | const PP_Rect& caret, |
| 150 | const PP_Rect& bounding_box); |
| 151 | void OnHostMsgCancelCompositionText(PP_Instance instance); |
| 152 | void OnHostMsgUpdateSurroundingText( |
| 153 | PP_Instance instance, |
| 154 | const std::string& text, |
| 155 | uint32_t caret, |
| 156 | uint32_t anchor); |
[email protected] | 32938de | 2012-10-19 18:42:32 | [diff] [blame] | 157 | void OnHostMsgGetDocumentURL(PP_Instance instance, |
| 158 | PP_URLComponents_Dev* components, |
| 159 | SerializedVarReturnValue result); |
[email protected] | e5aeef0 | 2012-08-17 00:18:43 | [diff] [blame] | 160 | |
Xiaohan Wang | 0fd6e56a | 2022-01-13 20:26:11 | [diff] [blame] | 161 | #if !BUILDFLAG(IS_NACL) |
[email protected] | e8f07ac | 2012-01-03 17:43:36 | [diff] [blame] | 162 | void OnHostMsgResolveRelativeToDocument(PP_Instance instance, |
| 163 | SerializedVarReceiveInput relative, |
| 164 | SerializedVarReturnValue result); |
| 165 | void OnHostMsgDocumentCanRequest(PP_Instance instance, |
| 166 | SerializedVarReceiveInput url, |
| 167 | PP_Bool* result); |
| 168 | void OnHostMsgDocumentCanAccessDocument(PP_Instance active, |
| 169 | PP_Instance target, |
| 170 | PP_Bool* result); |
[email protected] | e8f07ac | 2012-01-03 17:43:36 | [diff] [blame] | 171 | void OnHostMsgGetPluginInstanceURL(PP_Instance instance, |
| 172 | SerializedVarReturnValue result); |
[email protected] | f5a1402 | 2013-09-07 15:47:40 | [diff] [blame] | 173 | void OnHostMsgGetPluginReferrerURL(PP_Instance instance, |
| 174 | SerializedVarReturnValue result); |
Xiaohan Wang | 0fd6e56a | 2022-01-13 20:26:11 | [diff] [blame] | 175 | #endif // !BUILDFLAG(IS_NACL) |
[email protected] | 0f41c01 | 2011-10-21 19:49:20 | [diff] [blame] | 176 | |
| 177 | // Host -> Plugin message handlers. |
[email protected] | e8f07ac | 2012-01-03 17:43:36 | [diff] [blame] | 178 | void OnPluginMsgMouseLockComplete(PP_Instance instance, int32_t result); |
[email protected] | 0f41c01 | 2011-10-21 19:49:20 | [diff] [blame] | 179 | |
| 180 | void MouseLockCompleteInHost(int32_t result, PP_Instance instance); |
| 181 | |
[email protected] | a8e7214 | 2012-08-21 17:24:20 | [diff] [blame] | 182 | // Other helpers. |
| 183 | void CancelAnyPendingRequestSurroundingText(PP_Instance instance); |
| 184 | |
[email protected] | 47a961c | 2012-07-13 19:18:52 | [diff] [blame] | 185 | ProxyCompletionCallbackFactory<PPB_Instance_Proxy> callback_factory_; |
[email protected] | 4c2e935 | 2010-11-05 22:13:02 | [diff] [blame] | 186 | }; |
| 187 | |
| 188 | } // namespace proxy |
[email protected] | 4d2efd2 | 2011-08-18 21:58:02 | [diff] [blame] | 189 | } // namespace ppapi |
[email protected] | 4c2e935 | 2010-11-05 22:13:02 | [diff] [blame] | 190 | |
| 191 | #endif // PPAPI_PROXY_PPB_INSTANCE_PROXY_H_ |