| 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/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" | 
| 10 #include "base/logging.h" | 10 #include "base/logging.h" | 
| 11 #include "base/memory/linked_ptr.h" | 11 #include "base/memory/linked_ptr.h" | 
| 12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" | 
| 13 #include "base/stl_util.h" | 13 #include "base/stl_util.h" | 
| 14 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" | 
| 15 #include "base/strings/utf_offset_string_conversions.h" | 15 #include "base/strings/utf_offset_string_conversions.h" | 
| 16 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" | 
| 17 #include "base/time/time.h" | 17 #include "base/time/time.h" | 
| 18 #include "cc/layers/texture_layer.h" | 18 #include "cc/layers/texture_layer.h" | 
| 19 #include "content/public/common/page_zoom.h" | 19 #include "content/public/common/page_zoom.h" | 
| 20 #include "content/public/renderer/content_renderer_client.h" | 20 #include "content/public/renderer/content_renderer_client.h" | 
| 21 #include "content/renderer/pepper/common.h" | 21 #include "content/renderer/pepper/common.h" | 
| 22 #include "content/renderer/pepper/content_decryptor_delegate.h" | 22 #include "content/renderer/pepper/content_decryptor_delegate.h" | 
| 23 #include "content/renderer/pepper/event_conversion.h" | 23 #include "content/renderer/pepper/event_conversion.h" | 
| 24 #include "content/renderer/pepper/fullscreen_container.h" | 24 #include "content/renderer/pepper/fullscreen_container.h" | 
| 25 #include "content/renderer/pepper/gfx_conversion.h" | 25 #include "content/renderer/pepper/gfx_conversion.h" | 
| 26 #include "content/renderer/pepper/host_globals.h" | 26 #include "content/renderer/pepper/host_globals.h" | 
| 27 #include "content/renderer/pepper/message_channel.h" | 27 #include "content/renderer/pepper/message_channel.h" | 
| 28 #include "content/renderer/pepper/npapi_glue.h" | 28 #include "content/renderer/pepper/npapi_glue.h" | 
| 29 #include "content/renderer/pepper/pepper_graphics_2d_host.h" | 29 #include "content/renderer/pepper/pepper_graphics_2d_host.h" | 
|  | 30 #include "content/renderer/pepper/pepper_helper_impl.h" | 
| 30 #include "content/renderer/pepper/pepper_platform_context_3d.h" | 31 #include "content/renderer/pepper/pepper_platform_context_3d.h" | 
| 31 #include "content/renderer/pepper/pepper_plugin_delegate_impl.h" |  | 
| 32 #include "content/renderer/pepper/plugin_module.h" | 32 #include "content/renderer/pepper/plugin_module.h" | 
| 33 #include "content/renderer/pepper/plugin_object.h" | 33 #include "content/renderer/pepper/plugin_object.h" | 
| 34 #include "content/renderer/pepper/ppb_buffer_impl.h" | 34 #include "content/renderer/pepper/ppb_buffer_impl.h" | 
| 35 #include "content/renderer/pepper/ppb_file_ref_impl.h" | 35 #include "content/renderer/pepper/ppb_file_ref_impl.h" | 
| 36 #include "content/renderer/pepper/ppb_graphics_3d_impl.h" | 36 #include "content/renderer/pepper/ppb_graphics_3d_impl.h" | 
| 37 #include "content/renderer/pepper/ppb_image_data_impl.h" | 37 #include "content/renderer/pepper/ppb_image_data_impl.h" | 
| 38 #include "content/renderer/pepper/ppp_pdf.h" | 38 #include "content/renderer/pepper/ppp_pdf.h" | 
| 39 #include "content/renderer/pepper/renderer_ppapi_host_impl.h" | 39 #include "content/renderer/pepper/renderer_ppapi_host_impl.h" | 
| 40 #include "content/renderer/pepper/url_request_info_util.h" | 40 #include "content/renderer/pepper/url_request_info_util.h" | 
| 41 #include "content/renderer/render_thread_impl.h" | 41 #include "content/renderer/render_thread_impl.h" | 
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 345 | 345 | 
| 346  private: | 346  private: | 
| 347   PepperPluginInstanceImpl* plugin_; | 347   PepperPluginInstanceImpl* plugin_; | 
| 348 }; | 348 }; | 
| 349 | 349 | 
| 350 | 350 | 
| 351 }  // namespace | 351 }  // namespace | 
| 352 | 352 | 
| 353 // static | 353 // static | 
| 354 PepperPluginInstanceImpl* PepperPluginInstanceImpl::Create( | 354 PepperPluginInstanceImpl* PepperPluginInstanceImpl::Create( | 
| 355     PepperPluginDelegateImpl* delegate, | 355     PepperHelperImpl* helper, | 
| 356     RenderViewImpl* render_view, | 356     RenderViewImpl* render_view, | 
| 357     PluginModule* module, | 357     PluginModule* module, | 
| 358     WebPluginContainer* container, | 358     WebPluginContainer* container, | 
| 359     const GURL& plugin_url) { | 359     const GURL& plugin_url) { | 
| 360   base::Callback<const void*(const char*)> get_plugin_interface_func = | 360   base::Callback<const void*(const char*)> get_plugin_interface_func = | 
| 361       base::Bind(&PluginModule::GetPluginInterface, module); | 361       base::Bind(&PluginModule::GetPluginInterface, module); | 
| 362   PPP_Instance_Combined* ppp_instance_combined = | 362   PPP_Instance_Combined* ppp_instance_combined = | 
| 363       PPP_Instance_Combined::Create(get_plugin_interface_func); | 363       PPP_Instance_Combined::Create(get_plugin_interface_func); | 
| 364   if (!ppp_instance_combined) | 364   if (!ppp_instance_combined) | 
| 365     return NULL; | 365     return NULL; | 
| 366   return new PepperPluginInstanceImpl(delegate, render_view, module, | 366   return new PepperPluginInstanceImpl(helper, render_view, module, | 
| 367                                       ppp_instance_combined, container, | 367                                       ppp_instance_combined, container, | 
| 368                                       plugin_url); | 368                                       plugin_url); | 
| 369 } | 369 } | 
| 370 | 370 | 
| 371 PepperPluginInstanceImpl::NaClDocumentLoader::NaClDocumentLoader() | 371 PepperPluginInstanceImpl::NaClDocumentLoader::NaClDocumentLoader() | 
| 372     : finished_loading_(false) { | 372     : finished_loading_(false) { | 
| 373 } | 373 } | 
| 374 | 374 | 
| 375 PepperPluginInstanceImpl::NaClDocumentLoader::~NaClDocumentLoader(){ | 375 PepperPluginInstanceImpl::NaClDocumentLoader::~NaClDocumentLoader(){ | 
| 376 } | 376 } | 
| (...skipping 29 matching lines...) Expand all  Loading... | 
| 406   finished_loading_ = true; | 406   finished_loading_ = true; | 
| 407 } | 407 } | 
| 408 | 408 | 
| 409 void PepperPluginInstanceImpl::NaClDocumentLoader::didFail( | 409 void PepperPluginInstanceImpl::NaClDocumentLoader::didFail( | 
| 410     WebURLLoader* loader, | 410     WebURLLoader* loader, | 
| 411     const WebURLError& error) { | 411     const WebURLError& error) { | 
| 412   DCHECK(!error_.get()); | 412   DCHECK(!error_.get()); | 
| 413   error_.reset(new WebURLError(error)); | 413   error_.reset(new WebURLError(error)); | 
| 414 } | 414 } | 
| 415 | 415 | 
| 416 PepperPluginInstanceImpl::GamepadImpl::GamepadImpl( | 416 PepperPluginInstanceImpl::GamepadImpl::GamepadImpl(PepperHelperImpl* helper) | 
| 417     PepperPluginDelegateImpl* delegate) |  | 
| 418     : Resource(::ppapi::Resource::Untracked()), | 417     : Resource(::ppapi::Resource::Untracked()), | 
| 419       delegate_(delegate) { | 418       helper_(helper) { | 
| 420 } | 419 } | 
| 421 | 420 | 
| 422 PepperPluginInstanceImpl::GamepadImpl::~GamepadImpl() { | 421 PepperPluginInstanceImpl::GamepadImpl::~GamepadImpl() { | 
| 423 } | 422 } | 
| 424 | 423 | 
| 425 PPB_Gamepad_API* PepperPluginInstanceImpl::GamepadImpl::AsPPB_Gamepad_API() { | 424 PPB_Gamepad_API* PepperPluginInstanceImpl::GamepadImpl::AsPPB_Gamepad_API() { | 
| 426   return this; | 425   return this; | 
| 427 } | 426 } | 
| 428 | 427 | 
| 429 void PepperPluginInstanceImpl::GamepadImpl::Sample( | 428 void PepperPluginInstanceImpl::GamepadImpl::Sample( | 
| 430     PP_Instance instance, | 429     PP_Instance instance, | 
| 431     PP_GamepadsSampleData* data) { | 430     PP_GamepadsSampleData* data) { | 
| 432   WebKit::WebGamepads webkit_data; | 431   WebKit::WebGamepads webkit_data; | 
| 433   delegate_->SampleGamepads(&webkit_data); | 432   helper_->SampleGamepads(&webkit_data); | 
| 434   ConvertWebKitGamepadData( | 433   ConvertWebKitGamepadData( | 
| 435       *reinterpret_cast<const ::ppapi::WebKitGamepads*>(&webkit_data), data); | 434       *reinterpret_cast<const ::ppapi::WebKitGamepads*>(&webkit_data), data); | 
| 436 } | 435 } | 
| 437 | 436 | 
| 438 PepperPluginInstanceImpl::PepperPluginInstanceImpl( | 437 PepperPluginInstanceImpl::PepperPluginInstanceImpl( | 
| 439     PepperPluginDelegateImpl* delegate, | 438     PepperHelperImpl* helper, | 
| 440     RenderViewImpl* render_view, | 439     RenderViewImpl* render_view, | 
| 441     PluginModule* module, | 440     PluginModule* module, | 
| 442     ::ppapi::PPP_Instance_Combined* instance_interface, | 441     ::ppapi::PPP_Instance_Combined* instance_interface, | 
| 443     WebPluginContainer* container, | 442     WebPluginContainer* container, | 
| 444     const GURL& plugin_url) | 443     const GURL& plugin_url) | 
| 445     : delegate_(delegate), | 444     : helper_(helper), | 
| 446       render_view_(render_view), | 445       render_view_(render_view), | 
| 447       module_(module), | 446       module_(module), | 
| 448       instance_interface_(instance_interface), | 447       instance_interface_(instance_interface), | 
| 449       pp_instance_(0), | 448       pp_instance_(0), | 
| 450       container_(container), | 449       container_(container), | 
| 451       layer_bound_to_fullscreen_(false), | 450       layer_bound_to_fullscreen_(false), | 
| 452       plugin_url_(plugin_url), | 451       plugin_url_(plugin_url), | 
| 453       full_frame_(false), | 452       full_frame_(false), | 
| 454       sent_initial_did_change_view_(false), | 453       sent_initial_did_change_view_(false), | 
| 455       view_change_weak_ptr_factory_(this), | 454       view_change_weak_ptr_factory_(this), | 
| 456       bound_graphics_2d_platform_(NULL), | 455       bound_graphics_2d_platform_(NULL), | 
| 457       has_webkit_focus_(false), | 456       has_webkit_focus_(false), | 
| 458       has_content_area_focus_(false), | 457       has_content_area_focus_(false), | 
| 459       find_identifier_(-1), | 458       find_identifier_(-1), | 
| 460       plugin_find_interface_(NULL), | 459       plugin_find_interface_(NULL), | 
| 461       plugin_input_event_interface_(NULL), | 460       plugin_input_event_interface_(NULL), | 
| 462       plugin_messaging_interface_(NULL), | 461       plugin_messaging_interface_(NULL), | 
| 463       plugin_mouse_lock_interface_(NULL), | 462       plugin_mouse_lock_interface_(NULL), | 
| 464       plugin_pdf_interface_(NULL), | 463       plugin_pdf_interface_(NULL), | 
| 465       plugin_private_interface_(NULL), | 464       plugin_private_interface_(NULL), | 
| 466       plugin_selection_interface_(NULL), | 465       plugin_selection_interface_(NULL), | 
| 467       plugin_textinput_interface_(NULL), | 466       plugin_textinput_interface_(NULL), | 
| 468       plugin_zoom_interface_(NULL), | 467       plugin_zoom_interface_(NULL), | 
| 469       checked_for_plugin_input_event_interface_(false), | 468       checked_for_plugin_input_event_interface_(false), | 
| 470       checked_for_plugin_messaging_interface_(false), | 469       checked_for_plugin_messaging_interface_(false), | 
| 471       checked_for_plugin_pdf_interface_(false), | 470       checked_for_plugin_pdf_interface_(false), | 
| 472       gamepad_impl_(new GamepadImpl(delegate)), | 471       gamepad_impl_(new GamepadImpl(helper)), | 
| 473       plugin_print_interface_(NULL), | 472       plugin_print_interface_(NULL), | 
| 474       plugin_graphics_3d_interface_(NULL), | 473       plugin_graphics_3d_interface_(NULL), | 
| 475       always_on_top_(false), | 474       always_on_top_(false), | 
| 476       fullscreen_container_(NULL), | 475       fullscreen_container_(NULL), | 
| 477       flash_fullscreen_(false), | 476       flash_fullscreen_(false), | 
| 478       desired_fullscreen_state_(false), | 477       desired_fullscreen_state_(false), | 
| 479       sad_plugin_(NULL), | 478       sad_plugin_(NULL), | 
| 480       input_event_mask_(0), | 479       input_event_mask_(0), | 
| 481       filtered_input_event_mask_(0), | 480       filtered_input_event_mask_(0), | 
| 482       text_input_type_(kPluginDefaultTextInputType), | 481       text_input_type_(kPluginDefaultTextInputType), | 
| 483       text_input_caret_(0, 0, 0, 0), | 482       text_input_caret_(0, 0, 0, 0), | 
| 484       text_input_caret_bounds_(0, 0, 0, 0), | 483       text_input_caret_bounds_(0, 0, 0, 0), | 
| 485       text_input_caret_set_(false), | 484       text_input_caret_set_(false), | 
| 486       selection_caret_(0), | 485       selection_caret_(0), | 
| 487       selection_anchor_(0), | 486       selection_anchor_(0), | 
| 488       pending_user_gesture_(0.0), | 487       pending_user_gesture_(0.0), | 
| 489       document_loader_(NULL), | 488       document_loader_(NULL), | 
| 490       nacl_document_load_(false), | 489       nacl_document_load_(false), | 
| 491       npp_(new NPP_t), | 490       npp_(new NPP_t), | 
| 492       isolate_(v8::Isolate::GetCurrent()) { | 491       isolate_(v8::Isolate::GetCurrent()) { | 
| 493   pp_instance_ = HostGlobals::Get()->AddInstance(this); | 492   pp_instance_ = HostGlobals::Get()->AddInstance(this); | 
| 494 | 493 | 
| 495   memset(¤t_print_settings_, 0, sizeof(current_print_settings_)); | 494   memset(¤t_print_settings_, 0, sizeof(current_print_settings_)); | 
| 496   module_->InstanceCreated(this); | 495   module_->InstanceCreated(this); | 
| 497 | 496 | 
| 498   if (delegate_) | 497   if (helper_) | 
| 499     delegate_->InstanceCreated(this); | 498     helper_->InstanceCreated(this); | 
| 500 | 499 | 
| 501   if (render_view)  // NULL in tests | 500   if (render_view)  // NULL in tests | 
| 502     view_data_.is_page_visible = !render_view->is_hidden(); | 501     view_data_.is_page_visible = !render_view->is_hidden(); | 
| 503 | 502 | 
| 504   RendererPpapiHostImpl* host_impl = module_->renderer_ppapi_host(); | 503   RendererPpapiHostImpl* host_impl = module_->renderer_ppapi_host(); | 
| 505   resource_creation_ = host_impl->CreateInProcessResourceCreationAPI(this); | 504   resource_creation_ = host_impl->CreateInProcessResourceCreationAPI(this); | 
| 506 | 505 | 
| 507   // TODO(bbudge) remove this when the trusted NaCl plugin has been removed. | 506   // TODO(bbudge) remove this when the trusted NaCl plugin has been removed. | 
| 508   // We must defer certain plugin events for NaCl instances since we switch | 507   // We must defer certain plugin events for NaCl instances since we switch | 
| 509   // from the in-process to the out-of-process proxy after instantiating them. | 508   // from the in-process to the out-of-process proxy after instantiating them. | 
| (...skipping 16 matching lines...) Expand all  Loading... | 
| 526   // unregister themselves inside the delete call). | 525   // unregister themselves inside the delete call). | 
| 527   PluginObjectSet plugin_object_copy; | 526   PluginObjectSet plugin_object_copy; | 
| 528   live_plugin_objects_.swap(plugin_object_copy); | 527   live_plugin_objects_.swap(plugin_object_copy); | 
| 529   for (PluginObjectSet::iterator i = plugin_object_copy.begin(); | 528   for (PluginObjectSet::iterator i = plugin_object_copy.begin(); | 
| 530        i != plugin_object_copy.end(); ++i) | 529        i != plugin_object_copy.end(); ++i) | 
| 531     delete *i; | 530     delete *i; | 
| 532 | 531 | 
| 533   if (TrackedCallback::IsPending(lock_mouse_callback_)) | 532   if (TrackedCallback::IsPending(lock_mouse_callback_)) | 
| 534     lock_mouse_callback_->Abort(); | 533     lock_mouse_callback_->Abort(); | 
| 535 | 534 | 
| 536   if (delegate_) | 535   if (helper_) | 
| 537     delegate_->InstanceDeleted(this); | 536     helper_->InstanceDeleted(this); | 
| 538   UnSetAndDeleteLockTargetAdapter(); | 537   UnSetAndDeleteLockTargetAdapter(); | 
| 539   module_->InstanceDeleted(this); | 538   module_->InstanceDeleted(this); | 
| 540   // If we switched from the NaCl plugin module, notify it too. | 539   // If we switched from the NaCl plugin module, notify it too. | 
| 541   if (original_module_.get()) | 540   if (original_module_.get()) | 
| 542     original_module_->InstanceDeleted(this); | 541     original_module_->InstanceDeleted(this); | 
| 543 | 542 | 
| 544   // This should be last since some of the above "instance deleted" calls will | 543   // This should be last since some of the above "instance deleted" calls will | 
| 545   // want to look up in the global map to get info off of our object. | 544   // want to look up in the global map to get info off of our object. | 
| 546   HostGlobals::Get()->InstanceDeleted(pp_instance_); | 545   HostGlobals::Get()->InstanceDeleted(pp_instance_); | 
| 547 } | 546 } | 
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 711 | 710 | 
| 712 bool PepperPluginInstanceImpl::HandleDocumentLoad( | 711 bool PepperPluginInstanceImpl::HandleDocumentLoad( | 
| 713     const WebKit::WebURLResponse& response) { | 712     const WebKit::WebURLResponse& response) { | 
| 714   DCHECK(!document_loader_); | 713   DCHECK(!document_loader_); | 
| 715   if (!nacl_document_load_) { | 714   if (!nacl_document_load_) { | 
| 716     if (module()->is_crashed()) { | 715     if (module()->is_crashed()) { | 
| 717       // Don't create a resource for a crashed plugin. | 716       // Don't create a resource for a crashed plugin. | 
| 718       container()->element().document().frame()->stopLoading(); | 717       container()->element().document().frame()->stopLoading(); | 
| 719       return false; | 718       return false; | 
| 720     } | 719     } | 
| 721     delegate_->HandleDocumentLoad(this, response); | 720     helper_->HandleDocumentLoad(this, response); | 
| 722     // If the load was not abandoned, document_loader_ will now be set. It's | 721     // If the load was not abandoned, document_loader_ will now be set. It's | 
| 723     // possible that the load was canceled by now and document_loader_ was | 722     // possible that the load was canceled by now and document_loader_ was | 
| 724     // already nulled out. | 723     // already nulled out. | 
| 725   } else { | 724   } else { | 
| 726     // The NaCl proxy isn't available, so save the response and record document | 725     // The NaCl proxy isn't available, so save the response and record document | 
| 727     // load notifications for later replay. | 726     // load notifications for later replay. | 
| 728     nacl_document_response_ = response; | 727     nacl_document_response_ = response; | 
| 729     nacl_document_loader_.reset(new NaClDocumentLoader()); | 728     nacl_document_loader_.reset(new NaClDocumentLoader()); | 
| 730     document_loader_ = nacl_document_loader_.get(); | 729     document_loader_ = nacl_document_loader_.get(); | 
| 731   } | 730   } | 
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 886   caret.Offset(view_data_.rect.point.x, view_data_.rect.point.y); | 885   caret.Offset(view_data_.rect.point.x, view_data_.rect.point.y); | 
| 887   return caret; | 886   return caret; | 
| 888 } | 887 } | 
| 889 | 888 | 
| 890 bool PepperPluginInstanceImpl::HandleInputEvent( | 889 bool PepperPluginInstanceImpl::HandleInputEvent( | 
| 891     const WebKit::WebInputEvent& event, | 890     const WebKit::WebInputEvent& event, | 
| 892     WebCursorInfo* cursor_info) { | 891     WebCursorInfo* cursor_info) { | 
| 893   TRACE_EVENT0("ppapi", "PepperPluginInstanceImpl::HandleInputEvent"); | 892   TRACE_EVENT0("ppapi", "PepperPluginInstanceImpl::HandleInputEvent"); | 
| 894 | 893 | 
| 895   if (WebInputEvent::isMouseEventType(event.type)) { | 894   if (WebInputEvent::isMouseEventType(event.type)) { | 
| 896     delegate_->DidReceiveMouseEvent(this); | 895     helper_->DidReceiveMouseEvent(this); | 
| 897   } | 896   } | 
| 898 | 897 | 
| 899   // Don't dispatch input events to crashed plugins. | 898   // Don't dispatch input events to crashed plugins. | 
| 900   if (module()->is_crashed()) | 899   if (module()->is_crashed()) | 
| 901     return false; | 900     return false; | 
| 902 | 901 | 
| 903   // Keep a reference on the stack. See NOTE above. | 902   // Keep a reference on the stack. See NOTE above. | 
| 904   scoped_refptr<PepperPluginInstanceImpl> ref(this); | 903   scoped_refptr<PepperPluginInstanceImpl> ref(this); | 
| 905 | 904 | 
| 906   bool rv = false; | 905   bool rv = false; | 
| (...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1326   return !!plugin_zoom_interface_; | 1325   return !!plugin_zoom_interface_; | 
| 1327 } | 1326 } | 
| 1328 | 1327 | 
| 1329 bool PepperPluginInstanceImpl::PluginHasFocus() const { | 1328 bool PepperPluginInstanceImpl::PluginHasFocus() const { | 
| 1330   return flash_fullscreen_ || (has_webkit_focus_ && has_content_area_focus_); | 1329   return flash_fullscreen_ || (has_webkit_focus_ && has_content_area_focus_); | 
| 1331 } | 1330 } | 
| 1332 | 1331 | 
| 1333 void PepperPluginInstanceImpl::SendFocusChangeNotification() { | 1332 void PepperPluginInstanceImpl::SendFocusChangeNotification() { | 
| 1334   // This call can happen during PepperPluginIn>stanceImpl destruction, because | 1333   // This call can happen during PepperPluginIn>stanceImpl destruction, because | 
| 1335   // WebKit informs the plugin it's losing focus. See crbug.com/236574 | 1334   // WebKit informs the plugin it's losing focus. See crbug.com/236574 | 
| 1336   if (!delegate_ || !instance_interface_) | 1335   if (!helper_ || !instance_interface_) | 
| 1337     return; | 1336     return; | 
| 1338   bool has_focus = PluginHasFocus(); | 1337   bool has_focus = PluginHasFocus(); | 
| 1339   delegate_->PluginFocusChanged(this, has_focus); | 1338   helper_->PluginFocusChanged(this, has_focus); | 
| 1340   instance_interface_->DidChangeFocus(pp_instance(), PP_FromBool(has_focus)); | 1339   instance_interface_->DidChangeFocus(pp_instance(), PP_FromBool(has_focus)); | 
| 1341 } | 1340 } | 
| 1342 | 1341 | 
| 1343 void PepperPluginInstanceImpl::UpdateTouchEventRequest() { | 1342 void PepperPluginInstanceImpl::UpdateTouchEventRequest() { | 
| 1344   bool raw_touch = (filtered_input_event_mask_ & PP_INPUTEVENT_CLASS_TOUCH) || | 1343   bool raw_touch = (filtered_input_event_mask_ & PP_INPUTEVENT_CLASS_TOUCH) || | 
| 1345                    (input_event_mask_ & PP_INPUTEVENT_CLASS_TOUCH); | 1344                    (input_event_mask_ & PP_INPUTEVENT_CLASS_TOUCH); | 
| 1346   container_->requestTouchEventType(raw_touch ? | 1345   container_->requestTouchEventType(raw_touch ? | 
| 1347       WebKit::WebPluginContainer::TouchEventRequestTypeRaw : | 1346       WebKit::WebPluginContainer::TouchEventRequestTypeRaw : | 
| 1348       WebKit::WebPluginContainer::TouchEventRequestTypeSynthesizedMouse); | 1347       WebKit::WebPluginContainer::TouchEventRequestTypeSynthesizedMouse); | 
| 1349 } | 1348 } | 
| (...skipping 988 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2338 void PepperPluginInstanceImpl::UnlockMouse(PP_Instance instance) { | 2337 void PepperPluginInstanceImpl::UnlockMouse(PP_Instance instance) { | 
| 2339   GetMouseLockDispatcher()->UnlockMouse(GetOrCreateLockTargetAdapter()); | 2338   GetMouseLockDispatcher()->UnlockMouse(GetOrCreateLockTargetAdapter()); | 
| 2340 } | 2339 } | 
| 2341 | 2340 | 
| 2342 void PepperPluginInstanceImpl::SetTextInputType(PP_Instance instance, | 2341 void PepperPluginInstanceImpl::SetTextInputType(PP_Instance instance, | 
| 2343                                                 PP_TextInput_Type type) { | 2342                                                 PP_TextInput_Type type) { | 
| 2344   int itype = type; | 2343   int itype = type; | 
| 2345   if (itype < 0 || itype > ui::TEXT_INPUT_TYPE_URL) | 2344   if (itype < 0 || itype > ui::TEXT_INPUT_TYPE_URL) | 
| 2346     itype = ui::TEXT_INPUT_TYPE_NONE; | 2345     itype = ui::TEXT_INPUT_TYPE_NONE; | 
| 2347   text_input_type_ = static_cast<ui::TextInputType>(itype); | 2346   text_input_type_ = static_cast<ui::TextInputType>(itype); | 
| 2348   delegate_->PluginTextInputTypeChanged(this); | 2347   helper_->PluginTextInputTypeChanged(this); | 
| 2349 } | 2348 } | 
| 2350 | 2349 | 
| 2351 void PepperPluginInstanceImpl::UpdateCaretPosition( | 2350 void PepperPluginInstanceImpl::UpdateCaretPosition( | 
| 2352     PP_Instance instance, | 2351     PP_Instance instance, | 
| 2353     const PP_Rect& caret, | 2352     const PP_Rect& caret, | 
| 2354     const PP_Rect& bounding_box) { | 2353     const PP_Rect& bounding_box) { | 
| 2355   text_input_caret_ = PP_ToGfxRect(caret); | 2354   text_input_caret_ = PP_ToGfxRect(caret); | 
| 2356   text_input_caret_bounds_ = PP_ToGfxRect(bounding_box); | 2355   text_input_caret_bounds_ = PP_ToGfxRect(bounding_box); | 
| 2357   text_input_caret_set_ = true; | 2356   text_input_caret_set_ = true; | 
| 2358   delegate_->PluginCaretPositionChanged(this); | 2357   helper_->PluginCaretPositionChanged(this); | 
| 2359 } | 2358 } | 
| 2360 | 2359 | 
| 2361 void PepperPluginInstanceImpl::CancelCompositionText(PP_Instance instance) { | 2360 void PepperPluginInstanceImpl::CancelCompositionText(PP_Instance instance) { | 
| 2362   delegate_->PluginRequestedCancelComposition(this); | 2361   helper_->PluginRequestedCancelComposition(this); | 
| 2363 } | 2362 } | 
| 2364 | 2363 | 
| 2365 void PepperPluginInstanceImpl::SelectionChanged(PP_Instance instance) { | 2364 void PepperPluginInstanceImpl::SelectionChanged(PP_Instance instance) { | 
| 2366   // TODO(kinaba): currently the browser always calls RequestSurroundingText. | 2365   // TODO(kinaba): currently the browser always calls RequestSurroundingText. | 
| 2367   // It can be optimized so that it won't call it back until the information | 2366   // It can be optimized so that it won't call it back until the information | 
| 2368   // is really needed. | 2367   // is really needed. | 
| 2369 | 2368 | 
| 2370   // Avoid calling in nested context or else this will reenter the plugin. This | 2369   // Avoid calling in nested context or else this will reenter the plugin. This | 
| 2371   // uses a weak pointer rather than exploiting the fact that this class is | 2370   // uses a weak pointer rather than exploiting the fact that this class is | 
| 2372   // refcounted because we don't actually want this operation to affect the | 2371   // refcounted because we don't actually want this operation to affect the | 
| 2373   // lifetime of the instance. | 2372   // lifetime of the instance. | 
| 2374   base::MessageLoop::current()->PostTask( | 2373   base::MessageLoop::current()->PostTask( | 
| 2375       FROM_HERE, | 2374       FROM_HERE, | 
| 2376       base::Bind(&PepperPluginInstanceImpl::RequestSurroundingText, | 2375       base::Bind(&PepperPluginInstanceImpl::RequestSurroundingText, | 
| 2377                  AsWeakPtr(), | 2376                  AsWeakPtr(), | 
| 2378                  static_cast<size_t>(kExtraCharsForTextInput))); | 2377                  static_cast<size_t>(kExtraCharsForTextInput))); | 
| 2379 } | 2378 } | 
| 2380 | 2379 | 
| 2381 void PepperPluginInstanceImpl::UpdateSurroundingText(PP_Instance instance, | 2380 void PepperPluginInstanceImpl::UpdateSurroundingText(PP_Instance instance, | 
| 2382                                                      const char* text, | 2381                                                      const char* text, | 
| 2383                                                      uint32_t caret, | 2382                                                      uint32_t caret, | 
| 2384                                                      uint32_t anchor) { | 2383                                                      uint32_t anchor) { | 
| 2385   surrounding_text_ = text; | 2384   surrounding_text_ = text; | 
| 2386   selection_caret_ = caret; | 2385   selection_caret_ = caret; | 
| 2387   selection_anchor_ = anchor; | 2386   selection_anchor_ = anchor; | 
| 2388   delegate_->PluginSelectionChanged(this); | 2387   helper_->PluginSelectionChanged(this); | 
| 2389 } | 2388 } | 
| 2390 | 2389 | 
| 2391 PP_Var PepperPluginInstanceImpl::ResolveRelativeToDocument( | 2390 PP_Var PepperPluginInstanceImpl::ResolveRelativeToDocument( | 
| 2392     PP_Instance instance, | 2391     PP_Instance instance, | 
| 2393     PP_Var relative, | 2392     PP_Var relative, | 
| 2394     PP_URLComponents_Dev* components) { | 2393     PP_URLComponents_Dev* components) { | 
| 2395   StringVar* relative_string = StringVar::FromPPVar(relative); | 2394   StringVar* relative_string = StringVar::FromPPVar(relative); | 
| 2396   if (!relative_string) | 2395   if (!relative_string) | 
| 2397     return PP_MakeNull(); | 2396     return PP_MakeNull(); | 
| 2398 | 2397 | 
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2604     base::ProcessId plugin_pid, | 2603     base::ProcessId plugin_pid, | 
| 2605     int plugin_child_id) { | 2604     int plugin_child_id) { | 
| 2606   // Create a new module for each instance of the external plugin that is using | 2605   // Create a new module for each instance of the external plugin that is using | 
| 2607   // the IPC based out-of-process proxy. We can't use the existing module, | 2606   // the IPC based out-of-process proxy. We can't use the existing module, | 
| 2608   // because it is configured for the in-process plugin, and we must keep it | 2607   // because it is configured for the in-process plugin, and we must keep it | 
| 2609   // that way to allow the page to create other instances. | 2608   // that way to allow the page to create other instances. | 
| 2610   scoped_refptr<PluginModule> external_plugin_module( | 2609   scoped_refptr<PluginModule> external_plugin_module( | 
| 2611       module_->CreateModuleForExternalPluginInstance()); | 2610       module_->CreateModuleForExternalPluginInstance()); | 
| 2612 | 2611 | 
| 2613   RendererPpapiHost* renderer_ppapi_host = | 2612   RendererPpapiHost* renderer_ppapi_host = | 
| 2614       delegate_->CreateExternalPluginModule( | 2613       helper_->CreateExternalPluginModule( | 
| 2615           external_plugin_module, | 2614           external_plugin_module, | 
| 2616           file_path, | 2615           file_path, | 
| 2617           permissions, | 2616           permissions, | 
| 2618           channel_handle, | 2617           channel_handle, | 
| 2619           plugin_pid, | 2618           plugin_pid, | 
| 2620           plugin_child_id); | 2619           plugin_child_id); | 
| 2621   if (!renderer_ppapi_host) { | 2620   if (!renderer_ppapi_host) { | 
| 2622     DLOG(ERROR) << "CreateExternalPluginModule() failed"; | 2621     DLOG(ERROR) << "CreateExternalPluginModule() failed"; | 
| 2623     return PP_EXTERNAL_PLUGIN_ERROR_MODULE; | 2622     return PP_EXTERNAL_PLUGIN_ERROR_MODULE; | 
| 2624   } | 2623   } | 
| 2625 | 2624 | 
| 2626   // Finally, switch the instance to the proxy. | 2625   // Finally, switch the instance to the proxy. | 
| 2627   return external_plugin_module->InitAsProxiedExternalPlugin(this); | 2626   return external_plugin_module->InitAsProxiedExternalPlugin(this); | 
| 2628 } | 2627 } | 
| 2629 | 2628 | 
| 2630 void PepperPluginInstanceImpl::SetAlwaysOnTop(bool on_top) { | 2629 void PepperPluginInstanceImpl::SetAlwaysOnTop(bool on_top) { | 
| 2631   always_on_top_ = on_top; | 2630   always_on_top_ = on_top; | 
| 2632 } | 2631 } | 
| 2633 | 2632 | 
| 2634 void PepperPluginInstanceImpl::DoSetCursor(WebCursorInfo* cursor) { | 2633 void PepperPluginInstanceImpl::DoSetCursor(WebCursorInfo* cursor) { | 
| 2635   cursor_.reset(cursor); | 2634   cursor_.reset(cursor); | 
| 2636   if (fullscreen_container_) { | 2635   if (fullscreen_container_) { | 
| 2637     fullscreen_container_->DidChangeCursor(*cursor); | 2636     fullscreen_container_->DidChangeCursor(*cursor); | 
| 2638   } else { | 2637   } else { | 
| 2639     delegate_->DidChangeCursor(this, *cursor); | 2638     helper_->DidChangeCursor(this, *cursor); | 
| 2640   } | 2639   } | 
| 2641 } | 2640 } | 
| 2642 | 2641 | 
| 2643 bool PepperPluginInstanceImpl::IsFullPagePlugin() { | 2642 bool PepperPluginInstanceImpl::IsFullPagePlugin() { | 
| 2644   WebFrame* frame = container()->element().document().frame(); | 2643   WebFrame* frame = container()->element().document().frame(); | 
| 2645   return frame->view()->mainFrame()->document().isPluginDocument(); | 2644   return frame->view()->mainFrame()->document().isPluginDocument(); | 
| 2646 } | 2645 } | 
| 2647 | 2646 | 
| 2648 void PepperPluginInstanceImpl::FlashSetFullscreen(bool fullscreen, | 2647 void PepperPluginInstanceImpl::FlashSetFullscreen(bool fullscreen, | 
| 2649                                                   bool delay_report) { | 2648                                                   bool delay_report) { | 
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2818 } | 2817 } | 
| 2819 | 2818 | 
| 2820 void PepperPluginInstanceImpl::UnSetAndDeleteLockTargetAdapter() { | 2819 void PepperPluginInstanceImpl::UnSetAndDeleteLockTargetAdapter() { | 
| 2821   if (lock_target_.get()) { | 2820   if (lock_target_.get()) { | 
| 2822     GetMouseLockDispatcher()->OnLockTargetDestroyed(lock_target_.get()); | 2821     GetMouseLockDispatcher()->OnLockTargetDestroyed(lock_target_.get()); | 
| 2823     lock_target_.reset(); | 2822     lock_target_.reset(); | 
| 2824   } | 2823   } | 
| 2825 } | 2824 } | 
| 2826 | 2825 | 
| 2827 }  // namespace content | 2826 }  // namespace content | 
| OLD | NEW | 
|---|