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/public/renderer/render_view_observer.h" | 19 #include "content/public/renderer/render_view_observer.h" |
20 #include "content/renderer/pepper/pepper_browser_connection.h" | 20 #include "content/renderer/pepper/pepper_browser_connection.h" |
21 #include "content/renderer/pepper/plugin_delegate.h" | |
22 #include "content/renderer/render_view_pepper_helper.h" | 21 #include "content/renderer/render_view_pepper_helper.h" |
| 22 #include "ipc/ipc_platform_file.h" |
23 #include "ppapi/c/pp_file_info.h" | 23 #include "ppapi/c/pp_file_info.h" |
24 #include "ppapi/c/ppb_tcp_socket.h" | 24 #include "ppapi/c/ppb_tcp_socket.h" |
25 #include "ppapi/c/private/ppb_tcp_socket_private.h" | 25 #include "ppapi/c/private/ppb_tcp_socket_private.h" |
26 #include "ppapi/shared_impl/private/ppb_tcp_server_socket_shared.h" | 26 #include "ppapi/shared_impl/private/ppb_tcp_server_socket_shared.h" |
27 #include "ppapi/shared_impl/private/tcp_socket_private_impl.h" | 27 #include "ppapi/shared_impl/private/tcp_socket_private_impl.h" |
28 #include "ui/base/ime/text_input_type.h" | 28 #include "ui/base/ime/text_input_type.h" |
29 | 29 |
30 namespace base { | 30 namespace base { |
31 class FilePath; | 31 class FilePath; |
32 } | 32 } |
33 | 33 |
34 namespace ppapi { | 34 namespace ppapi { |
35 class PepperFilePath; | 35 class PepperFilePath; |
| 36 class PpapiPermissions; |
36 class PPB_X509Certificate_Fields; | 37 class PPB_X509Certificate_Fields; |
37 namespace host { | 38 namespace host { |
38 class ResourceHost; | 39 class ResourceHost; |
39 } | 40 } |
40 } | 41 } |
41 | 42 |
42 namespace WebKit { | 43 namespace WebKit { |
43 class WebGamepads; | 44 class WebGamepads; |
| 45 class WebURLResponse; |
44 struct WebCompositionUnderline; | 46 struct WebCompositionUnderline; |
| 47 struct WebCursorInfo; |
45 } | 48 } |
46 | 49 |
47 namespace content { | 50 namespace content { |
48 class ContextProviderCommandBuffer; | 51 class ContextProviderCommandBuffer; |
49 class GamepadSharedMemoryReader; | 52 class GamepadSharedMemoryReader; |
50 class PepperBroker; | 53 class PepperBroker; |
51 class PluginModule; | 54 class PluginModule; |
52 class PPB_Broker_Impl; | 55 class PPB_Broker_Impl; |
| 56 class PPB_TCPSocket_Private_Impl; |
53 class RenderViewImpl; | 57 class RenderViewImpl; |
54 struct WebPluginInfo; | 58 struct WebPluginInfo; |
55 | 59 |
56 class PepperPluginDelegateImpl | 60 class PepperPluginDelegateImpl |
57 : public PluginDelegate, | 61 : public RenderViewPepperHelper, |
58 public RenderViewPepperHelper, | |
59 public base::SupportsWeakPtr<PepperPluginDelegateImpl>, | 62 public base::SupportsWeakPtr<PepperPluginDelegateImpl>, |
60 public RenderViewObserver { | 63 public RenderViewObserver { |
61 public: | 64 public: |
62 explicit PepperPluginDelegateImpl(RenderViewImpl* render_view); | 65 explicit PepperPluginDelegateImpl(RenderViewImpl* render_view); |
63 virtual ~PepperPluginDelegateImpl(); | 66 virtual ~PepperPluginDelegateImpl(); |
64 | 67 |
65 RenderViewImpl* render_view() { return render_view_; } | 68 RenderViewImpl* render_view() { return render_view_; } |
66 | 69 |
67 PepperBrowserConnection* pepper_browser_connection() { | 70 PepperBrowserConnection* pepper_browser_connection() { |
68 return &pepper_browser_connection_; | 71 return &pepper_browser_connection_; |
(...skipping 14 matching lines...) Expand all Loading... |
83 | 86 |
84 // Notifies that |instance| has changed the cursor. | 87 // Notifies that |instance| has changed the cursor. |
85 // This will update the cursor appearance if it is currently over the plugin | 88 // This will update the cursor appearance if it is currently over the plugin |
86 // instance. | 89 // instance. |
87 void DidChangeCursor(PepperPluginInstanceImpl* instance, | 90 void DidChangeCursor(PepperPluginInstanceImpl* instance, |
88 const WebKit::WebCursorInfo& cursor); | 91 const WebKit::WebCursorInfo& cursor); |
89 | 92 |
90 // Notifies that |instance| has received a mouse event. | 93 // Notifies that |instance| has received a mouse event. |
91 void DidReceiveMouseEvent(PepperPluginInstanceImpl* instance); | 94 void DidReceiveMouseEvent(PepperPluginInstanceImpl* instance); |
92 | 95 |
| 96 // Notification that the given plugin is focused or unfocused. |
| 97 void PluginFocusChanged(PepperPluginInstanceImpl* instance, bool focused); |
| 98 |
| 99 // Notification that the text input status of the given plugin is changed. |
| 100 void PluginTextInputTypeChanged(PepperPluginInstanceImpl* instance); |
| 101 |
| 102 // Notification that the caret position in the given plugin is changed. |
| 103 void PluginCaretPositionChanged(PepperPluginInstanceImpl* instance); |
| 104 |
| 105 // Notification that the plugin requested to cancel the current composition. |
| 106 void PluginRequestedCancelComposition(PepperPluginInstanceImpl* instance); |
| 107 |
| 108 // Notification that the text selection in the given plugin is changed. |
| 109 void PluginSelectionChanged(PepperPluginInstanceImpl* instance); |
| 110 |
| 111 // Indicates that the given instance has been created. |
| 112 void InstanceCreated(PepperPluginInstanceImpl* instance); |
| 113 |
| 114 // Indicates that the given instance is being destroyed. This is called from |
| 115 // the destructor, so it's important that the instance is not dereferenced |
| 116 // from this call. |
| 117 void InstanceDeleted(PepperPluginInstanceImpl* instance); |
| 118 |
| 119 // Sends an async IPC to open a local file. |
| 120 typedef base::Callback<void (base::PlatformFileError, base::PassPlatformFile)> |
| 121 AsyncOpenFileCallback; |
| 122 bool AsyncOpenFile(const base::FilePath& path, |
| 123 int flags, |
| 124 const AsyncOpenFileCallback& callback); |
| 125 |
| 126 // Retrieve current gamepad data. |
| 127 void SampleGamepads(WebKit::WebGamepads* data); |
| 128 |
| 129 // Notifies the plugin of the document load. This should initiate the call to |
| 130 // PPP_Instance.HandleDocumentLoad. |
| 131 // |
| 132 // The loader object should set itself on the PluginInstance as the document |
| 133 // loader using set_document_loader. |
| 134 void HandleDocumentLoad(PepperPluginInstanceImpl* instance, |
| 135 const WebKit::WebURLResponse& response); |
| 136 |
| 137 // Sets up the renderer host and out-of-process proxy for an external plugin |
| 138 // module. Returns the renderer host, or NULL if it couldn't be created. |
| 139 RendererPpapiHost* CreateExternalPluginModule( |
| 140 scoped_refptr<PluginModule> module, |
| 141 const base::FilePath& path, |
| 142 ::ppapi::PpapiPermissions permissions, |
| 143 const IPC::ChannelHandle& channel_handle, |
| 144 base::ProcessId plugin_pid, |
| 145 int plugin_child_id); |
| 146 |
93 private: | 147 private: |
94 // RenderViewPepperHelper implementation. | 148 // RenderViewPepperHelper implementation. |
95 virtual WebKit::WebPlugin* CreatePepperWebPlugin( | 149 virtual WebKit::WebPlugin* CreatePepperWebPlugin( |
96 const WebPluginInfo& webplugin_info, | 150 const WebPluginInfo& webplugin_info, |
97 const WebKit::WebPluginParams& params) OVERRIDE; | 151 const WebKit::WebPluginParams& params) OVERRIDE; |
98 virtual void ViewWillInitiatePaint() OVERRIDE; | 152 virtual void ViewWillInitiatePaint() OVERRIDE; |
99 virtual void ViewInitiatedPaint() OVERRIDE; | 153 virtual void ViewInitiatedPaint() OVERRIDE; |
100 virtual void ViewFlushedPaint() OVERRIDE; | 154 virtual void ViewFlushedPaint() OVERRIDE; |
101 virtual PepperPluginInstanceImpl* GetBitmapForOptimizedPluginPaint( | 155 virtual PepperPluginInstanceImpl* GetBitmapForOptimizedPluginPaint( |
102 const gfx::Rect& paint_bounds, | 156 const gfx::Rect& paint_bounds, |
(...skipping 11 matching lines...) Expand all Loading... |
114 virtual void GetSurroundingText(string16* text, | 168 virtual void GetSurroundingText(string16* text, |
115 ui::Range* range) const OVERRIDE; | 169 ui::Range* range) const OVERRIDE; |
116 virtual void OnImeSetComposition( | 170 virtual void OnImeSetComposition( |
117 const string16& text, | 171 const string16& text, |
118 const std::vector<WebKit::WebCompositionUnderline>& underlines, | 172 const std::vector<WebKit::WebCompositionUnderline>& underlines, |
119 int selection_start, | 173 int selection_start, |
120 int selection_end) OVERRIDE; | 174 int selection_end) OVERRIDE; |
121 virtual void OnImeConfirmComposition(const string16& text) OVERRIDE; | 175 virtual void OnImeConfirmComposition(const string16& text) OVERRIDE; |
122 virtual void WillHandleMouseEvent() OVERRIDE; | 176 virtual void WillHandleMouseEvent() OVERRIDE; |
123 | 177 |
124 // PluginDelegate implementation. | |
125 virtual void PluginFocusChanged(PepperPluginInstanceImpl* instance, | |
126 bool focused) OVERRIDE; | |
127 virtual void PluginTextInputTypeChanged( | |
128 PepperPluginInstanceImpl* instance) OVERRIDE; | |
129 virtual void PluginCaretPositionChanged( | |
130 PepperPluginInstanceImpl* instance) OVERRIDE; | |
131 virtual void PluginRequestedCancelComposition( | |
132 PepperPluginInstanceImpl* instance) OVERRIDE; | |
133 virtual void PluginSelectionChanged( | |
134 PepperPluginInstanceImpl* instance) OVERRIDE; | |
135 virtual void InstanceCreated(PepperPluginInstanceImpl* instance) OVERRIDE; | |
136 virtual void InstanceDeleted(PepperPluginInstanceImpl* instance) OVERRIDE; | |
137 virtual bool AsyncOpenFile(const base::FilePath& path, | |
138 int flags, | |
139 const AsyncOpenFileCallback& callback) OVERRIDE; | |
140 virtual scoped_refptr<base::MessageLoopProxy> | |
141 GetFileThreadMessageLoopProxy() OVERRIDE; | |
142 virtual void SampleGamepads(WebKit::WebGamepads* data) OVERRIDE; | |
143 virtual void HandleDocumentLoad( | |
144 PepperPluginInstanceImpl* instance, | |
145 const WebKit::WebURLResponse& response) OVERRIDE; | |
146 virtual RendererPpapiHost* CreateExternalPluginModule( | |
147 scoped_refptr<PluginModule> module, | |
148 const base::FilePath& path, | |
149 ::ppapi::PpapiPermissions permissions, | |
150 const IPC::ChannelHandle& channel_handle, | |
151 base::ProcessId plugin_pid, | |
152 int plugin_child_id) OVERRIDE; | |
153 | |
154 // RenderViewObserver implementation. | 178 // RenderViewObserver implementation. |
155 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 179 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
156 virtual void OnDestruct() OVERRIDE; | 180 virtual void OnDestruct() OVERRIDE; |
157 | 181 |
158 void OnTCPSocketConnectACK(uint32 plugin_dispatcher_id, | 182 void OnTCPSocketConnectACK(uint32 plugin_dispatcher_id, |
159 uint32 socket_id, | 183 uint32 socket_id, |
160 int32_t result, | 184 int32_t result, |
161 const PP_NetAddress_Private& local_addr, | 185 const PP_NetAddress_Private& local_addr, |
162 const PP_NetAddress_Private& remote_addr); | 186 const PP_NetAddress_Private& remote_addr); |
163 void OnTCPSocketSSLHandshakeACK( | 187 void OnTCPSocketSSLHandshakeACK( |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 scoped_ptr<GamepadSharedMemoryReader> gamepad_shared_memory_reader_; | 281 scoped_ptr<GamepadSharedMemoryReader> gamepad_shared_memory_reader_; |
258 | 282 |
259 scoped_refptr<ContextProviderCommandBuffer> offscreen_context3d_; | 283 scoped_refptr<ContextProviderCommandBuffer> offscreen_context3d_; |
260 | 284 |
261 DISALLOW_COPY_AND_ASSIGN(PepperPluginDelegateImpl); | 285 DISALLOW_COPY_AND_ASSIGN(PepperPluginDelegateImpl); |
262 }; | 286 }; |
263 | 287 |
264 } // namespace content | 288 } // namespace content |
265 | 289 |
266 #endif // CONTENT_RENDERER_PEPPER_PEPPER_PLUGIN_DELEGATE_IMPL_H_ | 290 #endif // CONTENT_RENDERER_PEPPER_PEPPER_PLUGIN_DELEGATE_IMPL_H_ |
OLD | NEW |