OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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_BROWSER_PLUGIN_BROWSER_PLUGIN_H_ | 5 #ifndef CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_H_ |
6 #define CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_H_ | 6 #define CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_H_ |
7 | 7 |
8 #include "third_party/WebKit/public/web/WebPlugin.h" | 8 #include "third_party/WebKit/public/web/WebPlugin.h" |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 struct BrowserPluginMsg_BuffersSwapped_Params; | 26 struct BrowserPluginMsg_BuffersSwapped_Params; |
27 struct BrowserPluginMsg_UpdateRect_Params; | 27 struct BrowserPluginMsg_UpdateRect_Params; |
28 | 28 |
29 namespace content { | 29 namespace content { |
30 | 30 |
31 class BrowserPluginCompositingHelper; | 31 class BrowserPluginCompositingHelper; |
32 class BrowserPluginManager; | 32 class BrowserPluginManager; |
33 class MockBrowserPlugin; | 33 class MockBrowserPlugin; |
34 | 34 |
35 class CONTENT_EXPORT BrowserPlugin : | 35 class CONTENT_EXPORT BrowserPlugin : |
36 NON_EXPORTED_BASE(public WebKit::WebPlugin), | 36 NON_EXPORTED_BASE(public blink::WebPlugin), |
37 public MouseLockDispatcher::LockTarget { | 37 public MouseLockDispatcher::LockTarget { |
38 public: | 38 public: |
39 RenderViewImpl* render_view() const { return render_view_.get(); } | 39 RenderViewImpl* render_view() const { return render_view_.get(); } |
40 int render_view_routing_id() const { return render_view_routing_id_; } | 40 int render_view_routing_id() const { return render_view_routing_id_; } |
41 int guest_instance_id() const { return guest_instance_id_; } | 41 int guest_instance_id() const { return guest_instance_id_; } |
42 bool attached() const { return attached_; } | 42 bool attached() const { return attached_; } |
43 | 43 |
44 static BrowserPlugin* FromContainer(WebKit::WebPluginContainer* container); | 44 static BrowserPlugin* FromContainer(blink::WebPluginContainer* container); |
45 | 45 |
46 bool OnMessageReceived(const IPC::Message& msg); | 46 bool OnMessageReceived(const IPC::Message& msg); |
47 | 47 |
48 // Update Browser Plugin's DOM Node attribute |attribute_name| with the value | 48 // Update Browser Plugin's DOM Node attribute |attribute_name| with the value |
49 // |attribute_value|. | 49 // |attribute_value|. |
50 void UpdateDOMAttribute(const std::string& attribute_name, | 50 void UpdateDOMAttribute(const std::string& attribute_name, |
51 const std::string& attribute_value); | 51 const std::string& attribute_value); |
52 // Remove the DOM Node attribute with the name |attribute_name|. | 52 // Remove the DOM Node attribute with the name |attribute_name|. |
53 void RemoveDOMAttribute(const std::string& attribute_name); | 53 void RemoveDOMAttribute(const std::string& attribute_name); |
54 // Get Browser Plugin's DOM Node attribute |attribute_name|'s value. | 54 // Get Browser Plugin's DOM Node attribute |attribute_name|'s value. |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 | 94 |
95 // Returns whether the guest process has crashed. | 95 // Returns whether the guest process has crashed. |
96 bool guest_crashed() const { return guest_crashed_; } | 96 bool guest_crashed() const { return guest_crashed_; } |
97 // Returns whether this BrowserPlugin has requested an instance ID. | 97 // Returns whether this BrowserPlugin has requested an instance ID. |
98 bool HasNavigated() const; | 98 bool HasNavigated() const; |
99 // Returns whether this BrowserPlugin has allocated an instance ID. | 99 // Returns whether this BrowserPlugin has allocated an instance ID. |
100 bool HasGuestInstanceID() const; | 100 bool HasGuestInstanceID() const; |
101 | 101 |
102 // Attaches the window identified by |window_id| to the the given node | 102 // Attaches the window identified by |window_id| to the the given node |
103 // encapsulating a BrowserPlugin. | 103 // encapsulating a BrowserPlugin. |
104 static bool AttachWindowTo(const WebKit::WebNode& node, | 104 static bool AttachWindowTo(const blink::WebNode& node, |
105 int window_id); | 105 int window_id); |
106 | 106 |
107 // Informs the guest of an updated focus state. | 107 // Informs the guest of an updated focus state. |
108 void UpdateGuestFocusState(); | 108 void UpdateGuestFocusState(); |
109 // Indicates whether the guest should be focused. | 109 // Indicates whether the guest should be focused. |
110 bool ShouldGuestBeFocused() const; | 110 bool ShouldGuestBeFocused() const; |
111 | 111 |
112 // Embedder's device scale factor changed, we need to update the guest | 112 // Embedder's device scale factor changed, we need to update the guest |
113 // renderer. | 113 // renderer. |
114 void UpdateDeviceScaleFactor(float device_scale_factor); | 114 void UpdateDeviceScaleFactor(float device_scale_factor); |
(...skipping 16 matching lines...) Expand all Loading... |
131 // passed in by the content embedder to the browser process. | 131 // passed in by the content embedder to the browser process. |
132 void Attach(scoped_ptr<base::DictionaryValue> extra_params); | 132 void Attach(scoped_ptr<base::DictionaryValue> extra_params); |
133 | 133 |
134 // Notify the plugin about a compositor commit so that frame ACKs could be | 134 // Notify the plugin about a compositor commit so that frame ACKs could be |
135 // sent, if needed. | 135 // sent, if needed. |
136 void DidCommitCompositorFrame(); | 136 void DidCommitCompositorFrame(); |
137 | 137 |
138 // Returns whether a message should be forwarded to BrowserPlugin. | 138 // Returns whether a message should be forwarded to BrowserPlugin. |
139 static bool ShouldForwardToBrowserPlugin(const IPC::Message& message); | 139 static bool ShouldForwardToBrowserPlugin(const IPC::Message& message); |
140 | 140 |
141 // WebKit::WebPlugin implementation. | 141 // blink::WebPlugin implementation. |
142 virtual WebKit::WebPluginContainer* container() const OVERRIDE; | 142 virtual blink::WebPluginContainer* container() const OVERRIDE; |
143 virtual bool initialize(WebKit::WebPluginContainer* container) OVERRIDE; | 143 virtual bool initialize(blink::WebPluginContainer* container) OVERRIDE; |
144 virtual void destroy() OVERRIDE; | 144 virtual void destroy() OVERRIDE; |
145 virtual NPObject* scriptableObject() OVERRIDE; | 145 virtual NPObject* scriptableObject() OVERRIDE; |
146 virtual struct _NPP* pluginNPP() OVERRIDE; | 146 virtual struct _NPP* pluginNPP() OVERRIDE; |
147 virtual bool supportsKeyboardFocus() const OVERRIDE; | 147 virtual bool supportsKeyboardFocus() const OVERRIDE; |
148 virtual bool supportsEditCommands() const OVERRIDE; | 148 virtual bool supportsEditCommands() const OVERRIDE; |
149 virtual bool canProcessDrag() const OVERRIDE; | 149 virtual bool canProcessDrag() const OVERRIDE; |
150 virtual void paint( | 150 virtual void paint( |
151 WebKit::WebCanvas* canvas, | 151 blink::WebCanvas* canvas, |
152 const WebKit::WebRect& rect) OVERRIDE; | 152 const blink::WebRect& rect) OVERRIDE; |
153 virtual void updateGeometry( | 153 virtual void updateGeometry( |
154 const WebKit::WebRect& frame_rect, | 154 const blink::WebRect& frame_rect, |
155 const WebKit::WebRect& clip_rect, | 155 const blink::WebRect& clip_rect, |
156 const WebKit::WebVector<WebKit::WebRect>& cut_outs_rects, | 156 const blink::WebVector<blink::WebRect>& cut_outs_rects, |
157 bool is_visible) OVERRIDE; | 157 bool is_visible) OVERRIDE; |
158 virtual void updateFocus(bool focused) OVERRIDE; | 158 virtual void updateFocus(bool focused) OVERRIDE; |
159 virtual void updateVisibility(bool visible) OVERRIDE; | 159 virtual void updateVisibility(bool visible) OVERRIDE; |
160 virtual bool acceptsInputEvents() OVERRIDE; | 160 virtual bool acceptsInputEvents() OVERRIDE; |
161 virtual bool handleInputEvent( | 161 virtual bool handleInputEvent( |
162 const WebKit::WebInputEvent& event, | 162 const blink::WebInputEvent& event, |
163 WebKit::WebCursorInfo& cursor_info) OVERRIDE; | 163 blink::WebCursorInfo& cursor_info) OVERRIDE; |
164 virtual bool handleDragStatusUpdate(WebKit::WebDragStatus drag_status, | 164 virtual bool handleDragStatusUpdate(blink::WebDragStatus drag_status, |
165 const WebKit::WebDragData& drag_data, | 165 const blink::WebDragData& drag_data, |
166 WebKit::WebDragOperationsMask mask, | 166 blink::WebDragOperationsMask mask, |
167 const WebKit::WebPoint& position, | 167 const blink::WebPoint& position, |
168 const WebKit::WebPoint& screen) OVERRIDE; | 168 const blink::WebPoint& screen) OVERRIDE; |
169 virtual void didReceiveResponse( | 169 virtual void didReceiveResponse( |
170 const WebKit::WebURLResponse& response) OVERRIDE; | 170 const blink::WebURLResponse& response) OVERRIDE; |
171 virtual void didReceiveData(const char* data, int data_length) OVERRIDE; | 171 virtual void didReceiveData(const char* data, int data_length) OVERRIDE; |
172 virtual void didFinishLoading() OVERRIDE; | 172 virtual void didFinishLoading() OVERRIDE; |
173 virtual void didFailLoading(const WebKit::WebURLError& error) OVERRIDE; | 173 virtual void didFailLoading(const blink::WebURLError& error) OVERRIDE; |
174 virtual void didFinishLoadingFrameRequest( | 174 virtual void didFinishLoadingFrameRequest( |
175 const WebKit::WebURL& url, | 175 const blink::WebURL& url, |
176 void* notify_data) OVERRIDE; | 176 void* notify_data) OVERRIDE; |
177 virtual void didFailLoadingFrameRequest( | 177 virtual void didFailLoadingFrameRequest( |
178 const WebKit::WebURL& url, | 178 const blink::WebURL& url, |
179 void* notify_data, | 179 void* notify_data, |
180 const WebKit::WebURLError& error) OVERRIDE; | 180 const blink::WebURLError& error) OVERRIDE; |
181 virtual bool executeEditCommand(const WebKit::WebString& name) OVERRIDE; | 181 virtual bool executeEditCommand(const blink::WebString& name) OVERRIDE; |
182 virtual bool executeEditCommand(const WebKit::WebString& name, | 182 virtual bool executeEditCommand(const blink::WebString& name, |
183 const WebKit::WebString& value) OVERRIDE; | 183 const blink::WebString& value) OVERRIDE; |
184 | 184 |
185 // MouseLockDispatcher::LockTarget implementation. | 185 // MouseLockDispatcher::LockTarget implementation. |
186 virtual void OnLockMouseACK(bool succeeded) OVERRIDE; | 186 virtual void OnLockMouseACK(bool succeeded) OVERRIDE; |
187 virtual void OnMouseLockLost() OVERRIDE; | 187 virtual void OnMouseLockLost() OVERRIDE; |
188 virtual bool HandleMouseLockedInputEvent( | 188 virtual bool HandleMouseLockedInputEvent( |
189 const WebKit::WebMouseEvent& event) OVERRIDE; | 189 const blink::WebMouseEvent& event) OVERRIDE; |
190 | 190 |
191 private: | 191 private: |
192 friend class base::DeleteHelper<BrowserPlugin>; | 192 friend class base::DeleteHelper<BrowserPlugin>; |
193 // Only the manager is allowed to create a BrowserPlugin. | 193 // Only the manager is allowed to create a BrowserPlugin. |
194 friend class BrowserPluginManagerImpl; | 194 friend class BrowserPluginManagerImpl; |
195 friend class MockBrowserPluginManager; | 195 friend class MockBrowserPluginManager; |
196 | 196 |
197 // For unit/integration tests. | 197 // For unit/integration tests. |
198 friend class MockBrowserPlugin; | 198 friend class MockBrowserPlugin; |
199 | 199 |
200 // A BrowserPlugin object is a controller that represents an instance of a | 200 // A BrowserPlugin object is a controller that represents an instance of a |
201 // browser plugin within the embedder renderer process. Each BrowserPlugin | 201 // browser plugin within the embedder renderer process. Each BrowserPlugin |
202 // within a RenderView has a unique instance_id that is used to track per- | 202 // within a RenderView has a unique instance_id that is used to track per- |
203 // BrowserPlugin state in the browser process. Once a BrowserPlugin does | 203 // BrowserPlugin state in the browser process. Once a BrowserPlugin does |
204 // an initial navigation or is attached to a newly created guest, it acquires | 204 // an initial navigation or is attached to a newly created guest, it acquires |
205 // a guest_instance_id as well. The guest instance ID uniquely identifies a | 205 // a guest_instance_id as well. The guest instance ID uniquely identifies a |
206 // guest WebContents that's hosted by this BrowserPlugin. | 206 // guest WebContents that's hosted by this BrowserPlugin. |
207 BrowserPlugin( | 207 BrowserPlugin( |
208 RenderViewImpl* render_view, | 208 RenderViewImpl* render_view, |
209 WebKit::WebFrame* frame, | 209 blink::WebFrame* frame, |
210 const WebKit::WebPluginParams& params); | 210 const blink::WebPluginParams& params); |
211 | 211 |
212 virtual ~BrowserPlugin(); | 212 virtual ~BrowserPlugin(); |
213 | 213 |
214 int width() const { return plugin_rect_.width(); } | 214 int width() const { return plugin_rect_.width(); } |
215 int height() const { return plugin_rect_.height(); } | 215 int height() const { return plugin_rect_.height(); } |
216 gfx::Rect plugin_rect() { return plugin_rect_; } | 216 gfx::Rect plugin_rect() { return plugin_rect_; } |
217 // Gets the Max Height value used for auto size. | 217 // Gets the Max Height value used for auto size. |
218 int GetAdjustedMaxHeight() const; | 218 int GetAdjustedMaxHeight() const; |
219 // Gets the Max Width value used for auto size. | 219 // Gets the Max Width value used for auto size. |
220 int GetAdjustedMaxWidth() const; | 220 int GetAdjustedMaxWidth() const; |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 // a guest WebContents. | 300 // a guest WebContents. |
301 int guest_instance_id_; | 301 int guest_instance_id_; |
302 // This indicates whether this BrowserPlugin has been attached to a | 302 // This indicates whether this BrowserPlugin has been attached to a |
303 // WebContents. | 303 // WebContents. |
304 bool attached_; | 304 bool attached_; |
305 base::WeakPtr<RenderViewImpl> render_view_; | 305 base::WeakPtr<RenderViewImpl> render_view_; |
306 // We cache the |render_view_|'s routing ID because we need it on destruction. | 306 // We cache the |render_view_|'s routing ID because we need it on destruction. |
307 // If the |render_view_| is destroyed before the BrowserPlugin is destroyed | 307 // If the |render_view_| is destroyed before the BrowserPlugin is destroyed |
308 // then we will attempt to access a NULL pointer. | 308 // then we will attempt to access a NULL pointer. |
309 int render_view_routing_id_; | 309 int render_view_routing_id_; |
310 WebKit::WebPluginContainer* container_; | 310 blink::WebPluginContainer* container_; |
311 scoped_ptr<BrowserPluginBindings> bindings_; | 311 scoped_ptr<BrowserPluginBindings> bindings_; |
312 scoped_ptr<BrowserPluginBackingStore> backing_store_; | 312 scoped_ptr<BrowserPluginBackingStore> backing_store_; |
313 scoped_ptr<base::SharedMemory> current_damage_buffer_; | 313 scoped_ptr<base::SharedMemory> current_damage_buffer_; |
314 scoped_ptr<base::SharedMemory> pending_damage_buffer_; | 314 scoped_ptr<base::SharedMemory> pending_damage_buffer_; |
315 uint32 damage_buffer_sequence_id_; | 315 uint32 damage_buffer_sequence_id_; |
316 bool paint_ack_received_; | 316 bool paint_ack_received_; |
317 gfx::Rect plugin_rect_; | 317 gfx::Rect plugin_rect_; |
318 float last_device_scale_factor_; | 318 float last_device_scale_factor_; |
319 // Bitmap for crashed plugin. Lazily initialized, non-owning pointer. | 319 // Bitmap for crashed plugin. Lazily initialized, non-owning pointer. |
320 SkBitmap* sad_guest_; | 320 SkBitmap* sad_guest_; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 base::WeakPtrFactory<BrowserPlugin> weak_ptr_factory_; | 361 base::WeakPtrFactory<BrowserPlugin> weak_ptr_factory_; |
362 | 362 |
363 std::vector<EditCommand> edit_commands_; | 363 std::vector<EditCommand> edit_commands_; |
364 | 364 |
365 DISALLOW_COPY_AND_ASSIGN(BrowserPlugin); | 365 DISALLOW_COPY_AND_ASSIGN(BrowserPlugin); |
366 }; | 366 }; |
367 | 367 |
368 } // namespace content | 368 } // namespace content |
369 | 369 |
370 #endif // CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_H_ | 370 #endif // CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_H_ |
OLD | NEW |