OLD | NEW |
---|---|
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 "content/renderer/pepper/pepper_plugin_instance_impl.h" | 5 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
176 using blink::WebURLRequest; | 176 using blink::WebURLRequest; |
177 using blink::WebURLResponse; | 177 using blink::WebURLResponse; |
178 using blink::WebUserGestureIndicator; | 178 using blink::WebUserGestureIndicator; |
179 using blink::WebUserGestureToken; | 179 using blink::WebUserGestureToken; |
180 using blink::WebView; | 180 using blink::WebView; |
181 | 181 |
182 namespace content { | 182 namespace content { |
183 | 183 |
184 #if defined(OS_WIN) | 184 #if defined(OS_WIN) |
185 // Exported by pdf.dll | 185 // Exported by pdf.dll |
186 typedef bool (*RenderPDFPageToDCProc)( | 186 typedef bool (*RenderPDFPageToDCProc)(const unsigned char* pdf_buffer, |
187 const unsigned char* pdf_buffer, int buffer_size, int page_number, HDC dc, | 187 int buffer_size, |
188 int dpi_x, int dpi_y, int bounds_origin_x, int bounds_origin_y, | 188 int page_number, |
189 int bounds_width, int bounds_height, bool fit_to_bounds, | 189 HDC dc, |
190 bool stretch_to_bounds, bool keep_aspect_ratio, bool center_in_bounds, | 190 int dpi_x, |
191 bool autorotate); | 191 int dpi_y, |
192 int bounds_origin_x, | |
193 int bounds_origin_y, | |
194 int bounds_width, | |
195 int bounds_height, | |
196 bool fit_to_bounds, | |
197 bool stretch_to_bounds, | |
198 bool keep_aspect_ratio, | |
199 bool center_in_bounds, | |
200 bool autorotate); | |
192 | 201 |
193 void DrawEmptyRectangle(HDC dc) { | 202 void DrawEmptyRectangle(HDC dc) { |
194 // TODO(sanjeevr): This is a temporary hack. If we output a JPEG | 203 // TODO(sanjeevr): This is a temporary hack. If we output a JPEG |
195 // to the EMF, the EnumEnhMetaFile call fails in the browser | 204 // to the EMF, the EnumEnhMetaFile call fails in the browser |
196 // process. The failure also happens if we output nothing here. | 205 // process. The failure also happens if we output nothing here. |
197 // We need to investigate the reason for this failure and fix it. | 206 // We need to investigate the reason for this failure and fix it. |
198 // In the meantime this temporary hack of drawing an empty | 207 // In the meantime this temporary hack of drawing an empty |
199 // rectangle in the DC gets us by. | 208 // rectangle in the DC gets us by. |
200 Rectangle(dc, 0, 0, 0, 0); | 209 Rectangle(dc, 0, 0, 0, 0); |
201 } | 210 } |
202 #endif // defined(OS_WIN) | 211 #endif // defined(OS_WIN) |
203 | 212 |
204 namespace { | 213 namespace { |
205 | 214 |
206 // Check PP_TextInput_Type and ui::TextInputType are kept in sync. | 215 // Check PP_TextInput_Type and ui::TextInputType are kept in sync. |
207 COMPILE_ASSERT(int(ui::TEXT_INPUT_TYPE_NONE) == \ | 216 COMPILE_ASSERT(int(ui::TEXT_INPUT_TYPE_NONE) == int(PP_TEXTINPUT_TYPE_NONE), |
208 int(PP_TEXTINPUT_TYPE_NONE), mismatching_enums); | 217 mismatching_enums); |
209 COMPILE_ASSERT(int(ui::TEXT_INPUT_TYPE_TEXT) == \ | 218 COMPILE_ASSERT(int(ui::TEXT_INPUT_TYPE_TEXT) == int(PP_TEXTINPUT_TYPE_TEXT), |
210 int(PP_TEXTINPUT_TYPE_TEXT), mismatching_enums); | 219 mismatching_enums); |
211 COMPILE_ASSERT(int(ui::TEXT_INPUT_TYPE_PASSWORD) == \ | 220 COMPILE_ASSERT(int(ui::TEXT_INPUT_TYPE_PASSWORD) == |
212 int(PP_TEXTINPUT_TYPE_PASSWORD), mismatching_enums); | 221 int(PP_TEXTINPUT_TYPE_PASSWORD), |
213 COMPILE_ASSERT(int(ui::TEXT_INPUT_TYPE_SEARCH) == \ | 222 mismatching_enums); |
214 int(PP_TEXTINPUT_TYPE_SEARCH), mismatching_enums); | 223 COMPILE_ASSERT(int(ui::TEXT_INPUT_TYPE_SEARCH) == int(PP_TEXTINPUT_TYPE_SEARCH), |
215 COMPILE_ASSERT(int(ui::TEXT_INPUT_TYPE_EMAIL) == \ | 224 mismatching_enums); |
216 int(PP_TEXTINPUT_TYPE_EMAIL), mismatching_enums); | 225 COMPILE_ASSERT(int(ui::TEXT_INPUT_TYPE_EMAIL) == int(PP_TEXTINPUT_TYPE_EMAIL), |
217 COMPILE_ASSERT(int(ui::TEXT_INPUT_TYPE_NUMBER) == \ | 226 mismatching_enums); |
218 int(PP_TEXTINPUT_TYPE_NUMBER), mismatching_enums); | 227 COMPILE_ASSERT(int(ui::TEXT_INPUT_TYPE_NUMBER) == int(PP_TEXTINPUT_TYPE_NUMBER), |
219 COMPILE_ASSERT(int(ui::TEXT_INPUT_TYPE_TELEPHONE) == \ | 228 mismatching_enums); |
220 int(PP_TEXTINPUT_TYPE_TELEPHONE), mismatching_enums); | 229 COMPILE_ASSERT(int(ui::TEXT_INPUT_TYPE_TELEPHONE) == |
221 COMPILE_ASSERT(int(ui::TEXT_INPUT_TYPE_URL) == \ | 230 int(PP_TEXTINPUT_TYPE_TELEPHONE), |
222 int(PP_TEXTINPUT_TYPE_URL), mismatching_enums); | 231 mismatching_enums); |
232 COMPILE_ASSERT(int(ui::TEXT_INPUT_TYPE_URL) == int(PP_TEXTINPUT_TYPE_URL), | |
233 mismatching_enums); | |
223 | 234 |
224 // The default text input type is to regard the plugin always accept text input. | 235 // The default text input type is to regard the plugin always accept text input. |
225 // This is for allowing users to use input methods even on completely-IME- | 236 // This is for allowing users to use input methods even on completely-IME- |
226 // unaware plugins (e.g., PPAPI Flash or PDF plugin for M16). | 237 // unaware plugins (e.g., PPAPI Flash or PDF plugin for M16). |
227 // Plugins need to explicitly opt out the text input mode if they know | 238 // Plugins need to explicitly opt out the text input mode if they know |
228 // that they don't accept texts. | 239 // that they don't accept texts. |
229 const ui::TextInputType kPluginDefaultTextInputType = ui::TEXT_INPUT_TYPE_TEXT; | 240 const ui::TextInputType kPluginDefaultTextInputType = ui::TEXT_INPUT_TYPE_TEXT; |
230 | 241 |
231 #define COMPILE_ASSERT_MATCHING_ENUM(webkit_name, np_name) \ | 242 #define COMPILE_ASSERT_MATCHING_ENUM(webkit_name, np_name) \ |
232 COMPILE_ASSERT(static_cast<int>(WebCursorInfo::webkit_name) \ | 243 COMPILE_ASSERT(static_cast<int>(WebCursorInfo::webkit_name) == \ |
233 == static_cast<int>(np_name), \ | 244 static_cast<int>(np_name), \ |
234 mismatching_enums) | 245 mismatching_enums) |
235 | 246 |
236 #define COMPILE_ASSERT_PRINT_SCALING_MATCHING_ENUM(webkit_name, pp_name) \ | 247 #define COMPILE_ASSERT_PRINT_SCALING_MATCHING_ENUM(webkit_name, pp_name) \ |
237 COMPILE_ASSERT(static_cast<int>(webkit_name) \ | 248 COMPILE_ASSERT(static_cast<int>(webkit_name) == static_cast<int>(pp_name), \ |
238 == static_cast<int>(pp_name), \ | 249 mismatching_enums) |
239 mismatching_enums) | |
240 | 250 |
241 // <embed>/<object> attributes. | 251 // <embed>/<object> attributes. |
242 const char kWidth[] = "width"; | 252 const char kWidth[] = "width"; |
243 const char kHeight[] = "height"; | 253 const char kHeight[] = "height"; |
244 const char kBorder[] = "border"; // According to w3c, deprecated. | 254 const char kBorder[] = "border"; // According to w3c, deprecated. |
245 const char kStyle[] = "style"; | 255 const char kStyle[] = "style"; |
246 | 256 |
247 COMPILE_ASSERT_MATCHING_ENUM(TypePointer, PP_MOUSECURSOR_TYPE_POINTER); | 257 COMPILE_ASSERT_MATCHING_ENUM(TypePointer, PP_MOUSECURSOR_TYPE_POINTER); |
248 COMPILE_ASSERT_MATCHING_ENUM(TypeCross, PP_MOUSECURSOR_TYPE_CROSS); | 258 COMPILE_ASSERT_MATCHING_ENUM(TypeCross, PP_MOUSECURSOR_TYPE_CROSS); |
249 COMPILE_ASSERT_MATCHING_ENUM(TypeHand, PP_MOUSECURSOR_TYPE_HAND); | 259 COMPILE_ASSERT_MATCHING_ENUM(TypeHand, PP_MOUSECURSOR_TYPE_HAND); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
306 COMPILE_ASSERT_MATCHING_ENUM(TypeGrabbing, PP_MOUSECURSOR_TYPE_GRABBING); | 316 COMPILE_ASSERT_MATCHING_ENUM(TypeGrabbing, PP_MOUSECURSOR_TYPE_GRABBING); |
307 // Do not assert WebCursorInfo::TypeCustom == PP_CURSORTYPE_CUSTOM; | 317 // Do not assert WebCursorInfo::TypeCustom == PP_CURSORTYPE_CUSTOM; |
308 // PP_CURSORTYPE_CUSTOM is pinned to allow new cursor types. | 318 // PP_CURSORTYPE_CUSTOM is pinned to allow new cursor types. |
309 | 319 |
310 COMPILE_ASSERT_PRINT_SCALING_MATCHING_ENUM(blink::WebPrintScalingOptionNone, | 320 COMPILE_ASSERT_PRINT_SCALING_MATCHING_ENUM(blink::WebPrintScalingOptionNone, |
311 PP_PRINTSCALINGOPTION_NONE); | 321 PP_PRINTSCALINGOPTION_NONE); |
312 COMPILE_ASSERT_PRINT_SCALING_MATCHING_ENUM( | 322 COMPILE_ASSERT_PRINT_SCALING_MATCHING_ENUM( |
313 blink::WebPrintScalingOptionFitToPrintableArea, | 323 blink::WebPrintScalingOptionFitToPrintableArea, |
314 PP_PRINTSCALINGOPTION_FIT_TO_PRINTABLE_AREA); | 324 PP_PRINTSCALINGOPTION_FIT_TO_PRINTABLE_AREA); |
315 COMPILE_ASSERT_PRINT_SCALING_MATCHING_ENUM( | 325 COMPILE_ASSERT_PRINT_SCALING_MATCHING_ENUM( |
316 blink::WebPrintScalingOptionSourceSize, PP_PRINTSCALINGOPTION_SOURCE_SIZE); | 326 blink::WebPrintScalingOptionSourceSize, |
327 PP_PRINTSCALINGOPTION_SOURCE_SIZE); | |
317 | 328 |
318 // Sets |*security_origin| to be the WebKit security origin associated with the | 329 // Sets |*security_origin| to be the WebKit security origin associated with the |
319 // document containing the given plugin instance. On success, returns true. If | 330 // document containing the given plugin instance. On success, returns true. If |
320 // the instance is invalid, returns false and |*security_origin| will be | 331 // the instance is invalid, returns false and |*security_origin| will be |
321 // unchanged. | 332 // unchanged. |
322 bool SecurityOriginForInstance(PP_Instance instance_id, | 333 bool SecurityOriginForInstance(PP_Instance instance_id, |
323 blink::WebSecurityOrigin* security_origin) { | 334 blink::WebSecurityOrigin* security_origin) { |
324 PepperPluginInstanceImpl* instance = | 335 PepperPluginInstanceImpl* instance = |
325 HostGlobals::Get()->GetInstance(instance_id); | 336 HostGlobals::Get()->GetInstance(instance_id); |
326 if (!instance) | 337 if (!instance) |
327 return false; | 338 return false; |
328 | 339 |
329 WebElement plugin_element = instance->container()->element(); | 340 WebElement plugin_element = instance->container()->element(); |
330 *security_origin = plugin_element.document().securityOrigin(); | 341 *security_origin = plugin_element.document().securityOrigin(); |
331 return true; | 342 return true; |
332 } | 343 } |
333 | 344 |
334 // Convert the given vector to an array of C-strings. The strings in the | 345 // Convert the given vector to an array of C-strings. The strings in the |
335 // returned vector are only guaranteed valid so long as the vector of strings | 346 // returned vector are only guaranteed valid so long as the vector of strings |
336 // is not modified. | 347 // is not modified. |
337 scoped_ptr<const char*[]> StringVectorToArgArray( | 348 scoped_ptr<const char* []> StringVectorToArgArray( |
338 const std::vector<std::string>& vector) { | 349 const std::vector<std::string>& vector) { |
339 scoped_ptr<const char*[]> array(new const char*[vector.size()]); | 350 scoped_ptr<const char * []> array(new const char* [vector.size()]); |
340 for (size_t i = 0; i < vector.size(); ++i) | 351 for (size_t i = 0; i < vector.size(); ++i) |
341 array[i] = vector[i].c_str(); | 352 array[i] = vector[i].c_str(); |
342 return array.Pass(); | 353 return array.Pass(); |
343 } | 354 } |
344 | 355 |
345 // Returns true if this is a "system reserved" key which should not be sent to | 356 // Returns true if this is a "system reserved" key which should not be sent to |
346 // a plugin. Some poorly behaving plugins (like Flash) incorrectly report that | 357 // a plugin. Some poorly behaving plugins (like Flash) incorrectly report that |
347 // they handle all keys sent to them. This can prevent keystrokes from working | 358 // they handle all keys sent to them. This can prevent keystrokes from working |
348 // for things like screen brightness and volume control. | 359 // for things like screen brightness and volume control. |
349 bool IsReservedSystemInputEvent(const blink::WebInputEvent& event) { | 360 bool IsReservedSystemInputEvent(const blink::WebInputEvent& event) { |
(...skipping 21 matching lines...) Expand all Loading... | |
371 | 382 |
372 class PluginInstanceLockTarget : public MouseLockDispatcher::LockTarget { | 383 class PluginInstanceLockTarget : public MouseLockDispatcher::LockTarget { |
373 public: | 384 public: |
374 PluginInstanceLockTarget(PepperPluginInstanceImpl* plugin) | 385 PluginInstanceLockTarget(PepperPluginInstanceImpl* plugin) |
375 : plugin_(plugin) {} | 386 : plugin_(plugin) {} |
376 | 387 |
377 virtual void OnLockMouseACK(bool succeeded) OVERRIDE { | 388 virtual void OnLockMouseACK(bool succeeded) OVERRIDE { |
378 plugin_->OnLockMouseACK(succeeded); | 389 plugin_->OnLockMouseACK(succeeded); |
379 } | 390 } |
380 | 391 |
381 virtual void OnMouseLockLost() OVERRIDE { | 392 virtual void OnMouseLockLost() OVERRIDE { plugin_->OnMouseLockLost(); } |
382 plugin_->OnMouseLockLost(); | |
383 } | |
384 | 393 |
385 virtual bool HandleMouseLockedInputEvent( | 394 virtual bool HandleMouseLockedInputEvent(const blink::WebMouseEvent& event) |
386 const blink::WebMouseEvent &event) OVERRIDE { | 395 OVERRIDE { |
387 plugin_->HandleMouseLockedInputEvent(event); | 396 plugin_->HandleMouseLockedInputEvent(event); |
388 return true; | 397 return true; |
389 } | 398 } |
390 | 399 |
391 private: | 400 private: |
392 PepperPluginInstanceImpl* plugin_; | 401 PepperPluginInstanceImpl* plugin_; |
393 }; | 402 }; |
394 | 403 |
395 | |
396 } // namespace | 404 } // namespace |
397 | 405 |
398 // static | 406 // static |
399 PepperPluginInstanceImpl* PepperPluginInstanceImpl::Create( | 407 PepperPluginInstanceImpl* PepperPluginInstanceImpl::Create( |
400 RenderFrameImpl* render_frame, | 408 RenderFrameImpl* render_frame, |
401 PluginModule* module, | 409 PluginModule* module, |
402 WebPluginContainer* container, | 410 WebPluginContainer* container, |
403 const GURL& plugin_url) { | 411 const GURL& plugin_url) { |
404 base::Callback<const void*(const char*)> get_plugin_interface_func = | 412 base::Callback<const void*(const char*)> get_plugin_interface_func = |
405 base::Bind(&PluginModule::GetPluginInterface, module); | 413 base::Bind(&PluginModule::GetPluginInterface, module); |
406 PPP_Instance_Combined* ppp_instance_combined = | 414 PPP_Instance_Combined* ppp_instance_combined = |
407 PPP_Instance_Combined::Create(get_plugin_interface_func); | 415 PPP_Instance_Combined::Create(get_plugin_interface_func); |
408 if (!ppp_instance_combined) | 416 if (!ppp_instance_combined) |
409 return NULL; | 417 return NULL; |
410 return new PepperPluginInstanceImpl(render_frame, module, | 418 return new PepperPluginInstanceImpl( |
411 ppp_instance_combined, container, | 419 render_frame, module, ppp_instance_combined, container, plugin_url); |
412 plugin_url); | |
413 } | 420 } |
414 | 421 |
415 PepperPluginInstanceImpl::ExternalDocumentLoader::ExternalDocumentLoader() | 422 PepperPluginInstanceImpl::ExternalDocumentLoader::ExternalDocumentLoader() |
416 : finished_loading_(false) { | 423 : finished_loading_(false) {} |
417 } | |
418 | 424 |
419 PepperPluginInstanceImpl::ExternalDocumentLoader::~ExternalDocumentLoader() { | 425 PepperPluginInstanceImpl::ExternalDocumentLoader::~ExternalDocumentLoader() {} |
420 } | |
421 | 426 |
422 void PepperPluginInstanceImpl::ExternalDocumentLoader::ReplayReceivedData( | 427 void PepperPluginInstanceImpl::ExternalDocumentLoader::ReplayReceivedData( |
423 WebURLLoaderClient* document_loader) { | 428 WebURLLoaderClient* document_loader) { |
424 for (std::list<std::string>::iterator it = data_.begin(); | 429 for (std::list<std::string>::iterator it = data_.begin(); it != data_.end(); |
425 it != data_.end(); ++it) { | 430 ++it) { |
426 document_loader->didReceiveData(NULL, it->c_str(), it->length(), | 431 document_loader->didReceiveData( |
427 0 /* encoded_data_length */); | 432 NULL, it->c_str(), it->length(), 0 /* encoded_data_length */); |
428 } | 433 } |
429 if (finished_loading_) { | 434 if (finished_loading_) { |
430 document_loader->didFinishLoading(NULL, 0 /* finish_time */, | 435 document_loader->didFinishLoading( |
436 NULL, | |
437 0 /* finish_time */, | |
431 blink::WebURLLoaderClient::kUnknownEncodedDataLength); | 438 blink::WebURLLoaderClient::kUnknownEncodedDataLength); |
432 } | 439 } |
433 if (error_.get()) { | 440 if (error_.get()) { |
434 document_loader->didFail(NULL, *error_); | 441 document_loader->didFail(NULL, *error_); |
435 } | 442 } |
436 } | 443 } |
437 | 444 |
438 void PepperPluginInstanceImpl::ExternalDocumentLoader::didReceiveData( | 445 void PepperPluginInstanceImpl::ExternalDocumentLoader::didReceiveData( |
439 WebURLLoader* loader, | 446 WebURLLoader* loader, |
440 const char* data, | 447 const char* data, |
(...skipping 11 matching lines...) Expand all Loading... | |
452 } | 459 } |
453 | 460 |
454 void PepperPluginInstanceImpl::ExternalDocumentLoader::didFail( | 461 void PepperPluginInstanceImpl::ExternalDocumentLoader::didFail( |
455 WebURLLoader* loader, | 462 WebURLLoader* loader, |
456 const WebURLError& error) { | 463 const WebURLError& error) { |
457 DCHECK(!error_.get()); | 464 DCHECK(!error_.get()); |
458 error_.reset(new WebURLError(error)); | 465 error_.reset(new WebURLError(error)); |
459 } | 466 } |
460 | 467 |
461 PepperPluginInstanceImpl::GamepadImpl::GamepadImpl() | 468 PepperPluginInstanceImpl::GamepadImpl::GamepadImpl() |
462 : Resource(ppapi::Resource::Untracked()) { | 469 : Resource(ppapi::Resource::Untracked()) {} |
463 } | |
464 | 470 |
465 PepperPluginInstanceImpl::GamepadImpl::~GamepadImpl() { | 471 PepperPluginInstanceImpl::GamepadImpl::~GamepadImpl() {} |
466 } | |
467 | 472 |
468 PPB_Gamepad_API* PepperPluginInstanceImpl::GamepadImpl::AsPPB_Gamepad_API() { | 473 PPB_Gamepad_API* PepperPluginInstanceImpl::GamepadImpl::AsPPB_Gamepad_API() { |
469 return this; | 474 return this; |
470 } | 475 } |
471 | 476 |
472 void PepperPluginInstanceImpl::GamepadImpl::Sample( | 477 void PepperPluginInstanceImpl::GamepadImpl::Sample( |
473 PP_Instance instance, | 478 PP_Instance instance, |
474 PP_GamepadsSampleData* data) { | 479 PP_GamepadsSampleData* data) { |
475 blink::WebGamepads webkit_data; | 480 blink::WebGamepads webkit_data; |
476 RenderThreadImpl::current()->SampleGamepads(&webkit_data); | 481 RenderThreadImpl::current()->SampleGamepads(&webkit_data); |
477 ConvertWebKitGamepadData( | 482 ConvertWebKitGamepadData(bit_cast<ppapi::WebKitGamepads>(webkit_data), data); |
478 bit_cast<ppapi::WebKitGamepads>(webkit_data), data); | |
479 } | 483 } |
480 | 484 |
481 PepperPluginInstanceImpl::PepperPluginInstanceImpl( | 485 PepperPluginInstanceImpl::PepperPluginInstanceImpl( |
482 RenderFrameImpl* render_frame, | 486 RenderFrameImpl* render_frame, |
483 PluginModule* module, | 487 PluginModule* module, |
484 ppapi::PPP_Instance_Combined* instance_interface, | 488 ppapi::PPP_Instance_Combined* instance_interface, |
485 WebPluginContainer* container, | 489 WebPluginContainer* container, |
486 const GURL& plugin_url) | 490 const GURL& plugin_url) |
487 : RenderFrameObserver(render_frame), | 491 : RenderFrameObserver(render_frame), |
488 render_frame_(render_frame), | 492 render_frame_(render_frame), |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
590 DCHECK(!fullscreen_container_); | 594 DCHECK(!fullscreen_container_); |
591 | 595 |
592 // Free all the plugin objects. This will automatically clear the back- | 596 // Free all the plugin objects. This will automatically clear the back- |
593 // pointer from the NPObject so WebKit can't call into the plugin any more. | 597 // pointer from the NPObject so WebKit can't call into the plugin any more. |
594 // | 598 // |
595 // Swap out the set so we can delete from it (the objects will try to | 599 // Swap out the set so we can delete from it (the objects will try to |
596 // unregister themselves inside the delete call). | 600 // unregister themselves inside the delete call). |
597 PluginObjectSet plugin_object_copy; | 601 PluginObjectSet plugin_object_copy; |
598 live_plugin_objects_.swap(plugin_object_copy); | 602 live_plugin_objects_.swap(plugin_object_copy); |
599 for (PluginObjectSet::iterator i = plugin_object_copy.begin(); | 603 for (PluginObjectSet::iterator i = plugin_object_copy.begin(); |
600 i != plugin_object_copy.end(); ++i) | 604 i != plugin_object_copy.end(); |
605 ++i) | |
601 delete *i; | 606 delete *i; |
602 | 607 |
603 if (TrackedCallback::IsPending(lock_mouse_callback_)) | 608 if (TrackedCallback::IsPending(lock_mouse_callback_)) |
604 lock_mouse_callback_->Abort(); | 609 lock_mouse_callback_->Abort(); |
605 | 610 |
606 if (!instance_deleted_callback_.is_null()) | 611 if (!instance_deleted_callback_.is_null()) |
607 instance_deleted_callback_.Run(); | 612 instance_deleted_callback_.Run(); |
608 | 613 |
609 if (!module_->IsProxied() && render_frame_) { | 614 if (!module_->IsProxied() && render_frame_) { |
610 PepperBrowserConnection* browser_connection = | 615 PepperBrowserConnection* browser_connection = |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
660 fullscreen_container_ = NULL; | 665 fullscreen_container_ = NULL; |
661 } | 666 } |
662 | 667 |
663 // Force-unbind any Graphics. In the case of Graphics2D, if the plugin | 668 // Force-unbind any Graphics. In the case of Graphics2D, if the plugin |
664 // leaks the graphics 2D, it may actually get cleaned up after our | 669 // leaks the graphics 2D, it may actually get cleaned up after our |
665 // destruction, so we need its pointers to be up-to-date. | 670 // destruction, so we need its pointers to be up-to-date. |
666 BindGraphics(pp_instance(), 0); | 671 BindGraphics(pp_instance(), 0); |
667 container_ = NULL; | 672 container_ = NULL; |
668 } | 673 } |
669 | 674 |
670 bool PepperPluginInstanceImpl::is_deleted() const { | 675 bool PepperPluginInstanceImpl::is_deleted() const { return is_deleted_; } |
671 return is_deleted_; | |
672 } | |
673 | 676 |
674 void PepperPluginInstanceImpl::Paint(WebCanvas* canvas, | 677 void PepperPluginInstanceImpl::Paint(WebCanvas* canvas, |
675 const gfx::Rect& plugin_rect, | 678 const gfx::Rect& plugin_rect, |
676 const gfx::Rect& paint_rect) { | 679 const gfx::Rect& paint_rect) { |
677 TRACE_EVENT0("ppapi", "PluginInstance::Paint"); | 680 TRACE_EVENT0("ppapi", "PluginInstance::Paint"); |
678 if (module()->is_crashed()) { | 681 if (module()->is_crashed()) { |
679 // Crashed plugin painting. | 682 // Crashed plugin painting. |
680 if (!sad_plugin_) // Lazily initialize bitmap. | 683 if (!sad_plugin_) // Lazily initialize bitmap. |
681 sad_plugin_ = GetContentClient()->renderer()->GetSadPluginBitmap(); | 684 sad_plugin_ = GetContentClient()->renderer()->GetSadPluginBitmap(); |
682 if (sad_plugin_) | 685 if (sad_plugin_) |
683 PaintSadPlugin(canvas, plugin_rect, *sad_plugin_); | 686 PaintSadPlugin(canvas, plugin_rect, *sad_plugin_); |
684 return; | 687 return; |
685 } | 688 } |
686 | 689 |
687 if (bound_graphics_2d_platform_) | 690 if (bound_graphics_2d_platform_) |
688 bound_graphics_2d_platform_->Paint(canvas, plugin_rect, paint_rect); | 691 bound_graphics_2d_platform_->Paint(canvas, plugin_rect, paint_rect); |
689 } | 692 } |
690 | 693 |
691 void PepperPluginInstanceImpl::InvalidateRect(const gfx::Rect& rect) { | 694 void PepperPluginInstanceImpl::InvalidateRect(const gfx::Rect& rect) { |
692 if (fullscreen_container_) { | 695 if (fullscreen_container_) { |
693 if (rect.IsEmpty()) | 696 if (rect.IsEmpty()) |
694 fullscreen_container_->Invalidate(); | 697 fullscreen_container_->Invalidate(); |
695 else | 698 else |
696 fullscreen_container_->InvalidateRect(rect); | 699 fullscreen_container_->InvalidateRect(rect); |
697 } else { | 700 } else { |
698 if (!container_ || | 701 if (!container_ || view_data_.rect.size.width == 0 || |
699 view_data_.rect.size.width == 0 || view_data_.rect.size.height == 0) | 702 view_data_.rect.size.height == 0) |
700 return; // Nothing to do. | 703 return; // Nothing to do. |
701 if (rect.IsEmpty()) | 704 if (rect.IsEmpty()) |
702 container_->invalidate(); | 705 container_->invalidate(); |
703 else | 706 else |
704 container_->invalidateRect(rect); | 707 container_->invalidateRect(rect); |
705 } | 708 } |
706 if (texture_layer_) { | 709 if (texture_layer_) { |
707 if (rect.IsEmpty()) { | 710 if (rect.IsEmpty()) { |
708 texture_layer_->SetNeedsDisplay(); | 711 texture_layer_->SetNeedsDisplay(); |
709 } else { | 712 } else { |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
762 } | 765 } |
763 | 766 |
764 if (render_frame_) | 767 if (render_frame_) |
765 render_frame_->PluginCrashed(module_->path(), module_->GetPeerProcessId()); | 768 render_frame_->PluginCrashed(module_->path(), module_->GetPeerProcessId()); |
766 UnSetAndDeleteLockTargetAdapter(); | 769 UnSetAndDeleteLockTargetAdapter(); |
767 } | 770 } |
768 | 771 |
769 static void SetGPUHistogram(const ppapi::Preferences& prefs, | 772 static void SetGPUHistogram(const ppapi::Preferences& prefs, |
770 const std::vector<std::string>& arg_names, | 773 const std::vector<std::string>& arg_names, |
771 const std::vector<std::string>& arg_values) { | 774 const std::vector<std::string>& arg_values) { |
772 // Calculate a histogram to let us determine how likely people are to try to | 775 // Calculate a histogram to let us determine how likely people are to try to |
773 // run Stage3D content on machines that have it blacklisted. | 776 // run Stage3D content on machines that have it blacklisted. |
bbudge
2014/04/07 17:02:17
Comment aligned to #if here, probably should be mo
| |
774 #if defined(OS_WIN) | 777 #if defined(OS_WIN) |
775 bool needs_gpu = false; | 778 bool needs_gpu = false; |
776 bool is_xp = base::win::GetVersion() <= base::win::VERSION_XP; | 779 bool is_xp = base::win::GetVersion() <= base::win::VERSION_XP; |
777 | 780 |
778 for (size_t i = 0; i < arg_names.size(); i++) { | 781 for (size_t i = 0; i < arg_names.size(); i++) { |
779 if (arg_names[i] == "wmode") { | 782 if (arg_names[i] == "wmode") { |
780 // In theory content other than Flash could have a "wmode" argument, | 783 // In theory content other than Flash could have a "wmode" argument, |
781 // but that's pretty unlikely. | 784 // but that's pretty unlikely. |
782 if (arg_values[i] == "direct" || arg_values[i] == "gpu") | 785 if (arg_values[i] == "direct" || arg_values[i] == "gpu") |
783 needs_gpu = true; | 786 needs_gpu = true; |
784 break; | 787 break; |
785 } | 788 } |
786 } | 789 } |
787 // 0 : No 3D content and GPU is blacklisted | 790 // 0 : No 3D content and GPU is blacklisted |
788 // 1 : No 3D content and GPU is not blacklisted | 791 // 1 : No 3D content and GPU is not blacklisted |
789 // 2 : 3D content but GPU is blacklisted | 792 // 2 : 3D content but GPU is blacklisted |
790 // 3 : 3D content and GPU is not blacklisted | 793 // 3 : 3D content and GPU is not blacklisted |
791 // 4 : No 3D content and GPU is blacklisted on XP | 794 // 4 : No 3D content and GPU is blacklisted on XP |
792 // 5 : No 3D content and GPU is not blacklisted on XP | 795 // 5 : No 3D content and GPU is not blacklisted on XP |
793 // 6 : 3D content but GPU is blacklisted on XP | 796 // 6 : 3D content but GPU is blacklisted on XP |
794 // 7 : 3D content and GPU is not blacklisted on XP | 797 // 7 : 3D content and GPU is not blacklisted on XP |
795 UMA_HISTOGRAM_ENUMERATION("Flash.UsesGPU", | 798 UMA_HISTOGRAM_ENUMERATION( |
796 is_xp * 4 + needs_gpu * 2 + prefs.is_webgl_supported, 8); | 799 "Flash.UsesGPU", is_xp * 4 + needs_gpu * 2 + prefs.is_webgl_supported, 8); |
797 #endif | 800 #endif |
798 } | 801 } |
799 | 802 |
800 bool PepperPluginInstanceImpl::Initialize( | 803 bool PepperPluginInstanceImpl::Initialize( |
801 const std::vector<std::string>& arg_names, | 804 const std::vector<std::string>& arg_names, |
802 const std::vector<std::string>& arg_values, | 805 const std::vector<std::string>& arg_values, |
803 bool full_frame) { | 806 bool full_frame) { |
804 if (!render_frame_) | 807 if (!render_frame_) |
805 return false; | 808 return false; |
806 message_channel_.reset(new MessageChannel(this)); | 809 message_channel_.reset(new MessageChannel(this)); |
807 | 810 |
808 full_frame_ = full_frame; | 811 full_frame_ = full_frame; |
809 | 812 |
810 UpdateTouchEventRequest(); | 813 UpdateTouchEventRequest(); |
811 container_->setWantsWheelEvents(IsAcceptingWheelEvents()); | 814 container_->setWantsWheelEvents(IsAcceptingWheelEvents()); |
812 | 815 |
813 SetGPUHistogram(ppapi::Preferences( | 816 SetGPUHistogram( |
814 render_frame_->render_view()->webkit_preferences()), | 817 ppapi::Preferences(render_frame_->render_view()->webkit_preferences()), |
815 arg_names, arg_values); | 818 arg_names, |
819 arg_values); | |
816 | 820 |
817 argn_ = arg_names; | 821 argn_ = arg_names; |
818 argv_ = arg_values; | 822 argv_ = arg_values; |
819 scoped_ptr<const char*[]> argn_array(StringVectorToArgArray(argn_)); | 823 scoped_ptr<const char * []> argn_array(StringVectorToArgArray(argn_)); |
820 scoped_ptr<const char*[]> argv_array(StringVectorToArgArray(argv_)); | 824 scoped_ptr<const char * []> argv_array(StringVectorToArgArray(argv_)); |
821 bool success = PP_ToBool(instance_interface_->DidCreate(pp_instance(), | 825 bool success = PP_ToBool(instance_interface_->DidCreate( |
822 argn_.size(), | 826 pp_instance(), argn_.size(), argn_array.get(), argv_array.get())); |
823 argn_array.get(), | |
824 argv_array.get())); | |
825 if (success) | 827 if (success) |
826 message_channel_->StopQueueingJavaScriptMessages(); | 828 message_channel_->StopQueueingJavaScriptMessages(); |
827 return success; | 829 return success; |
828 } | 830 } |
829 | 831 |
830 bool PepperPluginInstanceImpl::HandleDocumentLoad( | 832 bool PepperPluginInstanceImpl::HandleDocumentLoad( |
831 const blink::WebURLResponse& response) { | 833 const blink::WebURLResponse& response) { |
832 DCHECK(!document_loader_); | 834 DCHECK(!document_loader_); |
833 if (external_document_load_) { | 835 if (external_document_load_) { |
834 // The external proxy isn't available, so save the response and record | 836 // The external proxy isn't available, so save the response and record |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
876 response, | 878 response, |
877 pending_host_id)); | 879 pending_host_id)); |
878 | 880 |
879 // If the load was not abandoned, document_loader_ will now be set. It's | 881 // If the load was not abandoned, document_loader_ will now be set. It's |
880 // possible that the load was canceled by now and document_loader_ was | 882 // possible that the load was canceled by now and document_loader_ was |
881 // already nulled out. | 883 // already nulled out. |
882 return true; | 884 return true; |
883 } | 885 } |
884 | 886 |
885 bool PepperPluginInstanceImpl::SendCompositionEventToPlugin( | 887 bool PepperPluginInstanceImpl::SendCompositionEventToPlugin( |
886 PP_InputEvent_Type type, const base::string16& text) { | 888 PP_InputEvent_Type type, |
889 const base::string16& text) { | |
887 std::vector<blink::WebCompositionUnderline> empty; | 890 std::vector<blink::WebCompositionUnderline> empty; |
888 return SendCompositionEventWithUnderlineInformationToPlugin( | 891 return SendCompositionEventWithUnderlineInformationToPlugin( |
889 type, text, empty, static_cast<int>(text.size()), | 892 type, |
893 text, | |
894 empty, | |
895 static_cast<int>(text.size()), | |
890 static_cast<int>(text.size())); | 896 static_cast<int>(text.size())); |
891 } | 897 } |
892 | 898 |
893 bool PepperPluginInstanceImpl:: | 899 bool |
894 SendCompositionEventWithUnderlineInformationToPlugin( | 900 PepperPluginInstanceImpl::SendCompositionEventWithUnderlineInformationToPlugin( |
895 PP_InputEvent_Type type, | 901 PP_InputEvent_Type type, |
896 const base::string16& text, | 902 const base::string16& text, |
897 const std::vector<blink::WebCompositionUnderline>& underlines, | 903 const std::vector<blink::WebCompositionUnderline>& underlines, |
898 int selection_start, | 904 int selection_start, |
899 int selection_end) { | 905 int selection_end) { |
900 // Keep a reference on the stack. See NOTE above. | 906 // Keep a reference on the stack. See NOTE above. |
901 scoped_refptr<PepperPluginInstanceImpl> ref(this); | 907 scoped_refptr<PepperPluginInstanceImpl> ref(this); |
902 | 908 |
903 if (!LoadInputEventInterface()) | 909 if (!LoadInputEventInterface()) |
904 return false; | 910 return false; |
905 | 911 |
906 PP_InputEvent_Class event_class = PP_INPUTEVENT_CLASS_IME; | 912 PP_InputEvent_Class event_class = PP_INPUTEVENT_CLASS_IME; |
907 if (!(filtered_input_event_mask_ & event_class) && | 913 if (!(filtered_input_event_mask_ & event_class) && |
908 !(input_event_mask_ & event_class)) | 914 !(input_event_mask_ & event_class)) |
909 return false; | 915 return false; |
910 | 916 |
911 ppapi::InputEventData event; | 917 ppapi::InputEventData event; |
912 event.event_type = type; | 918 event.event_type = type; |
913 event.event_time_stamp = ppapi::TimeTicksToPPTimeTicks( | 919 event.event_time_stamp = |
914 base::TimeTicks::Now()); | 920 ppapi::TimeTicksToPPTimeTicks(base::TimeTicks::Now()); |
915 | 921 |
916 // Convert UTF16 text to UTF8 with offset conversion. | 922 // Convert UTF16 text to UTF8 with offset conversion. |
917 std::vector<size_t> utf16_offsets; | 923 std::vector<size_t> utf16_offsets; |
918 utf16_offsets.push_back(selection_start); | 924 utf16_offsets.push_back(selection_start); |
919 utf16_offsets.push_back(selection_end); | 925 utf16_offsets.push_back(selection_end); |
920 for (size_t i = 0; i < underlines.size(); ++i) { | 926 for (size_t i = 0; i < underlines.size(); ++i) { |
921 utf16_offsets.push_back(underlines[i].startOffset); | 927 utf16_offsets.push_back(underlines[i].startOffset); |
922 utf16_offsets.push_back(underlines[i].endOffset); | 928 utf16_offsets.push_back(underlines[i].endOffset); |
923 } | 929 } |
924 std::vector<size_t> utf8_offsets(utf16_offsets); | 930 std::vector<size_t> utf8_offsets(utf16_offsets); |
925 event.character_text = base::UTF16ToUTF8AndAdjustOffsets(text, &utf8_offsets); | 931 event.character_text = base::UTF16ToUTF8AndAdjustOffsets(text, &utf8_offsets); |
926 | 932 |
927 // Set the converted selection range. | 933 // Set the converted selection range. |
928 event.composition_selection_start = (utf8_offsets[0] == std::string::npos ? | 934 event.composition_selection_start = |
929 event.character_text.size() : utf8_offsets[0]); | 935 (utf8_offsets[0] == std::string::npos ? event.character_text.size() |
930 event.composition_selection_end = (utf8_offsets[1] == std::string::npos ? | 936 : utf8_offsets[0]); |
931 event.character_text.size() : utf8_offsets[1]); | 937 event.composition_selection_end = |
938 (utf8_offsets[1] == std::string::npos ? event.character_text.size() | |
939 : utf8_offsets[1]); | |
932 | 940 |
933 // Set the converted segmentation points. | 941 // Set the converted segmentation points. |
934 // Be sure to add 0 and size(), and remove duplication or errors. | 942 // Be sure to add 0 and size(), and remove duplication or errors. |
935 std::set<size_t> offset_set(utf8_offsets.begin()+2, utf8_offsets.end()); | 943 std::set<size_t> offset_set(utf8_offsets.begin() + 2, utf8_offsets.end()); |
936 offset_set.insert(0); | 944 offset_set.insert(0); |
937 offset_set.insert(event.character_text.size()); | 945 offset_set.insert(event.character_text.size()); |
938 offset_set.erase(std::string::npos); | 946 offset_set.erase(std::string::npos); |
939 event.composition_segment_offsets.assign(offset_set.begin(), | 947 event.composition_segment_offsets.assign(offset_set.begin(), |
940 offset_set.end()); | 948 offset_set.end()); |
941 | 949 |
942 // Set the composition target. | 950 // Set the composition target. |
943 for (size_t i = 0; i < underlines.size(); ++i) { | 951 for (size_t i = 0; i < underlines.size(); ++i) { |
944 if (underlines[i].thick) { | 952 if (underlines[i].thick) { |
945 std::vector<uint32_t>::iterator it = | 953 std::vector<uint32_t>::iterator it = |
946 std::find(event.composition_segment_offsets.begin(), | 954 std::find(event.composition_segment_offsets.begin(), |
947 event.composition_segment_offsets.end(), | 955 event.composition_segment_offsets.end(), |
948 utf8_offsets[2*i+2]); | 956 utf8_offsets[2 * i + 2]); |
949 if (it != event.composition_segment_offsets.end()) { | 957 if (it != event.composition_segment_offsets.end()) { |
950 event.composition_target_segment = | 958 event.composition_target_segment = |
951 it - event.composition_segment_offsets.begin(); | 959 it - event.composition_segment_offsets.begin(); |
952 break; | 960 break; |
953 } | 961 } |
954 } | 962 } |
955 } | 963 } |
956 | 964 |
957 // Send the event. | 965 // Send the event. |
958 bool handled = false; | 966 bool handled = false; |
(...skipping 22 matching lines...) Expand all Loading... | |
981 text); | 989 text); |
982 } | 990 } |
983 | 991 |
984 bool PepperPluginInstanceImpl::HandleCompositionUpdate( | 992 bool PepperPluginInstanceImpl::HandleCompositionUpdate( |
985 const base::string16& text, | 993 const base::string16& text, |
986 const std::vector<blink::WebCompositionUnderline>& underlines, | 994 const std::vector<blink::WebCompositionUnderline>& underlines, |
987 int selection_start, | 995 int selection_start, |
988 int selection_end) { | 996 int selection_end) { |
989 return SendCompositionEventWithUnderlineInformationToPlugin( | 997 return SendCompositionEventWithUnderlineInformationToPlugin( |
990 PP_INPUTEVENT_TYPE_IME_COMPOSITION_UPDATE, | 998 PP_INPUTEVENT_TYPE_IME_COMPOSITION_UPDATE, |
991 text, underlines, selection_start, selection_end); | 999 text, |
1000 underlines, | |
1001 selection_start, | |
1002 selection_end); | |
992 } | 1003 } |
993 | 1004 |
994 bool PepperPluginInstanceImpl::HandleCompositionEnd( | 1005 bool PepperPluginInstanceImpl::HandleCompositionEnd( |
995 const base::string16& text) { | 1006 const base::string16& text) { |
996 return SendCompositionEventToPlugin(PP_INPUTEVENT_TYPE_IME_COMPOSITION_END, | 1007 return SendCompositionEventToPlugin(PP_INPUTEVENT_TYPE_IME_COMPOSITION_END, |
997 text); | 1008 text); |
998 } | 1009 } |
999 | 1010 |
1000 bool PepperPluginInstanceImpl::HandleTextInput(const base::string16& text) { | 1011 bool PepperPluginInstanceImpl::HandleTextInput(const base::string16& text) { |
1001 return SendCompositionEventToPlugin(PP_INPUTEVENT_TYPE_IME_TEXT, | 1012 return SendCompositionEventToPlugin(PP_INPUTEVENT_TYPE_IME_TEXT, text); |
1002 text); | |
1003 } | 1013 } |
1004 | 1014 |
1005 void PepperPluginInstanceImpl::GetSurroundingText(base::string16* text, | 1015 void PepperPluginInstanceImpl::GetSurroundingText(base::string16* text, |
1006 gfx::Range* range) const { | 1016 gfx::Range* range) const { |
1007 std::vector<size_t> offsets; | 1017 std::vector<size_t> offsets; |
1008 offsets.push_back(selection_anchor_); | 1018 offsets.push_back(selection_anchor_); |
1009 offsets.push_back(selection_caret_); | 1019 offsets.push_back(selection_caret_); |
1010 *text = base::UTF8ToUTF16AndAdjustOffsets(surrounding_text_, &offsets); | 1020 *text = base::UTF8ToUTF16AndAdjustOffsets(surrounding_text_, &offsets); |
1011 range->set_start(offsets[0] == base::string16::npos ? text->size() | 1021 range->set_start(offsets[0] == base::string16::npos ? text->size() |
1012 : offsets[0]); | 1022 : offsets[0]); |
1013 range->set_end(offsets[1] == base::string16::npos ? text->size() | 1023 range->set_end(offsets[1] == base::string16::npos ? text->size() |
1014 : offsets[1]); | 1024 : offsets[1]); |
1015 } | 1025 } |
1016 | 1026 |
1017 bool PepperPluginInstanceImpl::IsPluginAcceptingCompositionEvents() const { | 1027 bool PepperPluginInstanceImpl::IsPluginAcceptingCompositionEvents() const { |
1018 return (filtered_input_event_mask_ & PP_INPUTEVENT_CLASS_IME) || | 1028 return (filtered_input_event_mask_ & PP_INPUTEVENT_CLASS_IME) || |
1019 (input_event_mask_ & PP_INPUTEVENT_CLASS_IME); | 1029 (input_event_mask_ & PP_INPUTEVENT_CLASS_IME); |
1020 } | 1030 } |
1021 | 1031 |
1022 gfx::Rect PepperPluginInstanceImpl::GetCaretBounds() const { | 1032 gfx::Rect PepperPluginInstanceImpl::GetCaretBounds() const { |
1023 if (!text_input_caret_set_) { | 1033 if (!text_input_caret_set_) { |
1024 // If it is never set by the plugin, use the bottom left corner. | 1034 // If it is never set by the plugin, use the bottom left corner. |
1025 return gfx::Rect(view_data_.rect.point.x, | 1035 return gfx::Rect(view_data_.rect.point.x, |
1026 view_data_.rect.point.y + view_data_.rect.size.height, | 1036 view_data_.rect.point.y + view_data_.rect.size.height, |
1027 0, 0); | 1037 0, |
1038 0); | |
1028 } | 1039 } |
1029 | 1040 |
1030 // TODO(kinaba) Take CSS transformation into accont. | 1041 // TODO(kinaba) Take CSS transformation into accont. |
1031 // TODO(kinaba) Take bounding_box into account. On some platforms, an | 1042 // TODO(kinaba) Take bounding_box into account. On some platforms, an |
1032 // "exclude rectangle" where candidate window must avoid the region can be | 1043 // "exclude rectangle" where candidate window must avoid the region can be |
1033 // passed to IME. Currently, we pass only the caret rectangle because | 1044 // passed to IME. Currently, we pass only the caret rectangle because |
1034 // it is the only information supported uniformly in Chromium. | 1045 // it is the only information supported uniformly in Chromium. |
1035 gfx::Rect caret(text_input_caret_); | 1046 gfx::Rect caret(text_input_caret_); |
1036 caret.Offset(view_data_.rect.point.x, view_data_.rect.point.y); | 1047 caret.Offset(view_data_.rect.point.x, view_data_.rect.point.y); |
1037 return caret; | 1048 return caret; |
(...skipping 23 matching lines...) Expand all Loading... | |
1061 | 1072 |
1062 bool rv = false; | 1073 bool rv = false; |
1063 if (LoadInputEventInterface()) { | 1074 if (LoadInputEventInterface()) { |
1064 PP_InputEvent_Class event_class = ClassifyInputEvent(event.type); | 1075 PP_InputEvent_Class event_class = ClassifyInputEvent(event.type); |
1065 if (!event_class) | 1076 if (!event_class) |
1066 return false; | 1077 return false; |
1067 | 1078 |
1068 if ((filtered_input_event_mask_ & event_class) || | 1079 if ((filtered_input_event_mask_ & event_class) || |
1069 (input_event_mask_ & event_class)) { | 1080 (input_event_mask_ & event_class)) { |
1070 // Actually send the event. | 1081 // Actually send the event. |
1071 std::vector< ppapi::InputEventData > events; | 1082 std::vector<ppapi::InputEventData> events; |
1072 CreateInputEventData(event, &events); | 1083 CreateInputEventData(event, &events); |
1073 | 1084 |
1074 // Allow the user gesture to be pending after the plugin handles the | 1085 // Allow the user gesture to be pending after the plugin handles the |
1075 // event. This allows out-of-process plugins to respond to the user | 1086 // event. This allows out-of-process plugins to respond to the user |
1076 // gesture after processing has finished here. | 1087 // gesture after processing has finished here. |
1077 if (WebUserGestureIndicator::isProcessingUserGesture()) { | 1088 if (WebUserGestureIndicator::isProcessingUserGesture()) { |
1078 pending_user_gesture_ = | 1089 pending_user_gesture_ = |
1079 ppapi::EventTimeToPPTimeTicks(event.timeStampSeconds); | 1090 ppapi::EventTimeToPPTimeTicks(event.timeStampSeconds); |
1080 pending_user_gesture_token_ = | 1091 pending_user_gesture_token_ = |
1081 WebUserGestureIndicator::currentUserGestureToken(); | 1092 WebUserGestureIndicator::currentUserGestureToken(); |
1082 pending_user_gesture_token_.setOutOfProcess(); | 1093 pending_user_gesture_token_.setOutOfProcess(); |
1083 } | 1094 } |
1084 | 1095 |
1085 // Each input event may generate more than one PP_InputEvent. | 1096 // Each input event may generate more than one PP_InputEvent. |
1086 for (size_t i = 0; i < events.size(); i++) { | 1097 for (size_t i = 0; i < events.size(); i++) { |
1087 if (filtered_input_event_mask_ & event_class) | 1098 if (filtered_input_event_mask_ & event_class) |
1088 events[i].is_filtered = true; | 1099 events[i].is_filtered = true; |
1089 else | 1100 else |
1090 rv = true; // Unfiltered events are assumed to be handled. | 1101 rv = true; // Unfiltered events are assumed to be handled. |
1091 scoped_refptr<PPB_InputEvent_Shared> event_resource( | 1102 scoped_refptr<PPB_InputEvent_Shared> event_resource( |
1092 new PPB_InputEvent_Shared(ppapi::OBJECT_IS_IMPL, | 1103 new PPB_InputEvent_Shared( |
1093 pp_instance(), events[i])); | 1104 ppapi::OBJECT_IS_IMPL, pp_instance(), events[i])); |
1094 | 1105 |
1095 rv |= PP_ToBool(plugin_input_event_interface_->HandleInputEvent( | 1106 rv |= PP_ToBool(plugin_input_event_interface_->HandleInputEvent( |
1096 pp_instance(), event_resource->pp_resource())); | 1107 pp_instance(), event_resource->pp_resource())); |
1097 } | 1108 } |
1098 } | 1109 } |
1099 } | 1110 } |
1100 | 1111 |
1101 if (cursor_) | 1112 if (cursor_) |
1102 *cursor_info = *cursor_; | 1113 *cursor_info = *cursor_; |
1103 return rv; | 1114 return rv; |
(...skipping 29 matching lines...) Expand all Loading... | |
1133 // in the "everything is clipped" case. | 1144 // in the "everything is clipped" case. |
1134 gfx::Rect new_clip; | 1145 gfx::Rect new_clip; |
1135 if (!clip.IsEmpty()) | 1146 if (!clip.IsEmpty()) |
1136 new_clip = clip; | 1147 new_clip = clip; |
1137 | 1148 |
1138 cut_outs_rects_ = cut_outs_rects; | 1149 cut_outs_rects_ = cut_outs_rects; |
1139 | 1150 |
1140 view_data_.rect = PP_FromGfxRect(position); | 1151 view_data_.rect = PP_FromGfxRect(position); |
1141 view_data_.clip_rect = PP_FromGfxRect(clip); | 1152 view_data_.clip_rect = PP_FromGfxRect(clip); |
1142 view_data_.device_scale = container_->deviceScaleFactor(); | 1153 view_data_.device_scale = container_->deviceScaleFactor(); |
1143 view_data_.css_scale = container_->pageZoomFactor() * | 1154 view_data_.css_scale = |
1144 container_->pageScaleFactor(); | 1155 container_->pageZoomFactor() * container_->pageScaleFactor(); |
1145 | 1156 |
1146 if (desired_fullscreen_state_ || view_data_.is_fullscreen) { | 1157 if (desired_fullscreen_state_ || view_data_.is_fullscreen) { |
1147 WebElement element = container_->element(); | 1158 WebElement element = container_->element(); |
1148 WebDocument document = element.document(); | 1159 WebDocument document = element.document(); |
1149 bool is_fullscreen_element = (element == document.fullScreenElement()); | 1160 bool is_fullscreen_element = (element == document.fullScreenElement()); |
1150 if (!view_data_.is_fullscreen && desired_fullscreen_state_ && | 1161 if (!view_data_.is_fullscreen && desired_fullscreen_state_ && |
1151 render_frame()->GetRenderWidget()->is_fullscreen() && | 1162 render_frame()->GetRenderWidget()->is_fullscreen() && |
1152 is_fullscreen_element) { | 1163 is_fullscreen_element) { |
1153 // Entered fullscreen. Only possible via SetFullscreen(). | 1164 // Entered fullscreen. Only possible via SetFullscreen(). |
1154 view_data_.is_fullscreen = true; | 1165 view_data_.is_fullscreen = true; |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1263 | 1274 |
1264 gfx::Rect clip_page = PP_ToGfxRect(view_data_.clip_rect); | 1275 gfx::Rect clip_page = PP_ToGfxRect(view_data_.clip_rect); |
1265 gfx::Rect plugin_paint_rect = | 1276 gfx::Rect plugin_paint_rect = |
1266 gfx::IntersectRects(plugin_backing_store_rect, clip_page); | 1277 gfx::IntersectRects(plugin_backing_store_rect, clip_page); |
1267 if (!plugin_paint_rect.Contains(relative_paint_bounds)) | 1278 if (!plugin_paint_rect.Contains(relative_paint_bounds)) |
1268 return false; | 1279 return false; |
1269 | 1280 |
1270 // Don't do optimized painting if the area to paint intersects with the | 1281 // Don't do optimized painting if the area to paint intersects with the |
1271 // cut-out rects, otherwise we will paint over them. | 1282 // cut-out rects, otherwise we will paint over them. |
1272 for (std::vector<gfx::Rect>::const_iterator iter = cut_outs_rects_.begin(); | 1283 for (std::vector<gfx::Rect>::const_iterator iter = cut_outs_rects_.begin(); |
1273 iter != cut_outs_rects_.end(); ++iter) { | 1284 iter != cut_outs_rects_.end(); |
1285 ++iter) { | |
1274 if (relative_paint_bounds.Intersects(*iter)) | 1286 if (relative_paint_bounds.Intersects(*iter)) |
1275 return false; | 1287 return false; |
1276 } | 1288 } |
1277 | 1289 |
1278 *dib = image_data->GetTransportDIB(); | 1290 *dib = image_data->GetTransportDIB(); |
1279 plugin_backing_store_rect.Offset(plugin_offset); | 1291 plugin_backing_store_rect.Offset(plugin_offset); |
1280 *location = plugin_backing_store_rect; | 1292 *location = plugin_backing_store_rect; |
1281 clip_page.Offset(plugin_offset); | 1293 clip_page.Offset(plugin_offset); |
1282 *clip = clip_page; | 1294 *clip = clip_page; |
1283 // The plugin scale factor is inverted, e.g. for a device scale factor of 2x | 1295 // The plugin scale factor is inverted, e.g. for a device scale factor of 2x |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1360 | 1372 |
1361 bool PepperPluginInstanceImpl::StartFind(const base::string16& search_text, | 1373 bool PepperPluginInstanceImpl::StartFind(const base::string16& search_text, |
1362 bool case_sensitive, | 1374 bool case_sensitive, |
1363 int identifier) { | 1375 int identifier) { |
1364 // Keep a reference on the stack. See NOTE above. | 1376 // Keep a reference on the stack. See NOTE above. |
1365 scoped_refptr<PepperPluginInstanceImpl> ref(this); | 1377 scoped_refptr<PepperPluginInstanceImpl> ref(this); |
1366 if (!LoadFindInterface()) | 1378 if (!LoadFindInterface()) |
1367 return false; | 1379 return false; |
1368 find_identifier_ = identifier; | 1380 find_identifier_ = identifier; |
1369 return PP_ToBool( | 1381 return PP_ToBool( |
1370 plugin_find_interface_->StartFind( | 1382 plugin_find_interface_->StartFind(pp_instance(), |
1371 pp_instance(), | 1383 base::UTF16ToUTF8(search_text).c_str(), |
1372 base::UTF16ToUTF8(search_text).c_str(), | 1384 PP_FromBool(case_sensitive))); |
1373 PP_FromBool(case_sensitive))); | |
1374 } | 1385 } |
1375 | 1386 |
1376 void PepperPluginInstanceImpl::SelectFindResult(bool forward) { | 1387 void PepperPluginInstanceImpl::SelectFindResult(bool forward) { |
1377 // Keep a reference on the stack. See NOTE above. | 1388 // Keep a reference on the stack. See NOTE above. |
1378 scoped_refptr<PepperPluginInstanceImpl> ref(this); | 1389 scoped_refptr<PepperPluginInstanceImpl> ref(this); |
1379 if (LoadFindInterface()) | 1390 if (LoadFindInterface()) |
1380 plugin_find_interface_->SelectFindResult(pp_instance(), | 1391 plugin_find_interface_->SelectFindResult(pp_instance(), |
1381 PP_FromBool(forward)); | 1392 PP_FromBool(forward)); |
1382 } | 1393 } |
1383 | 1394 |
1384 void PepperPluginInstanceImpl::StopFind() { | 1395 void PepperPluginInstanceImpl::StopFind() { |
1385 // Keep a reference on the stack. See NOTE above. | 1396 // Keep a reference on the stack. See NOTE above. |
1386 scoped_refptr<PepperPluginInstanceImpl> ref(this); | 1397 scoped_refptr<PepperPluginInstanceImpl> ref(this); |
1387 if (!LoadFindInterface()) | 1398 if (!LoadFindInterface()) |
1388 return; | 1399 return; |
1389 find_identifier_ = -1; | 1400 find_identifier_ = -1; |
1390 plugin_find_interface_->StopFind(pp_instance()); | 1401 plugin_find_interface_->StopFind(pp_instance()); |
1391 } | 1402 } |
1392 | 1403 |
1393 bool PepperPluginInstanceImpl::LoadFindInterface() { | 1404 bool PepperPluginInstanceImpl::LoadFindInterface() { |
1394 if (!module_->permissions().HasPermission(ppapi::PERMISSION_PRIVATE)) | 1405 if (!module_->permissions().HasPermission(ppapi::PERMISSION_PRIVATE)) |
1395 return false; | 1406 return false; |
1396 if (!plugin_find_interface_) { | 1407 if (!plugin_find_interface_) { |
1397 plugin_find_interface_ = | 1408 plugin_find_interface_ = static_cast<const PPP_Find_Private*>( |
1398 static_cast<const PPP_Find_Private*>(module_->GetPluginInterface( | 1409 module_->GetPluginInterface(PPP_FIND_PRIVATE_INTERFACE)); |
1399 PPP_FIND_PRIVATE_INTERFACE)); | |
1400 } | 1410 } |
1401 | 1411 |
1402 return !!plugin_find_interface_; | 1412 return !!plugin_find_interface_; |
1403 } | 1413 } |
1404 | 1414 |
1405 bool PepperPluginInstanceImpl::LoadInputEventInterface() { | 1415 bool PepperPluginInstanceImpl::LoadInputEventInterface() { |
1406 if (!checked_for_plugin_input_event_interface_) { | 1416 if (!checked_for_plugin_input_event_interface_) { |
1407 checked_for_plugin_input_event_interface_ = true; | 1417 checked_for_plugin_input_event_interface_ = true; |
1408 plugin_input_event_interface_ = | 1418 plugin_input_event_interface_ = static_cast<const PPP_InputEvent*>( |
1409 static_cast<const PPP_InputEvent*>(module_->GetPluginInterface( | 1419 module_->GetPluginInterface(PPP_INPUT_EVENT_INTERFACE)); |
1410 PPP_INPUT_EVENT_INTERFACE)); | |
1411 } | 1420 } |
1412 return !!plugin_input_event_interface_; | 1421 return !!plugin_input_event_interface_; |
1413 } | 1422 } |
1414 | 1423 |
1415 bool PepperPluginInstanceImpl::LoadMessagingInterface() { | 1424 bool PepperPluginInstanceImpl::LoadMessagingInterface() { |
1416 if (!checked_for_plugin_messaging_interface_) { | 1425 if (!checked_for_plugin_messaging_interface_) { |
1417 checked_for_plugin_messaging_interface_ = true; | 1426 checked_for_plugin_messaging_interface_ = true; |
1418 plugin_messaging_interface_ = | 1427 plugin_messaging_interface_ = static_cast<const PPP_Messaging*>( |
1419 static_cast<const PPP_Messaging*>(module_->GetPluginInterface( | 1428 module_->GetPluginInterface(PPP_MESSAGING_INTERFACE)); |
1420 PPP_MESSAGING_INTERFACE)); | |
1421 } | 1429 } |
1422 return !!plugin_messaging_interface_; | 1430 return !!plugin_messaging_interface_; |
1423 } | 1431 } |
1424 | 1432 |
1425 bool PepperPluginInstanceImpl::LoadMouseLockInterface() { | 1433 bool PepperPluginInstanceImpl::LoadMouseLockInterface() { |
1426 if (!plugin_mouse_lock_interface_) { | 1434 if (!plugin_mouse_lock_interface_) { |
1427 plugin_mouse_lock_interface_ = | 1435 plugin_mouse_lock_interface_ = static_cast<const PPP_MouseLock*>( |
1428 static_cast<const PPP_MouseLock*>(module_->GetPluginInterface( | 1436 module_->GetPluginInterface(PPP_MOUSELOCK_INTERFACE)); |
1429 PPP_MOUSELOCK_INTERFACE)); | |
1430 } | 1437 } |
1431 | 1438 |
1432 return !!plugin_mouse_lock_interface_; | 1439 return !!plugin_mouse_lock_interface_; |
1433 } | 1440 } |
1434 | 1441 |
1435 bool PepperPluginInstanceImpl::LoadPdfInterface() { | 1442 bool PepperPluginInstanceImpl::LoadPdfInterface() { |
1436 if (!checked_for_plugin_pdf_interface_) { | 1443 if (!checked_for_plugin_pdf_interface_) { |
1437 checked_for_plugin_pdf_interface_ = true; | 1444 checked_for_plugin_pdf_interface_ = true; |
1438 plugin_pdf_interface_ = | 1445 plugin_pdf_interface_ = static_cast<const PPP_Pdf_1*>( |
1439 static_cast<const PPP_Pdf_1*>(module_->GetPluginInterface( | 1446 module_->GetPluginInterface(PPP_PDF_INTERFACE_1)); |
1440 PPP_PDF_INTERFACE_1)); | |
1441 } | 1447 } |
1442 | 1448 |
1443 return !!plugin_pdf_interface_; | 1449 return !!plugin_pdf_interface_; |
1444 } | 1450 } |
1445 | 1451 |
1446 bool PepperPluginInstanceImpl::LoadPrintInterface() { | 1452 bool PepperPluginInstanceImpl::LoadPrintInterface() { |
1447 // Only check for the interface if the plugin has dev permission. | 1453 // Only check for the interface if the plugin has dev permission. |
1448 if (!module_->permissions().HasPermission(ppapi::PERMISSION_DEV)) | 1454 if (!module_->permissions().HasPermission(ppapi::PERMISSION_DEV)) |
1449 return false; | 1455 return false; |
1450 if (!plugin_print_interface_) { | 1456 if (!plugin_print_interface_) { |
1451 plugin_print_interface_ = static_cast<const PPP_Printing_Dev*>( | 1457 plugin_print_interface_ = static_cast<const PPP_Printing_Dev*>( |
1452 module_->GetPluginInterface(PPP_PRINTING_DEV_INTERFACE)); | 1458 module_->GetPluginInterface(PPP_PRINTING_DEV_INTERFACE)); |
1453 } | 1459 } |
1454 return !!plugin_print_interface_; | 1460 return !!plugin_print_interface_; |
1455 } | 1461 } |
1456 | 1462 |
1457 bool PepperPluginInstanceImpl::LoadPrivateInterface() { | 1463 bool PepperPluginInstanceImpl::LoadPrivateInterface() { |
1458 // If this is a NaCl app, we want to talk to the trusted NaCl plugin to | 1464 // If this is a NaCl app, we want to talk to the trusted NaCl plugin to |
1459 // call GetInstanceObject. This is necessary to ensure that the properties | 1465 // call GetInstanceObject. This is necessary to ensure that the properties |
1460 // the trusted plugin exposes (readyState and lastError) work properly. Note | 1466 // the trusted plugin exposes (readyState and lastError) work properly. Note |
1461 // that untrusted NaCl apps are not allowed to provide PPP_InstancePrivate, | 1467 // that untrusted NaCl apps are not allowed to provide PPP_InstancePrivate, |
1462 // so it's correct to never look up PPP_InstancePrivate for them. | 1468 // so it's correct to never look up PPP_InstancePrivate for them. |
1463 // | 1469 // |
1464 // If this is *not* a NaCl plugin, original_module_ will never be set; we talk | 1470 // If this is *not* a NaCl plugin, original_module_ will never be set; we talk |
1465 // to the "real" module. | 1471 // to the "real" module. |
1466 scoped_refptr<PluginModule> module = original_module_ ? original_module_ : | 1472 scoped_refptr<PluginModule> module = |
1467 module_; | 1473 original_module_ ? original_module_ : module_; |
1468 // Only check for the interface if the plugin has private permission. | 1474 // Only check for the interface if the plugin has private permission. |
1469 if (!module->permissions().HasPermission(ppapi::PERMISSION_PRIVATE)) | 1475 if (!module->permissions().HasPermission(ppapi::PERMISSION_PRIVATE)) |
1470 return false; | 1476 return false; |
1471 if (!plugin_private_interface_) { | 1477 if (!plugin_private_interface_) { |
1472 plugin_private_interface_ = static_cast<const PPP_Instance_Private*>( | 1478 plugin_private_interface_ = static_cast<const PPP_Instance_Private*>( |
1473 module->GetPluginInterface(PPP_INSTANCE_PRIVATE_INTERFACE)); | 1479 module->GetPluginInterface(PPP_INSTANCE_PRIVATE_INTERFACE)); |
1474 } | 1480 } |
1475 | 1481 |
1476 return !!plugin_private_interface_; | 1482 return !!plugin_private_interface_; |
1477 } | 1483 } |
1478 | 1484 |
1479 bool PepperPluginInstanceImpl::LoadSelectionInterface() { | 1485 bool PepperPluginInstanceImpl::LoadSelectionInterface() { |
1480 if (!plugin_selection_interface_) { | 1486 if (!plugin_selection_interface_) { |
1481 plugin_selection_interface_ = | 1487 plugin_selection_interface_ = static_cast<const PPP_Selection_Dev*>( |
1482 static_cast<const PPP_Selection_Dev*>(module_->GetPluginInterface( | 1488 module_->GetPluginInterface(PPP_SELECTION_DEV_INTERFACE)); |
1483 PPP_SELECTION_DEV_INTERFACE)); | |
1484 } | 1489 } |
1485 return !!plugin_selection_interface_; | 1490 return !!plugin_selection_interface_; |
1486 } | 1491 } |
1487 | 1492 |
1488 bool PepperPluginInstanceImpl::LoadTextInputInterface() { | 1493 bool PepperPluginInstanceImpl::LoadTextInputInterface() { |
1489 if (!plugin_textinput_interface_) { | 1494 if (!plugin_textinput_interface_) { |
1490 plugin_textinput_interface_ = | 1495 plugin_textinput_interface_ = static_cast<const PPP_TextInput_Dev*>( |
1491 static_cast<const PPP_TextInput_Dev*>(module_->GetPluginInterface( | 1496 module_->GetPluginInterface(PPP_TEXTINPUT_DEV_INTERFACE)); |
1492 PPP_TEXTINPUT_DEV_INTERFACE)); | |
1493 } | 1497 } |
1494 | 1498 |
1495 return !!plugin_textinput_interface_; | 1499 return !!plugin_textinput_interface_; |
1496 } | 1500 } |
1497 | 1501 |
1498 bool PepperPluginInstanceImpl::LoadZoomInterface() { | 1502 bool PepperPluginInstanceImpl::LoadZoomInterface() { |
1499 if (!plugin_zoom_interface_) { | 1503 if (!plugin_zoom_interface_) { |
1500 plugin_zoom_interface_ = | 1504 plugin_zoom_interface_ = static_cast<const PPP_Zoom_Dev*>( |
1501 static_cast<const PPP_Zoom_Dev*>(module_->GetPluginInterface( | 1505 module_->GetPluginInterface(PPP_ZOOM_DEV_INTERFACE)); |
1502 PPP_ZOOM_DEV_INTERFACE)); | |
1503 } | 1506 } |
1504 | 1507 |
1505 return !!plugin_zoom_interface_; | 1508 return !!plugin_zoom_interface_; |
1506 } | 1509 } |
1507 | 1510 |
1508 void PepperPluginInstanceImpl::UpdateLayerTransform() { | 1511 void PepperPluginInstanceImpl::UpdateLayerTransform() { |
1509 if (!bound_graphics_2d_platform_ || !texture_layer_) { | 1512 if (!bound_graphics_2d_platform_ || !texture_layer_) { |
1510 // Currently the transform is only applied for Graphics2D. | 1513 // Currently the transform is only applied for Graphics2D. |
1511 return; | 1514 return; |
1512 } | 1515 } |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1547 | 1550 |
1548 // instance_interface_ may have been cleared in Delete() if the | 1551 // instance_interface_ may have been cleared in Delete() if the |
1549 // PepperWebPluginImpl is destroyed. | 1552 // PepperWebPluginImpl is destroyed. |
1550 if (instance_interface_) | 1553 if (instance_interface_) |
1551 instance_interface_->DidChangeFocus(pp_instance(), PP_FromBool(has_focus)); | 1554 instance_interface_->DidChangeFocus(pp_instance(), PP_FromBool(has_focus)); |
1552 } | 1555 } |
1553 | 1556 |
1554 void PepperPluginInstanceImpl::UpdateTouchEventRequest() { | 1557 void PepperPluginInstanceImpl::UpdateTouchEventRequest() { |
1555 bool raw_touch = (filtered_input_event_mask_ & PP_INPUTEVENT_CLASS_TOUCH) || | 1558 bool raw_touch = (filtered_input_event_mask_ & PP_INPUTEVENT_CLASS_TOUCH) || |
1556 (input_event_mask_ & PP_INPUTEVENT_CLASS_TOUCH); | 1559 (input_event_mask_ & PP_INPUTEVENT_CLASS_TOUCH); |
1557 container_->requestTouchEventType(raw_touch ? | 1560 container_->requestTouchEventType( |
1558 blink::WebPluginContainer::TouchEventRequestTypeRaw : | 1561 raw_touch |
1559 blink::WebPluginContainer::TouchEventRequestTypeSynthesizedMouse); | 1562 ? blink::WebPluginContainer::TouchEventRequestTypeRaw |
1563 : blink::WebPluginContainer::TouchEventRequestTypeSynthesizedMouse); | |
1560 } | 1564 } |
1561 | 1565 |
1562 bool PepperPluginInstanceImpl::IsAcceptingWheelEvents() const { | 1566 bool PepperPluginInstanceImpl::IsAcceptingWheelEvents() const { |
1563 return (filtered_input_event_mask_ & PP_INPUTEVENT_CLASS_WHEEL) || | 1567 return (filtered_input_event_mask_ & PP_INPUTEVENT_CLASS_WHEEL) || |
1564 (input_event_mask_ & PP_INPUTEVENT_CLASS_WHEEL); | 1568 (input_event_mask_ & PP_INPUTEVENT_CLASS_WHEEL); |
1565 } | 1569 } |
1566 | 1570 |
1567 void PepperPluginInstanceImpl::ScheduleAsyncDidChangeView() { | 1571 void PepperPluginInstanceImpl::ScheduleAsyncDidChangeView() { |
1568 if (view_change_weak_ptr_factory_.HasWeakPtrs()) | 1572 if (view_change_weak_ptr_factory_.HasWeakPtrs()) |
1569 return; // Already scheduled. | 1573 return; // Already scheduled. |
1570 base::MessageLoop::current()->PostTask( | 1574 base::MessageLoop::current()->PostTask( |
1571 FROM_HERE, | 1575 FROM_HERE, |
1572 base::Bind(&PepperPluginInstanceImpl::SendAsyncDidChangeView, | 1576 base::Bind(&PepperPluginInstanceImpl::SendAsyncDidChangeView, |
1573 view_change_weak_ptr_factory_.GetWeakPtr())); | 1577 view_change_weak_ptr_factory_.GetWeakPtr())); |
1574 } | 1578 } |
(...skipping 15 matching lines...) Expand all Loading... | |
1590 | 1594 |
1591 if (view_change_weak_ptr_factory_.HasWeakPtrs() || | 1595 if (view_change_weak_ptr_factory_.HasWeakPtrs() || |
1592 (sent_initial_did_change_view_ && | 1596 (sent_initial_did_change_view_ && |
1593 last_sent_view_data_.Equals(view_data_))) | 1597 last_sent_view_data_.Equals(view_data_))) |
1594 return; // Nothing to update. | 1598 return; // Nothing to update. |
1595 | 1599 |
1596 sent_initial_did_change_view_ = true; | 1600 sent_initial_did_change_view_ = true; |
1597 last_sent_view_data_ = view_data_; | 1601 last_sent_view_data_ = view_data_; |
1598 ScopedPPResource resource( | 1602 ScopedPPResource resource( |
1599 ScopedPPResource::PassRef(), | 1603 ScopedPPResource::PassRef(), |
1600 (new PPB_View_Shared(ppapi::OBJECT_IS_IMPL, | 1604 (new PPB_View_Shared(ppapi::OBJECT_IS_IMPL, pp_instance(), view_data_)) |
1601 pp_instance(), view_data_))->GetReference()); | 1605 ->GetReference()); |
1602 | 1606 |
1603 UpdateLayerTransform(); | 1607 UpdateLayerTransform(); |
1604 | 1608 |
1605 // It's possible that Delete() has been called but the renderer hasn't | 1609 // It's possible that Delete() has been called but the renderer hasn't |
1606 // released its reference to this object yet. | 1610 // released its reference to this object yet. |
1607 if (instance_interface_) { | 1611 if (instance_interface_) { |
1608 instance_interface_->DidChangeView(pp_instance(), resource, | 1612 instance_interface_->DidChangeView( |
1609 &view_data_.rect, | 1613 pp_instance(), resource, &view_data_.rect, &view_data_.clip_rect); |
1610 &view_data_.clip_rect); | |
1611 } | 1614 } |
1612 } | 1615 } |
1613 | 1616 |
1614 void PepperPluginInstanceImpl::ReportGeometry() { | 1617 void PepperPluginInstanceImpl::ReportGeometry() { |
1615 // If this call was delayed, we may have transitioned back to fullscreen in | 1618 // If this call was delayed, we may have transitioned back to fullscreen in |
1616 // the mean time, so only report the geometry if we are actually in normal | 1619 // the mean time, so only report the geometry if we are actually in normal |
1617 // mode. | 1620 // mode. |
1618 if (container_ && !fullscreen_container_ && !flash_fullscreen_) | 1621 if (container_ && !fullscreen_container_ && !flash_fullscreen_) |
1619 container_->reportGeometry(); | 1622 container_->reportGeometry(); |
1620 } | 1623 } |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1657 return 0; | 1660 return 0; |
1658 } | 1661 } |
1659 int num_pages = 0; | 1662 int num_pages = 0; |
1660 PP_PrintSettings_Dev print_settings; | 1663 PP_PrintSettings_Dev print_settings; |
1661 print_settings.printable_area = PP_FromGfxRect(print_params.printableArea); | 1664 print_settings.printable_area = PP_FromGfxRect(print_params.printableArea); |
1662 print_settings.content_area = PP_FromGfxRect(print_params.printContentArea); | 1665 print_settings.content_area = PP_FromGfxRect(print_params.printContentArea); |
1663 print_settings.paper_size = PP_FromGfxSize(print_params.paperSize); | 1666 print_settings.paper_size = PP_FromGfxSize(print_params.paperSize); |
1664 print_settings.dpi = print_params.printerDPI; | 1667 print_settings.dpi = print_params.printerDPI; |
1665 print_settings.orientation = PP_PRINTORIENTATION_NORMAL; | 1668 print_settings.orientation = PP_PRINTORIENTATION_NORMAL; |
1666 print_settings.grayscale = PP_FALSE; | 1669 print_settings.grayscale = PP_FALSE; |
1667 print_settings.print_scaling_option = static_cast<PP_PrintScalingOption_Dev>( | 1670 print_settings.print_scaling_option = |
1668 print_params.printScalingOption); | 1671 static_cast<PP_PrintScalingOption_Dev>(print_params.printScalingOption); |
1669 print_settings.format = format; | 1672 print_settings.format = format; |
1670 num_pages = plugin_print_interface_->Begin(pp_instance(), | 1673 num_pages = plugin_print_interface_->Begin(pp_instance(), &print_settings); |
1671 &print_settings); | |
1672 if (!num_pages) | 1674 if (!num_pages) |
1673 return 0; | 1675 return 0; |
1674 current_print_settings_ = print_settings; | 1676 current_print_settings_ = print_settings; |
1675 canvas_.clear(); | 1677 canvas_.clear(); |
1676 ranges_.clear(); | 1678 ranges_.clear(); |
1677 return num_pages; | 1679 return num_pages; |
1678 } | 1680 } |
1679 | 1681 |
1680 bool PepperPluginInstanceImpl::PrintPage(int page_number, | 1682 bool PepperPluginInstanceImpl::PrintPage(int page_number, |
1681 blink::WebCanvas* canvas) { | 1683 blink::WebCanvas* canvas) { |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1748 if (!LoadPdfInterface()) | 1750 if (!LoadPdfInterface()) |
1749 return false; | 1751 return false; |
1750 | 1752 |
1751 return true; | 1753 return true; |
1752 } | 1754 } |
1753 | 1755 |
1754 void PepperPluginInstanceImpl::RotateView(WebPlugin::RotationType type) { | 1756 void PepperPluginInstanceImpl::RotateView(WebPlugin::RotationType type) { |
1755 if (!LoadPdfInterface()) | 1757 if (!LoadPdfInterface()) |
1756 return; | 1758 return; |
1757 PP_PrivatePageTransformType transform_type = | 1759 PP_PrivatePageTransformType transform_type = |
1758 type == WebPlugin::RotationType90Clockwise ? | 1760 type == WebPlugin::RotationType90Clockwise |
1759 PP_PRIVATEPAGETRANSFORMTYPE_ROTATE_90_CW : | 1761 ? PP_PRIVATEPAGETRANSFORMTYPE_ROTATE_90_CW |
1760 PP_PRIVATEPAGETRANSFORMTYPE_ROTATE_90_CCW; | 1762 : PP_PRIVATEPAGETRANSFORMTYPE_ROTATE_90_CCW; |
1761 plugin_pdf_interface_->Transform(pp_instance(), transform_type); | 1763 plugin_pdf_interface_->Transform(pp_instance(), transform_type); |
1762 // NOTE: plugin instance may have been deleted. | 1764 // NOTE: plugin instance may have been deleted. |
1763 } | 1765 } |
1764 | 1766 |
1765 bool PepperPluginInstanceImpl::FlashIsFullscreenOrPending() { | 1767 bool PepperPluginInstanceImpl::FlashIsFullscreenOrPending() { |
1766 return fullscreen_container_ != NULL; | 1768 return fullscreen_container_ != NULL; |
1767 } | 1769 } |
1768 | 1770 |
1769 bool PepperPluginInstanceImpl::IsFullscreenOrPending() { | 1771 bool PepperPluginInstanceImpl::IsFullscreenOrPending() { |
1770 return desired_fullscreen_state_; | 1772 return desired_fullscreen_state_; |
1771 } | 1773 } |
1772 | 1774 |
1773 bool PepperPluginInstanceImpl::SetFullscreen(bool fullscreen) { | 1775 bool PepperPluginInstanceImpl::SetFullscreen(bool fullscreen) { |
1774 // Keep a reference on the stack. See NOTE above. | 1776 // Keep a reference on the stack. See NOTE above. |
1775 scoped_refptr<PepperPluginInstanceImpl> ref(this); | 1777 scoped_refptr<PepperPluginInstanceImpl> ref(this); |
1776 | 1778 |
1777 // Check whether we are trying to switch to the state we're already going | 1779 // Check whether we are trying to switch to the state we're already going |
1778 // to (i.e. if we're already switching to fullscreen but the fullscreen | 1780 // to (i.e. if we're already switching to fullscreen but the fullscreen |
1779 // container isn't ready yet, don't do anything more). | 1781 // container isn't ready yet, don't do anything more). |
1780 if (fullscreen == IsFullscreenOrPending()) | 1782 if (fullscreen == IsFullscreenOrPending()) |
1781 return false; | 1783 return false; |
1782 | 1784 |
1783 if (!render_frame_) | 1785 if (!render_frame_) |
1784 return false; | 1786 return false; |
1785 if (fullscreen && | 1787 if (fullscreen && !render_frame_->render_view() |
1786 !render_frame_->render_view()->renderer_preferences(). | 1788 ->renderer_preferences() |
1787 plugin_fullscreen_allowed) | 1789 .plugin_fullscreen_allowed) |
1788 return false; | 1790 return false; |
1789 | 1791 |
1790 // Check whether we are trying to switch while the state is in transition. | 1792 // Check whether we are trying to switch while the state is in transition. |
1791 // The 2nd request gets dropped while messing up the internal state, so | 1793 // The 2nd request gets dropped while messing up the internal state, so |
1792 // disallow this. | 1794 // disallow this. |
1793 if (view_data_.is_fullscreen != desired_fullscreen_state_) | 1795 if (view_data_.is_fullscreen != desired_fullscreen_state_) |
1794 return false; | 1796 return false; |
1795 | 1797 |
1796 if (fullscreen && !IsProcessingUserGesture()) | 1798 if (fullscreen && !IsProcessingUserGesture()) |
1797 return false; | 1799 return false; |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1871 BufferAutoMapper mapper(enter.object()); | 1873 BufferAutoMapper mapper(enter.object()); |
1872 if (!mapper.data() || !mapper.size()) { | 1874 if (!mapper.data() || !mapper.size()) { |
1873 NOTREACHED(); | 1875 NOTREACHED(); |
1874 return false; | 1876 return false; |
1875 } | 1877 } |
1876 #if defined(OS_WIN) | 1878 #if defined(OS_WIN) |
1877 // For Windows, we need the PDF DLL to render the output PDF to a DC. | 1879 // For Windows, we need the PDF DLL to render the output PDF to a DC. |
1878 HMODULE pdf_module = GetModuleHandle(L"pdf.dll"); | 1880 HMODULE pdf_module = GetModuleHandle(L"pdf.dll"); |
1879 if (!pdf_module) | 1881 if (!pdf_module) |
1880 return false; | 1882 return false; |
1881 RenderPDFPageToDCProc render_proc = | 1883 RenderPDFPageToDCProc render_proc = reinterpret_cast<RenderPDFPageToDCProc>( |
1882 reinterpret_cast<RenderPDFPageToDCProc>( | 1884 GetProcAddress(pdf_module, "RenderPDFPageToDC")); |
1883 GetProcAddress(pdf_module, "RenderPDFPageToDC")); | |
1884 if (!render_proc) | 1885 if (!render_proc) |
1885 return false; | 1886 return false; |
1886 #endif // defined(OS_WIN) | 1887 #endif // defined(OS_WIN) |
1887 | 1888 |
1888 bool ret = false; | 1889 bool ret = false; |
1889 #if defined(OS_POSIX) && !defined(OS_ANDROID) | 1890 #if defined(OS_POSIX) && !defined(OS_ANDROID) |
1890 // On Linux we just set the final bits in the native metafile | 1891 // On Linux we just set the final bits in the native metafile |
1891 // (NativeMetafile and PreviewMetafile must have compatible formats, | 1892 // (NativeMetafile and PreviewMetafile must have compatible formats, |
1892 // i.e. both PDF for this to work). | 1893 // i.e. both PDF for this to work). |
1893 printing::Metafile* metafile = | 1894 printing::Metafile* metafile = |
1894 printing::MetafileSkiaWrapper::GetMetafileFromCanvas(*canvas); | 1895 printing::MetafileSkiaWrapper::GetMetafileFromCanvas(*canvas); |
1895 DCHECK(metafile != NULL); | 1896 DCHECK(metafile != NULL); |
1896 if (metafile) | 1897 if (metafile) |
1897 ret = metafile->InitFromData(mapper.data(), mapper.size()); | 1898 ret = metafile->InitFromData(mapper.data(), mapper.size()); |
1898 #elif defined(OS_WIN) | 1899 #elif defined(OS_WIN) |
1899 printing::Metafile* metafile = | 1900 printing::Metafile* metafile = |
1900 printing::MetafileSkiaWrapper::GetMetafileFromCanvas(*canvas); | 1901 printing::MetafileSkiaWrapper::GetMetafileFromCanvas(*canvas); |
1901 if (metafile) { | 1902 if (metafile) { |
1902 // We only have a metafile when doing print preview, so we just want to | 1903 // We only have a metafile when doing print preview, so we just want to |
1903 // pass the PDF off to preview. | 1904 // pass the PDF off to preview. |
1904 ret = metafile->InitFromData(mapper.data(), mapper.size()); | 1905 ret = metafile->InitFromData(mapper.data(), mapper.size()); |
1905 } else { | 1906 } else { |
1906 // On Windows, we now need to render the PDF to the DC that backs the | 1907 // On Windows, we now need to render the PDF to the DC that backs the |
1907 // supplied canvas. | 1908 // supplied canvas. |
1908 HDC dc = skia::BeginPlatformPaint(canvas); | 1909 HDC dc = skia::BeginPlatformPaint(canvas); |
1909 DrawEmptyRectangle(dc); | 1910 DrawEmptyRectangle(dc); |
1910 gfx::Size size_in_pixels; | 1911 gfx::Size size_in_pixels; |
1911 size_in_pixels.set_width(printing::ConvertUnit( | 1912 size_in_pixels.set_width( |
1912 current_print_settings_.printable_area.size.width, | 1913 printing::ConvertUnit(current_print_settings_.printable_area.size.width, |
1913 static_cast<int>(printing::kPointsPerInch), | 1914 static_cast<int>(printing::kPointsPerInch), |
1914 current_print_settings_.dpi)); | 1915 current_print_settings_.dpi)); |
1915 size_in_pixels.set_height(printing::ConvertUnit( | 1916 size_in_pixels.set_height(printing::ConvertUnit( |
1916 current_print_settings_.printable_area.size.height, | 1917 current_print_settings_.printable_area.size.height, |
1917 static_cast<int>(printing::kPointsPerInch), | 1918 static_cast<int>(printing::kPointsPerInch), |
1918 current_print_settings_.dpi)); | 1919 current_print_settings_.dpi)); |
1919 // We need to scale down DC to fit an entire page into DC available area. | 1920 // We need to scale down DC to fit an entire page into DC available area. |
1920 // First, we'll try to use default scaling based on the 72dpi that is | 1921 // First, we'll try to use default scaling based on the 72dpi that is |
1921 // used in webkit for printing. | 1922 // used in webkit for printing. |
1922 // If default scaling is not enough to fit the entire PDF without | 1923 // If default scaling is not enough to fit the entire PDF without |
1923 // Current metafile is based on screen DC and have current screen size. | 1924 // Current metafile is based on screen DC and have current screen size. |
1924 // Writing outside of those boundaries will result in the cut-off output. | 1925 // Writing outside of those boundaries will result in the cut-off output. |
1925 // On metafiles (this is the case here), scaling down will still record | 1926 // On metafiles (this is the case here), scaling down will still record |
1926 // original coordinates and we'll be able to print in full resolution. | 1927 // original coordinates and we'll be able to print in full resolution. |
1927 // Before playback we'll need to counter the scaling up that will happen | 1928 // Before playback we'll need to counter the scaling up that will happen |
1928 // in the browser (printed_document_win.cc). | 1929 // in the browser (printed_document_win.cc). |
1929 double dynamic_scale = gfx::CalculatePageScale(dc, size_in_pixels.width(), | 1930 double dynamic_scale = gfx::CalculatePageScale( |
1930 size_in_pixels.height()); | 1931 dc, size_in_pixels.width(), size_in_pixels.height()); |
1931 double page_scale = static_cast<double>(printing::kPointsPerInch) / | 1932 double page_scale = static_cast<double>(printing::kPointsPerInch) / |
1932 static_cast<double>(current_print_settings_.dpi); | 1933 static_cast<double>(current_print_settings_.dpi); |
1933 | 1934 |
1934 if (dynamic_scale < page_scale) { | 1935 if (dynamic_scale < page_scale) { |
1935 page_scale = dynamic_scale; | 1936 page_scale = dynamic_scale; |
1936 printing::MetafileSkiaWrapper::SetCustomScaleOnCanvas(*canvas, | 1937 printing::MetafileSkiaWrapper::SetCustomScaleOnCanvas(*canvas, |
1937 page_scale); | 1938 page_scale); |
1938 } | 1939 } |
1939 | 1940 |
1940 gfx::ScaleDC(dc, page_scale); | 1941 gfx::ScaleDC(dc, page_scale); |
1941 | 1942 |
1942 ret = render_proc(static_cast<unsigned char*>(mapper.data()), mapper.size(), | 1943 ret = render_proc(static_cast<unsigned char*>(mapper.data()), |
1943 0, dc, current_print_settings_.dpi, | 1944 mapper.size(), |
1944 current_print_settings_.dpi, 0, 0, size_in_pixels.width(), | 1945 0, |
1945 size_in_pixels.height(), true, false, true, true, true); | 1946 dc, |
1947 current_print_settings_.dpi, | |
1948 current_print_settings_.dpi, | |
1949 0, | |
1950 0, | |
1951 size_in_pixels.width(), | |
1952 size_in_pixels.height(), | |
1953 true, | |
1954 false, | |
1955 true, | |
1956 true, | |
1957 true); | |
1946 skia::EndPlatformPaint(canvas); | 1958 skia::EndPlatformPaint(canvas); |
1947 } | 1959 } |
1948 #endif // defined(OS_WIN) | 1960 #endif // defined(OS_WIN) |
1949 | 1961 |
1950 return ret; | 1962 return ret; |
1951 #else // defined(ENABLE_FULL_PRINTING) | 1963 #else // defined(ENABLE_FULL_PRINTING) |
1952 return false; | 1964 return false; |
1953 #endif | 1965 #endif |
1954 } | 1966 } |
1955 | 1967 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2010 } else { | 2022 } else { |
2011 container_->setWebLayer(web_layer_.get()); | 2023 container_->setWebLayer(web_layer_.get()); |
2012 texture_layer_->SetContentsOpaque(opaque); | 2024 texture_layer_->SetContentsOpaque(opaque); |
2013 } | 2025 } |
2014 } | 2026 } |
2015 layer_bound_to_fullscreen_ = !!fullscreen_container_; | 2027 layer_bound_to_fullscreen_ = !!fullscreen_container_; |
2016 layer_is_hardware_ = want_3d_layer; | 2028 layer_is_hardware_ = want_3d_layer; |
2017 UpdateLayerTransform(); | 2029 UpdateLayerTransform(); |
2018 } | 2030 } |
2019 | 2031 |
2020 unsigned PepperPluginInstanceImpl::PrepareTexture() { | 2032 unsigned PepperPluginInstanceImpl::PrepareTexture() { return 0; } |
2021 return 0; | |
2022 } | |
2023 | 2033 |
2024 bool PepperPluginInstanceImpl::PrepareTextureMailbox( | 2034 bool PepperPluginInstanceImpl::PrepareTextureMailbox( |
2025 cc::TextureMailbox* mailbox, | 2035 cc::TextureMailbox* mailbox, |
2026 scoped_ptr<cc::SingleReleaseCallback>* release_callback, | 2036 scoped_ptr<cc::SingleReleaseCallback>* release_callback, |
2027 bool use_shared_memory) { | 2037 bool use_shared_memory) { |
2028 if (!bound_graphics_2d_platform_) | 2038 if (!bound_graphics_2d_platform_) |
2029 return false; | 2039 return false; |
2030 return bound_graphics_2d_platform_->PrepareTextureMailbox( | 2040 return bound_graphics_2d_platform_->PrepareTextureMailbox(mailbox, |
2031 mailbox, release_callback); | 2041 release_callback); |
2032 } | 2042 } |
2033 | 2043 |
2034 void PepperPluginInstanceImpl::OnDestruct() { | 2044 void PepperPluginInstanceImpl::OnDestruct() { render_frame_ = NULL; } |
2035 render_frame_ = NULL; | |
2036 } | |
2037 | 2045 |
2038 void PepperPluginInstanceImpl::AddPluginObject(PluginObject* plugin_object) { | 2046 void PepperPluginInstanceImpl::AddPluginObject(PluginObject* plugin_object) { |
2039 DCHECK(live_plugin_objects_.find(plugin_object) == | 2047 DCHECK(live_plugin_objects_.find(plugin_object) == |
2040 live_plugin_objects_.end()); | 2048 live_plugin_objects_.end()); |
2041 live_plugin_objects_.insert(plugin_object); | 2049 live_plugin_objects_.insert(plugin_object); |
2042 } | 2050 } |
2043 | 2051 |
2044 void PepperPluginInstanceImpl::RemovePluginObject(PluginObject* plugin_object) { | 2052 void PepperPluginInstanceImpl::RemovePluginObject(PluginObject* plugin_object) { |
2045 // Don't actually verify that the object is in the set since during module | 2053 // Don't actually verify that the object is in the set since during module |
2046 // deletion we'll be in the process of freeing them. | 2054 // deletion we'll be in the process of freeing them. |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2089 bool handled = SimulateIMEEvent(input_event); | 2097 bool handled = SimulateIMEEvent(input_event); |
2090 if (handled) | 2098 if (handled) |
2091 return; | 2099 return; |
2092 | 2100 |
2093 std::vector<linked_ptr<WebInputEvent> > events = | 2101 std::vector<linked_ptr<WebInputEvent> > events = |
2094 CreateSimulatedWebInputEvents( | 2102 CreateSimulatedWebInputEvents( |
2095 input_event, | 2103 input_event, |
2096 view_data_.rect.point.x + view_data_.rect.size.width / 2, | 2104 view_data_.rect.point.x + view_data_.rect.size.width / 2, |
2097 view_data_.rect.point.y + view_data_.rect.size.height / 2); | 2105 view_data_.rect.point.y + view_data_.rect.size.height / 2); |
2098 for (std::vector<linked_ptr<WebInputEvent> >::iterator it = events.begin(); | 2106 for (std::vector<linked_ptr<WebInputEvent> >::iterator it = events.begin(); |
2099 it != events.end(); ++it) { | 2107 it != events.end(); |
2108 ++it) { | |
2100 web_view->handleInputEvent(*it->get()); | 2109 web_view->handleInputEvent(*it->get()); |
2101 } | 2110 } |
2102 } | 2111 } |
2103 | 2112 |
2104 bool PepperPluginInstanceImpl::SimulateIMEEvent( | 2113 bool PepperPluginInstanceImpl::SimulateIMEEvent( |
2105 const InputEventData& input_event) { | 2114 const InputEventData& input_event) { |
2106 switch (input_event.event_type) { | 2115 switch (input_event.event_type) { |
2107 case PP_INPUTEVENT_TYPE_IME_COMPOSITION_START: | 2116 case PP_INPUTEVENT_TYPE_IME_COMPOSITION_START: |
2108 case PP_INPUTEVENT_TYPE_IME_COMPOSITION_UPDATE: | 2117 case PP_INPUTEVENT_TYPE_IME_COMPOSITION_UPDATE: |
2109 SimulateImeSetCompositionEvent(input_event); | 2118 SimulateImeSetCompositionEvent(input_event); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2147 if (input_event.composition_target_segment == static_cast<int32_t>(i - 2)) | 2156 if (input_event.composition_target_segment == static_cast<int32_t>(i - 2)) |
2148 underline.thick = true; | 2157 underline.thick = true; |
2149 underlines.push_back(underline); | 2158 underlines.push_back(underline); |
2150 } | 2159 } |
2151 | 2160 |
2152 render_frame_->SimulateImeSetComposition( | 2161 render_frame_->SimulateImeSetComposition( |
2153 utf16_text, underlines, offsets[0], offsets[1]); | 2162 utf16_text, underlines, offsets[0], offsets[1]); |
2154 } | 2163 } |
2155 | 2164 |
2156 ContentDecryptorDelegate* | 2165 ContentDecryptorDelegate* |
2157 PepperPluginInstanceImpl::GetContentDecryptorDelegate() { | 2166 PepperPluginInstanceImpl::GetContentDecryptorDelegate() { |
2158 if (content_decryptor_delegate_) | 2167 if (content_decryptor_delegate_) |
2159 return content_decryptor_delegate_.get(); | 2168 return content_decryptor_delegate_.get(); |
2160 | 2169 |
2161 const PPP_ContentDecryptor_Private* plugin_decryption_interface = | 2170 const PPP_ContentDecryptor_Private* plugin_decryption_interface = |
2162 static_cast<const PPP_ContentDecryptor_Private*>( | 2171 static_cast<const PPP_ContentDecryptor_Private*>( |
2163 module_->GetPluginInterface( | 2172 module_->GetPluginInterface(PPP_CONTENTDECRYPTOR_PRIVATE_INTERFACE)); |
2164 PPP_CONTENTDECRYPTOR_PRIVATE_INTERFACE)); | |
2165 if (!plugin_decryption_interface) | 2173 if (!plugin_decryption_interface) |
2166 return NULL; | 2174 return NULL; |
2167 | 2175 |
2168 content_decryptor_delegate_.reset( | 2176 content_decryptor_delegate_.reset( |
2169 new ContentDecryptorDelegate(pp_instance_, plugin_decryption_interface)); | 2177 new ContentDecryptorDelegate(pp_instance_, plugin_decryption_interface)); |
2170 return content_decryptor_delegate_.get(); | 2178 return content_decryptor_delegate_.get(); |
2171 } | 2179 } |
2172 | 2180 |
2173 PP_Bool PepperPluginInstanceImpl::BindGraphics(PP_Instance instance, | 2181 PP_Bool PepperPluginInstanceImpl::BindGraphics(PP_Instance instance, |
2174 PP_Resource device) { | 2182 PP_Resource device) { |
(...skipping 27 matching lines...) Expand all Loading... | |
2202 RendererPpapiHost::GetForPPInstance(instance)->GetPpapiHost(); | 2210 RendererPpapiHost::GetForPPInstance(instance)->GetPpapiHost(); |
2203 ppapi::host::ResourceHost* host = ppapi_host->GetResourceHost(device); | 2211 ppapi::host::ResourceHost* host = ppapi_host->GetResourceHost(device); |
2204 PepperGraphics2DHost* graphics_2d = NULL; | 2212 PepperGraphics2DHost* graphics_2d = NULL; |
2205 if (host) { | 2213 if (host) { |
2206 if (host->IsGraphics2DHost()) | 2214 if (host->IsGraphics2DHost()) |
2207 graphics_2d = static_cast<PepperGraphics2DHost*>(host); | 2215 graphics_2d = static_cast<PepperGraphics2DHost*>(host); |
2208 DLOG_IF(ERROR, !graphics_2d) << "Resource is not PepperGraphics2DHost."; | 2216 DLOG_IF(ERROR, !graphics_2d) << "Resource is not PepperGraphics2DHost."; |
2209 } | 2217 } |
2210 | 2218 |
2211 EnterResourceNoLock<PPB_Graphics3D_API> enter_3d(device, false); | 2219 EnterResourceNoLock<PPB_Graphics3D_API> enter_3d(device, false); |
2212 PPB_Graphics3D_Impl* graphics_3d = enter_3d.succeeded() ? | 2220 PPB_Graphics3D_Impl* graphics_3d = |
2213 static_cast<PPB_Graphics3D_Impl*>(enter_3d.object()) : NULL; | 2221 enter_3d.succeeded() |
2222 ? static_cast<PPB_Graphics3D_Impl*>(enter_3d.object()) | |
2223 : NULL; | |
2214 | 2224 |
2215 if (graphics_2d) { | 2225 if (graphics_2d) { |
2216 if (graphics_2d->BindToInstance(this)) { | 2226 if (graphics_2d->BindToInstance(this)) { |
2217 bound_graphics_2d_platform_ = graphics_2d; | 2227 bound_graphics_2d_platform_ = graphics_2d; |
2218 UpdateLayer(); | 2228 UpdateLayer(); |
2219 return PP_TRUE; | 2229 return PP_TRUE; |
2220 } | 2230 } |
2221 } else if (graphics_3d) { | 2231 } else if (graphics_3d) { |
2222 // Make sure graphics can only be bound to the instance it is | 2232 // Make sure graphics can only be bound to the instance it is |
2223 // associated with. | 2233 // associated with. |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2287 WebFrame* frame = container_->element().document().frame(); | 2297 WebFrame* frame = container_->element().document().frame(); |
2288 if (!frame) { | 2298 if (!frame) { |
2289 try_catch.SetException("No frame to execute script in."); | 2299 try_catch.SetException("No frame to execute script in."); |
2290 return PP_MakeUndefined(); | 2300 return PP_MakeUndefined(); |
2291 } | 2301 } |
2292 | 2302 |
2293 NPVariant result; | 2303 NPVariant result; |
2294 bool ok = false; | 2304 bool ok = false; |
2295 if (IsProcessingUserGesture()) { | 2305 if (IsProcessingUserGesture()) { |
2296 blink::WebScopedUserGesture user_gesture(CurrentUserGestureToken()); | 2306 blink::WebScopedUserGesture user_gesture(CurrentUserGestureToken()); |
2297 ok = WebBindings::evaluate(NULL, frame->windowObject(), &np_script, | 2307 ok = |
2298 &result); | 2308 WebBindings::evaluate(NULL, frame->windowObject(), &np_script, &result); |
2299 } else { | 2309 } else { |
2300 ok = WebBindings::evaluate(NULL, frame->windowObject(), &np_script, | 2310 ok = |
2301 &result); | 2311 WebBindings::evaluate(NULL, frame->windowObject(), &np_script, &result); |
2302 } | 2312 } |
2303 if (!ok) { | 2313 if (!ok) { |
2304 // TryCatch doesn't catch the exceptions properly. Since this is only for | 2314 // TryCatch doesn't catch the exceptions properly. Since this is only for |
2305 // a trusted API, just set to a general exception message. | 2315 // a trusted API, just set to a general exception message. |
2306 try_catch.SetException("Exception caught"); | 2316 try_catch.SetException("Exception caught"); |
2307 WebBindings::releaseVariantValue(&result); | 2317 WebBindings::releaseVariantValue(&result); |
2308 return PP_MakeUndefined(); | 2318 return PP_MakeUndefined(); |
2309 } | 2319 } |
2310 | 2320 |
2311 PP_Var ret = NPVariantToPPVar(this, &result); | 2321 PP_Var ret = NPVariantToPPVar(this, &result); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2392 request_id); | 2402 request_id); |
2393 } | 2403 } |
2394 | 2404 |
2395 void PepperPluginInstanceImpl::DecoderResetDone( | 2405 void PepperPluginInstanceImpl::DecoderResetDone( |
2396 PP_Instance instance, | 2406 PP_Instance instance, |
2397 PP_DecryptorStreamType decoder_type, | 2407 PP_DecryptorStreamType decoder_type, |
2398 uint32_t request_id) { | 2408 uint32_t request_id) { |
2399 content_decryptor_delegate_->DecoderResetDone(decoder_type, request_id); | 2409 content_decryptor_delegate_->DecoderResetDone(decoder_type, request_id); |
2400 } | 2410 } |
2401 | 2411 |
2402 | |
2403 void PepperPluginInstanceImpl::DeliverFrame( | 2412 void PepperPluginInstanceImpl::DeliverFrame( |
2404 PP_Instance instance, | 2413 PP_Instance instance, |
2405 PP_Resource decrypted_frame, | 2414 PP_Resource decrypted_frame, |
2406 const PP_DecryptedFrameInfo* frame_info) { | 2415 const PP_DecryptedFrameInfo* frame_info) { |
2407 content_decryptor_delegate_->DeliverFrame(decrypted_frame, frame_info); | 2416 content_decryptor_delegate_->DeliverFrame(decrypted_frame, frame_info); |
2408 } | 2417 } |
2409 | 2418 |
2410 void PepperPluginInstanceImpl::DeliverSamples( | 2419 void PepperPluginInstanceImpl::DeliverSamples( |
2411 PP_Instance instance, | 2420 PP_Instance instance, |
2412 PP_Resource audio_frames, | 2421 PP_Resource audio_frames, |
2413 const PP_DecryptedSampleInfo* sample_info) { | 2422 const PP_DecryptedSampleInfo* sample_info) { |
2414 content_decryptor_delegate_->DeliverSamples(audio_frames, sample_info); | 2423 content_decryptor_delegate_->DeliverSamples(audio_frames, sample_info); |
2415 } | 2424 } |
2416 | 2425 |
2417 void PepperPluginInstanceImpl::SetPluginToHandleFindRequests( | 2426 void PepperPluginInstanceImpl::SetPluginToHandleFindRequests( |
2418 PP_Instance instance) { | 2427 PP_Instance instance) { |
2419 if (!LoadFindInterface()) | 2428 if (!LoadFindInterface()) |
2420 return; | 2429 return; |
2421 bool is_main_frame = render_frame_ && | 2430 bool is_main_frame = |
2431 render_frame_ && | |
2422 render_frame_->GetRenderView()->GetMainRenderFrame() == render_frame_; | 2432 render_frame_->GetRenderView()->GetMainRenderFrame() == render_frame_; |
2423 if (!is_main_frame) | 2433 if (!is_main_frame) |
2424 return; | 2434 return; |
2425 render_frame_->render_view()->set_plugin_find_handler(this); | 2435 render_frame_->render_view()->set_plugin_find_handler(this); |
2426 } | 2436 } |
2427 | 2437 |
2428 void PepperPluginInstanceImpl::NumberOfFindResultsChanged( | 2438 void PepperPluginInstanceImpl::NumberOfFindResultsChanged( |
2429 PP_Instance instance, | 2439 PP_Instance instance, |
2430 int32_t total, | 2440 int32_t total, |
2431 PP_Bool final_result) { | 2441 PP_Bool final_result) { |
(...skipping 18 matching lines...) Expand all Loading... | |
2450 uint32_t count) { | 2460 uint32_t count) { |
2451 if (!render_frame_ || !render_frame_->GetWebFrame()) | 2461 if (!render_frame_ || !render_frame_->GetWebFrame()) |
2452 return; | 2462 return; |
2453 | 2463 |
2454 blink::WebVector<blink::WebRect> tickmarks_converted( | 2464 blink::WebVector<blink::WebRect> tickmarks_converted( |
2455 static_cast<size_t>(count)); | 2465 static_cast<size_t>(count)); |
2456 for (uint32 i = 0; i < count; ++i) { | 2466 for (uint32 i = 0; i < count; ++i) { |
2457 tickmarks_converted[i] = blink::WebRect(tickmarks[i].point.x, | 2467 tickmarks_converted[i] = blink::WebRect(tickmarks[i].point.x, |
2458 tickmarks[i].point.y, | 2468 tickmarks[i].point.y, |
2459 tickmarks[i].size.width, | 2469 tickmarks[i].size.width, |
2460 tickmarks[i].size.height);; | 2470 tickmarks[i].size.height); |
2471 ; | |
2461 } | 2472 } |
2462 blink::WebFrame* frame = render_frame_->GetWebFrame(); | 2473 blink::WebFrame* frame = render_frame_->GetWebFrame(); |
2463 frame->setTickmarks(tickmarks_converted); | 2474 frame->setTickmarks(tickmarks_converted); |
2464 } | 2475 } |
2465 | 2476 |
2466 PP_Bool PepperPluginInstanceImpl::IsFullscreen(PP_Instance instance) { | 2477 PP_Bool PepperPluginInstanceImpl::IsFullscreen(PP_Instance instance) { |
2467 return PP_FromBool(view_data_.is_fullscreen); | 2478 return PP_FromBool(view_data_.is_fullscreen); |
2468 } | 2479 } |
2469 | 2480 |
2470 PP_Bool PepperPluginInstanceImpl::SetFullscreen(PP_Instance instance, | 2481 PP_Bool PepperPluginInstanceImpl::SetFullscreen(PP_Instance instance, |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2554 double minimum_factor, | 2565 double minimum_factor, |
2555 double maximum_factor) { | 2566 double maximum_factor) { |
2556 if (!render_frame_) | 2567 if (!render_frame_) |
2557 return; | 2568 return; |
2558 if (minimum_factor > maximum_factor) { | 2569 if (minimum_factor > maximum_factor) { |
2559 NOTREACHED(); | 2570 NOTREACHED(); |
2560 return; | 2571 return; |
2561 } | 2572 } |
2562 double minimum_level = ZoomFactorToZoomLevel(minimum_factor); | 2573 double minimum_level = ZoomFactorToZoomLevel(minimum_factor); |
2563 double maximum_level = ZoomFactorToZoomLevel(maximum_factor); | 2574 double maximum_level = ZoomFactorToZoomLevel(maximum_factor); |
2564 render_frame_->render_view()->webview()->zoomLimitsChanged( | 2575 render_frame_->render_view()->webview()->zoomLimitsChanged(minimum_level, |
2565 minimum_level, maximum_level); | 2576 maximum_level); |
2566 } | 2577 } |
2567 | 2578 |
2568 void PepperPluginInstanceImpl::PostMessage(PP_Instance instance, | 2579 void PepperPluginInstanceImpl::PostMessage(PP_Instance instance, |
2569 PP_Var message) { | 2580 PP_Var message) { |
2570 message_channel_->PostMessageToJavaScript(message); | 2581 message_channel_->PostMessageToJavaScript(message); |
2571 } | 2582 } |
2572 | 2583 |
2573 PP_Bool PepperPluginInstanceImpl::SetCursor(PP_Instance instance, | 2584 PP_Bool PepperPluginInstanceImpl::SetCursor(PP_Instance instance, |
2574 PP_MouseCursor_Type type, | 2585 PP_MouseCursor_Type type, |
2575 PP_Resource image, | 2586 PP_Resource image, |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2702 PP_Instance instance, | 2713 PP_Instance instance, |
2703 PP_Var relative, | 2714 PP_Var relative, |
2704 PP_URLComponents_Dev* components) { | 2715 PP_URLComponents_Dev* components) { |
2705 StringVar* relative_string = StringVar::FromPPVar(relative); | 2716 StringVar* relative_string = StringVar::FromPPVar(relative); |
2706 if (!relative_string) | 2717 if (!relative_string) |
2707 return PP_MakeNull(); | 2718 return PP_MakeNull(); |
2708 | 2719 |
2709 WebElement plugin_element = container()->element(); | 2720 WebElement plugin_element = container()->element(); |
2710 GURL document_url = plugin_element.document().baseURL(); | 2721 GURL document_url = plugin_element.document().baseURL(); |
2711 return ppapi::PPB_URLUtil_Shared::GenerateURLReturn( | 2722 return ppapi::PPB_URLUtil_Shared::GenerateURLReturn( |
2712 document_url.Resolve(relative_string->value()), | 2723 document_url.Resolve(relative_string->value()), components); |
2713 components); | |
2714 } | 2724 } |
2715 | 2725 |
2716 PP_Bool PepperPluginInstanceImpl::DocumentCanRequest(PP_Instance instance, | 2726 PP_Bool PepperPluginInstanceImpl::DocumentCanRequest(PP_Instance instance, |
2717 PP_Var url) { | 2727 PP_Var url) { |
2718 StringVar* url_string = StringVar::FromPPVar(url); | 2728 StringVar* url_string = StringVar::FromPPVar(url); |
2719 if (!url_string) | 2729 if (!url_string) |
2720 return PP_FALSE; | 2730 return PP_FALSE; |
2721 | 2731 |
2722 blink::WebSecurityOrigin security_origin; | 2732 blink::WebSecurityOrigin security_origin; |
2723 if (!SecurityOriginForInstance(instance, &security_origin)) | 2733 if (!SecurityOriginForInstance(instance, &security_origin)) |
(...skipping 24 matching lines...) Expand all Loading... | |
2748 PP_Instance instance, | 2758 PP_Instance instance, |
2749 PP_URLComponents_Dev* components) { | 2759 PP_URLComponents_Dev* components) { |
2750 blink::WebDocument document = container()->element().document(); | 2760 blink::WebDocument document = container()->element().document(); |
2751 return ppapi::PPB_URLUtil_Shared::GenerateURLReturn(document.url(), | 2761 return ppapi::PPB_URLUtil_Shared::GenerateURLReturn(document.url(), |
2752 components); | 2762 components); |
2753 } | 2763 } |
2754 | 2764 |
2755 PP_Var PepperPluginInstanceImpl::GetPluginInstanceURL( | 2765 PP_Var PepperPluginInstanceImpl::GetPluginInstanceURL( |
2756 PP_Instance instance, | 2766 PP_Instance instance, |
2757 PP_URLComponents_Dev* components) { | 2767 PP_URLComponents_Dev* components) { |
2758 return ppapi::PPB_URLUtil_Shared::GenerateURLReturn(plugin_url_, | 2768 return ppapi::PPB_URLUtil_Shared::GenerateURLReturn(plugin_url_, components); |
2759 components); | |
2760 } | 2769 } |
2761 | 2770 |
2762 PP_Var PepperPluginInstanceImpl::GetPluginReferrerURL( | 2771 PP_Var PepperPluginInstanceImpl::GetPluginReferrerURL( |
2763 PP_Instance instance, | 2772 PP_Instance instance, |
2764 PP_URLComponents_Dev* components) { | 2773 PP_URLComponents_Dev* components) { |
2765 blink::WebDocument document = container()->element().document(); | 2774 blink::WebDocument document = container()->element().document(); |
2766 if (!full_frame_) | 2775 if (!full_frame_) |
2767 return ppapi::PPB_URLUtil_Shared::GenerateURLReturn(document.url(), | 2776 return ppapi::PPB_URLUtil_Shared::GenerateURLReturn(document.url(), |
2768 components); | 2777 components); |
2769 WebFrame* frame = document.frame(); | 2778 WebFrame* frame = document.frame(); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2812 checked_for_plugin_messaging_interface_ = false; | 2821 checked_for_plugin_messaging_interface_ = false; |
2813 plugin_mouse_lock_interface_ = NULL; | 2822 plugin_mouse_lock_interface_ = NULL; |
2814 plugin_pdf_interface_ = NULL; | 2823 plugin_pdf_interface_ = NULL; |
2815 checked_for_plugin_pdf_interface_ = false; | 2824 checked_for_plugin_pdf_interface_ = false; |
2816 plugin_private_interface_ = NULL; | 2825 plugin_private_interface_ = NULL; |
2817 plugin_selection_interface_ = NULL; | 2826 plugin_selection_interface_ = NULL; |
2818 plugin_textinput_interface_ = NULL; | 2827 plugin_textinput_interface_ = NULL; |
2819 plugin_zoom_interface_ = NULL; | 2828 plugin_zoom_interface_ = NULL; |
2820 | 2829 |
2821 // Re-send the DidCreate event via the proxy. | 2830 // Re-send the DidCreate event via the proxy. |
2822 scoped_ptr<const char*[]> argn_array(StringVectorToArgArray(argn_)); | 2831 scoped_ptr<const char * []> argn_array(StringVectorToArgArray(argn_)); |
2823 scoped_ptr<const char*[]> argv_array(StringVectorToArgArray(argv_)); | 2832 scoped_ptr<const char * []> argv_array(StringVectorToArgArray(argv_)); |
bbudge
2014/04/07 17:02:17
This is kind of weird.
| |
2824 if (!instance_interface_->DidCreate(pp_instance(), argn_.size(), | 2833 if (!instance_interface_->DidCreate( |
2825 argn_array.get(), argv_array.get())) | 2834 pp_instance(), argn_.size(), argn_array.get(), argv_array.get())) |
2826 return PP_EXTERNAL_PLUGIN_ERROR_INSTANCE; | 2835 return PP_EXTERNAL_PLUGIN_ERROR_INSTANCE; |
2827 message_channel_->StopQueueingJavaScriptMessages(); | 2836 message_channel_->StopQueueingJavaScriptMessages(); |
2828 | 2837 |
2829 // Clear sent_initial_did_change_view_ and cancel any pending DidChangeView | 2838 // Clear sent_initial_did_change_view_ and cancel any pending DidChangeView |
2830 // event. This way, SendDidChangeView will send the "current" view | 2839 // event. This way, SendDidChangeView will send the "current" view |
2831 // immediately (before other events like HandleDocumentLoad). | 2840 // immediately (before other events like HandleDocumentLoad). |
2832 sent_initial_did_change_view_ = false; | 2841 sent_initial_did_change_view_ = false; |
2833 view_change_weak_ptr_factory_.InvalidateWeakPtrs(); | 2842 view_change_weak_ptr_factory_.InvalidateWeakPtrs(); |
2834 SendDidChangeView(); | 2843 SendDidChangeView(); |
2835 | 2844 |
2836 DCHECK(external_document_load_); | 2845 DCHECK(external_document_load_); |
2837 external_document_load_ = false; | 2846 external_document_load_ = false; |
2838 if (!external_document_response_.isNull()) { | 2847 if (!external_document_response_.isNull()) { |
2839 document_loader_ = NULL; | 2848 document_loader_ = NULL; |
2840 // Pass the response to the new proxy. | 2849 // Pass the response to the new proxy. |
2841 HandleDocumentLoad(external_document_response_); | 2850 HandleDocumentLoad(external_document_response_); |
2842 external_document_response_ = blink::WebURLResponse(); | 2851 external_document_response_ = blink::WebURLResponse(); |
2843 // Replay any document load events we've received to the real loader. | 2852 // Replay any document load events we've received to the real loader. |
2844 external_document_loader_->ReplayReceivedData(document_loader_); | 2853 external_document_loader_->ReplayReceivedData(document_loader_); |
2845 external_document_loader_.reset(NULL); | 2854 external_document_loader_.reset(NULL); |
2846 } | 2855 } |
2847 | 2856 |
2848 return PP_EXTERNAL_PLUGIN_OK; | 2857 return PP_EXTERNAL_PLUGIN_OK; |
2849 } | 2858 } |
2850 | 2859 |
2851 bool PepperPluginInstanceImpl::IsValidInstanceOf(PluginModule* module) { | 2860 bool PepperPluginInstanceImpl::IsValidInstanceOf(PluginModule* module) { |
2852 DCHECK(module); | 2861 DCHECK(module); |
2853 return module == module_.get() || | 2862 return module == module_.get() || module == original_module_.get(); |
2854 module == original_module_.get(); | |
2855 } | 2863 } |
2856 | 2864 |
2857 NPP PepperPluginInstanceImpl::instanceNPP() { | 2865 NPP PepperPluginInstanceImpl::instanceNPP() { return npp_.get(); } |
2858 return npp_.get(); | |
2859 } | |
2860 | 2866 |
2861 PepperPluginInstance* PepperPluginInstance::Get(PP_Instance instance_id) { | 2867 PepperPluginInstance* PepperPluginInstance::Get(PP_Instance instance_id) { |
2862 return HostGlobals::Get()->GetInstance(instance_id); | 2868 return HostGlobals::Get()->GetInstance(instance_id); |
2863 } | 2869 } |
2864 | 2870 |
2865 RenderView* PepperPluginInstanceImpl::GetRenderView() { | 2871 RenderView* PepperPluginInstanceImpl::GetRenderView() { |
2866 return render_frame_ ? render_frame_->render_view() : NULL; | 2872 return render_frame_ ? render_frame_->render_view() : NULL; |
2867 } | 2873 } |
2868 | 2874 |
2869 blink::WebPluginContainer* PepperPluginInstanceImpl::GetContainer() { | 2875 blink::WebPluginContainer* PepperPluginInstanceImpl::GetContainer() { |
2870 return container_; | 2876 return container_; |
2871 } | 2877 } |
2872 | 2878 |
2873 v8::Isolate* PepperPluginInstanceImpl::GetIsolate() const { | 2879 v8::Isolate* PepperPluginInstanceImpl::GetIsolate() const { return isolate_; } |
2874 return isolate_; | |
2875 } | |
2876 | 2880 |
2877 ppapi::VarTracker* PepperPluginInstanceImpl::GetVarTracker() { | 2881 ppapi::VarTracker* PepperPluginInstanceImpl::GetVarTracker() { |
2878 return HostGlobals::Get()->GetVarTracker(); | 2882 return HostGlobals::Get()->GetVarTracker(); |
2879 } | 2883 } |
2880 | 2884 |
2881 const GURL& PepperPluginInstanceImpl::GetPluginURL() { | 2885 const GURL& PepperPluginInstanceImpl::GetPluginURL() { return plugin_url_; } |
2882 return plugin_url_; | |
2883 } | |
2884 | 2886 |
2885 base::FilePath PepperPluginInstanceImpl::GetModulePath() { | 2887 base::FilePath PepperPluginInstanceImpl::GetModulePath() { |
2886 return module_->path(); | 2888 return module_->path(); |
2887 } | 2889 } |
2888 | 2890 |
2889 PP_Resource PepperPluginInstanceImpl::CreateImage(gfx::ImageSkia* source_image, | 2891 PP_Resource PepperPluginInstanceImpl::CreateImage(gfx::ImageSkia* source_image, |
2890 float scale) { | 2892 float scale) { |
2891 gfx::ImageSkiaRep image_skia_rep = source_image->GetRepresentation(scale); | 2893 gfx::ImageSkiaRep image_skia_rep = source_image->GetRepresentation(scale); |
2892 | 2894 |
2893 if (image_skia_rep.is_null() || image_skia_rep.scale() != scale) | 2895 if (image_skia_rep.is_null() || image_skia_rep.scale() != scale) |
2894 return 0; | 2896 return 0; |
2895 | 2897 |
2896 scoped_refptr<PPB_ImageData_Impl> image_data(new PPB_ImageData_Impl( | 2898 scoped_refptr<PPB_ImageData_Impl> image_data( |
2897 pp_instance(), | 2899 new PPB_ImageData_Impl(pp_instance(), PPB_ImageData_Impl::PLATFORM)); |
2898 PPB_ImageData_Impl::PLATFORM)); | 2900 if (!image_data->Init(PPB_ImageData_Impl::GetNativeImageDataFormat(), |
2899 if (!image_data->Init( | 2901 image_skia_rep.pixel_width(), |
2900 PPB_ImageData_Impl::GetNativeImageDataFormat(), | 2902 image_skia_rep.pixel_height(), |
2901 image_skia_rep.pixel_width(), | 2903 false)) { |
2902 image_skia_rep.pixel_height(), | |
2903 false)) { | |
2904 return 0; | 2904 return 0; |
2905 } | 2905 } |
2906 | 2906 |
2907 ImageDataAutoMapper mapper(image_data.get()); | 2907 ImageDataAutoMapper mapper(image_data.get()); |
2908 if (!mapper.is_valid()) | 2908 if (!mapper.is_valid()) |
2909 return 0; | 2909 return 0; |
2910 | 2910 |
2911 skia::PlatformCanvas* canvas = image_data->GetPlatformCanvas(); | 2911 skia::PlatformCanvas* canvas = image_data->GetPlatformCanvas(); |
2912 // Note: Do not SkBitmap::copyTo the canvas bitmap directly because it will | 2912 // Note: Do not SkBitmap::copyTo the canvas bitmap directly because it will |
2913 // ignore the allocated pixels in shared memory and re-allocate a new buffer. | 2913 // ignore the allocated pixels in shared memory and re-allocate a new buffer. |
2914 canvas->writePixels(image_skia_rep.sk_bitmap(), 0, 0); | 2914 canvas->writePixels(image_skia_rep.sk_bitmap(), 0, 0); |
2915 | 2915 |
2916 return image_data->GetReference(); | 2916 return image_data->GetReference(); |
2917 } | 2917 } |
2918 | 2918 |
2919 PP_ExternalPluginResult PepperPluginInstanceImpl::SwitchToOutOfProcessProxy( | 2919 PP_ExternalPluginResult PepperPluginInstanceImpl::SwitchToOutOfProcessProxy( |
2920 const base::FilePath& file_path, | 2920 const base::FilePath& file_path, |
2921 ppapi::PpapiPermissions permissions, | 2921 ppapi::PpapiPermissions permissions, |
2922 const IPC::ChannelHandle& channel_handle, | 2922 const IPC::ChannelHandle& channel_handle, |
2923 base::ProcessId plugin_pid, | 2923 base::ProcessId plugin_pid, |
2924 int plugin_child_id) { | 2924 int plugin_child_id) { |
2925 // Create a new module for each instance of the external plugin that is using | 2925 // Create a new module for each instance of the external plugin that is using |
2926 // the IPC based out-of-process proxy. We can't use the existing module, | 2926 // the IPC based out-of-process proxy. We can't use the existing module, |
2927 // because it is configured for the in-process plugin, and we must keep it | 2927 // because it is configured for the in-process plugin, and we must keep it |
2928 // that way to allow the page to create other instances. | 2928 // that way to allow the page to create other instances. |
2929 scoped_refptr<PluginModule> external_plugin_module( | 2929 scoped_refptr<PluginModule> external_plugin_module( |
2930 module_->CreateModuleForExternalPluginInstance()); | 2930 module_->CreateModuleForExternalPluginInstance()); |
2931 | 2931 |
2932 RendererPpapiHostImpl* renderer_ppapi_host = | 2932 RendererPpapiHostImpl* renderer_ppapi_host = |
2933 external_plugin_module->CreateOutOfProcessModule( | 2933 external_plugin_module->CreateOutOfProcessModule(render_frame_, |
2934 render_frame_, | 2934 file_path, |
2935 file_path, | 2935 permissions, |
2936 permissions, | 2936 channel_handle, |
2937 channel_handle, | 2937 plugin_pid, |
2938 plugin_pid, | 2938 plugin_child_id, |
2939 plugin_child_id, | 2939 true); |
2940 true); | |
2941 if (!renderer_ppapi_host) { | 2940 if (!renderer_ppapi_host) { |
2942 DLOG(ERROR) << "CreateExternalPluginModule() failed"; | 2941 DLOG(ERROR) << "CreateExternalPluginModule() failed"; |
2943 return PP_EXTERNAL_PLUGIN_ERROR_MODULE; | 2942 return PP_EXTERNAL_PLUGIN_ERROR_MODULE; |
2944 } | 2943 } |
2945 | 2944 |
2946 // Finally, switch the instance to the proxy. | 2945 // Finally, switch the instance to the proxy. |
2947 return external_plugin_module->InitAsProxiedExternalPlugin(this); | 2946 return external_plugin_module->InitAsProxiedExternalPlugin(this); |
2948 } | 2947 } |
2949 | 2948 |
2950 void PepperPluginInstanceImpl::SetAlwaysOnTop(bool on_top) { | 2949 void PepperPluginInstanceImpl::SetAlwaysOnTop(bool on_top) { |
(...skipping 21 matching lines...) Expand all Loading... | |
2972 scoped_refptr<PepperPluginInstanceImpl> ref(this); | 2971 scoped_refptr<PepperPluginInstanceImpl> ref(this); |
2973 | 2972 |
2974 // We check whether we are trying to switch to the state we're already going | 2973 // We check whether we are trying to switch to the state we're already going |
2975 // to (i.e. if we're already switching to fullscreen but the fullscreen | 2974 // to (i.e. if we're already switching to fullscreen but the fullscreen |
2976 // container isn't ready yet, don't do anything more). | 2975 // container isn't ready yet, don't do anything more). |
2977 if (fullscreen == FlashIsFullscreenOrPending()) | 2976 if (fullscreen == FlashIsFullscreenOrPending()) |
2978 return true; | 2977 return true; |
2979 | 2978 |
2980 if (!render_frame_) | 2979 if (!render_frame_) |
2981 return false; | 2980 return false; |
2982 if (fullscreen && | 2981 if (fullscreen && !render_frame_->render_view() |
2983 !render_frame_->render_view()->renderer_preferences(). | 2982 ->renderer_preferences() |
2984 plugin_fullscreen_allowed) | 2983 .plugin_fullscreen_allowed) |
2985 return false; | 2984 return false; |
2986 | 2985 |
2987 // Unbind current 2D or 3D graphics context. | 2986 // Unbind current 2D or 3D graphics context. |
2988 VLOG(1) << "Setting fullscreen to " << (fullscreen ? "on" : "off"); | 2987 VLOG(1) << "Setting fullscreen to " << (fullscreen ? "on" : "off"); |
2989 if (fullscreen) { | 2988 if (fullscreen) { |
2990 DCHECK(!fullscreen_container_); | 2989 DCHECK(!fullscreen_container_); |
2991 fullscreen_container_ = | 2990 fullscreen_container_ = |
2992 render_frame_->CreatePepperFullscreenContainer(this); | 2991 render_frame_->CreatePepperFullscreenContainer(this); |
2993 UpdateLayer(); | 2992 UpdateLayer(); |
2994 } else { | 2993 } else { |
(...skipping 28 matching lines...) Expand all Loading... | |
3023 return PP_ERROR_FAILED; | 3022 return PP_ERROR_FAILED; |
3024 | 3023 |
3025 WebDocument document = container_->element().document(); | 3024 WebDocument document = container_->element().document(); |
3026 WebFrame* frame = document.frame(); | 3025 WebFrame* frame = document.frame(); |
3027 if (!frame) | 3026 if (!frame) |
3028 return PP_ERROR_FAILED; | 3027 return PP_ERROR_FAILED; |
3029 | 3028 |
3030 ppapi::URLRequestInfoData completed_request = request; | 3029 ppapi::URLRequestInfoData completed_request = request; |
3031 | 3030 |
3032 WebURLRequest web_request; | 3031 WebURLRequest web_request; |
3033 if (!CreateWebURLRequest(pp_instance_, | 3032 if (!CreateWebURLRequest( |
3034 &completed_request, | 3033 pp_instance_, &completed_request, frame, &web_request)) { |
3035 frame, | |
3036 &web_request)) { | |
3037 return PP_ERROR_FAILED; | 3034 return PP_ERROR_FAILED; |
3038 } | 3035 } |
3039 web_request.setFirstPartyForCookies(document.firstPartyForCookies()); | 3036 web_request.setFirstPartyForCookies(document.firstPartyForCookies()); |
3040 web_request.setHasUserGesture(from_user_action); | 3037 web_request.setHasUserGesture(from_user_action); |
3041 | 3038 |
3042 GURL gurl(web_request.url()); | 3039 GURL gurl(web_request.url()); |
3043 if (gurl.SchemeIs("javascript")) { | 3040 if (gurl.SchemeIs("javascript")) { |
3044 // In imitation of the NPAPI implementation, only |target_frame == frame| is | 3041 // In imitation of the NPAPI implementation, only |target_frame == frame| is |
3045 // allowed for security reasons. | 3042 // allowed for security reasons. |
3046 WebFrame* target_frame = | 3043 WebFrame* target_frame = |
3047 frame->view()->findFrameByName(WebString::fromUTF8(target), frame); | 3044 frame->view()->findFrameByName(WebString::fromUTF8(target), frame); |
3048 if (target_frame != frame) | 3045 if (target_frame != frame) |
3049 return PP_ERROR_NOACCESS; | 3046 return PP_ERROR_NOACCESS; |
3050 | 3047 |
3051 // TODO(viettrungluu): NPAPI sends the result back to the plugin -- do we | 3048 // TODO(viettrungluu): NPAPI sends the result back to the plugin -- do we |
3052 // need that? | 3049 // need that? |
3053 WebString result = container_->executeScriptURL(gurl, from_user_action); | 3050 WebString result = container_->executeScriptURL(gurl, from_user_action); |
3054 return result.isNull() ? PP_ERROR_FAILED : PP_OK; | 3051 return result.isNull() ? PP_ERROR_FAILED : PP_OK; |
3055 } | 3052 } |
3056 | 3053 |
3057 // Only GETs and POSTs are supported. | 3054 // Only GETs and POSTs are supported. |
3058 if (web_request.httpMethod() != "GET" && | 3055 if (web_request.httpMethod() != "GET" && web_request.httpMethod() != "POST") |
3059 web_request.httpMethod() != "POST") | |
3060 return PP_ERROR_BADARGUMENT; | 3056 return PP_ERROR_BADARGUMENT; |
3061 | 3057 |
3062 WebString target_str = WebString::fromUTF8(target); | 3058 WebString target_str = WebString::fromUTF8(target); |
3063 container_->loadFrameRequest(web_request, target_str, false, NULL); | 3059 container_->loadFrameRequest(web_request, target_str, false, NULL); |
3064 return PP_OK; | 3060 return PP_OK; |
3065 } | 3061 } |
3066 | 3062 |
3067 int PepperPluginInstanceImpl::MakePendingFileRefRendererHost( | 3063 int PepperPluginInstanceImpl::MakePendingFileRefRendererHost( |
3068 const base::FilePath& path) { | 3064 const base::FilePath& path) { |
3069 RendererPpapiHostImpl* host_impl = module_->renderer_ppapi_host(); | 3065 RendererPpapiHostImpl* host_impl = module_->renderer_ppapi_host(); |
3070 PepperFileRefRendererHost* file_ref_host( | 3066 PepperFileRefRendererHost* file_ref_host( |
3071 new PepperFileRefRendererHost(host_impl, pp_instance(), 0, path)); | 3067 new PepperFileRefRendererHost(host_impl, pp_instance(), 0, path)); |
3072 return host_impl->GetPpapiHost()->AddPendingResourceHost( | 3068 return host_impl->GetPpapiHost()->AddPendingResourceHost( |
3073 scoped_ptr<ppapi::host::ResourceHost>(file_ref_host)); | 3069 scoped_ptr<ppapi::host::ResourceHost>(file_ref_host)); |
3074 } | 3070 } |
3075 | 3071 |
3076 void PepperPluginInstanceImpl::SetEmbedProperty(PP_Var key, | 3072 void PepperPluginInstanceImpl::SetEmbedProperty(PP_Var key, PP_Var value) { |
3077 PP_Var value) { | |
3078 message_channel_->SetReadOnlyProperty(key, value); | 3073 message_channel_->SetReadOnlyProperty(key, value); |
3079 } | 3074 } |
3080 | 3075 |
3081 bool PepperPluginInstanceImpl::CanAccessMainFrame() const { | 3076 bool PepperPluginInstanceImpl::CanAccessMainFrame() const { |
3082 if (!container_) | 3077 if (!container_) |
3083 return false; | 3078 return false; |
3084 blink::WebDocument containing_document = container_->element().document(); | 3079 blink::WebDocument containing_document = container_->element().document(); |
3085 | 3080 |
3086 if (!containing_document.frame() || | 3081 if (!containing_document.frame() || !containing_document.frame()->view() || |
3087 !containing_document.frame()->view() || | |
3088 !containing_document.frame()->view()->mainFrame()) { | 3082 !containing_document.frame()->view()->mainFrame()) { |
3089 return false; | 3083 return false; |
3090 } | 3084 } |
3091 blink::WebDocument main_document = | 3085 blink::WebDocument main_document = |
3092 containing_document.frame()->view()->mainFrame()->document(); | 3086 containing_document.frame()->view()->mainFrame()->document(); |
3093 | 3087 |
3094 return containing_document.securityOrigin().canAccess( | 3088 return containing_document.securityOrigin().canAccess( |
3095 main_document.securityOrigin()); | 3089 main_document.securityOrigin()); |
3096 } | 3090 } |
3097 | 3091 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3143 bool PepperPluginInstanceImpl::IsMouseLocked() { | 3137 bool PepperPluginInstanceImpl::IsMouseLocked() { |
3144 return GetMouseLockDispatcher()->IsMouseLockedTo( | 3138 return GetMouseLockDispatcher()->IsMouseLockedTo( |
3145 GetOrCreateLockTargetAdapter()); | 3139 GetOrCreateLockTargetAdapter()); |
3146 } | 3140 } |
3147 | 3141 |
3148 bool PepperPluginInstanceImpl::LockMouse() { | 3142 bool PepperPluginInstanceImpl::LockMouse() { |
3149 return GetMouseLockDispatcher()->LockMouse(GetOrCreateLockTargetAdapter()); | 3143 return GetMouseLockDispatcher()->LockMouse(GetOrCreateLockTargetAdapter()); |
3150 } | 3144 } |
3151 | 3145 |
3152 MouseLockDispatcher::LockTarget* | 3146 MouseLockDispatcher::LockTarget* |
3153 PepperPluginInstanceImpl::GetOrCreateLockTargetAdapter() { | 3147 PepperPluginInstanceImpl::GetOrCreateLockTargetAdapter() { |
3154 if (!lock_target_.get()) { | 3148 if (!lock_target_.get()) { |
3155 lock_target_.reset(new PluginInstanceLockTarget(this)); | 3149 lock_target_.reset(new PluginInstanceLockTarget(this)); |
3156 } | 3150 } |
3157 return lock_target_.get(); | 3151 return lock_target_.get(); |
3158 } | 3152 } |
3159 | 3153 |
3160 MouseLockDispatcher* PepperPluginInstanceImpl::GetMouseLockDispatcher() { | 3154 MouseLockDispatcher* PepperPluginInstanceImpl::GetMouseLockDispatcher() { |
3161 if (flash_fullscreen_) { | 3155 if (flash_fullscreen_) { |
3162 RenderWidgetFullscreenPepper* container = | 3156 RenderWidgetFullscreenPepper* container = |
3163 static_cast<RenderWidgetFullscreenPepper*>(fullscreen_container_); | 3157 static_cast<RenderWidgetFullscreenPepper*>(fullscreen_container_); |
(...skipping 16 matching lines...) Expand all Loading... | |
3180 int pending_host_id, | 3174 int pending_host_id, |
3181 const ppapi::URLResponseInfoData& data) { | 3175 const ppapi::URLResponseInfoData& data) { |
3182 RendererPpapiHostImpl* host_impl = module_->renderer_ppapi_host(); | 3176 RendererPpapiHostImpl* host_impl = module_->renderer_ppapi_host(); |
3183 | 3177 |
3184 if (host_impl->in_process_router()) { | 3178 if (host_impl->in_process_router()) { |
3185 // Running in-process, we can just create the resource and call the | 3179 // Running in-process, we can just create the resource and call the |
3186 // PPP_Instance function directly. | 3180 // PPP_Instance function directly. |
3187 scoped_refptr<ppapi::proxy::URLLoaderResource> loader_resource( | 3181 scoped_refptr<ppapi::proxy::URLLoaderResource> loader_resource( |
3188 new ppapi::proxy::URLLoaderResource( | 3182 new ppapi::proxy::URLLoaderResource( |
3189 host_impl->in_process_router()->GetPluginConnection(pp_instance()), | 3183 host_impl->in_process_router()->GetPluginConnection(pp_instance()), |
3190 pp_instance(), pending_host_id, data)); | 3184 pp_instance(), |
3185 pending_host_id, | |
3186 data)); | |
3191 | 3187 |
3192 PP_Resource loader_pp_resource = loader_resource->GetReference(); | 3188 PP_Resource loader_pp_resource = loader_resource->GetReference(); |
3193 if (!instance_interface_->HandleDocumentLoad( | 3189 if (!instance_interface_->HandleDocumentLoad(pp_instance(), |
3194 pp_instance(), loader_pp_resource)) | 3190 loader_pp_resource)) |
3195 loader_resource->Close(); | 3191 loader_resource->Close(); |
3196 // We don't pass a ref into the plugin, if it wants one, it will have taken | 3192 // We don't pass a ref into the plugin, if it wants one, it will have taken |
3197 // an additional one. | 3193 // an additional one. |
3198 ppapi::PpapiGlobals::Get()->GetResourceTracker()->ReleaseResource( | 3194 ppapi::PpapiGlobals::Get()->GetResourceTracker()->ReleaseResource( |
3199 loader_pp_resource); | 3195 loader_pp_resource); |
3200 } else { | 3196 } else { |
3201 // Running out-of-process. Initiate an IPC call to notify the plugin | 3197 // Running out-of-process. Initiate an IPC call to notify the plugin |
3202 // process. | 3198 // process. |
3203 ppapi::proxy::HostDispatcher* dispatcher = | 3199 ppapi::proxy::HostDispatcher* dispatcher = |
3204 ppapi::proxy::HostDispatcher::GetForInstance(pp_instance()); | 3200 ppapi::proxy::HostDispatcher::GetForInstance(pp_instance()); |
3205 dispatcher->Send(new PpapiMsg_PPPInstance_HandleDocumentLoad( | 3201 dispatcher->Send(new PpapiMsg_PPPInstance_HandleDocumentLoad( |
3206 ppapi::API_ID_PPP_INSTANCE, pp_instance(), pending_host_id, data)); | 3202 ppapi::API_ID_PPP_INSTANCE, pp_instance(), pending_host_id, data)); |
3207 } | 3203 } |
3208 } | 3204 } |
3209 | 3205 |
3210 } // namespace content | 3206 } // namespace content |
OLD | NEW |