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

Side by Side Diff: webkit/plugins/ppapi/ppapi_plugin_instance.cc

Issue 19828007: Hide knowledge of webkit::ppapi::Plugin from chrome. This is part of moving ppapi implementation fr… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: nits Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « webkit/plugins/ppapi/ppapi_plugin_instance.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" 5 #include "webkit/plugins/ppapi/ppapi_plugin_instance.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"
(...skipping 13 matching lines...) Expand all
24 #include "ppapi/c/dev/ppp_zoom_dev.h" 24 #include "ppapi/c/dev/ppp_zoom_dev.h"
25 #include "ppapi/c/pp_rect.h" 25 #include "ppapi/c/pp_rect.h"
26 #include "ppapi/c/ppb_audio_config.h" 26 #include "ppapi/c/ppb_audio_config.h"
27 #include "ppapi/c/ppb_core.h" 27 #include "ppapi/c/ppb_core.h"
28 #include "ppapi/c/ppb_gamepad.h" 28 #include "ppapi/c/ppb_gamepad.h"
29 #include "ppapi/c/ppp_input_event.h" 29 #include "ppapi/c/ppp_input_event.h"
30 #include "ppapi/c/ppp_instance.h" 30 #include "ppapi/c/ppp_instance.h"
31 #include "ppapi/c/ppp_messaging.h" 31 #include "ppapi/c/ppp_messaging.h"
32 #include "ppapi/c/ppp_mouse_lock.h" 32 #include "ppapi/c/ppp_mouse_lock.h"
33 #include "ppapi/c/private/ppp_instance_private.h" 33 #include "ppapi/c/private/ppp_instance_private.h"
34 #include "ppapi/shared_impl/ppapi_permissions.h"
34 #include "ppapi/shared_impl/ppapi_preferences.h" 35 #include "ppapi/shared_impl/ppapi_preferences.h"
35 #include "ppapi/shared_impl/ppb_gamepad_shared.h" 36 #include "ppapi/shared_impl/ppb_gamepad_shared.h"
36 #include "ppapi/shared_impl/ppb_input_event_shared.h" 37 #include "ppapi/shared_impl/ppb_input_event_shared.h"
37 #include "ppapi/shared_impl/ppb_url_util_shared.h" 38 #include "ppapi/shared_impl/ppb_url_util_shared.h"
38 #include "ppapi/shared_impl/ppb_view_shared.h" 39 #include "ppapi/shared_impl/ppb_view_shared.h"
39 #include "ppapi/shared_impl/ppp_instance_combined.h" 40 #include "ppapi/shared_impl/ppp_instance_combined.h"
40 #include "ppapi/shared_impl/resource.h" 41 #include "ppapi/shared_impl/resource.h"
41 #include "ppapi/shared_impl/scoped_pp_resource.h" 42 #include "ppapi/shared_impl/scoped_pp_resource.h"
42 #include "ppapi/shared_impl/time_conversion.h" 43 #include "ppapi/shared_impl/time_conversion.h"
43 #include "ppapi/shared_impl/url_request_info_data.h" 44 #include "ppapi/shared_impl/url_request_info_data.h"
(...skipping 2407 matching lines...) Expand 10 before | Expand all | Expand 10 after
2451 components); 2452 components);
2452 } 2453 }
2453 2454
2454 PP_Var PluginInstance::GetPluginInstanceURL( 2455 PP_Var PluginInstance::GetPluginInstanceURL(
2455 PP_Instance instance, 2456 PP_Instance instance,
2456 PP_URLComponents_Dev* components) { 2457 PP_URLComponents_Dev* components) {
2457 return ::ppapi::PPB_URLUtil_Shared::GenerateURLReturn(plugin_url_, 2458 return ::ppapi::PPB_URLUtil_Shared::GenerateURLReturn(plugin_url_,
2458 components); 2459 components);
2459 } 2460 }
2460 2461
2461 PP_NaClResult PluginInstance::ResetAsProxied( 2462 PP_ExternalPluginResult PluginInstance::ResetAsProxied(
2462 scoped_refptr<PluginModule> module) { 2463 scoped_refptr<PluginModule> module) {
2463 // Save the original module and switch over to the new one now that this 2464 // Save the original module and switch over to the new one now that this
2464 // plugin is using the IPC-based proxy. 2465 // plugin is using the IPC-based proxy.
2465 original_module_ = module_; 2466 original_module_ = module_;
2466 module_ = module; 2467 module_ = module;
2467 2468
2468 // Don't send any messages to the plugin until DidCreate() has finished. 2469 // Don't send any messages to the plugin until DidCreate() has finished.
2469 message_channel_->QueueJavaScriptMessages(); 2470 message_channel_->QueueJavaScriptMessages();
2470 2471
2471 // For NaCl instances, remember the NaCl plugin instance interface, so we 2472 // For NaCl instances, remember the NaCl plugin instance interface, so we
2472 // can shut it down by calling its DidDestroy in our Delete() method. 2473 // can shut it down by calling its DidDestroy in our Delete() method.
2473 original_instance_interface_.reset(instance_interface_.release()); 2474 original_instance_interface_.reset(instance_interface_.release());
2474 2475
2475 base::Callback<const void*(const char*)> get_plugin_interface_func = 2476 base::Callback<const void*(const char*)> get_plugin_interface_func =
2476 base::Bind(&PluginModule::GetPluginInterface, module_.get()); 2477 base::Bind(&PluginModule::GetPluginInterface, module_.get());
2477 PPP_Instance_Combined* ppp_instance_combined = 2478 PPP_Instance_Combined* ppp_instance_combined =
2478 PPP_Instance_Combined::Create(get_plugin_interface_func); 2479 PPP_Instance_Combined::Create(get_plugin_interface_func);
2479 if (!ppp_instance_combined) { 2480 if (!ppp_instance_combined) {
2480 // The proxy must support at least one usable PPP_Instance interface. 2481 // The proxy must support at least one usable PPP_Instance interface.
2481 // While this could be a failure to implement the interface in the NaCl 2482 // While this could be a failure to implement the interface in the NaCl
2482 // module, it is more likely that the NaCl process has crashed. Either 2483 // module, it is more likely that the NaCl process has crashed. Either
2483 // way, report that module initialization failed. 2484 // way, report that module initialization failed.
2484 return PP_NACL_ERROR_MODULE; 2485 return PP_EXTERNAL_PLUGIN_ERROR_MODULE;
2485 } 2486 }
2486 2487
2487 instance_interface_.reset(ppp_instance_combined); 2488 instance_interface_.reset(ppp_instance_combined);
2488 // Clear all PPP interfaces we may have cached. 2489 // Clear all PPP interfaces we may have cached.
2489 plugin_find_interface_ = NULL; 2490 plugin_find_interface_ = NULL;
2490 plugin_input_event_interface_ = NULL; 2491 plugin_input_event_interface_ = NULL;
2491 checked_for_plugin_input_event_interface_ = false; 2492 checked_for_plugin_input_event_interface_ = false;
2492 plugin_messaging_interface_ = NULL; 2493 plugin_messaging_interface_ = NULL;
2493 checked_for_plugin_messaging_interface_ = false; 2494 checked_for_plugin_messaging_interface_ = false;
2494 plugin_mouse_lock_interface_ = NULL; 2495 plugin_mouse_lock_interface_ = NULL;
2495 plugin_pdf_interface_ = NULL; 2496 plugin_pdf_interface_ = NULL;
2496 checked_for_plugin_pdf_interface_ = false; 2497 checked_for_plugin_pdf_interface_ = false;
2497 plugin_private_interface_ = NULL; 2498 plugin_private_interface_ = NULL;
2498 plugin_selection_interface_ = NULL; 2499 plugin_selection_interface_ = NULL;
2499 plugin_textinput_interface_ = NULL; 2500 plugin_textinput_interface_ = NULL;
2500 plugin_zoom_interface_ = NULL; 2501 plugin_zoom_interface_ = NULL;
2501 2502
2502 // Re-send the DidCreate event via the proxy. 2503 // Re-send the DidCreate event via the proxy.
2503 scoped_ptr<const char*[]> argn_array(StringVectorToArgArray(argn_)); 2504 scoped_ptr<const char*[]> argn_array(StringVectorToArgArray(argn_));
2504 scoped_ptr<const char*[]> argv_array(StringVectorToArgArray(argv_)); 2505 scoped_ptr<const char*[]> argv_array(StringVectorToArgArray(argv_));
2505 if (!instance_interface_->DidCreate(pp_instance(), argn_.size(), 2506 if (!instance_interface_->DidCreate(pp_instance(), argn_.size(),
2506 argn_array.get(), argv_array.get())) 2507 argn_array.get(), argv_array.get()))
2507 return PP_NACL_ERROR_INSTANCE; 2508 return PP_EXTERNAL_PLUGIN_ERROR_INSTANCE;
2508 message_channel_->StopQueueingJavaScriptMessages(); 2509 message_channel_->StopQueueingJavaScriptMessages();
2509 2510
2510 // Clear sent_initial_did_change_view_ and cancel any pending DidChangeView 2511 // Clear sent_initial_did_change_view_ and cancel any pending DidChangeView
2511 // event. This way, SendDidChangeView will send the "current" view 2512 // event. This way, SendDidChangeView will send the "current" view
2512 // immediately (before other events like HandleDocumentLoad). 2513 // immediately (before other events like HandleDocumentLoad).
2513 sent_initial_did_change_view_ = false; 2514 sent_initial_did_change_view_ = false;
2514 view_change_weak_ptr_factory_.InvalidateWeakPtrs(); 2515 view_change_weak_ptr_factory_.InvalidateWeakPtrs();
2515 SendDidChangeView(); 2516 SendDidChangeView();
2516 2517
2517 DCHECK(nacl_document_load_); 2518 DCHECK(nacl_document_load_);
2518 nacl_document_load_ = false; 2519 nacl_document_load_ = false;
2519 if (!nacl_document_response_.isNull()) { 2520 if (!nacl_document_response_.isNull()) {
2520 document_loader_ = NULL; 2521 document_loader_ = NULL;
2521 // Pass the response to the new proxy. 2522 // Pass the response to the new proxy.
2522 HandleDocumentLoad(nacl_document_response_); 2523 HandleDocumentLoad(nacl_document_response_);
2523 nacl_document_response_ = WebKit::WebURLResponse(); 2524 nacl_document_response_ = WebKit::WebURLResponse();
2524 // Replay any document load events we've received to the real loader. 2525 // Replay any document load events we've received to the real loader.
2525 nacl_document_loader_->ReplayReceivedData(document_loader_); 2526 nacl_document_loader_->ReplayReceivedData(document_loader_);
2526 nacl_document_loader_.reset(NULL); 2527 nacl_document_loader_.reset(NULL);
2527 } 2528 }
2528 2529
2529 return PP_NACL_OK; 2530 return PP_EXTERNAL_PLUGIN_OK;
2530 } 2531 }
2531 2532
2532 bool PluginInstance::IsValidInstanceOf(PluginModule* module) { 2533 bool PluginInstance::IsValidInstanceOf(PluginModule* module) {
2533 DCHECK(module); 2534 DCHECK(module);
2534 return module == module_.get() || 2535 return module == module_.get() ||
2535 module == original_module_.get(); 2536 module == original_module_.get();
2536 } 2537 }
2537 2538
2538 NPP PluginInstance::instanceNPP() { 2539 NPP PluginInstance::instanceNPP() {
2539 return npp_.get(); 2540 return npp_.get();
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
2577 return 0; 2578 return 0;
2578 2579
2579 skia::PlatformCanvas* canvas = image_data->GetPlatformCanvas(); 2580 skia::PlatformCanvas* canvas = image_data->GetPlatformCanvas();
2580 // Note: Do not SkBitmap::copyTo the canvas bitmap directly because it will 2581 // Note: Do not SkBitmap::copyTo the canvas bitmap directly because it will
2581 // ignore the allocated pixels in shared memory and re-allocate a new buffer. 2582 // ignore the allocated pixels in shared memory and re-allocate a new buffer.
2582 canvas->writePixels(image_skia_rep.sk_bitmap(), 0, 0); 2583 canvas->writePixels(image_skia_rep.sk_bitmap(), 0, 0);
2583 2584
2584 return image_data->GetReference(); 2585 return image_data->GetReference();
2585 } 2586 }
2586 2587
2588 base::FilePath PluginInstance::GetModulePath() {
2589 return module_->path();
2590 }
2591
2592 PP_ExternalPluginResult PluginInstance::SwitchToOutOfProcessProxy(
2593 const base::FilePath& file_path,
2594 ::ppapi::PpapiPermissions permissions,
2595 const IPC::ChannelHandle& channel_handle,
2596 base::ProcessId plugin_pid,
2597 int plugin_child_id) {
2598 // Create a new module for each instance of the external plugin that is using
2599 // the IPC based out-of-process proxy. We can't use the existing module,
2600 // because it is configured for the in-process plugin, and we must keep it
2601 // that way to allow the page to create other instances.
2602 scoped_refptr<webkit::ppapi::PluginModule> external_plugin_module(
2603 module_->CreateModuleForExternalPluginInstance());
2604
2605 content::RendererPpapiHost* renderer_ppapi_host =
2606 delegate_->CreateExternalPluginModule(
2607 external_plugin_module,
2608 file_path,
2609 permissions,
2610 channel_handle,
2611 plugin_pid,
2612 plugin_child_id);
2613 if (!renderer_ppapi_host) {
2614 DLOG(ERROR) << "CreateExternalPluginModule() failed";
2615 return PP_EXTERNAL_PLUGIN_ERROR_MODULE;
2616 }
2617
2618 // Finally, switch the instance to the proxy.
2619 return external_plugin_module->InitAsProxiedExternalPlugin(this);
2620 }
2621
2587 void PluginInstance::DoSetCursor(WebCursorInfo* cursor) { 2622 void PluginInstance::DoSetCursor(WebCursorInfo* cursor) {
2588 cursor_.reset(cursor); 2623 cursor_.reset(cursor);
2589 if (fullscreen_container_) { 2624 if (fullscreen_container_) {
2590 fullscreen_container_->DidChangeCursor(*cursor); 2625 fullscreen_container_->DidChangeCursor(*cursor);
2591 } else { 2626 } else {
2592 delegate()->DidChangeCursor(this, *cursor); 2627 delegate()->DidChangeCursor(this, *cursor);
2593 } 2628 }
2594 } 2629 }
2595 2630
2596 bool PluginInstance::CanAccessMainFrame() const { 2631 bool PluginInstance::CanAccessMainFrame() const {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
2647 screen_size_for_fullscreen_ = gfx::Size(); 2682 screen_size_for_fullscreen_ = gfx::Size();
2648 WebElement element = container_->element(); 2683 WebElement element = container_->element();
2649 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_); 2684 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_);
2650 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_); 2685 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_);
2651 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_); 2686 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_);
2652 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_); 2687 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_);
2653 } 2688 }
2654 2689
2655 } // namespace ppapi 2690 } // namespace ppapi
2656 } // namespace webkit 2691 } // namespace webkit
OLDNEW
« no previous file with comments | « webkit/plugins/ppapi/ppapi_plugin_instance.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698