[email protected] | 0a424af | 2012-01-10 19:24:28 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[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 | |
| 8 | #include "ppapi/c/pp_instance.h" |
| 9 | #include "ppapi/c/pp_resource.h" |
[email protected] | 3b98ced7 | 2012-03-09 02:08:33 | [diff] [blame] | 10 | #include "ppapi/c/pp_time.h" |
[email protected] | 4c2e935 | 2010-11-05 22:13:02 | [diff] [blame] | 11 | #include "ppapi/c/pp_var.h" |
| 12 | #include "ppapi/proxy/interface_proxy.h" |
[email protected] | 47a961c | 2012-07-13 19:18:52 | [diff] [blame] | 13 | #include "ppapi/proxy/proxy_completion_callback_factory.h" |
[email protected] | be0a84b | 2011-08-13 04:18:44 | [diff] [blame] | 14 | #include "ppapi/shared_impl/host_resource.h" |
[email protected] | 9a57839 | 2011-12-07 18:59:27 | [diff] [blame] | 15 | #include "ppapi/shared_impl/ppb_instance_shared.h" |
[email protected] | ceadc39 | 2011-06-15 23:04:24 | [diff] [blame] | 16 | #include "ppapi/thunk/ppb_instance_api.h" |
[email protected] | ae5ff9ae | 2012-01-06 22:50:33 | [diff] [blame] | 17 | #include "ppapi/utility/completion_callback_factory.h" |
[email protected] | 4c2e935 | 2010-11-05 22:13:02 | [diff] [blame] | 18 | |
[email protected] | 0f41c01 | 2011-10-21 19:49:20 | [diff] [blame] | 19 | // Windows headers interfere with this file. |
| 20 | #ifdef PostMessage |
| 21 | #undef PostMessage |
| 22 | #endif |
| 23 | |
[email protected] | 4d2efd2 | 2011-08-18 21:58:02 | [diff] [blame] | 24 | namespace ppapi { |
[email protected] | 4c2e935 | 2010-11-05 22:13:02 | [diff] [blame] | 25 | namespace proxy { |
| 26 | |
| 27 | class SerializedVarReceiveInput; |
| 28 | class SerializedVarOutParam; |
| 29 | class SerializedVarReturnValue; |
| 30 | |
[email protected] | ceadc39 | 2011-06-15 23:04:24 | [diff] [blame] | 31 | class PPB_Instance_Proxy : public InterfaceProxy, |
[email protected] | a9b16dd | 2012-01-31 05:00:26 | [diff] [blame] | 32 | public PPB_Instance_Shared { |
[email protected] | 4c2e935 | 2010-11-05 22:13:02 | [diff] [blame] | 33 | public: |
[email protected] | 5c96602 | 2011-09-13 18:09:37 | [diff] [blame] | 34 | PPB_Instance_Proxy(Dispatcher* dispatcher); |
[email protected] | 4c2e935 | 2010-11-05 22:13:02 | [diff] [blame] | 35 | virtual ~PPB_Instance_Proxy(); |
| 36 | |
[email protected] | ceadc39 | 2011-06-15 23:04:24 | [diff] [blame] | 37 | static const Info* GetInfoPrivate(); |
[email protected] | 4c2e935 | 2010-11-05 22:13:02 | [diff] [blame] | 38 | |
| 39 | // InterfaceProxy implementation. |
[email protected] | a95986a8 | 2010-12-24 06:19:28 | [diff] [blame] | 40 | virtual bool OnMessageReceived(const IPC::Message& msg); |
[email protected] | 4c2e935 | 2010-11-05 22:13:02 | [diff] [blame] | 41 | |
[email protected] | 4f200612 | 2012-04-30 05:13:17 | [diff] [blame] | 42 | // PPB_Instance_API implementation. |
[email protected] | ceadc39 | 2011-06-15 23:04:24 | [diff] [blame] | 43 | virtual PP_Bool BindGraphics(PP_Instance instance, |
| 44 | PP_Resource device) OVERRIDE; |
| 45 | virtual PP_Bool IsFullFrame(PP_Instance instance) OVERRIDE; |
[email protected] | e8f07ac | 2012-01-03 17:43:36 | [diff] [blame] | 46 | virtual const ViewData* GetViewData(PP_Instance instance) OVERRIDE; |
[email protected] | ceadc39 | 2011-06-15 23:04:24 | [diff] [blame] | 47 | virtual PP_Var GetWindowObject(PP_Instance instance) OVERRIDE; |
| 48 | virtual PP_Var GetOwnerElementObject(PP_Instance instance) OVERRIDE; |
| 49 | virtual PP_Var ExecuteScript(PP_Instance instance, |
| 50 | PP_Var script, |
| 51 | PP_Var* exception) OVERRIDE; |
[email protected] | c59ed589 | 2012-02-18 01:10:19 | [diff] [blame] | 52 | virtual uint32_t GetAudioHardwareOutputSampleRate(PP_Instance instance) |
| 53 | OVERRIDE; |
| 54 | virtual uint32_t GetAudioHardwareOutputBufferSize(PP_Instance instance) |
| 55 | OVERRIDE; |
[email protected] | 8d770e49 | 2011-10-11 04:54:31 | [diff] [blame] | 56 | virtual PP_Var GetDefaultCharSet(PP_Instance instance) OVERRIDE; |
[email protected] | 59cf702 | 2011-09-14 22:44:19 | [diff] [blame] | 57 | virtual void NumberOfFindResultsChanged(PP_Instance instance, |
| 58 | int32_t total, |
| 59 | PP_Bool final_result) OVERRIDE; |
| 60 | virtual void SelectedFindResultChanged(PP_Instance instance, |
| 61 | int32_t index) OVERRIDE; |
[email protected] | 7a26d92e | 2012-02-17 20:15:25 | [diff] [blame] | 62 | virtual PP_Var GetFontFamilies(PP_Instance instance) OVERRIDE; |
[email protected] | 06e0a34 | 2011-09-27 04:24:30 | [diff] [blame] | 63 | virtual PP_Bool SetFullscreen(PP_Instance instance, |
[email protected] | 3b98ced7 | 2012-03-09 02:08:33 | [diff] [blame] | 64 | PP_Bool fullscreen) OVERRIDE; |
[email protected] | 06e0a34 | 2011-09-27 04:24:30 | [diff] [blame] | 65 | virtual PP_Bool GetScreenSize(PP_Instance instance, |
[email protected] | a085aed7 | 2012-04-24 05:32:04 | [diff] [blame] | 66 | PP_Size* size) OVERRIDE; |
| 67 | virtual thunk::PPB_Flash_API* GetFlashAPI() OVERRIDE; |
[email protected] | 957c93a | 2012-03-01 06:44:51 | [diff] [blame] | 68 | virtual void SampleGamepads(PP_Instance instance, |
[email protected] | d5cc719 | 2012-03-07 16:53:16 | [diff] [blame] | 69 | PP_GamepadsSampleData* data) OVERRIDE; |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 70 | virtual int32_t RequestInputEvents(PP_Instance instance, |
| 71 | uint32_t event_classes) OVERRIDE; |
| 72 | virtual int32_t RequestFilteringInputEvents(PP_Instance instance, |
| 73 | uint32_t event_classes) OVERRIDE; |
| 74 | virtual void ClearInputEventRequest(PP_Instance instance, |
| 75 | uint32_t event_classes) OVERRIDE; |
[email protected] | 3b98ced7 | 2012-03-09 02:08:33 | [diff] [blame] | 76 | virtual void ClosePendingUserGesture(PP_Instance instance, |
| 77 | PP_TimeTicks timestamp) OVERRIDE; |
[email protected] | 55a5a52 | 2011-07-06 22:52:40 | [diff] [blame] | 78 | virtual void ZoomChanged(PP_Instance instance, double factor) OVERRIDE; |
| 79 | virtual void ZoomLimitsChanged(PP_Instance instance, |
| 80 | double minimum_factor, |
| 81 | double maximium_factor) OVERRIDE; |
[email protected] | c962f86 | 2012-04-12 00:02:04 | [diff] [blame] | 82 | virtual void PostMessage(PP_Instance instance, PP_Var message) OVERRIDE; |
| 83 | virtual PP_Bool SetCursor(PP_Instance instance, |
| 84 | PP_MouseCursor_Type type, |
| 85 | PP_Resource image, |
| 86 | const PP_Point* hot_spot) OVERRIDE; |
| 87 | virtual int32_t LockMouse(PP_Instance instance, |
[email protected] | aed9653 | 2012-06-23 14:27:42 | [diff] [blame] | 88 | scoped_refptr<TrackedCallback> callback) OVERRIDE; |
[email protected] | c962f86 | 2012-04-12 00:02:04 | [diff] [blame] | 89 | virtual void UnlockMouse(PP_Instance instance) OVERRIDE; |
[email protected] | 772a7462 | 2012-06-14 21:15:50 | [diff] [blame] | 90 | virtual PP_Bool GetDefaultPrintSettings( |
| 91 | PP_Instance instance, |
| 92 | PP_PrintSettings_Dev* print_settings) OVERRIDE; |
[email protected] | 4c44183a | 2012-04-27 16:52:23 | [diff] [blame] | 93 | virtual void SetTextInputType(PP_Instance instance, |
| 94 | PP_TextInput_Type type) OVERRIDE; |
| 95 | virtual void UpdateCaretPosition(PP_Instance instance, |
| 96 | const PP_Rect& caret, |
| 97 | const PP_Rect& bounding_box) OVERRIDE; |
| 98 | virtual void CancelCompositionText(PP_Instance instance) OVERRIDE; |
| 99 | virtual void SelectionChanged(PP_Instance instance) OVERRIDE; |
| 100 | virtual void UpdateSurroundingText(PP_Instance instance, |
| 101 | const char* text, |
| 102 | uint32_t caret, |
| 103 | uint32_t anchor) OVERRIDE; |
[email protected] | c962f86 | 2012-04-12 00:02:04 | [diff] [blame] | 104 | |
| 105 | #if !defined(OS_NACL) |
[email protected] | 0346023 | 2011-10-10 17:23:57 | [diff] [blame] | 106 | virtual PP_Var ResolveRelativeToDocument( |
| 107 | PP_Instance instance, |
| 108 | PP_Var relative, |
| 109 | PP_URLComponents_Dev* components) OVERRIDE; |
| 110 | virtual PP_Bool DocumentCanRequest(PP_Instance instance, PP_Var url) OVERRIDE; |
| 111 | virtual PP_Bool DocumentCanAccessDocument(PP_Instance instance, |
| 112 | PP_Instance target) OVERRIDE; |
| 113 | virtual PP_Var GetDocumentURL(PP_Instance instance, |
| 114 | PP_URLComponents_Dev* components) OVERRIDE; |
| 115 | virtual PP_Var GetPluginInstanceURL( |
| 116 | PP_Instance instance, |
| 117 | PP_URLComponents_Dev* components) OVERRIDE; |
[email protected] | e5aeef0 | 2012-08-17 00:18:43 | [diff] [blame] | 118 | virtual void NeedKey(PP_Instance instance, |
| 119 | PP_Var key_system, |
| 120 | PP_Var session_id, |
| 121 | PP_Var init_data) OVERRIDE; |
| 122 | virtual void KeyAdded(PP_Instance instance, |
| 123 | PP_Var key_system, |
| 124 | PP_Var session_id) OVERRIDE; |
| 125 | virtual void KeyMessage(PP_Instance instance, |
| 126 | PP_Var key_system, |
| 127 | PP_Var session_id, |
| 128 | PP_Resource message, |
| 129 | PP_Var default_url) OVERRIDE; |
| 130 | virtual void KeyError(PP_Instance instance, |
| 131 | PP_Var key_system, |
| 132 | PP_Var session_id, |
| 133 | int32_t media_error, |
| 134 | int32_t system_code) OVERRIDE; |
| 135 | virtual void DeliverBlock(PP_Instance instance, |
| 136 | PP_Resource decrypted_block, |
| 137 | int32_t request_id) OVERRIDE; |
| 138 | virtual void DeliverFrame(PP_Instance instance, |
| 139 | PP_Resource decrypted_frame, |
| 140 | int32_t request_id) OVERRIDE; |
| 141 | virtual void DeliverSamples(PP_Instance instance, |
| 142 | PP_Resource decrypted_samples, |
| 143 | int32_t request_id) OVERRIDE; |
[email protected] | c962f86 | 2012-04-12 00:02:04 | [diff] [blame] | 144 | #endif // !defined(OS_NACL) |
[email protected] | ceadc39 | 2011-06-15 23:04:24 | [diff] [blame] | 145 | |
[email protected] | ac4b54d | 2011-10-20 23:09:28 | [diff] [blame] | 146 | static const ApiID kApiID = API_ID_PPB_INSTANCE; |
[email protected] | 5c96602 | 2011-09-13 18:09:37 | [diff] [blame] | 147 | |
[email protected] | 4c2e935 | 2010-11-05 22:13:02 | [diff] [blame] | 148 | private: |
[email protected] | 0f41c01 | 2011-10-21 19:49:20 | [diff] [blame] | 149 | // Plugin -> Host message handlers. |
[email protected] | e8f07ac | 2012-01-03 17:43:36 | [diff] [blame] | 150 | void OnHostMsgGetWindowObject(PP_Instance instance, |
| 151 | SerializedVarReturnValue result); |
| 152 | void OnHostMsgGetOwnerElementObject(PP_Instance instance, |
[email protected] | 0346023 | 2011-10-10 17:23:57 | [diff] [blame] | 153 | SerializedVarReturnValue result); |
[email protected] | e8f07ac | 2012-01-03 17:43:36 | [diff] [blame] | 154 | void OnHostMsgBindGraphics(PP_Instance instance, |
| 155 | const ppapi::HostResource& device, |
| 156 | PP_Bool* result); |
| 157 | void OnHostMsgIsFullFrame(PP_Instance instance, PP_Bool* result); |
| 158 | void OnHostMsgExecuteScript(PP_Instance instance, |
| 159 | SerializedVarReceiveInput script, |
| 160 | SerializedVarOutParam out_exception, |
| 161 | SerializedVarReturnValue result); |
[email protected] | c59ed589 | 2012-02-18 01:10:19 | [diff] [blame] | 162 | void OnHostMsgGetAudioHardwareOutputSampleRate(PP_Instance instance, |
| 163 | uint32_t *result); |
| 164 | void OnHostMsgGetAudioHardwareOutputBufferSize(PP_Instance instance, |
| 165 | uint32_t *result); |
[email protected] | e8f07ac | 2012-01-03 17:43:36 | [diff] [blame] | 166 | void OnHostMsgGetDefaultCharSet(PP_Instance instance, |
| 167 | SerializedVarReturnValue result); |
[email protected] | e8f07ac | 2012-01-03 17:43:36 | [diff] [blame] | 168 | void OnHostMsgSetFullscreen(PP_Instance instance, |
| 169 | PP_Bool fullscreen, |
| 170 | PP_Bool* result); |
| 171 | void OnHostMsgGetScreenSize(PP_Instance instance, |
| 172 | PP_Bool* result, |
| 173 | PP_Size* size); |
[email protected] | e8f07ac | 2012-01-03 17:43:36 | [diff] [blame] | 174 | void OnHostMsgRequestInputEvents(PP_Instance instance, |
| 175 | bool is_filtering, |
| 176 | uint32_t event_classes); |
| 177 | void OnHostMsgClearInputEvents(PP_Instance instance, |
| 178 | uint32_t event_classes); |
[email protected] | 3b98ced7 | 2012-03-09 02:08:33 | [diff] [blame] | 179 | void OnMsgHandleInputEventAck(PP_Instance instance, |
| 180 | PP_TimeTicks timestamp); |
[email protected] | e8f07ac | 2012-01-03 17:43:36 | [diff] [blame] | 181 | void OnHostMsgPostMessage(PP_Instance instance, |
| 182 | SerializedVarReceiveInput message); |
| 183 | void OnHostMsgLockMouse(PP_Instance instance); |
| 184 | void OnHostMsgUnlockMouse(PP_Instance instance); |
[email protected] | 4d80a3db | 2012-06-21 17:58:24 | [diff] [blame] | 185 | void OnHostMsgGetDefaultPrintSettings(PP_Instance instance, |
| 186 | PP_PrintSettings_Dev* settings, |
| 187 | bool* result); |
[email protected] | c962f86 | 2012-04-12 00:02:04 | [diff] [blame] | 188 | void OnHostMsgSetCursor(PP_Instance instance, |
| 189 | int32_t type, |
| 190 | const ppapi::HostResource& custom_image, |
| 191 | const PP_Point& hot_spot); |
[email protected] | 4c44183a | 2012-04-27 16:52:23 | [diff] [blame] | 192 | void OnHostMsgSetTextInputType(PP_Instance instance, PP_TextInput_Type type); |
| 193 | void OnHostMsgUpdateCaretPosition(PP_Instance instance, |
| 194 | const PP_Rect& caret, |
| 195 | const PP_Rect& bounding_box); |
| 196 | void OnHostMsgCancelCompositionText(PP_Instance instance); |
| 197 | void OnHostMsgUpdateSurroundingText( |
| 198 | PP_Instance instance, |
| 199 | const std::string& text, |
| 200 | uint32_t caret, |
| 201 | uint32_t anchor); |
[email protected] | e5aeef0 | 2012-08-17 00:18:43 | [diff] [blame] | 202 | |
[email protected] | c962f86 | 2012-04-12 00:02:04 | [diff] [blame] | 203 | #if !defined(OS_NACL) |
[email protected] | e8f07ac | 2012-01-03 17:43:36 | [diff] [blame] | 204 | void OnHostMsgResolveRelativeToDocument(PP_Instance instance, |
| 205 | SerializedVarReceiveInput relative, |
| 206 | SerializedVarReturnValue result); |
| 207 | void OnHostMsgDocumentCanRequest(PP_Instance instance, |
| 208 | SerializedVarReceiveInput url, |
| 209 | PP_Bool* result); |
| 210 | void OnHostMsgDocumentCanAccessDocument(PP_Instance active, |
| 211 | PP_Instance target, |
| 212 | PP_Bool* result); |
| 213 | void OnHostMsgGetDocumentURL(PP_Instance instance, |
| 214 | SerializedVarReturnValue result); |
| 215 | void OnHostMsgGetPluginInstanceURL(PP_Instance instance, |
| 216 | SerializedVarReturnValue result); |
[email protected] | e5aeef0 | 2012-08-17 00:18:43 | [diff] [blame] | 217 | virtual void OnHostMsgNeedKey(PP_Instance instance, |
| 218 | SerializedVarReceiveInput key_system, |
| 219 | SerializedVarReceiveInput session_id, |
| 220 | SerializedVarReceiveInput init_data); |
| 221 | virtual void OnHostMsgKeyAdded(PP_Instance instance, |
| 222 | SerializedVarReceiveInput key_system, |
| 223 | SerializedVarReceiveInput session_id); |
| 224 | virtual void OnHostMsgKeyMessage(PP_Instance instance, |
| 225 | SerializedVarReceiveInput key_system, |
| 226 | SerializedVarReceiveInput session_id, |
| 227 | PP_Resource message, |
| 228 | SerializedVarReceiveInput default_url); |
| 229 | virtual void OnHostMsgKeyError(PP_Instance instance, |
| 230 | SerializedVarReceiveInput key_system, |
| 231 | SerializedVarReceiveInput session_id, |
| 232 | int32_t media_error, |
| 233 | int32_t system_code); |
| 234 | virtual void OnHostMsgDeliverBlock(PP_Instance instance, |
| 235 | PP_Resource decrypted_block, |
| 236 | int32_t request_id); |
| 237 | virtual void OnHostMsgDeliverFrame(PP_Instance instance, |
| 238 | PP_Resource decrypted_frame, |
| 239 | int32_t request_id); |
| 240 | virtual void OnHostMsgDeliverSamples(PP_Instance instance, |
| 241 | PP_Resource decrypted_samples, |
| 242 | int32_t request_id); |
[email protected] | c962f86 | 2012-04-12 00:02:04 | [diff] [blame] | 243 | #endif // !defined(OS_NACL) |
[email protected] | 0f41c01 | 2011-10-21 19:49:20 | [diff] [blame] | 244 | |
| 245 | // Host -> Plugin message handlers. |
[email protected] | e8f07ac | 2012-01-03 17:43:36 | [diff] [blame] | 246 | void OnPluginMsgMouseLockComplete(PP_Instance instance, int32_t result); |
[email protected] | 0f41c01 | 2011-10-21 19:49:20 | [diff] [blame] | 247 | |
| 248 | void MouseLockCompleteInHost(int32_t result, PP_Instance instance); |
| 249 | |
[email protected] | a8e7214 | 2012-08-21 17:24:20 | [diff] [blame^] | 250 | // Other helpers. |
| 251 | void CancelAnyPendingRequestSurroundingText(PP_Instance instance); |
| 252 | |
[email protected] | 47a961c | 2012-07-13 19:18:52 | [diff] [blame] | 253 | ProxyCompletionCallbackFactory<PPB_Instance_Proxy> callback_factory_; |
[email protected] | 4c2e935 | 2010-11-05 22:13:02 | [diff] [blame] | 254 | }; |
| 255 | |
| 256 | } // namespace proxy |
[email protected] | 4d2efd2 | 2011-08-18 21:58:02 | [diff] [blame] | 257 | } // namespace ppapi |
[email protected] | 4c2e935 | 2010-11-05 22:13:02 | [diff] [blame] | 258 | |
| 259 | #endif // PPAPI_PROXY_PPB_INSTANCE_PROXY_H_ |