blob: 3f5b57d5b00a778411acc2eef6520329d4282f97 [file] [log] [blame]
Avi Drissmandb497b32022-09-15 19:47:281// Copyright 2012 The Chromium Authors
[email protected]4c2e9352010-11-05 22:13:022// 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
avie029c4132015-12-23 06:45:228#include <stdint.h>
9
[email protected]98ad9782012-08-22 04:06:2210#include <string>
jrummell1e9a7b12014-09-08 00:38:3111#include <vector>
[email protected]98ad9782012-08-22 04:06:2212
avie029c4132015-12-23 06:45:2213#include "build/build_config.h"
[email protected]4c2e9352010-11-05 22:13:0214#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]47a961c2012-07-13 19:18:5218#include "ppapi/proxy/proxy_completion_callback_factory.h"
[email protected]be0a84b2011-08-13 04:18:4419#include "ppapi/shared_impl/host_resource.h"
[email protected]9a578392011-12-07 18:59:2720#include "ppapi/shared_impl/ppb_instance_shared.h"
[email protected]109dcfb2012-11-29 17:59:1921#include "ppapi/shared_impl/singleton_resource_id.h"
[email protected]ceadc392011-06-15 23:04:2422#include "ppapi/thunk/ppb_instance_api.h"
[email protected]ae5ff9ae2012-01-06 22:50:3323#include "ppapi/utility/completion_callback_factory.h"
[email protected]4c2e9352010-11-05 22:13:0224
[email protected]0f41c012011-10-21 19:49:2025// Windows headers interfere with this file.
26#ifdef PostMessage
27#undef PostMessage
28#endif
29
[email protected]4d2efd22011-08-18 21:58:0230namespace ppapi {
[email protected]4c2e9352010-11-05 22:13:0231namespace proxy {
32
33class SerializedVarReceiveInput;
34class SerializedVarOutParam;
35class SerializedVarReturnValue;
36
[email protected]ceadc392011-06-15 23:04:2437class PPB_Instance_Proxy : public InterfaceProxy,
[email protected]a9b16dd2012-01-31 05:00:2638 public PPB_Instance_Shared {
[email protected]4c2e9352010-11-05 22:13:0239 public:
[email protected]5c966022011-09-13 18:09:3740 PPB_Instance_Proxy(Dispatcher* dispatcher);
jvoungbd2e01dd2015-01-21 20:35:3941 ~PPB_Instance_Proxy() override;
[email protected]4c2e9352010-11-05 22:13:0242
[email protected]4c2e9352010-11-05 22:13:0243 // InterfaceProxy implementation.
jvoungbd2e01dd2015-01-21 20:35:3944 bool OnMessageReceived(const IPC::Message& msg) override;
[email protected]4c2e9352010-11-05 22:13:0245
[email protected]4f2006122012-04-30 05:13:1746 // PPB_Instance_API implementation.
jvoungbd2e01dd2015-01-21 20:35:3947 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;
jvoungbd2e01dd2015-01-21 20:35:3950 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;
jvoungbd2e01dd2015-01-21 20:35:3958 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,
mostynb699af3c2014-10-06 18:03:3466 uint32_t event_classes) override;
jvoungbd2e01dd2015-01-21 20:35:3967 void ClearInputEventRequest(PP_Instance instance,
68 uint32_t event_classes) override;
jvoungbd2e01dd2015-01-21 20:35:3969 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;
jvoungbd2e01dd2015-01-21 20:35:3974 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 Wang0fd6e56a2022-01-13 20:26:1194#if !BUILDFLAG(IS_NACL)
jvoungbd2e01dd2015-01-21 20:35:3995 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 Wang0fd6e56a2022-01-13 20:26:11105#endif // !BUILDFLAG(IS_NACL)
[email protected]ceadc392011-06-15 23:04:24106
[email protected]ac4b54d2011-10-20 23:09:28107 static const ApiID kApiID = API_ID_PPB_INSTANCE;
[email protected]5c966022011-09-13 18:09:37108
[email protected]4c2e9352010-11-05 22:13:02109 private:
[email protected]0f41c012011-10-21 19:49:20110 // Plugin -> Host message handlers.
[email protected]e8f07ac2012-01-03 17:43:36111 void OnHostMsgGetWindowObject(PP_Instance instance,
112 SerializedVarReturnValue result);
113 void OnHostMsgGetOwnerElementObject(PP_Instance instance,
[email protected]03460232011-10-10 17:23:57114 SerializedVarReturnValue result);
[email protected]e8f07ac2012-01-03 17:43:36115 void OnHostMsgBindGraphics(PP_Instance instance,
[email protected]473ef7d2012-12-03 23:39:05116 PP_Resource device);
[email protected]e8f07ac2012-01-03 17:43:36117 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]c59ed5892012-02-18 01:10:19122 void OnHostMsgGetAudioHardwareOutputSampleRate(PP_Instance instance,
123 uint32_t *result);
124 void OnHostMsgGetAudioHardwareOutputBufferSize(PP_Instance instance,
125 uint32_t *result);
[email protected]e8f07ac2012-01-03 17:43:36126 void OnHostMsgGetDefaultCharSet(PP_Instance instance,
127 SerializedVarReturnValue result);
[email protected]e8f07ac2012-01-03 17:43:36128 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]e8f07ac2012-01-03 17:43:36134 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]c962f862012-04-12 00:02:04143 void OnHostMsgSetCursor(PP_Instance instance,
144 int32_t type,
145 const ppapi::HostResource& custom_image,
146 const PP_Point& hot_spot);
[email protected]4c44183a2012-04-27 16:52:23147 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]32938de2012-10-19 18:42:32157 void OnHostMsgGetDocumentURL(PP_Instance instance,
158 PP_URLComponents_Dev* components,
159 SerializedVarReturnValue result);
[email protected]e5aeef02012-08-17 00:18:43160
Xiaohan Wang0fd6e56a2022-01-13 20:26:11161#if !BUILDFLAG(IS_NACL)
[email protected]e8f07ac2012-01-03 17:43:36162 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]e8f07ac2012-01-03 17:43:36171 void OnHostMsgGetPluginInstanceURL(PP_Instance instance,
172 SerializedVarReturnValue result);
[email protected]f5a14022013-09-07 15:47:40173 void OnHostMsgGetPluginReferrerURL(PP_Instance instance,
174 SerializedVarReturnValue result);
Xiaohan Wang0fd6e56a2022-01-13 20:26:11175#endif // !BUILDFLAG(IS_NACL)
[email protected]0f41c012011-10-21 19:49:20176
177 // Host -> Plugin message handlers.
[email protected]e8f07ac2012-01-03 17:43:36178 void OnPluginMsgMouseLockComplete(PP_Instance instance, int32_t result);
[email protected]0f41c012011-10-21 19:49:20179
180 void MouseLockCompleteInHost(int32_t result, PP_Instance instance);
181
[email protected]a8e72142012-08-21 17:24:20182 // Other helpers.
183 void CancelAnyPendingRequestSurroundingText(PP_Instance instance);
184
[email protected]47a961c2012-07-13 19:18:52185 ProxyCompletionCallbackFactory<PPB_Instance_Proxy> callback_factory_;
[email protected]4c2e9352010-11-05 22:13:02186};
187
188} // namespace proxy
[email protected]4d2efd22011-08-18 21:58:02189} // namespace ppapi
[email protected]4c2e9352010-11-05 22:13:02190
191#endif // PPAPI_PROXY_PPB_INSTANCE_PROXY_H_