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" |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 bool ShouldGuestBeFocused() const; | 108 bool ShouldGuestBeFocused() const; |
109 | 109 |
110 // Inform the BrowserPlugin that the guest's contentWindow is ready, | 110 // Inform the BrowserPlugin that the guest's contentWindow is ready, |
111 // and provide it with a routing ID to grab it. | 111 // and provide it with a routing ID to grab it. |
112 void GuestContentWindowReady(int content_window_routing_id); | 112 void GuestContentWindowReady(int content_window_routing_id); |
113 | 113 |
114 // Informs the BrowserPlugin that the guest has started/stopped accepting | 114 // Informs the BrowserPlugin that the guest has started/stopped accepting |
115 // touch events. | 115 // touch events. |
116 void SetAcceptTouchEvents(bool accept); | 116 void SetAcceptTouchEvents(bool accept); |
117 | 117 |
118 // Indicates whether there are any Javascript listeners attached to a | |
119 // provided event_name. | |
120 bool HasListeners(const std::string& event_name); | |
121 // Add a custom event listener to this BrowserPlugin instance. | |
122 bool AddEventListener(const std::string& event_name, | |
123 v8::Local<v8::Function> function); | |
124 // Remove a custom event listener from this BrowserPlugin instance. | |
125 bool RemoveEventListener(const std::string& event_name, | |
126 v8::Local<v8::Function> function); | |
127 // Tells the BrowserPlugin to tell the guest to navigate to the previous | 118 // Tells the BrowserPlugin to tell the guest to navigate to the previous |
128 // navigation entry in the navigation history. | 119 // navigation entry in the navigation history. |
129 void Back(); | 120 void Back(); |
130 // Tells the BrowserPlugin to tell the guest to navigate to the next | 121 // Tells the BrowserPlugin to tell the guest to navigate to the next |
131 // navigation entry in the navigation history. | 122 // navigation entry in the navigation history. |
132 void Forward(); | 123 void Forward(); |
133 // Tells the BrowserPlugin to tell the guest to navigate to a position | 124 // Tells the BrowserPlugin to tell the guest to navigate to a position |
134 // relative to the current index in its navigation history. | 125 // relative to the current index in its navigation history. |
135 void Go(int relativeIndex); | 126 void Go(int relativeIndex); |
136 // Tells the BrowserPlugin to terminate the guest process. | 127 // Tells the BrowserPlugin to terminate the guest process. |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 // Initializes the valid events. | 213 // Initializes the valid events. |
223 void InitializeEvents(); | 214 void InitializeEvents(); |
224 | 215 |
225 // Cleanup event listener state to free v8 resources when a BrowserPlugin | 216 // Cleanup event listener state to free v8 resources when a BrowserPlugin |
226 // is destroyed. | 217 // is destroyed. |
227 void RemoveEventListeners(); | 218 void RemoveEventListeners(); |
228 | 219 |
229 // Returns whether |event_name| is a valid event. | 220 // Returns whether |event_name| is a valid event. |
230 bool IsValidEvent(const std::string& event_name); | 221 bool IsValidEvent(const std::string& event_name); |
231 | 222 |
232 // Triggers the event-listeners for |event_name|. | 223 // Triggers the event-listeners for |event_name|. Note that the function |
| 224 // frees all the values in |props|. |
233 void TriggerEvent(const std::string& event_name, | 225 void TriggerEvent(const std::string& event_name, |
234 v8::Local<v8::Object>* event); | 226 std::map<std::string, base::Value*>* props); |
235 | 227 |
236 // Creates and maps transport dib. Overridden in tests. | 228 // Creates and maps transport dib. Overridden in tests. |
237 virtual TransportDIB* CreateTransportDIB(const size_t size); | 229 virtual TransportDIB* CreateTransportDIB(const size_t size); |
238 // Frees up the damage buffer. Overridden in tests. | 230 // Frees up the damage buffer. Overridden in tests. |
239 virtual void FreeDamageBuffer(); | 231 virtual void FreeDamageBuffer(); |
240 // Populates BrowserPluginHostMsg_ResizeGuest_Params with resize state and | 232 // Populates BrowserPluginHostMsg_ResizeGuest_Params with resize state and |
241 // returns the newly allocated TransportDIB. | 233 // returns the newly allocated TransportDIB. |
242 TransportDIB* PopulateResizeGuestParameters( | 234 TransportDIB* PopulateResizeGuestParameters( |
243 BrowserPluginHostMsg_ResizeGuest_Params* params, | 235 BrowserPluginHostMsg_ResizeGuest_Params* params, |
244 int view_width, int view_height); | 236 int view_width, int view_height); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 int min_width_; | 271 int min_width_; |
280 int process_id_; | 272 int process_id_; |
281 std::string storage_partition_id_; | 273 std::string storage_partition_id_; |
282 bool persist_storage_; | 274 bool persist_storage_; |
283 int content_window_routing_id_; | 275 int content_window_routing_id_; |
284 bool plugin_focused_; | 276 bool plugin_focused_; |
285 bool embedder_focused_; | 277 bool embedder_focused_; |
286 // Tracks the visibility of the browser plugin regardless of the whole | 278 // Tracks the visibility of the browser plugin regardless of the whole |
287 // embedder RenderView's visibility. | 279 // embedder RenderView's visibility. |
288 bool visible_; | 280 bool visible_; |
289 typedef std::vector<v8::Local<v8::Function> > EventListenersLocal; | 281 |
290 typedef std::vector<v8::Persistent<v8::Function> > EventListeners; | |
291 typedef std::map<std::string, EventListeners> EventListenerMap; | |
292 EventListenerMap event_listener_map_; | |
293 WebCursor cursor_; | 282 WebCursor cursor_; |
| 283 |
294 gfx::Size last_view_size_; | 284 gfx::Size last_view_size_; |
295 bool size_changed_in_flight_; | 285 bool size_changed_in_flight_; |
296 | 286 |
297 // Important: Do not add more history state here. | 287 // Important: Do not add more history state here. |
298 // We strongly discourage storing additional history state (such as page IDs) | 288 // We strongly discourage storing additional history state (such as page IDs) |
299 // in the embedder process, at the risk of having incorrect information that | 289 // in the embedder process, at the risk of having incorrect information that |
300 // can lead to broken back/forward logic in apps. | 290 // can lead to broken back/forward logic in apps. |
301 // It's also important that this state does not get modified by any logic in | 291 // It's also important that this state does not get modified by any logic in |
302 // the embedder process. It should only be updated in response to navigation | 292 // the embedder process. It should only be updated in response to navigation |
303 // events in the guest. No assumptions should be made about how the index | 293 // events in the guest. No assumptions should be made about how the index |
304 // will change after a navigation (e.g., for back, forward, or go), because | 294 // will change after a navigation (e.g., for back, forward, or go), because |
305 // the changes are not always obvious. For example, there is a maximum | 295 // the changes are not always obvious. For example, there is a maximum |
306 // number of entries and earlier ones will automatically be pruned. | 296 // number of entries and earlier ones will automatically be pruned. |
307 int current_nav_entry_index_; | 297 int current_nav_entry_index_; |
308 int nav_entry_count_; | 298 int nav_entry_count_; |
309 DISALLOW_COPY_AND_ASSIGN(BrowserPlugin); | 299 DISALLOW_COPY_AND_ASSIGN(BrowserPlugin); |
310 }; | 300 }; |
311 | 301 |
312 } // namespace content | 302 } // namespace content |
313 | 303 |
314 #endif // CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_H_ | 304 #endif // CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_H_ |
OLD | NEW |