Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(222)

Side by Side Diff: content/renderer/browser_plugin/browser_plugin.h

Issue 11093080: <webview>: First stab at implementing media permission request for guests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove hanging request on garbage collection, yay! Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 void Go(int relativeIndex); 111 void Go(int relativeIndex);
112 // Tells the BrowserPlugin to terminate the guest process. 112 // Tells the BrowserPlugin to terminate the guest process.
113 void TerminateGuest(); 113 void TerminateGuest();
114 114
115 // A request from Javascript has been made to stop the loading of the page. 115 // A request from Javascript has been made to stop the loading of the page.
116 void Stop(); 116 void Stop();
117 // A request from Javascript has been made to reload the page. 117 // A request from Javascript has been made to reload the page.
118 void Reload(); 118 void Reload();
119 // A request to enable hardware compositing. 119 // A request to enable hardware compositing.
120 void EnableCompositing(bool enable); 120 void EnableCompositing(bool enable);
121 // A request from shim to track lifetime of a js object related to media
122 // access request object.
123 // This is used to clean up hanging media requests.
124 void PersistRequestObject(const NPVariant* request, int id);
121 125
122 // Returns true if |point| lies within the bounds of the plugin rectangle. 126 // Returns true if |point| lies within the bounds of the plugin rectangle.
123 // Not OK to use this function for making security-sensitive decision since it 127 // Not OK to use this function for making security-sensitive decision since it
124 // can return false positives when the plugin has rotation transformation 128 // can return false positives when the plugin has rotation transformation
125 // applied. 129 // applied.
126 bool InBounds(const gfx::Point& point) const; 130 bool InBounds(const gfx::Point& point) const;
127 131
128 gfx::Point ToLocalCoordinates(const gfx::Point& point) const; 132 gfx::Point ToLocalCoordinates(const gfx::Point& point) const;
133 // Called by browser plugin binding.
134 void OnListenerCallMediaAccess(int request_id, bool allow);
135
129 136
130 // WebKit::WebPlugin implementation. 137 // WebKit::WebPlugin implementation.
131 virtual WebKit::WebPluginContainer* container() const OVERRIDE; 138 virtual WebKit::WebPluginContainer* container() const OVERRIDE;
132 virtual bool initialize(WebKit::WebPluginContainer* container) OVERRIDE; 139 virtual bool initialize(WebKit::WebPluginContainer* container) OVERRIDE;
133 virtual void destroy() OVERRIDE; 140 virtual void destroy() OVERRIDE;
134 virtual NPObject* scriptableObject() OVERRIDE; 141 virtual NPObject* scriptableObject() OVERRIDE;
135 virtual bool supportsKeyboardFocus() const OVERRIDE; 142 virtual bool supportsKeyboardFocus() const OVERRIDE;
136 virtual bool canProcessDrag() const OVERRIDE; 143 virtual bool canProcessDrag() const OVERRIDE;
137 virtual void paint( 144 virtual void paint(
138 WebKit::WebCanvas* canvas, 145 WebKit::WebCanvas* canvas,
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 void GetDamageBufferWithSizeParams( 243 void GetDamageBufferWithSizeParams(
237 BrowserPluginHostMsg_AutoSize_Params* auto_size_params, 244 BrowserPluginHostMsg_AutoSize_Params* auto_size_params,
238 BrowserPluginHostMsg_ResizeGuest_Params* resize_guest_params); 245 BrowserPluginHostMsg_ResizeGuest_Params* resize_guest_params);
239 246
240 // Informs the guest of an updated autosize state. 247 // Informs the guest of an updated autosize state.
241 void UpdateGuestAutoSizeState(bool current_auto_size); 248 void UpdateGuestAutoSizeState(bool current_auto_size);
242 249
243 // Informs the BrowserPlugin that guest has changed its size in autosize mode. 250 // Informs the BrowserPlugin that guest has changed its size in autosize mode.
244 void SizeChangedDueToAutoSize(const gfx::Size& old_view_size); 251 void SizeChangedDueToAutoSize(const gfx::Size& old_view_size);
245 252
253 bool HasEventListeners(const std::string& event_name);
254
246 // Indicates whether a damage buffer was used by the guest process for the 255 // Indicates whether a damage buffer was used by the guest process for the
247 // provided |params|. 256 // provided |params|.
248 static bool UsesDamageBuffer( 257 static bool UsesDamageBuffer(
249 const BrowserPluginMsg_UpdateRect_Params& params); 258 const BrowserPluginMsg_UpdateRect_Params& params);
250 259
251 // Indicates whether the |pending_damage_buffer_| was used to copy over pixels 260 // Indicates whether the |pending_damage_buffer_| was used to copy over pixels
252 // given the provided |params|. 261 // given the provided |params|.
253 bool UsesPendingDamageBuffer( 262 bool UsesPendingDamageBuffer(
254 const BrowserPluginMsg_UpdateRect_Params& params); 263 const BrowserPluginMsg_UpdateRect_Params& params);
255 264
(...skipping 24 matching lines...) Expand all
280 const GURL& old_url, 289 const GURL& old_url,
281 const GURL& new_url, 290 const GURL& new_url,
282 bool is_top_level); 291 bool is_top_level);
283 void OnLoadStart(int instance_id, const GURL& url, bool is_top_level); 292 void OnLoadStart(int instance_id, const GURL& url, bool is_top_level);
284 void OnLoadStop(int instance_id); 293 void OnLoadStop(int instance_id);
285 void OnSetCursor(int instance_id, const WebCursor& cursor); 294 void OnSetCursor(int instance_id, const WebCursor& cursor);
286 void OnShouldAcceptTouchEvents(int instance_id, bool accept); 295 void OnShouldAcceptTouchEvents(int instance_id, bool accept);
287 void OnUpdatedName(int instance_id, const std::string& name); 296 void OnUpdatedName(int instance_id, const std::string& name);
288 void OnUpdateRect(int instance_id, 297 void OnUpdateRect(int instance_id,
289 const BrowserPluginMsg_UpdateRect_Params& params); 298 const BrowserPluginMsg_UpdateRect_Params& params);
299 // Requests media access permission from the embedder.
300 void OnRequestMediaAccess(int instance_id,
301 int request_id,
302 const GURL& security_origin);
303 // Informs the BrowserPlugin that the guest's request for media access has
304 // been allowed or denied by the embedder.
305 void RespondMediaAccess(int request_id, bool allow);
306
307 void RespondMediaAccessIfPending(int request_id, bool allow);
308 void OnMediaRequestGarbageCollected(int request_id);
309 static void WeakCallbackForPersistObject(v8::Persistent<v8::Value> object,
310 void* param);
290 311
291 int instance_id_; 312 int instance_id_;
292 base::WeakPtr<RenderViewImpl> render_view_; 313 base::WeakPtr<RenderViewImpl> render_view_;
293 // We cache the |render_view_|'s routing ID because we need it on destruction. 314 // We cache the |render_view_|'s routing ID because we need it on destruction.
294 // If the |render_view_| is destroyed before the BrowserPlugin is destroyed 315 // If the |render_view_| is destroyed before the BrowserPlugin is destroyed
295 // then we will attempt to access a NULL pointer. 316 // then we will attempt to access a NULL pointer.
296 int render_view_routing_id_; 317 int render_view_routing_id_;
297 WebKit::WebPluginContainer* container_; 318 WebKit::WebPluginContainer* container_;
298 scoped_ptr<BrowserPluginBindings> bindings_; 319 scoped_ptr<BrowserPluginBindings> bindings_;
299 scoped_ptr<BrowserPluginBackingStore> backing_store_; 320 scoped_ptr<BrowserPluginBackingStore> backing_store_;
(...skipping 18 matching lines...) Expand all
318 bool plugin_focused_; 339 bool plugin_focused_;
319 // Tracks the visibility of the browser plugin regardless of the whole 340 // Tracks the visibility of the browser plugin regardless of the whole
320 // embedder RenderView's visibility. 341 // embedder RenderView's visibility.
321 bool visible_; 342 bool visible_;
322 343
323 WebCursor cursor_; 344 WebCursor cursor_;
324 345
325 gfx::Size last_view_size_; 346 gfx::Size last_view_size_;
326 bool size_changed_in_flight_; 347 bool size_changed_in_flight_;
327 bool allocate_instance_id_sent_; 348 bool allocate_instance_id_sent_;
349 typedef std::set<int> MediaAccessPendingRequestIds;
350 MediaAccessPendingRequestIds media_access_pending_request_ids_;
351
352 typedef std::pair<int*, BrowserPlugin*> MediaAccessAliveV8RequestItem;
353 std::map<int, MediaAccessAliveV8RequestItem*>
354 media_access_alive_v8_request_objects_;
328 355
329 // BrowserPlugin outlives RenderViewImpl in Chrome Apps and so we need to 356 // BrowserPlugin outlives RenderViewImpl in Chrome Apps and so we need to
330 // store the BrowserPlugin's BrowserPluginManager in a member variable to 357 // store the BrowserPlugin's BrowserPluginManager in a member variable to
331 // avoid accessing the RenderViewImpl. 358 // avoid accessing the RenderViewImpl.
332 scoped_refptr<BrowserPluginManager> browser_plugin_manager_; 359 scoped_refptr<BrowserPluginManager> browser_plugin_manager_;
333 360
334 // Important: Do not add more history state here. 361 // Important: Do not add more history state here.
335 // We strongly discourage storing additional history state (such as page IDs) 362 // We strongly discourage storing additional history state (such as page IDs)
336 // in the embedder process, at the risk of having incorrect information that 363 // in the embedder process, at the risk of having incorrect information that
337 // can lead to broken back/forward logic in apps. 364 // can lead to broken back/forward logic in apps.
338 // It's also important that this state does not get modified by any logic in 365 // It's also important that this state does not get modified by any logic in
339 // the embedder process. It should only be updated in response to navigation 366 // the embedder process. It should only be updated in response to navigation
340 // events in the guest. No assumptions should be made about how the index 367 // events in the guest. No assumptions should be made about how the index
341 // will change after a navigation (e.g., for back, forward, or go), because 368 // will change after a navigation (e.g., for back, forward, or go), because
342 // the changes are not always obvious. For example, there is a maximum 369 // the changes are not always obvious. For example, there is a maximum
343 // number of entries and earlier ones will automatically be pruned. 370 // number of entries and earlier ones will automatically be pruned.
344 int current_nav_entry_index_; 371 int current_nav_entry_index_;
345 int nav_entry_count_; 372 int nav_entry_count_;
346 373
347 // Used for HW compositing. 374 // Used for HW compositing.
348 bool compositing_enabled_; 375 bool compositing_enabled_;
349 scoped_refptr<BrowserPluginCompositingHelper> compositing_helper_; 376 scoped_refptr<BrowserPluginCompositingHelper> compositing_helper_;
350 377
351 DISALLOW_COPY_AND_ASSIGN(BrowserPlugin); 378 DISALLOW_COPY_AND_ASSIGN(BrowserPlugin);
352 }; 379 };
353 380
354 } // namespace content 381 } // namespace content
355 382
356 #endif // CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_H_ 383 #endif // CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698