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;
150 virtual void ZoomChanged(PP_Instance instance
, double factor
) = 0;
151 virtual void ZoomLimitsChanged(PP_Instance instance
,
152 double minimum_factor
,
153 double maximum_factor
) = 0;
154 // Testing and URLUtil.
155 virtual PP_Var
GetDocumentURL(PP_Instance instance
,
156 PP_URLComponents_Dev
* components
) = 0;
157 #if !defined(OS_NACL)
158 // Content Decryptor.
159 virtual void PromiseResolved(PP_Instance instance
, uint32 promise_id
) = 0;
160 virtual void PromiseResolvedWithSession(PP_Instance instance
,
162 PP_Var session_id_var
) = 0;
163 virtual void PromiseRejected(PP_Instance instance
,
165 PP_CdmExceptionCode exception_code
,
167 PP_Var error_description_var
) = 0;
168 virtual void SessionMessage(PP_Instance instance
,
169 PP_Var session_id_var
,
170 PP_CdmMessageType message_type
,
172 PP_Var legacy_destination_url_var
) = 0;
173 virtual void SessionKeysChange(
174 PP_Instance instance
,
175 PP_Var session_id_var
,
176 PP_Bool has_additional_usable_key
,
178 const struct PP_KeyInformation key_information
[]) = 0;
179 virtual void SessionExpirationChange(PP_Instance instance
,
180 PP_Var session_id_var
,
181 PP_Time new_expiry_time
) = 0;
182 virtual void SessionClosed(PP_Instance instance
, PP_Var session_id_var
) = 0;
183 virtual void LegacySessionError(PP_Instance instance
,
184 PP_Var session_id_var
,
185 PP_CdmExceptionCode exception_code
,
187 PP_Var error_description_var
) = 0;
188 virtual void DeliverBlock(PP_Instance instance
,
189 PP_Resource decrypted_block
,
190 const PP_DecryptedBlockInfo
* block_info
) = 0;
191 virtual void DecoderInitializeDone(PP_Instance instance
,
192 PP_DecryptorStreamType decoder_type
,
194 PP_Bool success
) = 0;
195 virtual void DecoderDeinitializeDone(PP_Instance instance
,
196 PP_DecryptorStreamType decoder_type
,
197 uint32_t request_id
) = 0;
198 virtual void DecoderResetDone(PP_Instance instance
,
199 PP_DecryptorStreamType decoder_type
,
200 uint32_t request_id
) = 0;
201 virtual void DeliverFrame(PP_Instance instance
,
202 PP_Resource decrypted_frame
,
203 const PP_DecryptedFrameInfo
* frame_info
) = 0;
204 virtual void DeliverSamples(PP_Instance instance
,
205 PP_Resource audio_frames
,
206 const PP_DecryptedSampleInfo
* sample_info
) = 0;
209 virtual PP_Var
ResolveRelativeToDocument(
210 PP_Instance instance
,
212 PP_URLComponents_Dev
* components
) = 0;
213 virtual PP_Bool
DocumentCanRequest(PP_Instance instance
, PP_Var url
) = 0;
214 virtual PP_Bool
DocumentCanAccessDocument(PP_Instance instance
,
215 PP_Instance target
) = 0;
216 virtual PP_Var
GetPluginInstanceURL(PP_Instance instance
,
217 PP_URLComponents_Dev
* components
) = 0;
218 virtual PP_Var
GetPluginReferrerURL(PP_Instance instance
,
219 PP_URLComponents_Dev
* components
) = 0;
220 #endif // !defined(OS_NACL)
222 static const ApiID kApiID
= API_ID_PPB_INSTANCE
;
228 #endif // PPAPI_THUNK_INSTANCE_API_H_