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 #include "base/logging.h"
6 #include "ppapi/c/pp_array_output.h"
7 #include "ppapi/c/pp_errors.h"
8 #include "ppapi/c/private/ppb_flash.h"
9 #include "ppapi/shared_impl/ppapi_globals.h"
10 #include "ppapi/shared_impl/proxy_lock.h"
11 #include "ppapi/shared_impl/var.h"
12 #include "ppapi/thunk/enter.h"
13 #include "ppapi/thunk/ppb_flash_functions_api.h"
14 #include "ppapi/thunk/ppb_instance_api.h"
15 #include "ppapi/thunk/ppb_video_capture_api.h"
16 #include "ppapi/thunk/thunk.h"
23 void SetInstanceAlwaysOnTop(PP_Instance instance
, PP_Bool on_top
) {
24 EnterInstanceAPI
<PPB_Flash_Functions_API
> enter(instance
);
27 enter
.functions()->SetInstanceAlwaysOnTop(instance
, on_top
);
30 PP_Bool
DrawGlyphs(PP_Instance instance
,
31 PP_Resource pp_image_data
,
32 const PP_BrowserFont_Trusted_Description
* font_desc
,
34 const PP_Point
* position
,
36 const float transformation
[3][3],
37 PP_Bool allow_subpixel_aa
,
39 const uint16_t glyph_indices
[],
40 const PP_Point glyph_advances
[]) {
41 EnterInstanceAPI
<PPB_Flash_Functions_API
> enter(instance
);
44 return enter
.functions()->DrawGlyphs(
45 instance
, pp_image_data
, font_desc
, color
, position
, clip
, transformation
,
46 allow_subpixel_aa
, glyph_count
, glyph_indices
, glyph_advances
);
49 PP_Var
GetProxyForURL(PP_Instance instance
, const char* url
) {
50 EnterInstanceAPI
<PPB_Flash_Functions_API
> enter(instance
);
52 return PP_MakeUndefined();
53 return enter
.functions()->GetProxyForURL(instance
, url
);
56 int32_t Navigate(PP_Resource request_id
,
58 PP_Bool from_user_action
) {
59 // TODO(brettw): this function should take an instance.
60 // To work around this, use the PP_Instance from the resource.
63 EnterResource
<PPB_URLRequestInfo_API
> enter(request_id
, true);
65 return PP_ERROR_BADRESOURCE
;
66 instance
= enter
.resource()->pp_instance();
69 EnterInstanceAPI
<PPB_Flash_Functions_API
> enter(instance
);
71 return PP_ERROR_BADARGUMENT
;
72 return enter
.functions()->Navigate(instance
, request_id
, target
,
76 void RunMessageLoop(PP_Instance instance
) {
82 void QuitMessageLoop(PP_Instance instance
) {
88 double GetLocalTimeZoneOffset(PP_Instance instance
, PP_Time t
) {
89 EnterInstanceAPI
<PPB_Flash_Functions_API
> enter(instance
);
92 return enter
.functions()->GetLocalTimeZoneOffset(instance
, t
);
95 PP_Var
GetCommandLineArgs(PP_Module
/* pp_module */) {
96 // There's no instance so we have to reach into the globals without thunking.
98 return StringVar::StringToPPVar(PpapiGlobals::Get()->GetCmdLine());
101 void PreLoadFontWin(const void* logfontw
) {
102 // There's no instance so we have to reach into the delegate without
105 PpapiGlobals::Get()->PreCacheFontForFlash(logfontw
);
108 PP_Bool
IsRectTopmost(PP_Instance instance
, const PP_Rect
* rect
) {
109 EnterInstanceAPI
<PPB_Flash_Functions_API
> enter(instance
);
112 return enter
.functions()->IsRectTopmost(instance
, rect
);
115 int32_t InvokePrinting(PP_Instance instance
) {
116 // This function is no longer supported, use PPB_Flash_Print instead.
117 return PP_ERROR_NOTSUPPORTED
;
120 void UpdateActivity(PP_Instance instance
) {
121 EnterInstanceAPI
<PPB_Flash_Functions_API
> enter(instance
);
124 enter
.functions()->UpdateActivity(instance
);
127 PP_Var
GetDeviceID(PP_Instance instance
) {
130 return PP_MakeUndefined();
133 int32_t GetSettingInt(PP_Instance instance
, PP_FlashSetting setting
) {
139 PP_Var
GetSetting(PP_Instance instance
, PP_FlashSetting setting
) {
140 EnterInstanceAPI
<PPB_Flash_Functions_API
> enter(instance
);
142 return PP_MakeUndefined();
143 return enter
.functions()->GetSetting(instance
, setting
);
146 PP_Bool
SetCrashData(PP_Instance instance
,
147 PP_FlashCrashKey key
,
149 EnterInstanceAPI
<PPB_Flash_Functions_API
> enter(instance
);
152 return enter
.functions()->SetCrashData(instance
, key
, value
);
155 int32_t EnumerateVideoCaptureDevices(PP_Instance instance
,
156 PP_Resource video_capture
,
157 PP_ArrayOutput devices
) {
158 EnterResource
<PPB_VideoCapture_API
> enter(video_capture
, true);
160 return enter
.retval();
161 return enter
.object()->EnumerateDevicesSync(devices
);
164 const PPB_Flash_12_4 g_ppb_flash_12_4_thunk
= {
165 &SetInstanceAlwaysOnTop
,
171 &GetLocalTimeZoneOffset
,
182 const PPB_Flash_12_5 g_ppb_flash_12_5_thunk
= {
183 &SetInstanceAlwaysOnTop
,
189 &GetLocalTimeZoneOffset
,
201 const PPB_Flash_12_6 g_ppb_flash_12_6_thunk
= {
202 &SetInstanceAlwaysOnTop
,
208 &GetLocalTimeZoneOffset
,
218 &EnumerateVideoCaptureDevices
221 const PPB_Flash_13_0 g_ppb_flash_13_0_thunk
= {
222 &SetInstanceAlwaysOnTop
,
226 &GetLocalTimeZoneOffset
,
233 &EnumerateVideoCaptureDevices
238 const PPB_Flash_12_4
* GetPPB_Flash_12_4_Thunk() {
239 return &g_ppb_flash_12_4_thunk
;
242 const PPB_Flash_12_5
* GetPPB_Flash_12_5_Thunk() {
243 return &g_ppb_flash_12_5_thunk
;
246 const PPB_Flash_12_6
* GetPPB_Flash_12_6_Thunk() {
247 return &g_ppb_flash_12_6_thunk
;
250 const PPB_Flash_13_0
* GetPPB_Flash_13_0_Thunk() {
251 return &g_ppb_flash_13_0_thunk
;