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

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: Address comments from fsamuel@ 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,
125 const std::string& type,
126 int id);
121 127
122 // Returns true if |point| lies within the bounds of the plugin rectangle. 128 // 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 129 // Not OK to use this function for making security-sensitive decision since it
124 // can return false positives when the plugin has rotation transformation 130 // can return false positives when the plugin has rotation transformation
125 // applied. 131 // applied.
126 bool InBounds(const gfx::Point& point) const; 132 bool InBounds(const gfx::Point& point) const;
127 133
128 gfx::Point ToLocalCoordinates(const gfx::Point& point) const; 134 gfx::Point ToLocalCoordinates(const gfx::Point& point) const;
135 // Called by browser plugin binding.
136 void OnEmbedderDecidedPermission(int request_id, bool allow);
137
129 138
130 // WebKit::WebPlugin implementation. 139 // WebKit::WebPlugin implementation.
131 virtual WebKit::WebPluginContainer* container() const OVERRIDE; 140 virtual WebKit::WebPluginContainer* container() const OVERRIDE;
132 virtual bool initialize(WebKit::WebPluginContainer* container) OVERRIDE; 141 virtual bool initialize(WebKit::WebPluginContainer* container) OVERRIDE;
133 virtual void destroy() OVERRIDE; 142 virtual void destroy() OVERRIDE;
134 virtual NPObject* scriptableObject() OVERRIDE; 143 virtual NPObject* scriptableObject() OVERRIDE;
135 virtual bool supportsKeyboardFocus() const OVERRIDE; 144 virtual bool supportsKeyboardFocus() const OVERRIDE;
136 virtual bool canProcessDrag() const OVERRIDE; 145 virtual bool canProcessDrag() const OVERRIDE;
137 virtual void paint( 146 virtual void paint(
138 WebKit::WebCanvas* canvas, 147 WebKit::WebCanvas* canvas,
(...skipping 28 matching lines...) Expand all
167 const WebKit::WebURLError& error) OVERRIDE; 176 const WebKit::WebURLError& error) OVERRIDE;
168 private: 177 private:
169 friend class base::DeleteHelper<BrowserPlugin>; 178 friend class base::DeleteHelper<BrowserPlugin>;
170 // Only the manager is allowed to create a BrowserPlugin. 179 // Only the manager is allowed to create a BrowserPlugin.
171 friend class BrowserPluginManagerImpl; 180 friend class BrowserPluginManagerImpl;
172 friend class MockBrowserPluginManager; 181 friend class MockBrowserPluginManager;
173 182
174 // For unit/integration tests. 183 // For unit/integration tests.
175 friend class MockBrowserPlugin; 184 friend class MockBrowserPlugin;
176 185
186 enum PermissionRequestType {
187 INVALID = -1,
188 MEDIA
189 };
190
177 // A BrowserPlugin object is a controller that represents an instance of a 191 // A BrowserPlugin object is a controller that represents an instance of a
178 // browser plugin within the embedder renderer process. Each BrowserPlugin 192 // browser plugin within the embedder renderer process. Each BrowserPlugin
179 // within a process has a unique instance_id that is used to route messages 193 // within a process has a unique instance_id that is used to route messages
180 // to it. It takes in a RenderViewImpl that it's associated with along 194 // to it. It takes in a RenderViewImpl that it's associated with along
181 // with the frame within which it lives and the initial attributes assigned 195 // with the frame within which it lives and the initial attributes assigned
182 // to it on creation. 196 // to it on creation.
183 BrowserPlugin( 197 BrowserPlugin(
184 RenderViewImpl* render_view, 198 RenderViewImpl* render_view,
185 WebKit::WebFrame* frame, 199 WebKit::WebFrame* frame,
186 const WebKit::WebPluginParams& params); 200 const WebKit::WebPluginParams& params);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 void GetDamageBufferWithSizeParams( 250 void GetDamageBufferWithSizeParams(
237 BrowserPluginHostMsg_AutoSize_Params* auto_size_params, 251 BrowserPluginHostMsg_AutoSize_Params* auto_size_params,
238 BrowserPluginHostMsg_ResizeGuest_Params* resize_guest_params); 252 BrowserPluginHostMsg_ResizeGuest_Params* resize_guest_params);
239 253
240 // Informs the guest of an updated autosize state. 254 // Informs the guest of an updated autosize state.
241 void UpdateGuestAutoSizeState(bool current_auto_size); 255 void UpdateGuestAutoSizeState(bool current_auto_size);
242 256
243 // Informs the BrowserPlugin that guest has changed its size in autosize mode. 257 // Informs the BrowserPlugin that guest has changed its size in autosize mode.
244 void SizeChangedDueToAutoSize(const gfx::Size& old_view_size); 258 void SizeChangedDueToAutoSize(const gfx::Size& old_view_size);
245 259
260 bool HasEventListeners(const std::string& event_name);
261
246 // Indicates whether a damage buffer was used by the guest process for the 262 // Indicates whether a damage buffer was used by the guest process for the
247 // provided |params|. 263 // provided |params|.
248 static bool UsesDamageBuffer( 264 static bool UsesDamageBuffer(
249 const BrowserPluginMsg_UpdateRect_Params& params); 265 const BrowserPluginMsg_UpdateRect_Params& params);
250 266
251 // Indicates whether the |pending_damage_buffer_| was used to copy over pixels 267 // Indicates whether the |pending_damage_buffer_| was used to copy over pixels
252 // given the provided |params|. 268 // given the provided |params|.
253 bool UsesPendingDamageBuffer( 269 bool UsesPendingDamageBuffer(
254 const BrowserPluginMsg_UpdateRect_Params& params); 270 const BrowserPluginMsg_UpdateRect_Params& params);
255 271
256 // Sets the instance ID of the BrowserPlugin and requests a guest from the 272 // Sets the instance ID of the BrowserPlugin and requests a guest from the
257 // browser process. 273 // browser process.
258 void SetInstanceID(int instance_id); 274 void SetInstanceID(int instance_id);
259 275
276 // Populates the ancestor set with the ancestors of the BrowserPlugin. A new
277 // BrowserPlugin gets created when we reparent the <object> node, so this
278 // set should always be valid.
279 void PopulateAncestorList();
280
260 // IPC message handlers. 281 // IPC message handlers.
261 // Please keep in alphabetical order. 282 // Please keep in alphabetical order.
262 void OnAdvanceFocus(int instance_id, bool reverse); 283 void OnAdvanceFocus(int instance_id, bool reverse);
263 void OnBuffersSwapped(int instance_id, 284 void OnBuffersSwapped(int instance_id,
264 const gfx::Size& size, 285 const gfx::Size& size,
265 std::string mailbox_name, 286 std::string mailbox_name,
266 int gpu_route_id, 287 int gpu_route_id,
267 int gpu_host_id); 288 int gpu_host_id);
268 void OnGuestContentWindowReady(int instance_id, 289 void OnGuestContentWindowReady(int instance_id,
269 int content_window_routing_id); 290 int content_window_routing_id);
(...skipping 10 matching lines...) Expand all
280 const GURL& old_url, 301 const GURL& old_url,
281 const GURL& new_url, 302 const GURL& new_url,
282 bool is_top_level); 303 bool is_top_level);
283 void OnLoadStart(int instance_id, const GURL& url, bool is_top_level); 304 void OnLoadStart(int instance_id, const GURL& url, bool is_top_level);
284 void OnLoadStop(int instance_id); 305 void OnLoadStop(int instance_id);
285 void OnSetCursor(int instance_id, const WebCursor& cursor); 306 void OnSetCursor(int instance_id, const WebCursor& cursor);
286 void OnShouldAcceptTouchEvents(int instance_id, bool accept); 307 void OnShouldAcceptTouchEvents(int instance_id, bool accept);
287 void OnUpdatedName(int instance_id, const std::string& name); 308 void OnUpdatedName(int instance_id, const std::string& name);
288 void OnUpdateRect(int instance_id, 309 void OnUpdateRect(int instance_id,
289 const BrowserPluginMsg_UpdateRect_Params& params); 310 const BrowserPluginMsg_UpdateRect_Params& params);
311 // Requests permission from the embedder.
312 void OnRequestPermission(int instance_id,
Fady Samuel 2013/02/12 19:13:09 nit: Put in alphabetical order with the message ha
lazyboy 2013/02/12 22:14:33 Done.
313 const std::string& permission_type,
314 int request_id,
315 const base::DictionaryValue& request_info);
316 // Requests media access permission from the embedder.
Fady Samuel 2013/02/12 19:13:09 nit: The methods below are not message handlers. M
lazyboy 2013/02/12 22:14:33 Done.
317 void RequestMediaPermission(int request_id,
318 const base::DictionaryValue& request_info);
319 // Informs the BrowserPlugin that the guest's permission request has been
320 // allowed or denied by the embedder.
321 void RespondPermission(PermissionRequestType type,
322 int request_id,
323 bool allow);
324
325 void RespondPermissionIfPending(int request_id, bool allow);
326 void OnRequestObjectGarbageCollected(int request_id);
327 static void WeakCallbackForPersistObject(v8::Persistent<v8::Value> object,
328 void* param);
290 329
291 int instance_id_; 330 int instance_id_;
292 base::WeakPtr<RenderViewImpl> render_view_; 331 base::WeakPtr<RenderViewImpl> render_view_;
293 // We cache the |render_view_|'s routing ID because we need it on destruction. 332 // 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 333 // If the |render_view_| is destroyed before the BrowserPlugin is destroyed
295 // then we will attempt to access a NULL pointer. 334 // then we will attempt to access a NULL pointer.
296 int render_view_routing_id_; 335 int render_view_routing_id_;
297 WebKit::WebPluginContainer* container_; 336 WebKit::WebPluginContainer* container_;
298 scoped_ptr<BrowserPluginBindings> bindings_; 337 scoped_ptr<BrowserPluginBindings> bindings_;
299 scoped_ptr<BrowserPluginBackingStore> backing_store_; 338 scoped_ptr<BrowserPluginBackingStore> backing_store_;
(...skipping 19 matching lines...) Expand all
319 // Tracks the visibility of the browser plugin regardless of the whole 358 // Tracks the visibility of the browser plugin regardless of the whole
320 // embedder RenderView's visibility. 359 // embedder RenderView's visibility.
321 bool visible_; 360 bool visible_;
322 361
323 WebCursor cursor_; 362 WebCursor cursor_;
324 363
325 gfx::Size last_view_size_; 364 gfx::Size last_view_size_;
326 bool size_changed_in_flight_; 365 bool size_changed_in_flight_;
327 bool allocate_instance_id_sent_; 366 bool allocate_instance_id_sent_;
328 367
368 typedef std::map<int, std::pair<int, PermissionRequestType> >
369 PendingPermissionRequests;
370 PendingPermissionRequests pending_permission_requests_;
371
372 typedef std::pair<int, base::WeakPtr<BrowserPlugin> >
373 AliveV8PermissionRequestItem;
374 std::map<int, AliveV8PermissionRequestItem*>
375 alive_v8_permission_request_objects;
376
329 // BrowserPlugin outlives RenderViewImpl in Chrome Apps and so we need to 377 // BrowserPlugin outlives RenderViewImpl in Chrome Apps and so we need to
330 // store the BrowserPlugin's BrowserPluginManager in a member variable to 378 // store the BrowserPlugin's BrowserPluginManager in a member variable to
331 // avoid accessing the RenderViewImpl. 379 // avoid accessing the RenderViewImpl.
332 scoped_refptr<BrowserPluginManager> browser_plugin_manager_; 380 scoped_refptr<BrowserPluginManager> browser_plugin_manager_;
333 381
334 // Important: Do not add more history state here. 382 // Important: Do not add more history state here.
335 // We strongly discourage storing additional history state (such as page IDs) 383 // We strongly discourage storing additional history state (such as page IDs)
336 // in the embedder process, at the risk of having incorrect information that 384 // in the embedder process, at the risk of having incorrect information that
337 // can lead to broken back/forward logic in apps. 385 // 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 386 // 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 387 // 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 388 // 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 389 // 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 390 // the changes are not always obvious. For example, there is a maximum
343 // number of entries and earlier ones will automatically be pruned. 391 // number of entries and earlier ones will automatically be pruned.
344 int current_nav_entry_index_; 392 int current_nav_entry_index_;
345 int nav_entry_count_; 393 int nav_entry_count_;
346 394
347 // Used for HW compositing. 395 // Used for HW compositing.
348 bool compositing_enabled_; 396 bool compositing_enabled_;
349 scoped_refptr<BrowserPluginCompositingHelper> compositing_helper_; 397 scoped_refptr<BrowserPluginCompositingHelper> compositing_helper_;
350 398
399 // Weak factory used in v8 |MakeWeak| callback, since the v8 callback might
400 // get called after BrowserPlugin has been destroyed.
401 base::WeakPtrFactory<BrowserPlugin> weak_ptr_factory_;
402
403 // Set of ancestor nodes.
404 std::vector<WebKit::WebNode> ancestors_;
405
351 DISALLOW_COPY_AND_ASSIGN(BrowserPlugin); 406 DISALLOW_COPY_AND_ASSIGN(BrowserPlugin);
352 }; 407 };
353 408
354 } // namespace content 409 } // namespace content
355 410
356 #endif // CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_H_ 411 #endif // CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698