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_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/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 12 #include "base/process_util.h" | 12 #include "base/process_util.h" |
| 13 #include "base/sequenced_task_runner_helpers.h" | 13 #include "base/sequenced_task_runner_helpers.h" |
| 14 #if defined(OS_WIN) | 14 #if defined(OS_WIN) |
| 15 #include "base/shared_memory.h" | 15 #include "base/shared_memory.h" |
| 16 #endif | 16 #endif |
| 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 | 21 |
| 22 struct BrowserPluginHostMsg_AutoSize_Params; | |
| 22 struct BrowserPluginHostMsg_ResizeGuest_Params; | 23 struct BrowserPluginHostMsg_ResizeGuest_Params; |
| 23 struct BrowserPluginMsg_LoadCommit_Params; | 24 struct BrowserPluginMsg_LoadCommit_Params; |
| 24 struct BrowserPluginMsg_UpdateRect_Params; | 25 struct BrowserPluginMsg_UpdateRect_Params; |
| 25 | 26 |
| 26 namespace content { | 27 namespace content { |
| 27 | 28 |
| 28 class BrowserPluginManager; | 29 class BrowserPluginManager; |
| 29 class MockBrowserPlugin; | 30 class MockBrowserPlugin; |
| 30 | 31 |
| 31 class CONTENT_EXPORT BrowserPlugin : | 32 class CONTENT_EXPORT BrowserPlugin : |
| 32 NON_EXPORTED_BASE(public WebKit::WebPlugin) { | 33 NON_EXPORTED_BASE(public WebKit::WebPlugin) { |
| 33 public: | 34 public: |
| 34 // Called only by tests to clean up before we blow away the MockRenderProcess. | 35 // Called only by tests to clean up before we blow away the MockRenderProcess. |
| 35 void Cleanup(); | 36 void Cleanup(); |
| 36 | 37 |
| 37 // Get the src attribute value of the BrowserPlugin instance if the guest | 38 // Get the src attribute value of the BrowserPlugin instance. |
| 38 // has not crashed. | |
| 39 std::string GetSrcAttribute() const; | 39 std::string GetSrcAttribute() const; |
| 40 // Set the src attribute value of the BrowserPlugin instance and reset | 40 // Set the src attribute value of the BrowserPlugin instance. |
| 41 // the guest_crashed_ flag. | |
| 42 void SetSrcAttribute(const std::string& src); | 41 void SetSrcAttribute(const std::string& src); |
| 42 // Get the autosize attribute value. | |
| 43 bool GetAutoSizeAttribute() const; | |
| 44 // Sets the autosize attribute value. | |
| 45 void SetAutoSizeAttribute(bool autosize); | |
| 46 // Get the maxheight attribute value. | |
| 47 int GetMaxHeightAttribute() const; | |
| 48 // Set the maxheight attribute value. | |
| 49 void SetMaxHeightAttribute(int maxheight); | |
| 50 // Get the maxwidth attribute value. | |
| 51 int GetMaxWidthAttribute() const; | |
| 52 // Set the maxwidth attribute value. | |
| 53 void SetMaxWidthAttribute(int maxwidth); | |
| 54 // Get the minheight attribute value. | |
| 55 int GetMinHeightAttribute() const; | |
| 56 // Set the minheight attribute value. | |
| 57 void SetMinHeightAttribute(int minheight); | |
| 58 // Get the minwidth attribute value. | |
| 59 int GetMinWidthAttribute() const; | |
| 60 // Set the minwidth attribute value. | |
| 61 void SetMinWidthAttribute(int minwidth); | |
| 62 | |
| 43 // Get the guest's DOMWindow proxy. | 63 // Get the guest's DOMWindow proxy. |
| 44 NPObject* GetContentWindow() const; | 64 NPObject* GetContentWindow() const; |
| 65 | |
| 45 // Returns Chrome's process ID for the current guest. | 66 // Returns Chrome's process ID for the current guest. |
| 46 int process_id() const { return process_id_; } | 67 int process_id() const { return process_id_; } |
| 47 // The partition identifier string is stored as UTF-8. | 68 // The partition identifier string is stored as UTF-8. |
| 48 std::string GetPartitionAttribute() const; | 69 std::string GetPartitionAttribute() const; |
| 49 // Query whether the guest can navigate back to the previous entry. | 70 // Query whether the guest can navigate back to the previous entry. |
| 50 bool CanGoBack() const; | 71 bool CanGoBack() const; |
| 51 // Query whether the guest can navigation forward to the next entry. | 72 // Query whether the guest can navigation forward to the next entry. |
| 52 bool CanGoForward() const; | 73 bool CanGoForward() const; |
| 53 // This method can be successfully called only before the first navigation for | 74 // This method can be successfully called only before the first navigation for |
| 54 // this instance of BrowserPlugin. If an error occurs, the |error_message| is | 75 // this instance of BrowserPlugin. If an error occurs, the |error_message| is |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 199 | 220 |
| 200 // Triggers the event-listeners for |event_name|. | 221 // Triggers the event-listeners for |event_name|. |
| 201 void TriggerEvent(const std::string& event_name, | 222 void TriggerEvent(const std::string& event_name, |
| 202 v8::Local<v8::Object>* event); | 223 v8::Local<v8::Object>* event); |
| 203 | 224 |
| 204 // Creates and maps transport dib. Overridden in tests. | 225 // Creates and maps transport dib. Overridden in tests. |
| 205 virtual TransportDIB* CreateTransportDIB(const size_t size); | 226 virtual TransportDIB* CreateTransportDIB(const size_t size); |
| 206 // Frees up the damage buffer. Overridden in tests. | 227 // Frees up the damage buffer. Overridden in tests. |
| 207 virtual void FreeDamageBuffer(); | 228 virtual void FreeDamageBuffer(); |
| 208 | 229 |
| 230 // Populates BrowserPluginHostMsg_AutoSize_Params object with autosize state. | |
| 231 void PopulateAutoSizeParameters( | |
| 232 BrowserPluginHostMsg_AutoSize_Params* params) const; | |
| 233 // Informs the guest of an updated autosize state. | |
| 234 void UpdateGuestAutoSizeState() const; | |
| 235 | |
| 209 int instance_id_; | 236 int instance_id_; |
| 210 base::WeakPtr<RenderViewImpl> render_view_; | 237 base::WeakPtr<RenderViewImpl> render_view_; |
| 211 // We cache the |render_view_|'s routing ID because we need it on destruction. | 238 // We cache the |render_view_|'s routing ID because we need it on destruction. |
| 212 // If the |render_view_| is destroyed before the BrowserPlugin is destroyed | 239 // If the |render_view_| is destroyed before the BrowserPlugin is destroyed |
| 213 // then we will attempt to access a NULL pointer. | 240 // then we will attempt to access a NULL pointer. |
| 214 int render_view_routing_id_; | 241 int render_view_routing_id_; |
| 215 WebKit::WebPluginContainer* container_; | 242 WebKit::WebPluginContainer* container_; |
| 216 scoped_ptr<BrowserPluginBindings> bindings_; | 243 scoped_ptr<BrowserPluginBindings> bindings_; |
| 217 scoped_ptr<BrowserPluginBackingStore> backing_store_; | 244 scoped_ptr<BrowserPluginBackingStore> backing_store_; |
| 218 TransportDIB* damage_buffer_; | 245 TransportDIB* damage_buffer_; |
| 219 gfx::Rect plugin_rect_; | 246 gfx::Rect plugin_rect_; |
| 220 // Bitmap for crashed plugin. Lazily initialized, non-owning pointer. | 247 // Bitmap for crashed plugin. Lazily initialized, non-owning pointer. |
| 221 SkBitmap* sad_guest_; | 248 SkBitmap* sad_guest_; |
| 222 bool guest_crashed_; | 249 bool guest_crashed_; |
| 223 bool resize_pending_; | 250 bool resize_pending_; |
| 224 scoped_ptr<BrowserPluginHostMsg_ResizeGuest_Params> pending_resize_params_; | 251 scoped_ptr<BrowserPluginHostMsg_ResizeGuest_Params> pending_resize_params_; |
| 225 // True if we have ever sent a NavigateGuest message to the embedder. | 252 // True if we have ever sent a NavigateGuest message to the embedder. |
| 226 bool navigate_src_sent_; | 253 bool navigate_src_sent_; |
| 227 std::string src_; | 254 std::string src_; |
| 255 bool autosize_; | |
|
jam
2012/11/02 19:11:10
nit: auto_size_
also below, max_height_, max_width
Fady Samuel
2012/11/02 20:32:23
Done.
| |
| 256 int maxheight_; | |
| 257 int maxwidth_; | |
| 258 int minheight_; | |
| 259 int minwidth_; | |
| 228 int process_id_; | 260 int process_id_; |
| 229 std::string storage_partition_id_; | 261 std::string storage_partition_id_; |
| 230 bool persist_storage_; | 262 bool persist_storage_; |
| 231 int content_window_routing_id_; | 263 int content_window_routing_id_; |
| 232 bool focused_; | 264 bool focused_; |
| 233 // Tracks the visibility of the browser plugin regardless of the whole | 265 // Tracks the visibility of the browser plugin regardless of the whole |
| 234 // embedder RenderView's visibility. | 266 // embedder RenderView's visibility. |
| 235 bool visible_; | 267 bool visible_; |
| 236 typedef std::vector<v8::Local<v8::Function> > EventListenersLocal; | 268 typedef std::vector<v8::Local<v8::Function> > EventListenersLocal; |
| 237 typedef std::vector<v8::Persistent<v8::Function> > EventListeners; | 269 typedef std::vector<v8::Persistent<v8::Function> > EventListeners; |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 251 // the changes are not always obvious. For example, there is a maximum | 283 // the changes are not always obvious. For example, there is a maximum |
| 252 // number of entries and earlier ones will automatically be pruned. | 284 // number of entries and earlier ones will automatically be pruned. |
| 253 int current_nav_entry_index_; | 285 int current_nav_entry_index_; |
| 254 int nav_entry_count_; | 286 int nav_entry_count_; |
| 255 DISALLOW_COPY_AND_ASSIGN(BrowserPlugin); | 287 DISALLOW_COPY_AND_ASSIGN(BrowserPlugin); |
| 256 }; | 288 }; |
| 257 | 289 |
| 258 } // namespace content | 290 } // namespace content |
| 259 | 291 |
| 260 #endif // CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_H_ | 292 #endif // CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_H_ |
| OLD | NEW |