| 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_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/Source/WebKit/chromium/public/WebPlugin.h" | 8 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPlugin.h" |
| 9 | 9 |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/sequenced_task_runner_helpers.h" | 11 #include "base/sequenced_task_runner_helpers.h" |
| 12 #include "content/renderer/browser_plugin/browser_plugin_backing_store.h" | 12 #include "content/renderer/browser_plugin/browser_plugin_backing_store.h" |
| 13 #include "content/renderer/browser_plugin/browser_plugin_bindings.h" | 13 #include "content/renderer/browser_plugin/browser_plugin_bindings.h" |
| 14 #include "content/renderer/render_view_impl.h" | 14 #include "content/renderer/render_view_impl.h" |
| 15 #include "ipc/ipc_forwarding_message_filter.h" |
| 15 | 16 |
| 16 struct BrowserPluginMsg_UpdateRect_Params; | 17 struct BrowserPluginMsg_UpdateRect_Params; |
| 18 struct BrowserPlugin_SwapInfo; |
| 19 |
| 20 namespace gfx { |
| 21 class Size; |
| 22 } |
| 17 | 23 |
| 18 namespace content { | 24 namespace content { |
| 19 | 25 |
| 20 class BrowserPluginManager; | 26 class BrowserPluginManager; |
| 27 class BrowserPluginTextureProvider; |
| 21 class MockBrowserPlugin; | 28 class MockBrowserPlugin; |
| 22 | 29 |
| 23 class CONTENT_EXPORT BrowserPlugin : | 30 class CONTENT_EXPORT BrowserPlugin : |
| 24 NON_EXPORTED_BASE(public WebKit::WebPlugin) { | 31 NON_EXPORTED_BASE(public WebKit::WebPlugin) { |
| 25 public: | 32 public: |
| 26 // Called only by tests to clean up before we blow away the MockRenderProcess. | 33 // Called only by tests to clean up before we blow away the MockRenderProcess. |
| 27 void Cleanup(); | 34 void Cleanup(); |
| 28 | 35 |
| 29 // Get the src attribute value of the BrowserPlugin instance if the guest | 36 // Get the src attribute value of the BrowserPlugin instance if the guest |
| 30 // has not crashed. | 37 // has not crashed. |
| 31 std::string GetSrcAttribute() const; | 38 std::string GetSrcAttribute() const; |
| 32 // Set the src attribute value of the BrowserPlugin instance and reset | 39 // Set the src attribute value of the BrowserPlugin instance and reset |
| 33 // the guest_crashed_ flag. | 40 // the guest_crashed_ flag. |
| 34 void SetSrcAttribute(const std::string& src); | 41 void SetSrcAttribute(const std::string& src); |
| 35 | 42 |
| 36 // Inform the BrowserPlugin to update its backing store with the pixels in | 43 // Inform the BrowserPlugin to update its backing store with the pixels in |
| 37 // its damage buffer. | 44 // its damage buffer. |
| 38 void UpdateRect(int message_id, | 45 void UpdateRect(int message_id, |
| 39 const BrowserPluginMsg_UpdateRect_Params& params); | 46 const BrowserPluginMsg_UpdateRect_Params& params); |
| 40 // Inform the BrowserPlugin that its guest has crashed. | 47 // Inform the BrowserPlugin that its guest has crashed. |
| 41 void GuestCrashed(); | 48 void GuestCrashed(); |
| 42 // Informs the BrowserPlugin that the guest has navigated to a new URL. | 49 // Informs the BrowserPlugin that the guest has navigated to a new URL. |
| 43 void DidNavigate(const GURL& url); | 50 void DidNavigate(const GURL& url); |
| 44 // Tells the BrowserPlugin to advance the focus to the next (or previous) | 51 // Tells the BrowserPlugin to advance the focus to the next (or previous) |
| 45 // element. | 52 // element. |
| 46 void AdvanceFocus(bool reverse); | 53 void AdvanceFocus(bool reverse); |
| 54 void BuffersSwapped( |
| 55 uint64 surface_handle, |
| 56 const BrowserPlugin_SwapInfo& info); |
| 57 void SurfaceResize(const gfx::Size& size); |
| 58 void PostMessage(const std::string& message, |
| 59 const std::string& target_origin); |
| 60 |
| 61 void TextureProviderIsReady(); |
| 47 | 62 |
| 48 // Indicates whether there are any Javascript listeners attached to a | 63 // Indicates whether there are any Javascript listeners attached to a |
| 49 // provided event_name. | 64 // provided event_name. |
| 50 bool HasListeners(const std::string& event_name); | 65 bool HasListeners(const std::string& event_name); |
| 51 // Add a custom event listener to this BrowserPlugin instance. | 66 // Add a custom event listener to this BrowserPlugin instance. |
| 52 bool AddEventListener(const std::string& event_name, | 67 bool AddEventListener(const std::string& event_name, |
| 53 v8::Local<v8::Function> function); | 68 v8::Local<v8::Function> function); |
| 54 // Remove a custom event listener from this BrowserPlugin instance. | 69 // Remove a custom event listener from this BrowserPlugin instance. |
| 55 bool RemoveEventListener(const std::string& event_name, | 70 bool RemoveEventListener(const std::string& event_name, |
| 56 v8::Local<v8::Function> function); | 71 v8::Local<v8::Function> function); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 WebKit::WebFrame* frame, | 123 WebKit::WebFrame* frame, |
| 109 const WebKit::WebPluginParams& params); | 124 const WebKit::WebPluginParams& params); |
| 110 | 125 |
| 111 virtual ~BrowserPlugin(); | 126 virtual ~BrowserPlugin(); |
| 112 | 127 |
| 113 int width() const { return plugin_rect_.width(); } | 128 int width() const { return plugin_rect_.width(); } |
| 114 int height() const { return plugin_rect_.height(); } | 129 int height() const { return plugin_rect_.height(); } |
| 115 | 130 |
| 116 // Virtual to allow for mocking in tests. | 131 // Virtual to allow for mocking in tests. |
| 117 virtual float GetDeviceScaleFactor() const; | 132 virtual float GetDeviceScaleFactor() const; |
| 133 virtual BrowserPluginTextureProvider* CreateTextureProvider( |
| 134 int instance_id, |
| 135 int routing_id) const; |
| 118 | 136 |
| 119 // Parses the source URL of the browser plugin from the element's attributes | 137 // Parses the source URL of the browser plugin from the element's attributes |
| 120 // and outputs them. | 138 // and outputs them. |
| 121 bool ParseSrcAttribute(const WebKit::WebPluginParams& params, | 139 bool ParseSrcAttribute(const WebKit::WebPluginParams& params, |
| 122 std::string* src); | 140 std::string* src); |
| 123 | 141 |
| 124 // Cleanup event listener state to free v8 resources when a BrowserPlugin | 142 // Cleanup event listener state to free v8 resources when a BrowserPlugin |
| 125 // is destroyed. | 143 // is destroyed. |
| 126 void RemoveEventListeners(); | 144 void RemoveEventListeners(); |
| 127 | 145 |
| 128 int instance_id_; | 146 int instance_id_; |
| 129 RenderViewImpl* render_view_; | 147 RenderViewImpl* render_view_; |
| 130 WebKit::WebPluginContainer* container_; | 148 WebKit::WebPluginContainer* container_; |
| 131 scoped_ptr<BrowserPluginBindings> bindings_; | 149 scoped_ptr<BrowserPluginBindings> bindings_; |
| 132 scoped_ptr<BrowserPluginBackingStore> backing_store_; | 150 scoped_ptr<BrowserPluginBackingStore> backing_store_; |
| 133 TransportDIB* damage_buffer_; | 151 TransportDIB* damage_buffer_; |
| 134 gfx::Rect plugin_rect_; | 152 gfx::Rect plugin_rect_; |
| 135 // Bitmap for crashed plugin. Lazily initialized, non-owning pointer. | 153 // Bitmap for crashed plugin. Lazily initialized, non-owning pointer. |
| 136 SkBitmap* sad_guest_; | 154 SkBitmap* sad_guest_; |
| 137 bool guest_crashed_; | 155 bool guest_crashed_; |
| 138 bool resize_pending_; | 156 bool resize_pending_; |
| 139 int64 parent_frame_; | 157 int64 parent_frame_; |
| 140 std::string src_; | 158 std::string src_; |
| 159 BrowserPluginTextureProvider* provider_; |
| 160 bool ignore_input_; |
| 141 typedef std::vector<v8::Persistent<v8::Function> > EventListeners; | 161 typedef std::vector<v8::Persistent<v8::Function> > EventListeners; |
| 142 typedef std::map<std::string, EventListeners> EventListenerMap; | 162 typedef std::map<std::string, EventListeners> EventListenerMap; |
| 143 EventListenerMap event_listener_map_; | 163 EventListenerMap event_listener_map_; |
| 144 DISALLOW_COPY_AND_ASSIGN(BrowserPlugin); | 164 DISALLOW_COPY_AND_ASSIGN(BrowserPlugin); |
| 145 }; | 165 }; |
| 146 | 166 |
| 147 } // namespace content | 167 } // namespace content |
| 148 | 168 |
| 149 #endif // CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_H_ | 169 #endif // CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_H_ |
| OLD | NEW |