[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] | 0f41c01 | 2011-10-21 19:49:20 | [diff] [blame] | 13 | #include "ppapi/proxy/proxy_non_thread_safe_ref_count.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, |
| 88 | PP_CompletionCallback callback) OVERRIDE; |
| 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] | c962f86 | 2012-04-12 00:02:04 | [diff] [blame] | 118 | #endif // !defined(OS_NACL) |
[email protected] | ceadc39 | 2011-06-15 23:04:24 | [diff] [blame] | 119 | |
[email protected] | ac4b54d | 2011-10-20 23:09:28 | [diff] [blame] | 120 | static const ApiID kApiID = API_ID_PPB_INSTANCE; |
[email protected] | 5c96602 | 2011-09-13 18:09:37 | [diff] [blame] | 121 | |
[email protected] | 4c2e935 | 2010-11-05 22:13:02 | [diff] [blame] | 122 | private: |
[email protected] | 0f41c01 | 2011-10-21 19:49:20 | [diff] [blame] | 123 | // Plugin -> Host message handlers. |
[email protected] | e8f07ac | 2012-01-03 17:43:36 | [diff] [blame] | 124 | void OnHostMsgGetWindowObject(PP_Instance instance, |
| 125 | SerializedVarReturnValue result); |
| 126 | void OnHostMsgGetOwnerElementObject(PP_Instance instance, |
[email protected] | 0346023 | 2011-10-10 17:23:57 | [diff] [blame] | 127 | SerializedVarReturnValue result); |
[email protected] | e8f07ac | 2012-01-03 17:43:36 | [diff] [blame] | 128 | void OnHostMsgBindGraphics(PP_Instance instance, |
| 129 | const ppapi::HostResource& device, |
| 130 | PP_Bool* result); |
| 131 | void OnHostMsgIsFullFrame(PP_Instance instance, PP_Bool* result); |
| 132 | void OnHostMsgExecuteScript(PP_Instance instance, |
| 133 | SerializedVarReceiveInput script, |
| 134 | SerializedVarOutParam out_exception, |
| 135 | SerializedVarReturnValue result); |
[email protected] | c59ed589 | 2012-02-18 01:10:19 | [diff] [blame] | 136 | void OnHostMsgGetAudioHardwareOutputSampleRate(PP_Instance instance, |
| 137 | uint32_t *result); |
| 138 | void OnHostMsgGetAudioHardwareOutputBufferSize(PP_Instance instance, |
| 139 | uint32_t *result); |
[email protected] | e8f07ac | 2012-01-03 17:43:36 | [diff] [blame] | 140 | void OnHostMsgGetDefaultCharSet(PP_Instance instance, |
| 141 | SerializedVarReturnValue result); |
[email protected] | e8f07ac | 2012-01-03 17:43:36 | [diff] [blame] | 142 | void OnHostMsgSetFullscreen(PP_Instance instance, |
| 143 | PP_Bool fullscreen, |
| 144 | PP_Bool* result); |
| 145 | void OnHostMsgGetScreenSize(PP_Instance instance, |
| 146 | PP_Bool* result, |
| 147 | PP_Size* size); |
[email protected] | e8f07ac | 2012-01-03 17:43:36 | [diff] [blame] | 148 | void OnHostMsgRequestInputEvents(PP_Instance instance, |
| 149 | bool is_filtering, |
| 150 | uint32_t event_classes); |
| 151 | void OnHostMsgClearInputEvents(PP_Instance instance, |
| 152 | uint32_t event_classes); |
[email protected] | 3b98ced7 | 2012-03-09 02:08:33 | [diff] [blame] | 153 | void OnMsgHandleInputEventAck(PP_Instance instance, |
| 154 | PP_TimeTicks timestamp); |
[email protected] | e8f07ac | 2012-01-03 17:43:36 | [diff] [blame] | 155 | void OnHostMsgPostMessage(PP_Instance instance, |
| 156 | SerializedVarReceiveInput message); |
| 157 | void OnHostMsgLockMouse(PP_Instance instance); |
| 158 | void OnHostMsgUnlockMouse(PP_Instance instance); |
[email protected] | 772a7462 | 2012-06-14 21:15:50 | [diff] [blame^] | 159 | void OnHostMsgGetDefaultPrintSettings(PP_Instance instance, |
| 160 | PP_PrintSettings_Dev* settings, |
| 161 | bool* result); |
[email protected] | c962f86 | 2012-04-12 00:02:04 | [diff] [blame] | 162 | void OnHostMsgSetCursor(PP_Instance instance, |
| 163 | int32_t type, |
| 164 | const ppapi::HostResource& custom_image, |
| 165 | const PP_Point& hot_spot); |
[email protected] | 4c44183a | 2012-04-27 16:52:23 | [diff] [blame] | 166 | void OnHostMsgSetTextInputType(PP_Instance instance, PP_TextInput_Type type); |
| 167 | void OnHostMsgUpdateCaretPosition(PP_Instance instance, |
| 168 | const PP_Rect& caret, |
| 169 | const PP_Rect& bounding_box); |
| 170 | void OnHostMsgCancelCompositionText(PP_Instance instance); |
| 171 | void OnHostMsgUpdateSurroundingText( |
| 172 | PP_Instance instance, |
| 173 | const std::string& text, |
| 174 | uint32_t caret, |
| 175 | uint32_t anchor); |
[email protected] | c962f86 | 2012-04-12 00:02:04 | [diff] [blame] | 176 | #if !defined(OS_NACL) |
[email protected] | e8f07ac | 2012-01-03 17:43:36 | [diff] [blame] | 177 | void OnHostMsgResolveRelativeToDocument(PP_Instance instance, |
| 178 | SerializedVarReceiveInput relative, |
| 179 | SerializedVarReturnValue result); |
| 180 | void OnHostMsgDocumentCanRequest(PP_Instance instance, |
| 181 | SerializedVarReceiveInput url, |
| 182 | PP_Bool* result); |
| 183 | void OnHostMsgDocumentCanAccessDocument(PP_Instance active, |
| 184 | PP_Instance target, |
| 185 | PP_Bool* result); |
| 186 | void OnHostMsgGetDocumentURL(PP_Instance instance, |
| 187 | SerializedVarReturnValue result); |
| 188 | void OnHostMsgGetPluginInstanceURL(PP_Instance instance, |
| 189 | SerializedVarReturnValue result); |
[email protected] | c962f86 | 2012-04-12 00:02:04 | [diff] [blame] | 190 | #endif // !defined(OS_NACL) |
[email protected] | 0f41c01 | 2011-10-21 19:49:20 | [diff] [blame] | 191 | |
| 192 | // Host -> Plugin message handlers. |
[email protected] | e8f07ac | 2012-01-03 17:43:36 | [diff] [blame] | 193 | void OnPluginMsgMouseLockComplete(PP_Instance instance, int32_t result); |
[email protected] | 0f41c01 | 2011-10-21 19:49:20 | [diff] [blame] | 194 | |
| 195 | void MouseLockCompleteInHost(int32_t result, PP_Instance instance); |
| 196 | |
| 197 | pp::CompletionCallbackFactory<PPB_Instance_Proxy, |
| 198 | ProxyNonThreadSafeRefCount> callback_factory_; |
[email protected] | 4c2e935 | 2010-11-05 22:13:02 | [diff] [blame] | 199 | }; |
| 200 | |
| 201 | } // namespace proxy |
[email protected] | 4d2efd2 | 2011-08-18 21:58:02 | [diff] [blame] | 202 | } // namespace ppapi |
[email protected] | 4c2e935 | 2010-11-05 22:13:02 | [diff] [blame] | 203 | |
| 204 | #endif // PPAPI_PROXY_PPB_INSTANCE_PROXY_H_ |