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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 void AdvanceFocus(bool reverse); | 100 void AdvanceFocus(bool reverse); |
101 | 101 |
102 // Inform the BrowserPlugin that the guest's contentWindow is ready, | 102 // Inform the BrowserPlugin that the guest's contentWindow is ready, |
103 // and provide it with a routing ID to grab it. | 103 // and provide it with a routing ID to grab it. |
104 void GuestContentWindowReady(int content_window_routing_id); | 104 void GuestContentWindowReady(int content_window_routing_id); |
105 | 105 |
106 // Informs the BrowserPlugin that the guest has started/stopped accepting | 106 // Informs the BrowserPlugin that the guest has started/stopped accepting |
107 // touch events. | 107 // touch events. |
108 void SetAcceptTouchEvents(bool accept); | 108 void SetAcceptTouchEvents(bool accept); |
109 | 109 |
110 // Indicates whether there are any Javascript listeners attached to a | |
111 // provided event_name. | |
112 bool HasListeners(const std::string& event_name); | |
113 // Add a custom event listener to this BrowserPlugin instance. | 110 // Add a custom event listener to this BrowserPlugin instance. |
114 bool AddEventListener(const std::string& event_name, | |
115 v8::Local<v8::Function> function); | |
116 // Remove a custom event listener from this BrowserPlugin instance. | |
117 bool RemoveEventListener(const std::string& event_name, | |
118 v8::Local<v8::Function> function); | |
119 // Tells the BrowserPlugin to tell the guest to navigate to the previous | 111 // Tells the BrowserPlugin to tell the guest to navigate to the previous |
120 // navigation entry in the navigation history. | 112 // navigation entry in the navigation history. |
121 void Back(); | 113 void Back(); |
122 // Tells the BrowserPlugin to tell the guest to navigate to the next | 114 // Tells the BrowserPlugin to tell the guest to navigate to the next |
123 // navigation entry in the navigation history. | 115 // navigation entry in the navigation history. |
124 void Forward(); | 116 void Forward(); |
125 // Tells the BrowserPlugin to tell the guest to navigate to a position | 117 // Tells the BrowserPlugin to tell the guest to navigate to a position |
126 // relative to the current index in its navigation history. | 118 // relative to the current index in its navigation history. |
127 void Go(int relativeIndex); | 119 void Go(int relativeIndex); |
128 // Tells the BrowserPlugin to terminate the guest process. | 120 // Tells the BrowserPlugin to terminate the guest process. |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 | 205 |
214 // Cleanup event listener state to free v8 resources when a BrowserPlugin | 206 // Cleanup event listener state to free v8 resources when a BrowserPlugin |
215 // is destroyed. | 207 // is destroyed. |
216 void RemoveEventListeners(); | 208 void RemoveEventListeners(); |
217 | 209 |
218 // Returns whether |event_name| is a valid event. | 210 // Returns whether |event_name| is a valid event. |
219 bool IsValidEvent(const std::string& event_name); | 211 bool IsValidEvent(const std::string& event_name); |
220 | 212 |
221 // Triggers the event-listeners for |event_name|. | 213 // Triggers the event-listeners for |event_name|. |
222 void TriggerEvent(const std::string& event_name, | 214 void TriggerEvent(const std::string& event_name, |
223 v8::Local<v8::Object>* event); | 215 std::map<std::string, base::Value*>* props); |
224 | 216 |
225 // Creates and maps transport dib. Overridden in tests. | 217 // Creates and maps transport dib. Overridden in tests. |
226 virtual TransportDIB* CreateTransportDIB(const size_t size); | 218 virtual TransportDIB* CreateTransportDIB(const size_t size); |
227 // Frees up the damage buffer. Overridden in tests. | 219 // Frees up the damage buffer. Overridden in tests. |
228 virtual void FreeDamageBuffer(); | 220 virtual void FreeDamageBuffer(); |
229 | 221 |
230 // Populates BrowserPluginHostMsg_AutoSize_Params object with autosize state. | 222 // Populates BrowserPluginHostMsg_AutoSize_Params object with autosize state. |
231 void PopulateAutoSizeParameters( | 223 void PopulateAutoSizeParameters( |
232 BrowserPluginHostMsg_AutoSize_Params* params) const; | 224 BrowserPluginHostMsg_AutoSize_Params* params) const; |
233 // Informs the guest of an updated autosize state. | 225 // Informs the guest of an updated autosize state. |
(...skipping 24 matching lines...) Expand all Loading... |
258 int min_height_; | 250 int min_height_; |
259 int min_width_; | 251 int min_width_; |
260 int process_id_; | 252 int process_id_; |
261 std::string storage_partition_id_; | 253 std::string storage_partition_id_; |
262 bool persist_storage_; | 254 bool persist_storage_; |
263 int content_window_routing_id_; | 255 int content_window_routing_id_; |
264 bool focused_; | 256 bool focused_; |
265 // Tracks the visibility of the browser plugin regardless of the whole | 257 // Tracks the visibility of the browser plugin regardless of the whole |
266 // embedder RenderView's visibility. | 258 // embedder RenderView's visibility. |
267 bool visible_; | 259 bool visible_; |
268 typedef std::vector<v8::Local<v8::Function> > EventListenersLocal; | |
269 typedef std::vector<v8::Persistent<v8::Function> > EventListeners; | |
270 typedef std::map<std::string, EventListeners> EventListenerMap; | |
271 EventListenerMap event_listener_map_; | |
272 #if defined(OS_WIN) | 260 #if defined(OS_WIN) |
273 base::SharedMemory shared_memory_; | 261 base::SharedMemory shared_memory_; |
274 #endif | 262 #endif |
275 // Important: Do not add more history state here. | 263 // Important: Do not add more history state here. |
276 // We strongly discourage storing additional history state (such as page IDs) | 264 // We strongly discourage storing additional history state (such as page IDs) |
277 // in the embedder process, at the risk of having incorrect information that | 265 // in the embedder process, at the risk of having incorrect information that |
278 // can lead to broken back/forward logic in apps. | 266 // can lead to broken back/forward logic in apps. |
279 // It's also important that this state does not get modified by any logic in | 267 // It's also important that this state does not get modified by any logic in |
280 // the embedder process. It should only be updated in response to navigation | 268 // the embedder process. It should only be updated in response to navigation |
281 // events in the guest. No assumptions should be made about how the index | 269 // events in the guest. No assumptions should be made about how the index |
282 // will change after a navigation (e.g., for back, forward, or go), because | 270 // will change after a navigation (e.g., for back, forward, or go), because |
283 // the changes are not always obvious. For example, there is a maximum | 271 // the changes are not always obvious. For example, there is a maximum |
284 // number of entries and earlier ones will automatically be pruned. | 272 // number of entries and earlier ones will automatically be pruned. |
285 int current_nav_entry_index_; | 273 int current_nav_entry_index_; |
286 int nav_entry_count_; | 274 int nav_entry_count_; |
287 DISALLOW_COPY_AND_ASSIGN(BrowserPlugin); | 275 DISALLOW_COPY_AND_ASSIGN(BrowserPlugin); |
288 }; | 276 }; |
289 | 277 |
290 } // namespace content | 278 } // namespace content |
291 | 279 |
292 #endif // CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_H_ | 280 #endif // CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_H_ |
OLD | NEW |