diff options
Diffstat (limited to 'chromium/content/renderer/pepper/pepper_plugin_instance_impl.h')
-rw-r--r-- | chromium/content/renderer/pepper/pepper_plugin_instance_impl.h | 190 |
1 files changed, 117 insertions, 73 deletions
diff --git a/chromium/content/renderer/pepper/pepper_plugin_instance_impl.h b/chromium/content/renderer/pepper/pepper_plugin_instance_impl.h index 0ed093f9d52..ee66136bd4a 100644 --- a/chromium/content/renderer/pepper/pepper_plugin_instance_impl.h +++ b/chromium/content/renderer/pepper/pepper_plugin_instance_impl.h @@ -10,19 +10,20 @@ #include <string> #include <vector> +#include "base/callback.h" #include "base/compiler_specific.h" #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "base/strings/string16.h" #include "cc/layers/content_layer_client.h" +#include "cc/layers/layer.h" #include "cc/layers/texture_layer_client.h" #include "content/common/content_export.h" #include "content/public/renderer/pepper_plugin_instance.h" +#include "content/public/renderer/render_frame_observer.h" #include "content/renderer/mouse_lock_dispatcher.h" -#include "content/renderer/pepper/ppp_pdf.h" #include "ppapi/c/dev/pp_cursor_type_dev.h" -#include "ppapi/c/dev/ppp_find_dev.h" #include "ppapi/c/dev/ppp_printing_dev.h" #include "ppapi/c/dev/ppp_selection_dev.h" #include "ppapi/c/dev/ppp_text_input_dev.h" @@ -36,10 +37,11 @@ #include "ppapi/c/ppb_input_event.h" #include "ppapi/c/ppp_graphics_3d.h" #include "ppapi/c/ppp_input_event.h" -#include "ppapi/c/ppp_messaging.h" #include "ppapi/c/ppp_mouse_lock.h" #include "ppapi/c/private/ppb_content_decryptor_private.h" +#include "ppapi/c/private/ppp_find_private.h" #include "ppapi/c/private/ppp_instance_private.h" +#include "ppapi/c/private/ppp_pdf.h" #include "ppapi/shared_impl/ppb_instance_shared.h" #include "ppapi/shared_impl/ppb_view_shared.h" #include "ppapi/shared_impl/singleton_resource_id.h" @@ -54,6 +56,7 @@ #include "third_party/WebKit/public/web/WebPlugin.h" #include "third_party/WebKit/public/web/WebUserGestureToken.h" #include "ui/base/ime/text_input_type.h" +#include "ui/events/latency_info.h" #include "ui/gfx/rect.h" #include "url/gurl.h" @@ -88,6 +91,7 @@ namespace ppapi { class Resource; struct InputEventData; struct PPP_Instance_Combined; +class ScopedPPVar; } namespace v8 { @@ -99,6 +103,7 @@ namespace content { class ContentDecryptorDelegate; class FullscreenContainer; class MessageChannel; +class PepperCompositorHost; class PepperGraphics2DHost; class PluginModule; class PluginObject; @@ -116,17 +121,17 @@ class CONTENT_EXPORT PepperPluginInstanceImpl : public base::RefCounted<PepperPluginInstanceImpl>, public NON_EXPORTED_BASE(PepperPluginInstance), public ppapi::PPB_Instance_Shared, - public NON_EXPORTED_BASE(cc::TextureLayerClient) { + public NON_EXPORTED_BASE(cc::TextureLayerClient), + public RenderFrameObserver { public: // Create and return a PepperPluginInstanceImpl object which supports the most // recent version of PPP_Instance possible by querying the given // get_plugin_interface function. If the plugin does not support any valid // PPP_Instance interface, returns NULL. - static PepperPluginInstanceImpl* Create( - RenderFrameImpl* render_frame, - PluginModule* module, - blink::WebPluginContainer* container, - const GURL& plugin_url); + static PepperPluginInstanceImpl* Create(RenderFrameImpl* render_frame, + PluginModule* module, + blink::WebPluginContainer* container, + const GURL& plugin_url); RenderFrameImpl* render_frame() const { return render_frame_; } PluginModule* module() const { return module_.get(); } MessageChannel& message_channel() { return *message_channel_; } @@ -185,7 +190,8 @@ class CONTENT_EXPORT PepperPluginInstanceImpl bool HandleInputEvent(const blink::WebInputEvent& event, blink::WebCursorInfo* cursor_info); PP_Var GetInstanceObject(); - void ViewChanged(const gfx::Rect& position, const gfx::Rect& clip, + void ViewChanged(const gfx::Rect& position, + const gfx::Rect& clip, const std::vector<gfx::Rect>& cut_outs_rects); // Handlers for composition events. @@ -217,17 +223,6 @@ class CONTENT_EXPORT PepperPluginInstanceImpl void ViewInitiatedPaint(); void ViewFlushedPaint(); - // If this plugin can be painted merely by copying the backing store to the - // screen, and the plugin bounds encloses the given paint bounds, returns - // true. In this case, the location, clipping, and ID of the backing store - // will be filled into the given output parameters. - bool GetBitmapForOptimizedPluginPaint( - const gfx::Rect& paint_bounds, - TransportDIB** dib, - gfx::Rect* dib_bounds, - gfx::Rect* clip, - float* scale_factor); - // Tracks all live PluginObjects. void AddPluginObject(PluginObject* plugin_object); void RemovePluginObject(PluginObject* plugin_object); @@ -305,8 +300,14 @@ class CONTENT_EXPORT PepperPluginInstanceImpl // already in fullscreen mode). bool SetFullscreen(bool fullscreen); - // Implementation of PPP_Messaging. - void HandleMessage(PP_Var message); + // Send the message on to the plugin. + void HandleMessage(ppapi::ScopedPPVar message); + + // Send the message synchronously to the plugin, and get a result. Returns + // true if the plugin handled the message, false if it didn't. The plugin + // won't handle the message if it has not registered a PPP_MessageHandler. + bool HandleBlockingMessage(ppapi::ScopedPPVar message, + ppapi::ScopedPPVar* result); // Returns true if the plugin is processing a user gesture. bool IsProcessingUserGesture(); @@ -329,8 +330,7 @@ class CONTENT_EXPORT PepperPluginInstanceImpl // Simulates an IME event at the level of RenderView which sends it back up to // the plugin as if it came from the user. bool SimulateIMEEvent(const ppapi::InputEventData& input_event); - void SimulateImeSetCompositionEvent( - const ppapi::InputEventData& input_event); + void SimulateImeSetCompositionEvent(const ppapi::InputEventData& input_event); // The document loader is valid when the plugin is "full-frame" and in this // case is non-NULL as long as the corresponding loader resource is alive. @@ -367,9 +367,13 @@ class CONTENT_EXPORT PepperPluginInstanceImpl virtual int32_t Navigate(const ppapi::URLRequestInfoData& request, const char* target, bool from_user_action) OVERRIDE; - virtual int MakePendingFileRefRendererHost( - const base::FilePath& path) OVERRIDE; + virtual int MakePendingFileRefRendererHost(const base::FilePath& path) + OVERRIDE; virtual void SetEmbedProperty(PP_Var key, PP_Var value) OVERRIDE; + virtual void SetSelectedText(const base::string16& selected_text) OVERRIDE; + virtual void SetLinkUnderCursor(const std::string& url) OVERRIDE; + virtual void SetTextInputType(ui::TextInputType type) OVERRIDE; + virtual void PostMessageToJavaScript(PP_Var message) OVERRIDE; // PPB_Instance_API implementation. virtual PP_Bool BindGraphics(PP_Instance instance, @@ -387,36 +391,46 @@ class CONTENT_EXPORT PepperPluginInstanceImpl virtual uint32_t GetAudioHardwareOutputBufferSize(PP_Instance instance) OVERRIDE; virtual PP_Var GetDefaultCharSet(PP_Instance instance) OVERRIDE; + virtual void SetPluginToHandleFindRequests(PP_Instance) OVERRIDE; virtual void NumberOfFindResultsChanged(PP_Instance instance, int32_t total, PP_Bool final_result) OVERRIDE; virtual void SelectedFindResultChanged(PP_Instance instance, int32_t index) OVERRIDE; + virtual void SetTickmarks(PP_Instance instance, + const PP_Rect* tickmarks, + uint32_t count) OVERRIDE; virtual PP_Bool IsFullscreen(PP_Instance instance) OVERRIDE; virtual PP_Bool SetFullscreen(PP_Instance instance, PP_Bool fullscreen) OVERRIDE; - virtual PP_Bool GetScreenSize(PP_Instance instance, PP_Size* size) - OVERRIDE; + virtual PP_Bool GetScreenSize(PP_Instance instance, PP_Size* size) OVERRIDE; virtual ppapi::Resource* GetSingletonResource(PP_Instance instance, - ppapi::SingletonResourceID id) OVERRIDE; + ppapi::SingletonResourceID id) + OVERRIDE; virtual int32_t RequestInputEvents(PP_Instance instance, uint32_t event_classes) OVERRIDE; virtual int32_t RequestFilteringInputEvents(PP_Instance instance, uint32_t event_classes) OVERRIDE; virtual void ClearInputEventRequest(PP_Instance instance, uint32_t event_classes) OVERRIDE; + virtual void StartTrackingLatency(PP_Instance instance) OVERRIDE; virtual void ZoomChanged(PP_Instance instance, double factor) OVERRIDE; virtual void ZoomLimitsChanged(PP_Instance instance, double minimum_factor, double maximum_factor) OVERRIDE; virtual void PostMessage(PP_Instance instance, PP_Var message) OVERRIDE; + virtual int32_t RegisterMessageHandler(PP_Instance instance, + void* user_data, + const PPP_MessageHandler_0_1* handler, + PP_Resource message_loop) OVERRIDE; + virtual void UnregisterMessageHandler(PP_Instance instance) OVERRIDE; virtual PP_Bool SetCursor(PP_Instance instance, PP_MouseCursor_Type type, PP_Resource image, const PP_Point* hot_spot) OVERRIDE; - virtual int32_t LockMouse( - PP_Instance instance, - scoped_refptr<ppapi::TrackedCallback> callback) OVERRIDE; + virtual int32_t LockMouse(PP_Instance instance, + scoped_refptr<ppapi::TrackedCallback> callback) + OVERRIDE; virtual void UnlockMouse(PP_Instance instance) OVERRIDE; virtual void SetTextInputType(PP_Instance instance, PP_TextInput_Type type) OVERRIDE; @@ -429,37 +443,46 @@ class CONTENT_EXPORT PepperPluginInstanceImpl const char* text, uint32_t caret, uint32_t anchor) OVERRIDE; - virtual PP_Var ResolveRelativeToDocument( - PP_Instance instance, - PP_Var relative, - PP_URLComponents_Dev* components) OVERRIDE; + virtual PP_Var ResolveRelativeToDocument(PP_Instance instance, + PP_Var relative, + PP_URLComponents_Dev* components) + OVERRIDE; virtual PP_Bool DocumentCanRequest(PP_Instance instance, PP_Var url) OVERRIDE; virtual PP_Bool DocumentCanAccessDocument(PP_Instance instance, PP_Instance target) OVERRIDE; virtual PP_Var GetDocumentURL(PP_Instance instance, PP_URLComponents_Dev* components) OVERRIDE; - virtual PP_Var GetPluginInstanceURL( - PP_Instance instance, - PP_URLComponents_Dev* components) OVERRIDE; - virtual PP_Var GetPluginReferrerURL( - PP_Instance instance, - PP_URLComponents_Dev* components) OVERRIDE; + virtual PP_Var GetPluginInstanceURL(PP_Instance instance, + PP_URLComponents_Dev* components) + OVERRIDE; + virtual PP_Var GetPluginReferrerURL(PP_Instance instance, + PP_URLComponents_Dev* components) + OVERRIDE; // PPB_ContentDecryptor_Private implementation. - virtual void SessionCreated(PP_Instance instance, - uint32_t session_id, - PP_Var web_session_id_var) OVERRIDE; + virtual void PromiseResolved(PP_Instance instance, + uint32 promise_id) OVERRIDE; + virtual void PromiseResolvedWithSession(PP_Instance instance, + uint32 promise_id, + PP_Var web_session_id_var) OVERRIDE; + virtual void PromiseRejected(PP_Instance instance, + uint32 promise_id, + PP_CdmExceptionCode exception_code, + uint32 system_code, + PP_Var error_description_var) OVERRIDE; virtual void SessionMessage(PP_Instance instance, - uint32_t session_id, - PP_Var message, - PP_Var destination_url) OVERRIDE; - virtual void SessionReady(PP_Instance instance, uint32_t session_id) OVERRIDE; + PP_Var web_session_id_var, + PP_Var message_var, + PP_Var destination_url_var) OVERRIDE; + virtual void SessionReady(PP_Instance instance, + PP_Var web_session_id_var) OVERRIDE; virtual void SessionClosed(PP_Instance instance, - uint32_t session_id) OVERRIDE; + PP_Var web_session_id_var) OVERRIDE; virtual void SessionError(PP_Instance instance, - uint32_t session_id, - int32_t media_error, - int32_t system_code) OVERRIDE; + PP_Var web_session_id_var, + PP_CdmExceptionCode exception_code, + uint32 system_code, + PP_Var error_description_var) OVERRIDE; virtual void DeliverBlock(PP_Instance instance, PP_Resource decrypted_block, const PP_DecryptedBlockInfo* block_info) OVERRIDE; @@ -476,10 +499,10 @@ class CONTENT_EXPORT PepperPluginInstanceImpl virtual void DeliverFrame(PP_Instance instance, PP_Resource decrypted_frame, const PP_DecryptedFrameInfo* frame_info) OVERRIDE; - virtual void DeliverSamples( - PP_Instance instance, - PP_Resource audio_frames, - const PP_DecryptedSampleInfo* sample_info) OVERRIDE; + virtual void DeliverSamples(PP_Instance instance, + PP_Resource audio_frames, + const PP_DecryptedSampleInfo* sample_info) + OVERRIDE; // Reset this instance as proxied. Assigns the instance a new module, resets // cached interfaces to point to the out-of-process proxy and re-sends @@ -500,12 +523,16 @@ class CONTENT_EXPORT PepperPluginInstanceImpl struct _NPP* instanceNPP(); // cc::TextureLayerClient implementation. - virtual unsigned PrepareTexture() OVERRIDE; virtual bool PrepareTextureMailbox( cc::TextureMailbox* mailbox, scoped_ptr<cc::SingleReleaseCallback>* release_callback, bool use_shared_memory) OVERRIDE; + // RenderFrameObserver + virtual void OnDestruct() OVERRIDE; + + void AddLatencyInfo(const std::vector<ui::LatencyInfo>& latency_info); + private: friend class base::RefCounted<PepperPluginInstanceImpl>; friend class PpapiUnittest; @@ -528,7 +555,8 @@ class CONTENT_EXPORT PepperPluginInstanceImpl int data_length, int encoded_data_length); virtual void didFinishLoading(blink::WebURLLoader* loader, - double finish_time); + double finish_time, + int64_t total_encoded_data_length); virtual void didFail(blink::WebURLLoader* loader, const blink::WebURLError& error); @@ -548,6 +576,7 @@ class CONTENT_EXPORT PepperPluginInstanceImpl virtual ppapi::thunk::PPB_Gamepad_API* AsPPB_Gamepad_API() OVERRIDE; virtual void Sample(PP_Instance instance, PP_GamepadsSampleData* data) OVERRIDE; + private: virtual ~GamepadImpl(); }; @@ -564,7 +593,6 @@ class CONTENT_EXPORT PepperPluginInstanceImpl bool LoadFindInterface(); bool LoadInputEventInterface(); - bool LoadMessagingInterface(); bool LoadMouseLockInterface(); bool LoadPdfInterface(); bool LoadPrintInterface(); @@ -573,6 +601,9 @@ class CONTENT_EXPORT PepperPluginInstanceImpl bool LoadTextInputInterface(); bool LoadZoomInterface(); + // Update any transforms that should be applied to the texture layer. + void UpdateLayerTransform(); + // Determines if we think the plugin has focus, both content area and webkit // (see has_webkit_focus_ below). bool PluginHasFocus() const; @@ -604,7 +635,10 @@ class CONTENT_EXPORT PepperPluginInstanceImpl // - we are not in Flash full-screen mode (or transitioning to it) // Otherwise it destroys the layer. // It does either operation lazily. - void UpdateLayer(); + // device_changed: true if the bound device has been changed, and + // UpdateLayer() will be forced to recreate the layer and attaches to the + // container. + void UpdateLayer(bool device_changed); // Internal helper function for PrintPage(). bool PrintPageHelper(PP_PrintPageNumberRange_Dev* page_ranges, @@ -614,9 +648,8 @@ class CONTENT_EXPORT PepperPluginInstanceImpl void DoSetCursor(blink::WebCursorInfo* cursor); // Internal helper functions for HandleCompositionXXX(). - bool SendCompositionEventToPlugin( - PP_InputEvent_Type type, - const base::string16& text); + bool SendCompositionEventToPlugin(PP_InputEvent_Type type, + const base::string16& text); bool SendCompositionEventWithUnderlineInformationToPlugin( PP_InputEvent_Type type, const base::string16& text, @@ -647,12 +680,12 @@ class CONTENT_EXPORT PepperPluginInstanceImpl MouseLockDispatcher::LockTarget* GetOrCreateLockTargetAdapter(); void UnSetAndDeleteLockTargetAdapter(); - void DidDataFromWebURLResponse( - const blink::WebURLResponse& response, - int pending_host_id, - const ppapi::URLResponseInfoData& data); + void DidDataFromWebURLResponse(const blink::WebURLResponse& response, + int pending_host_id, + const ppapi::URLResponseInfoData& data); RenderFrameImpl* render_frame_; + base::Closure instance_deleted_callback_; scoped_refptr<PluginModule> module_; scoped_ptr<ppapi::PPP_Instance_Combined> instance_interface_; // If this is the NaCl plugin, we create a new module when we switch to the @@ -665,6 +698,7 @@ class CONTENT_EXPORT PepperPluginInstanceImpl // NULL until we have been initialized. blink::WebPluginContainer* container_; + scoped_refptr<cc::Layer> compositor_layer_; scoped_refptr<cc::TextureLayer> texture_layer_; scoped_ptr<blink::WebLayer> web_layer_; bool layer_bound_to_fullscreen_; @@ -688,9 +722,10 @@ class CONTENT_EXPORT PepperPluginInstanceImpl // same as the default values. bool sent_initial_did_change_view_; - // The current device context for painting in 2D and 3D. + // The current device context for painting in 2D, 3D or compositor. scoped_refptr<PPB_Graphics3D_Impl> bound_graphics_3d_; PepperGraphics2DHost* bound_graphics_2d_platform_; + PepperCompositorHost* bound_compositor_; // We track two types of focus, one from WebKit, which is the focus among // all elements of the page, one one from the browser, which is whether the @@ -707,9 +742,8 @@ class CONTENT_EXPORT PepperPluginInstanceImpl // The plugin-provided interfaces. // When adding PPP interfaces, make sure to reset them in ResetAsProxied. - const PPP_Find_Dev* plugin_find_interface_; + const PPP_Find_Private* plugin_find_interface_; const PPP_InputEvent* plugin_input_event_interface_; - const PPP_Messaging* plugin_messaging_interface_; const PPP_MouseLock* plugin_mouse_lock_interface_; const PPP_Pdf* plugin_pdf_interface_; const PPP_Instance_Private* plugin_private_interface_; @@ -721,7 +755,6 @@ class CONTENT_EXPORT PepperPluginInstanceImpl // corresponding interfaces, so that we can ask only once. // When adding flags, make sure to reset them in ResetAsProxied. bool checked_for_plugin_input_event_interface_; - bool checked_for_plugin_messaging_interface_; bool checked_for_plugin_pdf_interface_; // This is only valid between a successful PrintBegin call and a PrintEnd @@ -747,6 +780,7 @@ class CONTENT_EXPORT PepperPluginInstanceImpl std::vector<PP_PrintPageNumberRange_Dev> ranges_; scoped_refptr<ppapi::Resource> gamepad_impl_; + scoped_refptr<ppapi::Resource> uma_private_impl_; // The plugin print interface. const PPP_Printing_Dev* plugin_print_interface_; @@ -843,6 +877,9 @@ class CONTENT_EXPORT PepperPluginInstanceImpl // calls and handles PPB_ContentDecryptor_Private calls. scoped_ptr<ContentDecryptorDelegate> content_decryptor_delegate_; + // The link currently under the cursor. + base::string16 link_under_cursor_; + // Dummy NPP value used when calling in to WebBindings, to allow the bindings // to correctly track NPObjects belonging to this plugin instance. scoped_ptr<struct _NPP> npp_; @@ -855,6 +892,13 @@ class CONTENT_EXPORT PepperPluginInstanceImpl bool is_deleted_; + // The text that is currently selected in the plugin. + base::string16 selected_text_; + + int64 last_input_number_; + + bool is_tracking_latency_; + // We use a weak ptr factory for scheduling DidChangeView events so that we // can tell whether updates are pending and consolidate them. When there's // already a weak ptr pending (HasWeakPtrs is true), code should update the |