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.
5 #ifndef PPAPI_THUNK_INSTANCE_API_H_
6 #define PPAPI_THUNK_INSTANCE_API_H_
8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "ppapi/c/dev/ppb_url_util_dev.h"
11 #include "ppapi/c/pp_bool.h"
12 #include "ppapi/c/pp_completion_callback.h"
13 #include "ppapi/c/pp_size.h"
14 #include "ppapi/c/pp_time.h"
15 #include "ppapi/c/ppb_audio_config.h"
16 #include "ppapi/c/ppb_console.h"
17 #include "ppapi/c/ppb_gamepad.h"
18 #include "ppapi/c/ppb_instance.h"
19 #include "ppapi/c/ppb_mouse_cursor.h"
20 #include "ppapi/c/ppb_text_input_controller.h"
21 #include "ppapi/c/private/pp_content_decryptor.h"
22 #include "ppapi/c/private/ppb_instance_private.h"
23 #include "ppapi/shared_impl/api_id.h"
24 #include "ppapi/shared_impl/resource.h"
25 #include "ppapi/shared_impl/singleton_resource_id.h"
27 // Windows headers interfere with this file.
32 struct PP_DecryptedBlockInfo
;
33 struct PP_DecryptedFrameInfo
;
34 struct PPP_MessageHandler_0_2
;
39 class TrackedCallback
;
46 class PPB_Instance_API
{
48 virtual ~PPB_Instance_API() {}
50 virtual PP_Bool
BindGraphics(PP_Instance instance
, PP_Resource device
) = 0;
51 virtual PP_Bool
IsFullFrame(PP_Instance instance
) = 0;
53 // Unexposed PPAPI functions for proxying.
54 // Returns the internal view data struct.
55 virtual const ViewData
* GetViewData(PP_Instance instance
) = 0;
56 // Returns the flash fullscreen status.
57 virtual PP_Bool
FlashIsFullscreen(PP_Instance instance
) = 0;
60 virtual PP_Var
GetWindowObject(PP_Instance instance
) = 0;
61 virtual PP_Var
GetOwnerElementObject(PP_Instance instance
) = 0;
62 virtual PP_Var
ExecuteScript(PP_Instance instance
,
64 PP_Var
* exception
) = 0;
67 virtual uint32_t GetAudioHardwareOutputSampleRate(PP_Instance instance
) = 0;
68 virtual uint32_t GetAudioHardwareOutputBufferSize(PP_Instance instance
) = 0;
71 virtual PP_Var
GetDefaultCharSet(PP_Instance instance
) = 0;
74 virtual void Log(PP_Instance instance
,
75 PP_LogLevel log_level
,
77 virtual void LogWithSource(PP_Instance instance
,
78 PP_LogLevel log_level
,
83 virtual void SetPluginToHandleFindRequests(PP_Instance instance
) = 0;
84 virtual void NumberOfFindResultsChanged(PP_Instance instance
,
86 PP_Bool final_result
) = 0;
87 virtual void SelectedFindResultChanged(PP_Instance instance
,
89 virtual void SetTickmarks(PP_Instance instance
,
90 const PP_Rect
* tickmarks
,
94 virtual PP_Bool
IsFullscreen(PP_Instance instance
) = 0;
95 virtual PP_Bool
SetFullscreen(PP_Instance instance
,
96 PP_Bool fullscreen
) = 0;
97 virtual PP_Bool
GetScreenSize(PP_Instance instance
, PP_Size
* size
) = 0;
99 // This is an implementation-only function which grabs an instance of a
100 // "singleton resource". These are used to implement instance interfaces
101 // (functions which are associated with the instance itself as opposed to a
103 virtual Resource
* GetSingletonResource(
104 PP_Instance instance
, SingletonResourceID id
) = 0;
107 virtual int32_t RequestInputEvents(PP_Instance instance
,
108 uint32_t event_classes
) = 0;
109 virtual int32_t RequestFilteringInputEvents(PP_Instance instance
,
110 uint32_t event_classes
) = 0;
111 virtual void ClearInputEventRequest(PP_Instance instance
,
112 uint32_t event_classes
) = 0;
114 // InputEventPrivate.
115 virtual void StartTrackingLatency(PP_Instance instance
) = 0;
118 virtual void PostMessage(PP_Instance instance
, PP_Var message
) = 0;
119 virtual int32_t RegisterMessageHandler(PP_Instance instance
,
121 const PPP_MessageHandler_0_2
* handler
,
122 PP_Resource message_loop
) = 0;
123 virtual void UnregisterMessageHandler(PP_Instance instance
) = 0;
126 virtual PP_Bool
SetCursor(PP_Instance instance
,
127 PP_MouseCursor_Type type
,
129 const PP_Point
* hot_spot
) = 0;
132 virtual int32_t LockMouse(PP_Instance instance
,
133 scoped_refptr
<TrackedCallback
> callback
) = 0;
134 virtual void UnlockMouse(PP_Instance instance
) = 0;
137 virtual void SetTextInputType(PP_Instance instance
,
138 PP_TextInput_Type type
) = 0;
139 virtual void UpdateCaretPosition(PP_Instance instance
,
140 const PP_Rect
& caret
,
141 const PP_Rect
& bounding_box
) = 0;
142 virtual void CancelCompositionText(PP_Instance instance
) = 0;
143 virtual void SelectionChanged(PP_Instance instance
) = 0;
144 virtual void UpdateSurroundingText(PP_Instance instance
,
147 uint32_t anchor
) = 0;
149 // Testing and URLUtil.
150 virtual PP_Var
GetDocumentURL(PP_Instance instance
,
151 PP_URLComponents_Dev
* components
) = 0;
152 #if !defined(OS_NACL)
153 // Content Decryptor.
154 virtual void PromiseResolved(PP_Instance instance
, uint32 promise_id
) = 0;
155 virtual void PromiseResolvedWithSession(PP_Instance instance
,
157 PP_Var session_id_var
) = 0;
158 virtual void PromiseRejected(PP_Instance instance
,
160 PP_CdmExceptionCode exception_code
,
162 PP_Var error_description_var
) = 0;
163 virtual void SessionMessage(PP_Instance instance
,
164 PP_Var session_id_var
,
165 PP_CdmMessageType message_type
,
167 PP_Var legacy_destination_url_var
) = 0;
168 virtual void SessionKeysChange(
169 PP_Instance instance
,
170 PP_Var session_id_var
,
171 PP_Bool has_additional_usable_key
,
173 const struct PP_KeyInformation key_information
[]) = 0;
174 virtual void SessionExpirationChange(PP_Instance instance
,
175 PP_Var session_id_var
,
176 PP_Time new_expiry_time
) = 0;
177 virtual void SessionClosed(PP_Instance instance
, PP_Var session_id_var
) = 0;
178 virtual void LegacySessionError(PP_Instance instance
,
179 PP_Var session_id_var
,
180 PP_CdmExceptionCode exception_code
,
182 PP_Var error_description_var
) = 0;
183 virtual void DeliverBlock(PP_Instance instance
,
184 PP_Resource decrypted_block
,
185 const PP_DecryptedBlockInfo
* block_info
) = 0;
186 virtual void DecoderInitializeDone(PP_Instance instance
,
187 PP_DecryptorStreamType decoder_type
,
189 PP_Bool success
) = 0;
190 virtual void DecoderDeinitializeDone(PP_Instance instance
,
191 PP_DecryptorStreamType decoder_type
,
192 uint32_t request_id
) = 0;
193 virtual void DecoderResetDone(PP_Instance instance
,
194 PP_DecryptorStreamType decoder_type
,
195 uint32_t request_id
) = 0;
196 virtual void DeliverFrame(PP_Instance instance
,
197 PP_Resource decrypted_frame
,
198 const PP_DecryptedFrameInfo
* frame_info
) = 0;
199 virtual void DeliverSamples(PP_Instance instance
,
200 PP_Resource audio_frames
,
201 const PP_DecryptedSampleInfo
* sample_info
) = 0;
204 virtual PP_Var
ResolveRelativeToDocument(
205 PP_Instance instance
,
207 PP_URLComponents_Dev
* components
) = 0;
208 virtual PP_Bool
DocumentCanRequest(PP_Instance instance
, PP_Var url
) = 0;
209 virtual PP_Bool
DocumentCanAccessDocument(PP_Instance instance
,
210 PP_Instance target
) = 0;
211 virtual PP_Var
GetPluginInstanceURL(PP_Instance instance
,
212 PP_URLComponents_Dev
* components
) = 0;
213 virtual PP_Var
GetPluginReferrerURL(PP_Instance instance
,
214 PP_URLComponents_Dev
* components
) = 0;
215 #endif // !defined(OS_NACL)
217 static const ApiID kApiID
= API_ID_PPB_INSTANCE
;
223 #endif // PPAPI_THUNK_INSTANCE_API_H_