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

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

Powered by Google App Engine
This is Rietveld 408576698