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_BROWSER_PLUGIN_BROWSER_PLUGIN_H_ | 5 #ifndef CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_IMPL_H_ |
6 #define CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_H_ | 6 #define CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_IMPL_H_ |
7 | |
8 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPlugin.h" | |
9 | 7 |
10 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
11 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
10 #include "base/observer_list.h" | |
12 #include "base/process_util.h" | 11 #include "base/process_util.h" |
13 #include "base/sequenced_task_runner_helpers.h" | 12 #include "base/sequenced_task_runner_helpers.h" |
14 #if defined(OS_WIN) | 13 #if defined(OS_WIN) |
15 #include "base/shared_memory.h" | 14 #include "base/shared_memory.h" |
16 #endif | 15 #endif |
16 #include "content/public/renderer/browser_plugin/browser_plugin.h" | |
17 #include "content/renderer/browser_plugin/browser_plugin_backing_store.h" | 17 #include "content/renderer/browser_plugin/browser_plugin_backing_store.h" |
18 #include "content/renderer/browser_plugin/browser_plugin_bindings.h" | 18 #include "content/renderer/browser_plugin/browser_plugin_bindings.h" |
19 #include "content/renderer/render_view_impl.h" | 19 #include "content/renderer/render_view_impl.h" |
20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDragStatus.h" | 20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDragStatus.h" |
21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPlugin.h" | |
21 | 22 |
22 struct BrowserPluginHostMsg_AutoSize_Params; | 23 struct BrowserPluginHostMsg_AutoSize_Params; |
23 struct BrowserPluginHostMsg_ResizeGuest_Params; | 24 struct BrowserPluginHostMsg_ResizeGuest_Params; |
24 struct BrowserPluginMsg_LoadCommit_Params; | 25 struct BrowserPluginMsg_LoadCommit_Params; |
25 struct BrowserPluginMsg_UpdateRect_Params; | 26 struct BrowserPluginMsg_UpdateRect_Params; |
26 | 27 |
27 namespace content { | 28 namespace content { |
28 | 29 |
29 class BrowserPluginManager; | 30 class BrowserPluginManager; |
31 class BrowserPluginObserver; | |
30 class MockBrowserPlugin; | 32 class MockBrowserPlugin; |
31 | 33 |
32 class CONTENT_EXPORT BrowserPlugin : | 34 class CONTENT_EXPORT BrowserPluginImpl : |
33 NON_EXPORTED_BASE(public WebKit::WebPlugin) { | 35 NON_EXPORTED_BASE(public WebKit::WebPlugin), |
36 public BrowserPlugin { | |
34 public: | 37 public: |
35 RenderViewImpl* render_view() const { return render_view_.get(); } | 38 RenderViewImpl* render_view() const { return render_view_.get(); } |
36 | 39 |
37 bool OnMessageReceived(const IPC::Message& msg); | 40 bool OnMessageReceived(const IPC::Message& msg); |
38 | 41 |
39 // Update Browser Plugin's DOM Node attribute |attribute_name| with the value | 42 // Update Browser Plugin's DOM Node attribute |attribute_name| with the value |
40 // |attribute_value|. | 43 // |attribute_value|. |
41 void UpdateDOMAttribute(const std::string& attribute_name, | 44 void UpdateDOMAttribute(const std::string& attribute_name, |
42 const std::string& attribute_value); | 45 const std::string& attribute_value); |
43 | 46 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
111 void EnableCompositing(bool enable); | 114 void EnableCompositing(bool enable); |
112 | 115 |
113 // Returns true if |point| lies within the bounds of the plugin rectangle. | 116 // Returns true if |point| lies within the bounds of the plugin rectangle. |
114 // Not OK to use this function for making security-sensitive decision since it | 117 // Not OK to use this function for making security-sensitive decision since it |
115 // can return false positives when the plugin has rotation transformation | 118 // can return false positives when the plugin has rotation transformation |
116 // applied. | 119 // applied. |
117 bool InBounds(const gfx::Point& point) const; | 120 bool InBounds(const gfx::Point& point) const; |
118 | 121 |
119 gfx::Point ToLocalCoordinates(const gfx::Point& point) const; | 122 gfx::Point ToLocalCoordinates(const gfx::Point& point) const; |
120 | 123 |
124 // BrowserPlugin implementation. | |
125 | |
sadrul
2013/01/09 15:21:54
remove newline
Fady Samuel
2013/01/09 17:41:24
Done.
| |
126 virtual void AddMethodBinding( | |
127 BrowserPluginMethodBinding* method_binding) OVERRIDE; | |
128 virtual void AddPropertyBinding( | |
129 BrowserPluginPropertyBinding* method_binding) OVERRIDE; | |
130 virtual bool Send(IPC::Message* message) OVERRIDE; | |
sadrul
2013/01/09 15:21:54
It might make more sense to group the IPC::Sender
Fady Samuel
2013/01/09 17:41:24
Done.
| |
131 virtual void RequestMessage(uint32 message_id) OVERRIDE; | |
132 | |
121 // WebKit::WebPlugin implementation. | 133 // WebKit::WebPlugin implementation. |
122 virtual WebKit::WebPluginContainer* container() const OVERRIDE; | 134 virtual WebKit::WebPluginContainer* container() const OVERRIDE; |
123 virtual bool initialize(WebKit::WebPluginContainer* container) OVERRIDE; | 135 virtual bool initialize(WebKit::WebPluginContainer* container) OVERRIDE; |
124 virtual void destroy() OVERRIDE; | 136 virtual void destroy() OVERRIDE; |
125 virtual NPObject* scriptableObject() OVERRIDE; | 137 virtual NPObject* scriptableObject() OVERRIDE; |
126 virtual bool supportsKeyboardFocus() const OVERRIDE; | 138 virtual bool supportsKeyboardFocus() const OVERRIDE; |
127 virtual bool canProcessDrag() const OVERRIDE; | 139 virtual bool canProcessDrag() const OVERRIDE; |
128 virtual void paint( | 140 virtual void paint( |
129 WebKit::WebCanvas* canvas, | 141 WebKit::WebCanvas* canvas, |
130 const WebKit::WebRect& rect) OVERRIDE; | 142 const WebKit::WebRect& rect) OVERRIDE; |
(...skipping 19 matching lines...) Expand all Loading... | |
150 virtual void didFinishLoading() OVERRIDE; | 162 virtual void didFinishLoading() OVERRIDE; |
151 virtual void didFailLoading(const WebKit::WebURLError& error) OVERRIDE; | 163 virtual void didFailLoading(const WebKit::WebURLError& error) OVERRIDE; |
152 virtual void didFinishLoadingFrameRequest( | 164 virtual void didFinishLoadingFrameRequest( |
153 const WebKit::WebURL& url, | 165 const WebKit::WebURL& url, |
154 void* notify_data) OVERRIDE; | 166 void* notify_data) OVERRIDE; |
155 virtual void didFailLoadingFrameRequest( | 167 virtual void didFailLoadingFrameRequest( |
156 const WebKit::WebURL& url, | 168 const WebKit::WebURL& url, |
157 void* notify_data, | 169 void* notify_data, |
158 const WebKit::WebURLError& error) OVERRIDE; | 170 const WebKit::WebURLError& error) OVERRIDE; |
159 private: | 171 private: |
160 friend class base::DeleteHelper<BrowserPlugin>; | 172 friend class base::DeleteHelper<BrowserPluginImpl>; |
161 // Only the manager is allowed to create a BrowserPlugin. | 173 // Only the manager is allowed to create a BrowserPlugin. |
162 friend class BrowserPluginManagerImpl; | 174 friend class BrowserPluginManagerImpl; |
175 friend class BrowserPluginObserver; | |
163 friend class MockBrowserPluginManager; | 176 friend class MockBrowserPluginManager; |
164 | 177 |
165 // For unit/integration tests. | 178 // For unit/integration tests. |
166 friend class MockBrowserPlugin; | 179 friend class MockBrowserPlugin; |
167 | 180 |
168 // A BrowserPlugin object is a controller that represents an instance of a | 181 // A BrowserPlugin object is a controller that represents an instance of a |
sadrul
2013/01/09 15:21:54
Update comment
Fady Samuel
2013/01/09 17:41:24
Done.
| |
169 // browser plugin within the embedder renderer process. Each BrowserPlugin | 182 // browser plugin within the embedder renderer process. Each BrowserPlugin |
170 // within a process has a unique instance_id that is used to route messages | 183 // within a process has a unique instance_id that is used to route messages |
171 // to it. It takes in a RenderViewImpl that it's associated with along | 184 // to it. It takes in a RenderViewImpl that it's associated with along |
172 // with the frame within which it lives and the initial attributes assigned | 185 // with the frame within which it lives and the initial attributes assigned |
173 // to it on creation. | 186 // to it on creation. |
174 BrowserPlugin( | 187 BrowserPluginImpl( |
175 int instance_id, | 188 int instance_id, |
176 RenderViewImpl* render_view, | 189 RenderViewImpl* render_view, |
177 WebKit::WebFrame* frame, | 190 WebKit::WebFrame* frame, |
178 const WebKit::WebPluginParams& params); | 191 const WebKit::WebPluginParams& params); |
179 | 192 |
180 virtual ~BrowserPlugin(); | 193 virtual ~BrowserPluginImpl(); |
194 | |
195 // Add and remove observers for filtering IPC messages. Clients must be sure | |
sadrul
2013/01/09 15:21:54
single space after the dot
Fady Samuel
2013/01/09 17:41:24
Done.
| |
196 // to remove the observer before they go away. | |
197 void AddObserver(BrowserPluginObserver* observer); | |
198 void RemoveObserver(BrowserPluginObserver* observer); | |
181 | 199 |
182 int width() const { return plugin_rect_.width(); } | 200 int width() const { return plugin_rect_.width(); } |
183 int height() const { return plugin_rect_.height(); } | 201 int height() const { return plugin_rect_.height(); } |
184 int instance_id() const { return instance_id_; } | 202 int instance_id() const { return instance_id_; } |
185 int render_view_routing_id() const { return render_view_routing_id_; } | 203 int render_view_routing_id() const { return render_view_routing_id_; } |
186 BrowserPluginManager* browser_plugin_manager() const { | 204 BrowserPluginManager* browser_plugin_manager() const { |
187 return browser_plugin_manager_; | 205 return browser_plugin_manager_; |
188 } | 206 } |
189 | 207 |
190 // Virtual to allow for mocking in tests. | 208 // Virtual to allow for mocking in tests. |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
303 WebCursor cursor_; | 321 WebCursor cursor_; |
304 | 322 |
305 gfx::Size last_view_size_; | 323 gfx::Size last_view_size_; |
306 bool size_changed_in_flight_; | 324 bool size_changed_in_flight_; |
307 | 325 |
308 // BrowserPlugin outlives RenderViewImpl in Chrome Apps and so we need to | 326 // BrowserPlugin outlives RenderViewImpl in Chrome Apps and so we need to |
309 // store the BrowserPlugin's BrowserPluginManager in a member variable to | 327 // store the BrowserPlugin's BrowserPluginManager in a member variable to |
310 // avoid accessing the RenderViewImpl. | 328 // avoid accessing the RenderViewImpl. |
311 scoped_refptr<BrowserPluginManager> browser_plugin_manager_; | 329 scoped_refptr<BrowserPluginManager> browser_plugin_manager_; |
312 | 330 |
331 // A list of observers that filter messages. Weak references. | |
sadrul
2013/01/09 15:21:54
ditto
Fady Samuel
2013/01/09 17:41:24
Done.
| |
332 ObserverList<BrowserPluginObserver> observers_; | |
333 | |
313 // Important: Do not add more history state here. | 334 // Important: Do not add more history state here. |
314 // We strongly discourage storing additional history state (such as page IDs) | 335 // We strongly discourage storing additional history state (such as page IDs) |
315 // in the embedder process, at the risk of having incorrect information that | 336 // in the embedder process, at the risk of having incorrect information that |
316 // can lead to broken back/forward logic in apps. | 337 // can lead to broken back/forward logic in apps. |
317 // It's also important that this state does not get modified by any logic in | 338 // It's also important that this state does not get modified by any logic in |
318 // the embedder process. It should only be updated in response to navigation | 339 // the embedder process. It should only be updated in response to navigation |
319 // events in the guest. No assumptions should be made about how the index | 340 // events in the guest. No assumptions should be made about how the index |
320 // will change after a navigation (e.g., for back, forward, or go), because | 341 // will change after a navigation (e.g., for back, forward, or go), because |
321 // the changes are not always obvious. For example, there is a maximum | 342 // the changes are not always obvious. For example, there is a maximum |
322 // number of entries and earlier ones will automatically be pruned. | 343 // number of entries and earlier ones will automatically be pruned. |
323 int current_nav_entry_index_; | 344 int current_nav_entry_index_; |
324 int nav_entry_count_; | 345 int nav_entry_count_; |
325 | 346 |
326 // Used for HW compositing. | 347 // Used for HW compositing. |
327 bool compositing_enabled_; | 348 bool compositing_enabled_; |
328 | 349 |
329 DISALLOW_COPY_AND_ASSIGN(BrowserPlugin); | 350 DISALLOW_COPY_AND_ASSIGN(BrowserPluginImpl); |
330 }; | 351 }; |
331 | 352 |
332 } // namespace content | 353 } // namespace content |
333 | 354 |
334 #endif // CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_H_ | 355 #endif // CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_IMPL_H_ |
OLD | NEW |