Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(92)

Side by Side Diff: ppapi/proxy/ppb_flash_proxy.cc

Issue 11576016: Revert 172806 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ppapi/proxy/ppb_flash_proxy.h ('k') | ppapi/proxy/serialized_structs.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ppapi/proxy/ppb_flash_proxy.h" 5 #include "ppapi/proxy/ppb_flash_proxy.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 8
9 #include <limits> 9 #include <limits>
10 10
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 const PPB_Flash_Print_1_0* PPB_Flash_Proxy::GetFlashPrintInterface() { 93 const PPB_Flash_Print_1_0* PPB_Flash_Proxy::GetFlashPrintInterface() {
94 return &g_flash_print_interface; 94 return &g_flash_print_interface;
95 } 95 }
96 96
97 bool PPB_Flash_Proxy::OnMessageReceived(const IPC::Message& msg) { 97 bool PPB_Flash_Proxy::OnMessageReceived(const IPC::Message& msg) {
98 if (!dispatcher()->permissions().HasPermission(PERMISSION_FLASH)) 98 if (!dispatcher()->permissions().HasPermission(PERMISSION_FLASH))
99 return false; 99 return false;
100 100
101 bool handled = true; 101 bool handled = true;
102 IPC_BEGIN_MESSAGE_MAP(PPB_Flash_Proxy, msg) 102 IPC_BEGIN_MESSAGE_MAP(PPB_Flash_Proxy, msg)
103 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_SetInstanceAlwaysOnTop,
104 OnHostMsgSetInstanceAlwaysOnTop)
105 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_DrawGlyphs,
106 OnHostMsgDrawGlyphs)
107 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_Navigate, OnHostMsgNavigate)
103 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_GetLocalTimeZoneOffset, 108 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_GetLocalTimeZoneOffset,
104 OnHostMsgGetLocalTimeZoneOffset) 109 OnHostMsgGetLocalTimeZoneOffset)
110 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_IsRectTopmost,
111 OnHostMsgIsRectTopmost)
105 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_InvokePrinting, 112 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_InvokePrinting,
106 OnHostMsgInvokePrinting) 113 OnHostMsgInvokePrinting)
107 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_GetSetting, 114 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_GetSetting,
108 OnHostMsgGetSetting) 115 OnHostMsgGetSetting)
109 IPC_MESSAGE_UNHANDLED(handled = false) 116 IPC_MESSAGE_UNHANDLED(handled = false)
110 IPC_END_MESSAGE_MAP() 117 IPC_END_MESSAGE_MAP()
111 // TODO(brettw) handle bad messages! 118 // TODO(brettw) handle bad messages!
112 return handled; 119 return handled;
113 } 120 }
114 121
122 void PPB_Flash_Proxy::SetInstanceAlwaysOnTop(PP_Instance instance,
123 PP_Bool on_top) {
124 dispatcher()->Send(new PpapiHostMsg_PPBFlash_SetInstanceAlwaysOnTop(
125 API_ID_PPB_FLASH, instance, on_top));
126 }
127
128 PP_Bool PPB_Flash_Proxy::DrawGlyphs(
129 PP_Instance instance,
130 PP_Resource pp_image_data,
131 const PP_BrowserFont_Trusted_Description* font_desc,
132 uint32_t color,
133 const PP_Point* position,
134 const PP_Rect* clip,
135 const float transformation[3][3],
136 PP_Bool allow_subpixel_aa,
137 uint32_t glyph_count,
138 const uint16_t glyph_indices[],
139 const PP_Point glyph_advances[]) {
140 Resource* image_data =
141 PpapiGlobals::Get()->GetResourceTracker()->GetResource(pp_image_data);
142 if (!image_data)
143 return PP_FALSE;
144 // The instance parameter isn't strictly necessary but we check that it
145 // matches anyway.
146 if (image_data->pp_instance() != instance)
147 return PP_FALSE;
148
149 PPBFlash_DrawGlyphs_Params params;
150 params.image_data = image_data->host_resource();
151 params.font_desc.SetFromPPBrowserFontDescription(*font_desc);
152 params.color = color;
153 params.position = *position;
154 params.clip = *clip;
155 for (int i = 0; i < 3; i++) {
156 for (int j = 0; j < 3; j++)
157 params.transformation[i][j] = transformation[i][j];
158 }
159 params.allow_subpixel_aa = allow_subpixel_aa;
160
161 params.glyph_indices.insert(params.glyph_indices.begin(),
162 &glyph_indices[0],
163 &glyph_indices[glyph_count]);
164 params.glyph_advances.insert(params.glyph_advances.begin(),
165 &glyph_advances[0],
166 &glyph_advances[glyph_count]);
167
168 PP_Bool result = PP_FALSE;
169 dispatcher()->Send(new PpapiHostMsg_PPBFlash_DrawGlyphs(
170 API_ID_PPB_FLASH, instance, params, &result));
171 return result;
172 }
173
174 int32_t PPB_Flash_Proxy::Navigate(PP_Instance instance,
175 PP_Resource request_info,
176 const char* target,
177 PP_Bool from_user_action) {
178 thunk::EnterResourceNoLock<thunk::PPB_URLRequestInfo_API> enter(
179 request_info, true);
180 if (enter.failed())
181 return PP_ERROR_BADRESOURCE;
182 return Navigate(instance, enter.object()->GetData(), target,
183 from_user_action);
184 }
185
186 int32_t PPB_Flash_Proxy::Navigate(PP_Instance instance,
187 const URLRequestInfoData& data,
188 const char* target,
189 PP_Bool from_user_action) {
190 int32_t result = PP_ERROR_FAILED;
191 dispatcher()->Send(new PpapiHostMsg_PPBFlash_Navigate(
192 API_ID_PPB_FLASH, instance, data, target, from_user_action, &result));
193 return result;
194 }
195
115 double PPB_Flash_Proxy::GetLocalTimeZoneOffset(PP_Instance instance, 196 double PPB_Flash_Proxy::GetLocalTimeZoneOffset(PP_Instance instance,
116 PP_Time t) { 197 PP_Time t) {
117 LocalTimeZoneOffsetCache& cache = g_local_time_zone_offset_cache.Get(); 198 LocalTimeZoneOffsetCache& cache = g_local_time_zone_offset_cache.Get();
118 199
119 // Get the minimum PP_Time value that shares the same minute as |t|. 200 // Get the minimum PP_Time value that shares the same minute as |t|.
120 // Use cached offset if cache hasn't expired and |t| is in the same minute as 201 // Use cached offset if cache hasn't expired and |t| is in the same minute as
121 // the time for the cached offset (assume offsets change on minute 202 // the time for the cached offset (assume offsets change on minute
122 // boundaries). 203 // boundaries).
123 PP_Time t_minute_base = floor(t / 60.0) * 60.0; 204 PP_Time t_minute_base = floor(t / 60.0) * 60.0;
124 LocalTimeZoneOffsetCache::iterator iter = cache.Get(t_minute_base); 205 LocalTimeZoneOffsetCache::iterator iter = cache.Get(t_minute_base);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 base::Time adj_time = base::Time::FromUTCExploded(exploded); 237 base::Time adj_time = base::Time::FromUTCExploded(exploded);
157 base::Time cur = base::Time::FromUTCExploded(utc_exploded); 238 base::Time cur = base::Time::FromUTCExploded(utc_exploded);
158 cache_entry.offset = (adj_time - cur).InSecondsF(); 239 cache_entry.offset = (adj_time - cur).InSecondsF();
159 } 240 }
160 #endif 241 #endif
161 242
162 cache.Put(t_minute_base, cache_entry); 243 cache.Put(t_minute_base, cache_entry);
163 return cache_entry.offset; 244 return cache_entry.offset;
164 } 245 }
165 246
247 PP_Bool PPB_Flash_Proxy::IsRectTopmost(PP_Instance instance,
248 const PP_Rect* rect) {
249 PP_Bool result = PP_FALSE;
250 dispatcher()->Send(new PpapiHostMsg_PPBFlash_IsRectTopmost(
251 API_ID_PPB_FLASH, instance, *rect, &result));
252 return result;
253 }
254
166 PP_Var PPB_Flash_Proxy::GetSetting(PP_Instance instance, 255 PP_Var PPB_Flash_Proxy::GetSetting(PP_Instance instance,
167 PP_FlashSetting setting) { 256 PP_FlashSetting setting) {
168 PluginDispatcher* plugin_dispatcher = 257 PluginDispatcher* plugin_dispatcher =
169 static_cast<PluginDispatcher*>(dispatcher()); 258 static_cast<PluginDispatcher*>(dispatcher());
170 switch (setting) { 259 switch (setting) {
171 case PP_FLASHSETTING_3DENABLED: 260 case PP_FLASHSETTING_3DENABLED:
172 return PP_MakeBool(PP_FromBool( 261 return PP_MakeBool(PP_FromBool(
173 plugin_dispatcher->preferences().is_3d_supported)); 262 plugin_dispatcher->preferences().is_3d_supported));
174 case PP_FLASHSETTING_INCOGNITO: 263 case PP_FLASHSETTING_INCOGNITO:
175 return PP_MakeBool(PP_FromBool(plugin_dispatcher->incognito())); 264 return PP_MakeBool(PP_FromBool(plugin_dispatcher->incognito()));
176 case PP_FLASHSETTING_STAGE3DENABLED: 265 case PP_FLASHSETTING_STAGE3DENABLED:
177 return PP_MakeBool(PP_FromBool( 266 return PP_MakeBool(PP_FromBool(
178 plugin_dispatcher->preferences().is_stage3d_supported)); 267 plugin_dispatcher->preferences().is_stage3d_supported));
179 case PP_FLASHSETTING_LANGUAGE: 268 case PP_FLASHSETTING_LANGUAGE:
180 return StringVar::StringToPPVar( 269 return StringVar::StringToPPVar(
181 PluginGlobals::Get()->GetUILanguage()); 270 PluginGlobals::Get()->GetUILanguage());
182 case PP_FLASHSETTING_NUMCORES: 271 case PP_FLASHSETTING_NUMCORES:
183 return PP_MakeInt32(plugin_dispatcher->preferences().number_of_cpu_cores); 272 return PP_MakeInt32(plugin_dispatcher->preferences().number_of_cpu_cores);
184 case PP_FLASHSETTING_LSORESTRICTIONS: { 273 case PP_FLASHSETTING_LSORESTRICTIONS: {
185 ReceiveSerializedVarReturnValue result; 274 ReceiveSerializedVarReturnValue result;
186 dispatcher()->Send(new PpapiHostMsg_PPBFlash_GetSetting( 275 dispatcher()->Send(new PpapiHostMsg_PPBFlash_GetSetting(
187 API_ID_PPB_FLASH, instance, setting, &result)); 276 API_ID_PPB_FLASH, instance, setting, &result));
188 return result.Return(dispatcher()); 277 return result.Return(dispatcher());
189 } 278 }
190 } 279 }
191 return PP_MakeUndefined(); 280 return PP_MakeUndefined();
192 } 281 }
193 282
283 void PPB_Flash_Proxy::OnHostMsgSetInstanceAlwaysOnTop(PP_Instance instance,
284 PP_Bool on_top) {
285 EnterInstanceNoLock enter(instance);
286 if (enter.succeeded())
287 enter.functions()->GetFlashAPI()->SetInstanceAlwaysOnTop(instance, on_top);
288 }
289
290 void PPB_Flash_Proxy::OnHostMsgDrawGlyphs(
291 PP_Instance instance,
292 const PPBFlash_DrawGlyphs_Params& params,
293 PP_Bool* result) {
294 *result = PP_FALSE;
295 EnterInstanceNoLock enter(instance);
296 if (enter.failed())
297 return;
298
299 if (params.glyph_indices.size() != params.glyph_advances.size() ||
300 params.glyph_indices.empty())
301 return;
302
303 PP_BrowserFont_Trusted_Description font_desc;
304 params.font_desc.SetToPPBrowserFontDescription(&font_desc);
305
306 *result = enter.functions()->GetFlashAPI()->DrawGlyphs(
307 0, // Unused instance param.
308 params.image_data.host_resource(), &font_desc,
309 params.color, &params.position, &params.clip,
310 const_cast<float(*)[3]>(params.transformation),
311 params.allow_subpixel_aa,
312 static_cast<uint32_t>(params.glyph_indices.size()),
313 const_cast<uint16_t*>(&params.glyph_indices[0]),
314 const_cast<PP_Point*>(&params.glyph_advances[0]));
315
316 // SetToPPFontDescription() creates a var which is owned by the caller.
317 PpapiGlobals::Get()->GetVarTracker()->ReleaseVar(font_desc.face);
318 }
319
320 void PPB_Flash_Proxy::OnHostMsgNavigate(PP_Instance instance,
321 const URLRequestInfoData& data,
322 const std::string& target,
323 PP_Bool from_user_action,
324 int32_t* result) {
325 EnterInstanceNoLock enter_instance(instance);
326 if (enter_instance.failed()) {
327 *result = PP_ERROR_BADARGUMENT;
328 return;
329 }
330 DCHECK(!dispatcher()->IsPlugin());
331
332 // Validate the PP_Instance since we'll be constructing resources on its
333 // behalf.
334 HostDispatcher* host_dispatcher = static_cast<HostDispatcher*>(dispatcher());
335 if (HostDispatcher::GetForInstance(instance) != host_dispatcher) {
336 NOTREACHED();
337 *result = PP_ERROR_BADARGUMENT;
338 return;
339 }
340
341 // We need to allow re-entrancy here, because this may call into Javascript
342 // (e.g. with a "javascript:" URL), or do things like navigate away from the
343 // page, either one of which will need to re-enter into the plugin.
344 // It is safe, because it is essentially equivalent to NPN_GetURL, where Flash
345 // would expect re-entrancy. When running in-process, it does re-enter here.
346 host_dispatcher->set_allow_plugin_reentrancy();
347 *result = enter_instance.functions()->GetFlashAPI()->Navigate(
348 instance, data, target.c_str(), from_user_action);
349 }
350
194 void PPB_Flash_Proxy::OnHostMsgGetLocalTimeZoneOffset(PP_Instance instance, 351 void PPB_Flash_Proxy::OnHostMsgGetLocalTimeZoneOffset(PP_Instance instance,
195 PP_Time t, 352 PP_Time t,
196 double* result) { 353 double* result) {
197 EnterInstanceNoLock enter(instance); 354 EnterInstanceNoLock enter(instance);
198 if (enter.succeeded()) { 355 if (enter.succeeded()) {
199 *result = enter.functions()->GetFlashAPI()->GetLocalTimeZoneOffset( 356 *result = enter.functions()->GetFlashAPI()->GetLocalTimeZoneOffset(
200 instance, t); 357 instance, t);
201 } else { 358 } else {
202 *result = 0.0; 359 *result = 0.0;
203 } 360 }
204 } 361 }
205 362
363 void PPB_Flash_Proxy::OnHostMsgIsRectTopmost(PP_Instance instance,
364 PP_Rect rect,
365 PP_Bool* result) {
366 EnterInstanceNoLock enter(instance);
367 if (enter.succeeded())
368 *result = enter.functions()->GetFlashAPI()->IsRectTopmost(instance, &rect);
369 else
370 *result = PP_FALSE;
371 }
372
206 void PPB_Flash_Proxy::OnHostMsgGetSetting(PP_Instance instance, 373 void PPB_Flash_Proxy::OnHostMsgGetSetting(PP_Instance instance,
207 PP_FlashSetting setting, 374 PP_FlashSetting setting,
208 SerializedVarReturnValue id) { 375 SerializedVarReturnValue id) {
209 EnterInstanceNoLock enter(instance); 376 EnterInstanceNoLock enter(instance);
210 if (enter.succeeded()) { 377 if (enter.succeeded()) {
211 id.Return(dispatcher(), 378 id.Return(dispatcher(),
212 enter.functions()->GetFlashAPI()->GetSetting( 379 enter.functions()->GetFlashAPI()->GetSetting(
213 instance, setting)); 380 instance, setting));
214 } else { 381 } else {
215 id.Return(dispatcher(), PP_MakeUndefined()); 382 id.Return(dispatcher(), PP_MakeUndefined());
216 } 383 }
217 } 384 }
218 385
219 void PPB_Flash_Proxy::OnHostMsgInvokePrinting(PP_Instance instance) { 386 void PPB_Flash_Proxy::OnHostMsgInvokePrinting(PP_Instance instance) {
220 // This function is actually implemented in the PPB_Flash_Print interface. 387 // This function is actually implemented in the PPB_Flash_Print interface.
221 // It's rarely used enough that we just request this interface when needed. 388 // It's rarely used enough that we just request this interface when needed.
222 const PPB_Flash_Print_1_0* print_interface = 389 const PPB_Flash_Print_1_0* print_interface =
223 static_cast<const PPB_Flash_Print_1_0*>( 390 static_cast<const PPB_Flash_Print_1_0*>(
224 dispatcher()->local_get_interface()(PPB_FLASH_PRINT_INTERFACE_1_0)); 391 dispatcher()->local_get_interface()(PPB_FLASH_PRINT_INTERFACE_1_0));
225 if (print_interface) 392 if (print_interface)
226 print_interface->InvokePrinting(instance); 393 print_interface->InvokePrinting(instance);
227 } 394 }
228 395
229 } // namespace proxy 396 } // namespace proxy
230 } // namespace ppapi 397 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/proxy/ppb_flash_proxy.h ('k') | ppapi/proxy/serialized_structs.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698