| 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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 bool ShouldGuestBeFocused() const; | 118 bool ShouldGuestBeFocused() const; |
| 119 | 119 |
| 120 // Inform the BrowserPlugin that the guest's contentWindow is ready, | 120 // Inform the BrowserPlugin that the guest's contentWindow is ready, |
| 121 // and provide it with a routing ID to grab it. | 121 // and provide it with a routing ID to grab it. |
| 122 void GuestContentWindowReady(int content_window_routing_id); | 122 void GuestContentWindowReady(int content_window_routing_id); |
| 123 | 123 |
| 124 // Informs the BrowserPlugin that the guest has started/stopped accepting | 124 // Informs the BrowserPlugin that the guest has started/stopped accepting |
| 125 // touch events. | 125 // touch events. |
| 126 void SetAcceptTouchEvents(bool accept); | 126 void SetAcceptTouchEvents(bool accept); |
| 127 | 127 |
| 128 // Requests media access permission from the embedder. |
| 129 void RequestMediaAccess(int request_id, const GURL& security_origin); |
| 130 // Informs the BrowserPlugin that the guest's request for media access has |
| 131 // been allowed or denied by the embedder. |
| 132 void RespondMediaAccess(int request_id, bool allow); |
| 133 |
| 128 // Tells the BrowserPlugin to tell the guest to navigate to the previous | 134 // Tells the BrowserPlugin to tell the guest to navigate to the previous |
| 129 // navigation entry in the navigation history. | 135 // navigation entry in the navigation history. |
| 130 void Back(); | 136 void Back(); |
| 131 // Tells the BrowserPlugin to tell the guest to navigate to the next | 137 // Tells the BrowserPlugin to tell the guest to navigate to the next |
| 132 // navigation entry in the navigation history. | 138 // navigation entry in the navigation history. |
| 133 void Forward(); | 139 void Forward(); |
| 134 // Tells the BrowserPlugin to tell the guest to navigate to a position | 140 // Tells the BrowserPlugin to tell the guest to navigate to a position |
| 135 // relative to the current index in its navigation history. | 141 // relative to the current index in its navigation history. |
| 136 void Go(int relativeIndex); | 142 void Go(int relativeIndex); |
| 137 // Tells the BrowserPlugin to terminate the guest process. | 143 // Tells the BrowserPlugin to terminate the guest process. |
| 138 void TerminateGuest(); | 144 void TerminateGuest(); |
| 139 | 145 |
| 140 // A request from Javascript has been made to stop the loading of the page. | 146 // A request from Javascript has been made to stop the loading of the page. |
| 141 void Stop(); | 147 void Stop(); |
| 142 // A request from Javascript has been made to reload the page. | 148 // A request from Javascript has been made to reload the page. |
| 143 void Reload(); | 149 void Reload(); |
| 144 | 150 |
| 145 // Informs the BrowserPlugin of the cursor that the guest has requested. | 151 // Informs the BrowserPlugin of the cursor that the guest has requested. |
| 146 void SetCursor(const WebCursor& cursor); | 152 void SetCursor(const WebCursor& cursor); |
| 147 | 153 |
| 148 // Returns true if |point| lies within the bounds of the plugin rectangle. | 154 // Returns true if |point| lies within the bounds of the plugin rectangle. |
| 149 // Not OK to use this function for making security-sensitive decision since it | 155 // Not OK to use this function for making security-sensitive decision since it |
| 150 // can return false positives when the plugin has rotation transformation | 156 // can return false positives when the plugin has rotation transformation |
| 151 // applied. | 157 // applied. |
| 152 bool InBounds(const gfx::Point& point) const; | 158 bool InBounds(const gfx::Point& point) const; |
| 153 | 159 |
| 154 gfx::Point ToLocalCoordinates(const gfx::Point& point) const; | 160 gfx::Point ToLocalCoordinates(const gfx::Point& point) const; |
| 155 | 161 |
| 162 // Called by browser plugin binding. |
| 163 void OnListenerCallMediaAccess(int request_id, bool allow); |
| 164 |
| 156 // WebKit::WebPlugin implementation. | 165 // WebKit::WebPlugin implementation. |
| 157 virtual WebKit::WebPluginContainer* container() const OVERRIDE; | 166 virtual WebKit::WebPluginContainer* container() const OVERRIDE; |
| 158 virtual bool initialize(WebKit::WebPluginContainer* container) OVERRIDE; | 167 virtual bool initialize(WebKit::WebPluginContainer* container) OVERRIDE; |
| 159 virtual void destroy() OVERRIDE; | 168 virtual void destroy() OVERRIDE; |
| 160 virtual NPObject* scriptableObject() OVERRIDE; | 169 virtual NPObject* scriptableObject() OVERRIDE; |
| 161 virtual bool supportsKeyboardFocus() const OVERRIDE; | 170 virtual bool supportsKeyboardFocus() const OVERRIDE; |
| 162 virtual bool canProcessDrag() const OVERRIDE; | 171 virtual bool canProcessDrag() const OVERRIDE; |
| 163 virtual void paint( | 172 virtual void paint( |
| 164 WebKit::WebCanvas* canvas, | 173 WebKit::WebCanvas* canvas, |
| 165 const WebKit::WebRect& rect) OVERRIDE; | 174 const WebKit::WebRect& rect) OVERRIDE; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 184 virtual void didReceiveData(const char* data, int data_length) OVERRIDE; | 193 virtual void didReceiveData(const char* data, int data_length) OVERRIDE; |
| 185 virtual void didFinishLoading() OVERRIDE; | 194 virtual void didFinishLoading() OVERRIDE; |
| 186 virtual void didFailLoading(const WebKit::WebURLError& error) OVERRIDE; | 195 virtual void didFailLoading(const WebKit::WebURLError& error) OVERRIDE; |
| 187 virtual void didFinishLoadingFrameRequest( | 196 virtual void didFinishLoadingFrameRequest( |
| 188 const WebKit::WebURL& url, | 197 const WebKit::WebURL& url, |
| 189 void* notify_data) OVERRIDE; | 198 void* notify_data) OVERRIDE; |
| 190 virtual void didFailLoadingFrameRequest( | 199 virtual void didFailLoadingFrameRequest( |
| 191 const WebKit::WebURL& url, | 200 const WebKit::WebURL& url, |
| 192 void* notify_data, | 201 void* notify_data, |
| 193 const WebKit::WebURLError& error) OVERRIDE; | 202 const WebKit::WebURLError& error) OVERRIDE; |
| 203 |
| 194 private: | 204 private: |
| 195 friend class base::DeleteHelper<BrowserPlugin>; | 205 friend class base::DeleteHelper<BrowserPlugin>; |
| 196 // Only the manager is allowed to create a BrowserPlugin. | 206 // Only the manager is allowed to create a BrowserPlugin. |
| 197 friend class BrowserPluginManagerImpl; | 207 friend class BrowserPluginManagerImpl; |
| 198 friend class MockBrowserPluginManager; | 208 friend class MockBrowserPluginManager; |
| 199 | 209 |
| 200 // For unit/integration tests. | 210 // For unit/integration tests. |
| 201 friend class MockBrowserPlugin; | 211 friend class MockBrowserPlugin; |
| 202 | 212 |
| 203 // A BrowserPlugin object is a controller that represents an instance of a | 213 // A BrowserPlugin object is a controller that represents an instance of a |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 TransportDIB* GetDamageBufferWithSizeParams( | 276 TransportDIB* GetDamageBufferWithSizeParams( |
| 267 BrowserPluginHostMsg_AutoSize_Params* auto_size_params, | 277 BrowserPluginHostMsg_AutoSize_Params* auto_size_params, |
| 268 BrowserPluginHostMsg_ResizeGuest_Params* resize_guest_params); | 278 BrowserPluginHostMsg_ResizeGuest_Params* resize_guest_params); |
| 269 | 279 |
| 270 // Informs the guest of an updated autosize state. | 280 // Informs the guest of an updated autosize state. |
| 271 void UpdateGuestAutoSizeState(); | 281 void UpdateGuestAutoSizeState(); |
| 272 | 282 |
| 273 // Informs the BrowserPlugin that guest has changed its size in autosize mode. | 283 // Informs the BrowserPlugin that guest has changed its size in autosize mode. |
| 274 void SizeChangedDueToAutoSize(const gfx::Size& old_view_size); | 284 void SizeChangedDueToAutoSize(const gfx::Size& old_view_size); |
| 275 | 285 |
| 286 bool HasEventListeners(const std::string& event_name); |
| 287 size_t GetNumberOfEventListeners(const std::string& event_name); |
| 288 |
| 276 #if defined(OS_MACOSX) | 289 #if defined(OS_MACOSX) |
| 277 bool DamageBufferMatches(const TransportDIB* damage_buffer, | 290 bool DamageBufferMatches(const TransportDIB* damage_buffer, |
| 278 const TransportDIB::Id& other_damage_buffer_id); | 291 const TransportDIB::Id& other_damage_buffer_id); |
| 279 #else | 292 #else |
| 280 bool DamageBufferMatches( | 293 bool DamageBufferMatches( |
| 281 const TransportDIB* damage_buffer, | 294 const TransportDIB* damage_buffer, |
| 282 const TransportDIB::Handle& other_damage_buffer_handle); | 295 const TransportDIB::Handle& other_damage_buffer_handle); |
| 283 #endif | 296 #endif |
| 284 | 297 |
| 285 int instance_id_; | 298 int instance_id_; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 314 bool plugin_focused_; | 327 bool plugin_focused_; |
| 315 bool embedder_focused_; | 328 bool embedder_focused_; |
| 316 // Tracks the visibility of the browser plugin regardless of the whole | 329 // Tracks the visibility of the browser plugin regardless of the whole |
| 317 // embedder RenderView's visibility. | 330 // embedder RenderView's visibility. |
| 318 bool visible_; | 331 bool visible_; |
| 319 | 332 |
| 320 WebCursor cursor_; | 333 WebCursor cursor_; |
| 321 | 334 |
| 322 gfx::Size last_view_size_; | 335 gfx::Size last_view_size_; |
| 323 bool size_changed_in_flight_; | 336 bool size_changed_in_flight_; |
| 337 typedef std::map<int, size_t> MediaAccessPendingCountsMap; |
| 338 MediaAccessPendingCountsMap media_access_pending_counts_; |
| 324 | 339 |
| 325 // BrowserPlugin outlives RenderViewImpl in Chrome Apps and so we need to | 340 // BrowserPlugin outlives RenderViewImpl in Chrome Apps and so we need to |
| 326 // store the BrowserPlugin's BrowserPluginManager in a member variable to | 341 // store the BrowserPlugin's BrowserPluginManager in a member variable to |
| 327 // avoid accessing the RenderViewImpl. | 342 // avoid accessing the RenderViewImpl. |
| 328 scoped_refptr<BrowserPluginManager> browser_plugin_manager_; | 343 scoped_refptr<BrowserPluginManager> browser_plugin_manager_; |
| 329 | 344 |
| 330 // Important: Do not add more history state here. | 345 // Important: Do not add more history state here. |
| 331 // We strongly discourage storing additional history state (such as page IDs) | 346 // We strongly discourage storing additional history state (such as page IDs) |
| 332 // in the embedder process, at the risk of having incorrect information that | 347 // in the embedder process, at the risk of having incorrect information that |
| 333 // can lead to broken back/forward logic in apps. | 348 // can lead to broken back/forward logic in apps. |
| 334 // It's also important that this state does not get modified by any logic in | 349 // It's also important that this state does not get modified by any logic in |
| 335 // the embedder process. It should only be updated in response to navigation | 350 // the embedder process. It should only be updated in response to navigation |
| 336 // events in the guest. No assumptions should be made about how the index | 351 // events in the guest. No assumptions should be made about how the index |
| 337 // will change after a navigation (e.g., for back, forward, or go), because | 352 // will change after a navigation (e.g., for back, forward, or go), because |
| 338 // the changes are not always obvious. For example, there is a maximum | 353 // the changes are not always obvious. For example, there is a maximum |
| 339 // number of entries and earlier ones will automatically be pruned. | 354 // number of entries and earlier ones will automatically be pruned. |
| 340 int current_nav_entry_index_; | 355 int current_nav_entry_index_; |
| 341 int nav_entry_count_; | 356 int nav_entry_count_; |
| 342 DISALLOW_COPY_AND_ASSIGN(BrowserPlugin); | 357 DISALLOW_COPY_AND_ASSIGN(BrowserPlugin); |
| 343 }; | 358 }; |
| 344 | 359 |
| 345 } // namespace content | 360 } // namespace content |
| 346 | 361 |
| 347 #endif // CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_H_ | 362 #endif // CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_H_ |
| OLD | NEW |