1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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_THUNK_INSTANCE_API_H_ 6 #define PPAPI_THUNK_INSTANCE_API_H_ 7 8 #include "base/memory/ref_counted.h" 9 #include "base/memory/scoped_ptr.h" 10 #include "ppapi/c/dev/ppb_messaging_deprecated.h" 11 #include "ppapi/c/dev/ppb_url_util_dev.h" 12 #include "ppapi/c/pp_bool.h" 13 #include "ppapi/c/pp_completion_callback.h" 14 #include "ppapi/c/pp_size.h" 15 #include "ppapi/c/pp_time.h" 16 #include "ppapi/c/ppb_audio_config.h" 17 #include "ppapi/c/ppb_console.h" 18 #include "ppapi/c/ppb_gamepad.h" 19 #include "ppapi/c/ppb_instance.h" 20 #include "ppapi/c/ppb_mouse_cursor.h" 21 #include "ppapi/c/ppb_text_input_controller.h" 22 #include "ppapi/c/private/pp_content_decryptor.h" 23 #include "ppapi/c/private/ppb_instance_private.h" 24 #include "ppapi/shared_impl/api_id.h" 25 #include "ppapi/shared_impl/resource.h" 26 #include "ppapi/shared_impl/singleton_resource_id.h" 27 28 // Windows headers interfere with this file. 29 #ifdef PostMessage 30 #undef PostMessage 31 #endif 32 33 struct PP_DecryptedBlockInfo; 34 struct PP_DecryptedFrameInfo; 35 struct PPP_MessageHandler_0_2; 36 37 namespace ppapi { 38 39 class Resource; 40 class TrackedCallback; 41 struct ViewData; 42 43 namespace thunk { 44 45 class PPB_Flash_API; 46 47 class PPB_Instance_API { 48 public: ~PPB_Instance_API()49 virtual ~PPB_Instance_API() {} 50 51 virtual PP_Bool BindGraphics(PP_Instance instance, PP_Resource device) = 0; 52 virtual PP_Bool IsFullFrame(PP_Instance instance) = 0; 53 54 // Unexposed PPAPI functions for proxying. 55 // Returns the internal view data struct. 56 virtual const ViewData* GetViewData(PP_Instance instance) = 0; 57 // Returns the flash fullscreen status. 58 virtual PP_Bool FlashIsFullscreen(PP_Instance instance) = 0; 59 60 // InstancePrivate. 61 virtual PP_Var GetWindowObject(PP_Instance instance) = 0; 62 virtual PP_Var GetOwnerElementObject(PP_Instance instance) = 0; 63 virtual PP_Var ExecuteScript(PP_Instance instance, 64 PP_Var script, 65 PP_Var* exception) = 0; 66 67 // Audio. 68 virtual uint32_t GetAudioHardwareOutputSampleRate(PP_Instance instance) = 0; 69 virtual uint32_t GetAudioHardwareOutputBufferSize(PP_Instance instance) = 0; 70 71 // CharSet. 72 virtual PP_Var GetDefaultCharSet(PP_Instance instance) = 0; 73 74 // Console. 75 virtual void Log(PP_Instance instance, 76 PP_LogLevel log_level, 77 PP_Var value) = 0; 78 virtual void LogWithSource(PP_Instance instance, 79 PP_LogLevel log_level, 80 PP_Var source, 81 PP_Var value) = 0; 82 83 // Find. 84 virtual void SetPluginToHandleFindRequests(PP_Instance instance) = 0; 85 virtual void NumberOfFindResultsChanged(PP_Instance instance, 86 int32_t total, 87 PP_Bool final_result) = 0; 88 virtual void SelectedFindResultChanged(PP_Instance instance, 89 int32_t index) = 0; 90 virtual void SetTickmarks(PP_Instance instance, 91 const PP_Rect* tickmarks, 92 uint32_t count) = 0; 93 94 // Fullscreen. 95 virtual PP_Bool IsFullscreen(PP_Instance instance) = 0; 96 virtual PP_Bool SetFullscreen(PP_Instance instance, 97 PP_Bool fullscreen) = 0; 98 virtual PP_Bool GetScreenSize(PP_Instance instance, PP_Size* size) = 0; 99 100 // This is an implementation-only function which grabs an instance of a 101 // "singleton resource". These are used to implement instance interfaces 102 // (functions which are associated with the instance itself as opposed to a 103 // resource). 104 virtual Resource* GetSingletonResource( 105 PP_Instance instance, SingletonResourceID id) = 0; 106 107 // InputEvent. 108 virtual int32_t RequestInputEvents(PP_Instance instance, 109 uint32_t event_classes) = 0; 110 virtual int32_t RequestFilteringInputEvents(PP_Instance instance, 111 uint32_t event_classes) = 0; 112 virtual void ClearInputEventRequest(PP_Instance instance, 113 uint32_t event_classes) = 0; 114 115 // InputEventPrivate. 116 virtual void StartTrackingLatency(PP_Instance instance) = 0; 117 118 // Messaging. 119 virtual void PostMessage(PP_Instance instance, PP_Var message) = 0; 120 virtual int32_t RegisterMessageHandler(PP_Instance instance, 121 void* user_data, 122 const PPP_MessageHandler_0_2* handler, 123 PP_Resource message_loop) = 0; 124 virtual int32_t RegisterMessageHandler_1_1_Deprecated( 125 PP_Instance instance, 126 void* user_data, 127 const PPP_MessageHandler_0_1_Deprecated* handler, 128 PP_Resource message_loop) = 0; 129 virtual void UnregisterMessageHandler(PP_Instance instance) = 0; 130 131 // Mouse cursor. 132 virtual PP_Bool SetCursor(PP_Instance instance, 133 PP_MouseCursor_Type type, 134 PP_Resource image, 135 const PP_Point* hot_spot) = 0; 136 137 // MouseLock. 138 virtual int32_t LockMouse(PP_Instance instance, 139 scoped_refptr<TrackedCallback> callback) = 0; 140 virtual void UnlockMouse(PP_Instance instance) = 0; 141 142 // TextInput. 143 virtual void SetTextInputType(PP_Instance instance, 144 PP_TextInput_Type type) = 0; 145 virtual void UpdateCaretPosition(PP_Instance instance, 146 const PP_Rect& caret, 147 const PP_Rect& bounding_box) = 0; 148 virtual void CancelCompositionText(PP_Instance instance) = 0; 149 virtual void SelectionChanged(PP_Instance instance) = 0; 150 virtual void UpdateSurroundingText(PP_Instance instance, 151 const char* text, 152 uint32_t caret, 153 uint32_t anchor) = 0; 154 155 // Zoom. 156 virtual void ZoomChanged(PP_Instance instance, double factor) = 0; 157 virtual void ZoomLimitsChanged(PP_Instance instance, 158 double minimum_factor, 159 double maximum_factor) = 0; 160 // Testing and URLUtil. 161 virtual PP_Var GetDocumentURL(PP_Instance instance, 162 PP_URLComponents_Dev* components) = 0; 163 #if !defined(OS_NACL) 164 // Content Decryptor. 165 virtual void PromiseResolved(PP_Instance instance, uint32 promise_id) = 0; 166 virtual void PromiseResolvedWithSession(PP_Instance instance, 167 uint32 promise_id, 168 PP_Var web_session_id_var) = 0; 169 virtual void PromiseResolvedWithKeyIds(PP_Instance instance, 170 uint32 promise_id, 171 PP_Var key_ids_var) = 0; 172 virtual void PromiseRejected(PP_Instance instance, 173 uint32 promise_id, 174 PP_CdmExceptionCode exception_code, 175 uint32 system_code, 176 PP_Var error_description_var) = 0; 177 virtual void SessionMessage(PP_Instance instance, 178 PP_Var web_session_id_var, 179 PP_Var message_var, 180 PP_Var destination_url_var) = 0; 181 virtual void SessionKeysChange(PP_Instance instance, 182 PP_Var web_session_id_var, 183 PP_Bool has_additional_usable_key) = 0; 184 virtual void SessionExpirationChange(PP_Instance instance, 185 PP_Var web_session_id_var, 186 PP_Time new_expiry_time) = 0; 187 virtual void SessionReady(PP_Instance instance, 188 PP_Var web_session_id_var) = 0; 189 virtual void SessionClosed(PP_Instance instance, 190 PP_Var web_session_id_var) = 0; 191 virtual void SessionError(PP_Instance instance, 192 PP_Var web_session_id_var, 193 PP_CdmExceptionCode exception_code, 194 uint32 system_code, 195 PP_Var error_description_var) = 0; 196 virtual void DeliverBlock(PP_Instance instance, 197 PP_Resource decrypted_block, 198 const PP_DecryptedBlockInfo* block_info) = 0; 199 virtual void DecoderInitializeDone(PP_Instance instance, 200 PP_DecryptorStreamType decoder_type, 201 uint32_t request_id, 202 PP_Bool success) = 0; 203 virtual void DecoderDeinitializeDone(PP_Instance instance, 204 PP_DecryptorStreamType decoder_type, 205 uint32_t request_id) = 0; 206 virtual void DecoderResetDone(PP_Instance instance, 207 PP_DecryptorStreamType decoder_type, 208 uint32_t request_id) = 0; 209 virtual void DeliverFrame(PP_Instance instance, 210 PP_Resource decrypted_frame, 211 const PP_DecryptedFrameInfo* frame_info) = 0; 212 virtual void DeliverSamples(PP_Instance instance, 213 PP_Resource audio_frames, 214 const PP_DecryptedSampleInfo* sample_info) = 0; 215 216 // URLUtil. 217 virtual PP_Var ResolveRelativeToDocument( 218 PP_Instance instance, 219 PP_Var relative, 220 PP_URLComponents_Dev* components) = 0; 221 virtual PP_Bool DocumentCanRequest(PP_Instance instance, PP_Var url) = 0; 222 virtual PP_Bool DocumentCanAccessDocument(PP_Instance instance, 223 PP_Instance target) = 0; 224 virtual PP_Var GetPluginInstanceURL(PP_Instance instance, 225 PP_URLComponents_Dev* components) = 0; 226 virtual PP_Var GetPluginReferrerURL(PP_Instance instance, 227 PP_URLComponents_Dev* components) = 0; 228 #endif // !defined(OS_NACL) 229 230 static const ApiID kApiID = API_ID_PPB_INSTANCE; 231 }; 232 233 } // namespace thunk 234 } // namespace ppapi 235 236 #endif // PPAPI_THUNK_INSTANCE_API_H_ 237