Chromium Code Reviews| 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 #ifndef CONTENT_RENDERER_PEPPER_PEPPER_PLUGIN_DELEGATE_IMPL_H_ | 5 #ifndef CONTENT_RENDERER_PEPPER_PEPPER_PLUGIN_DELEGATE_IMPL_H_ |
| 6 #define CONTENT_RENDERER_PEPPER_PEPPER_PLUGIN_DELEGATE_IMPL_H_ | 6 #define CONTENT_RENDERER_PEPPER_PEPPER_PLUGIN_DELEGATE_IMPL_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
| 14 #include "base/id_map.h" | 14 #include "base/id_map.h" |
| 15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
| 16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
| 17 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
| 18 #include "base/observer_list.h" | 18 #include "base/observer_list.h" |
| 19 #include "content/common/content_export.h" | 19 #include "content/common/content_export.h" |
| 20 #include "content/public/renderer/render_view_observer.h" | 20 #include "content/public/renderer/render_view_observer.h" |
| 21 #include "content/renderer/mouse_lock_dispatcher.h" | 21 #include "content/renderer/mouse_lock_dispatcher.h" |
| 22 #include "content/renderer/pepper/pepper_parent_context_provider.h" | 22 #include "content/renderer/pepper/pepper_parent_context_provider.h" |
| 23 #include "content/renderer/plugin_delegate_helper.h" | |
| 23 #include "ppapi/shared_impl/private/ppb_host_resolver_shared.h" | 24 #include "ppapi/shared_impl/private/ppb_host_resolver_shared.h" |
| 24 #include "ppapi/shared_impl/private/ppb_tcp_server_socket_shared.h" | 25 #include "ppapi/shared_impl/private/ppb_tcp_server_socket_shared.h" |
| 25 #include "ppapi/shared_impl/private/tcp_socket_private_impl.h" | 26 #include "ppapi/shared_impl/private/tcp_socket_private_impl.h" |
| 26 #include "ppapi/shared_impl/private/udp_socket_private_impl.h" | 27 #include "ppapi/shared_impl/private/udp_socket_private_impl.h" |
| 27 #include "ui/base/ime/text_input_type.h" | 28 #include "ui/base/ime/text_input_type.h" |
| 28 #include "webkit/plugins/ppapi/plugin_delegate.h" | 29 #include "webkit/plugins/ppapi/plugin_delegate.h" |
| 29 | 30 |
| 30 class FilePath; | 31 class FilePath; |
| 31 class TransportDIB; | |
| 32 | |
| 33 namespace gfx { | |
| 34 class Point; | |
| 35 class Rect; | |
| 36 } | |
| 37 | 32 |
| 38 namespace IPC { | 33 namespace IPC { |
| 39 struct ChannelHandle; | 34 struct ChannelHandle; |
| 40 } | 35 } |
| 41 | 36 |
| 42 namespace ppapi { | 37 namespace ppapi { |
| 43 class PepperFilePath; | 38 class PepperFilePath; |
| 44 class PPB_X509Certificate_Fields; | 39 class PPB_X509Certificate_Fields; |
| 45 class PpapiPermissions; | 40 class PpapiPermissions; |
| 46 } | 41 } |
| 47 | 42 |
| 48 namespace ui { | |
| 49 class Range; | |
| 50 } | |
| 51 | |
| 52 namespace webkit { | 43 namespace webkit { |
| 53 struct WebPluginInfo; | 44 struct WebPluginInfo; |
| 54 namespace ppapi { | 45 namespace ppapi { |
| 55 class PluginInstance; | 46 class PluginInstance; |
| 56 class PluginModule; | 47 class PluginModule; |
| 57 } | 48 } |
| 58 } | 49 } |
| 59 | 50 |
| 60 namespace WebKit { | 51 namespace WebKit { |
| 61 class WebGamepads; | 52 class WebGamepads; |
| 62 class WebMouseEvent; | |
| 63 struct WebCompositionUnderline; | 53 struct WebCompositionUnderline; |
| 64 } | 54 } |
| 65 | 55 |
| 66 namespace content { | 56 namespace content { |
| 67 | |
| 68 class GamepadSharedMemoryReader; | 57 class GamepadSharedMemoryReader; |
| 69 class PepperBrokerImpl; | 58 class PepperBrokerImpl; |
| 70 class PepperDeviceEnumerationEventHandler; | 59 class PepperDeviceEnumerationEventHandler; |
| 71 class PepperPluginDelegateImpl; | |
| 72 class RenderViewImpl; | 60 class RenderViewImpl; |
| 73 | 61 |
| 74 class PepperPluginDelegateImpl | 62 class PepperPluginDelegateImpl |
| 75 : public webkit::ppapi::PluginDelegate, | 63 : public webkit::ppapi::PluginDelegate, |
| 64 public PluginDelegateHelper, | |
| 76 public base::SupportsWeakPtr<PepperPluginDelegateImpl>, | 65 public base::SupportsWeakPtr<PepperPluginDelegateImpl>, |
| 77 public PepperParentContextProvider, | 66 public PepperParentContextProvider, |
| 78 public RenderViewObserver { | 67 public RenderViewObserver { |
| 79 public: | 68 public: |
| 80 explicit PepperPluginDelegateImpl(RenderViewImpl* render_view); | 69 explicit PepperPluginDelegateImpl(RenderViewImpl* render_view); |
| 81 virtual ~PepperPluginDelegateImpl(); | 70 virtual ~PepperPluginDelegateImpl(); |
| 82 | 71 |
| 83 RenderViewImpl* render_view() { return render_view_; } | 72 RenderViewImpl* render_view() { return render_view_; } |
| 84 | 73 |
| 85 // Attempts to create a PPAPI plugin for the given filepath. On success, it | |
| 86 // will return the newly-created module. | |
| 87 // | |
| 88 // There are two reasons for failure. The first is that the plugin isn't | |
| 89 // a PPAPI plugin. In this case, |*pepper_plugin_was_registered| will be set | |
| 90 // to false and the caller may want to fall back on creating an NPAPI plugin. | |
| 91 // the second is that the plugin failed to initialize. In this case, | |
| 92 // |*pepper_plugin_was_registered| will be set to true and the caller should | |
| 93 // not fall back on any other plugin types. | |
| 94 CONTENT_EXPORT scoped_refptr<webkit::ppapi::PluginModule> | |
| 95 CreatePepperPluginModule( | |
| 96 const webkit::WebPluginInfo& webplugin_info, | |
| 97 bool* pepper_plugin_was_registered); | |
| 98 | |
| 99 // Sets up the renderer host and out-of-process proxy for an external plugin | 74 // Sets up the renderer host and out-of-process proxy for an external plugin |
| 100 // module. Returns the renderer host, or NULL if it couldn't be created. | 75 // module. Returns the renderer host, or NULL if it couldn't be created. |
| 101 RendererPpapiHost* CreateExternalPluginModule( | 76 RendererPpapiHost* CreateExternalPluginModule( |
| 102 scoped_refptr<webkit::ppapi::PluginModule> module, | 77 scoped_refptr<webkit::ppapi::PluginModule> module, |
| 103 const FilePath& path, | 78 const FilePath& path, |
| 104 ppapi::PpapiPermissions permissions, | 79 ppapi::PpapiPermissions permissions, |
| 105 const IPC::ChannelHandle& channel_handle, | 80 const IPC::ChannelHandle& channel_handle, |
| 106 int plugin_child_id); | 81 int plugin_child_id); |
| 107 | 82 |
| 108 // Called by RenderView to tell us about painting events, these two functions | 83 // Removes broker from pending_connect_broker_ if present. Returns true if so. |
| 109 // just correspond to the WillInitiatePaint, DidInitiatePaint and | 84 bool StopWaitingForBrokerConnection(PepperBrokerImpl* broker); |
| 110 // DidFlushPaint hooks in RenderView. | |
| 111 void ViewWillInitiatePaint(); | |
| 112 void ViewInitiatedPaint(); | |
| 113 void ViewFlushedPaint(); | |
| 114 | 85 |
| 115 // Called by RenderView to implement the corresponding function in its base | 86 CONTENT_EXPORT int GetRoutingID() const; |
| 116 // class RenderWidget (see that for more). | 87 |
| 117 webkit::ppapi::PluginInstance* GetBitmapForOptimizedPluginPaint( | 88 typedef base::Callback<void (int /* request_id */, |
| 89 bool /* succeeded */, | |
| 90 const std::string& /* label */)> | |
| 91 OpenDeviceCallback; | |
| 92 | |
| 93 // Opens the specified device. The request ID passed into the callback will be | |
| 94 // the same as the return value. If successful, the label passed into the | |
| 95 // callback identifies a audio/video steam, which can be used to call | |
| 96 // CloseDevice() and GetSesssionID(). | |
| 97 int OpenDevice(PP_DeviceType_Dev type, | |
| 98 const std::string& device_id, | |
| 99 const OpenDeviceCallback& callback); | |
| 100 void CloseDevice(const std::string& label); | |
| 101 // Gets audio/video session ID given a label. | |
| 102 int GetSessionID(PP_DeviceType_Dev type, const std::string& label); | |
| 103 | |
| 104 private: | |
| 105 // PluginDelegateHelper implementation. | |
| 106 virtual WebKit::WebPlugin* CreatePepperWebPlugin( | |
| 107 const webkit::WebPluginInfo& webplugin_info, | |
| 108 const WebKit::WebPluginParams& params) OVERRIDE; | |
| 109 virtual void ViewWillInitiatePaint() OVERRIDE; | |
| 110 virtual void ViewInitiatedPaint() OVERRIDE; | |
| 111 virtual void ViewFlushedPaint() OVERRIDE; | |
| 112 | |
|
brettw
2012/11/30 23:18:12
When implementing a base class, don't use blank li
nilesh
2012/12/01 00:41:35
Done.
| |
| 113 virtual webkit::ppapi::PluginInstance* GetBitmapForOptimizedPluginPaint( | |
| 118 const gfx::Rect& paint_bounds, | 114 const gfx::Rect& paint_bounds, |
| 119 TransportDIB** dib, | 115 TransportDIB** dib, |
| 120 gfx::Rect* location, | 116 gfx::Rect* location, |
| 121 gfx::Rect* clip, | 117 gfx::Rect* clip, |
| 122 float* scale_factor); | 118 float* scale_factor) OVERRIDE; |
| 123 | 119 |
| 124 // Called by RenderView when ViewMsg_AsyncOpenFile_ACK. | 120 virtual void OnAsyncFileOpened(base::PlatformFileError error_code, |
| 125 void OnAsyncFileOpened(base::PlatformFileError error_code, | 121 base::PlatformFile file, |
| 126 base::PlatformFile file, | 122 int message_id) OVERRIDE; |
| 127 int message_id); | |
| 128 | 123 |
| 129 // Called by RenderView when ViewMsg_PpapiBrokerChannelCreated. | 124 virtual void OnPpapiBrokerChannelCreated( |
| 130 void OnPpapiBrokerChannelCreated(int request_id, | 125 int request_id, |
| 131 const IPC::ChannelHandle& handle); | 126 const IPC::ChannelHandle& handle) OVERRIDE; |
| 132 | 127 |
| 133 // Removes broker from pending_connect_broker_ if present. Returns true if so. | 128 virtual void OnPpapiBrokerPermissionResult(int request_id, |
| 134 bool StopWaitingForBrokerConnection(PepperBrokerImpl* broker); | 129 bool result) OVERRIDE; |
| 135 | 130 |
| 136 // Called when we know whether permission to access the PPAPI broker was | 131 virtual void OnSetFocus(bool has_focus) OVERRIDE; |
| 137 // granted. | |
| 138 void OnPpapiBrokerPermissionResult(int request_id, bool result); | |
| 139 | 132 |
| 140 // Notification that the render view has been focused or defocused. This | 133 virtual void PageVisibilityChanged(bool is_visible) OVERRIDE; |
| 141 // notifies all of the plugins. | |
| 142 void OnSetFocus(bool has_focus); | |
| 143 | 134 |
| 144 // Notification that the page visibility has changed. The default is visible. | 135 virtual bool IsPluginFocused() const OVERRIDE; |
| 145 void PageVisibilityChanged(bool is_visible); | 136 virtual gfx::Rect GetCaretBounds() const OVERRIDE; |
| 137 virtual ui::TextInputType GetTextInputType() const OVERRIDE; | |
| 138 virtual bool IsPluginAcceptingCompositionEvents() const OVERRIDE; | |
| 139 virtual bool CanComposeInline() const OVERRIDE; | |
| 140 virtual void GetSurroundingText(string16* text, | |
| 141 ui::Range* range) const OVERRIDE; | |
| 146 | 142 |
| 147 // IME status. | 143 virtual void OnImeSetComposition( |
| 148 bool IsPluginFocused() const; | |
| 149 gfx::Rect GetCaretBounds() const; | |
| 150 ui::TextInputType GetTextInputType() const; | |
| 151 bool IsPluginAcceptingCompositionEvents() const; | |
| 152 bool CanComposeInline() const; | |
| 153 void GetSurroundingText(string16* text, ui::Range* range) const; | |
| 154 | |
| 155 // IME events. | |
| 156 void OnImeSetComposition( | |
| 157 const string16& text, | 144 const string16& text, |
| 158 const std::vector<WebKit::WebCompositionUnderline>& underlines, | 145 const std::vector<WebKit::WebCompositionUnderline>& underlines, |
| 159 int selection_start, | 146 int selection_start, |
| 160 int selection_end); | 147 int selection_end) OVERRIDE; |
| 161 void OnImeConfirmComposition(const string16& text); | 148 virtual void OnImeConfirmComposition(const string16& text) OVERRIDE; |
| 162 | 149 |
| 163 // Notification that a mouse event has arrived at the render view. | 150 virtual void WillHandleMouseEvent() OVERRIDE; |
| 164 void WillHandleMouseEvent(); | |
| 165 | 151 |
| 166 // PluginDelegate implementation. | 152 // PluginDelegate implementation. |
| 167 virtual void PluginFocusChanged(webkit::ppapi::PluginInstance* instance, | 153 virtual void PluginFocusChanged(webkit::ppapi::PluginInstance* instance, |
| 168 bool focused) OVERRIDE; | 154 bool focused) OVERRIDE; |
| 169 virtual void PluginTextInputTypeChanged( | 155 virtual void PluginTextInputTypeChanged( |
| 170 webkit::ppapi::PluginInstance* instance) OVERRIDE; | 156 webkit::ppapi::PluginInstance* instance) OVERRIDE; |
| 171 virtual void PluginCaretPositionChanged( | 157 virtual void PluginCaretPositionChanged( |
| 172 webkit::ppapi::PluginInstance* instance) OVERRIDE; | 158 webkit::ppapi::PluginInstance* instance) OVERRIDE; |
| 173 virtual void PluginRequestedCancelComposition( | 159 virtual void PluginRequestedCancelComposition( |
| 174 webkit::ppapi::PluginInstance* instance) OVERRIDE; | 160 webkit::ppapi::PluginInstance* instance) OVERRIDE; |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 434 uint32 accepted_socket_id, | 420 uint32 accepted_socket_id, |
| 435 const PP_NetAddress_Private& local_addr, | 421 const PP_NetAddress_Private& local_addr, |
| 436 const PP_NetAddress_Private& remote_addr); | 422 const PP_NetAddress_Private& remote_addr); |
| 437 void OnHostResolverResolveACK( | 423 void OnHostResolverResolveACK( |
| 438 uint32 plugin_dispatcher_id, | 424 uint32 plugin_dispatcher_id, |
| 439 uint32 host_resolver_id, | 425 uint32 host_resolver_id, |
| 440 bool succeeded, | 426 bool succeeded, |
| 441 const std::string& canonical_name, | 427 const std::string& canonical_name, |
| 442 const std::vector<PP_NetAddress_Private>& net_address_list); | 428 const std::vector<PP_NetAddress_Private>& net_address_list); |
| 443 | 429 |
| 444 CONTENT_EXPORT int GetRoutingID() const; | 430 // Attempts to create a PPAPI plugin for the given filepath. On success, it |
| 431 // will return the newly-created module. | |
| 432 // | |
| 433 // There are two reasons for failure. The first is that the plugin isn't | |
| 434 // a PPAPI plugin. In this case, |*pepper_plugin_was_registered| will be set | |
| 435 // to false and the caller may want to fall back on creating an NPAPI plugin. | |
| 436 // the second is that the plugin failed to initialize. In this case, | |
| 437 // |*pepper_plugin_was_registered| will be set to true and the caller should | |
| 438 // not fall back on any other plugin types. | |
| 439 CONTENT_EXPORT scoped_refptr<webkit::ppapi::PluginModule> | |
|
brettw
2012/11/30 23:18:12
Is this CONTENT_EXPORT needed? Now that this is a
nilesh
2012/12/01 00:41:35
Done.
| |
| 440 CreatePepperPluginModule( | |
| 441 const webkit::WebPluginInfo& webplugin_info, | |
| 442 bool* pepper_plugin_was_registered); | |
| 445 | 443 |
| 446 typedef base::Callback<void (int /* request_id */, | |
| 447 bool /* succeeded */, | |
| 448 const std::string& /* label */)> | |
| 449 OpenDeviceCallback; | |
| 450 | |
| 451 // Opens the specified device. The request ID passed into the callback will be | |
| 452 // the same as the return value. If successful, the label passed into the | |
| 453 // callback identifies a audio/video steam, which can be used to call | |
| 454 // CloseDevice() and GetSesssionID(). | |
| 455 int OpenDevice(PP_DeviceType_Dev type, | |
| 456 const std::string& device_id, | |
| 457 const OpenDeviceCallback& callback); | |
| 458 void CloseDevice(const std::string& label); | |
| 459 // Gets audio/video session ID given a label. | |
| 460 int GetSessionID(PP_DeviceType_Dev type, const std::string& label); | |
| 461 | |
| 462 private: | |
| 463 // Asynchronously attempts to create a PPAPI broker for the given plugin. | 444 // Asynchronously attempts to create a PPAPI broker for the given plugin. |
| 464 scoped_refptr<PepperBrokerImpl> CreateBroker( | 445 scoped_refptr<PepperBrokerImpl> CreateBroker( |
| 465 webkit::ppapi::PluginModule* plugin_module); | 446 webkit::ppapi::PluginModule* plugin_module); |
| 466 | 447 |
| 467 // Create a new HostDispatcher for proxying, hook it to the PluginModule, | 448 // Create a new HostDispatcher for proxying, hook it to the PluginModule, |
| 468 // and perform other common initialization. | 449 // and perform other common initialization. |
| 469 RendererPpapiHost* CreateOutOfProcessModule( | 450 RendererPpapiHost* CreateOutOfProcessModule( |
| 470 webkit::ppapi::PluginModule* module, | 451 webkit::ppapi::PluginModule* module, |
| 471 const FilePath& path, | 452 const FilePath& path, |
| 472 ppapi::PpapiPermissions permissions, | 453 ppapi::PpapiPermissions permissions, |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 527 | 508 |
| 528 scoped_ptr<PepperDeviceEnumerationEventHandler> | 509 scoped_ptr<PepperDeviceEnumerationEventHandler> |
| 529 device_enumeration_event_handler_; | 510 device_enumeration_event_handler_; |
| 530 | 511 |
| 531 DISALLOW_COPY_AND_ASSIGN(PepperPluginDelegateImpl); | 512 DISALLOW_COPY_AND_ASSIGN(PepperPluginDelegateImpl); |
| 532 }; | 513 }; |
| 533 | 514 |
| 534 } // namespace content | 515 } // namespace content |
| 535 | 516 |
| 536 #endif // CONTENT_RENDERER_PEPPER_PEPPER_PLUGIN_DELEGATE_IMPL_H_ | 517 #endif // CONTENT_RENDERER_PEPPER_PEPPER_PLUGIN_DELEGATE_IMPL_H_ |
| OLD | NEW |