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

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 creis@ 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
(...skipping 24 matching lines...) Expand all
280 const GURL& old_url, 296 const GURL& old_url,
281 const GURL& new_url, 297 const GURL& new_url,
282 bool is_top_level); 298 bool is_top_level);
283 void OnLoadStart(int instance_id, const GURL& url, bool is_top_level); 299 void OnLoadStart(int instance_id, const GURL& url, bool is_top_level);
284 void OnLoadStop(int instance_id); 300 void OnLoadStop(int instance_id);
285 void OnSetCursor(int instance_id, const WebCursor& cursor); 301 void OnSetCursor(int instance_id, const WebCursor& cursor);
286 void OnShouldAcceptTouchEvents(int instance_id, bool accept); 302 void OnShouldAcceptTouchEvents(int instance_id, bool accept);
287 void OnUpdatedName(int instance_id, const std::string& name); 303 void OnUpdatedName(int instance_id, const std::string& name);
288 void OnUpdateRect(int instance_id, 304 void OnUpdateRect(int instance_id,
289 const BrowserPluginMsg_UpdateRect_Params& params); 305 const BrowserPluginMsg_UpdateRect_Params& params);
306 // Requests permission from the embedder.
307 void OnRequestPermission(int instance_id,
308 const std::string& permission_type,
309 int request_id,
310 const base::DictionaryValue& request_info);
311 // Requests media access permission from the embedder.
312 void OnRequestMediaPermission(int request_id,
313 const base::DictionaryValue& request_info);
314 // Informs the BrowserPlugin that the guest's permission request has been
315 // allowed or denied by the embedder.
316 void RespondPermission(PermissionRequestType type,
317 int request_id,
318 bool allow);
319
320 void RespondPermissionIfPending(int request_id, bool allow);
321 void OnRequestObjectGarbageCollected(int request_id);
322 static void WeakCallbackForPersistObject(v8::Persistent<v8::Value> object,
323 void* param);
290 324
291 int instance_id_; 325 int instance_id_;
292 base::WeakPtr<RenderViewImpl> render_view_; 326 base::WeakPtr<RenderViewImpl> render_view_;
293 // We cache the |render_view_|'s routing ID because we need it on destruction. 327 // 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 328 // If the |render_view_| is destroyed before the BrowserPlugin is destroyed
295 // then we will attempt to access a NULL pointer. 329 // then we will attempt to access a NULL pointer.
296 int render_view_routing_id_; 330 int render_view_routing_id_;
297 WebKit::WebPluginContainer* container_; 331 WebKit::WebPluginContainer* container_;
298 scoped_ptr<BrowserPluginBindings> bindings_; 332 scoped_ptr<BrowserPluginBindings> bindings_;
299 scoped_ptr<BrowserPluginBackingStore> backing_store_; 333 scoped_ptr<BrowserPluginBackingStore> backing_store_;
(...skipping 19 matching lines...) Expand all
319 // Tracks the visibility of the browser plugin regardless of the whole 353 // Tracks the visibility of the browser plugin regardless of the whole
320 // embedder RenderView's visibility. 354 // embedder RenderView's visibility.
321 bool visible_; 355 bool visible_;
322 356
323 WebCursor cursor_; 357 WebCursor cursor_;
324 358
325 gfx::Size last_view_size_; 359 gfx::Size last_view_size_;
326 bool size_changed_in_flight_; 360 bool size_changed_in_flight_;
327 bool allocate_instance_id_sent_; 361 bool allocate_instance_id_sent_;
328 362
363 std::map<int, PermissionRequestType> pending_request_id_to_type_;
364
365 typedef std::set<int> PendingPermissionRequestIds;
366 PendingPermissionRequestIds pending_permission_request_ids_;
367
368 typedef std::pair<int, base::WeakPtr<BrowserPlugin> >
369 AliveV8PermissionRequestItem;
370 std::map<int, AliveV8PermissionRequestItem*>
371 alive_v8_permission_request_objects;
372
329 // BrowserPlugin outlives RenderViewImpl in Chrome Apps and so we need to 373 // BrowserPlugin outlives RenderViewImpl in Chrome Apps and so we need to
330 // store the BrowserPlugin's BrowserPluginManager in a member variable to 374 // store the BrowserPlugin's BrowserPluginManager in a member variable to
331 // avoid accessing the RenderViewImpl. 375 // avoid accessing the RenderViewImpl.
332 scoped_refptr<BrowserPluginManager> browser_plugin_manager_; 376 scoped_refptr<BrowserPluginManager> browser_plugin_manager_;
333 377
334 // Important: Do not add more history state here. 378 // Important: Do not add more history state here.
335 // We strongly discourage storing additional history state (such as page IDs) 379 // We strongly discourage storing additional history state (such as page IDs)
336 // in the embedder process, at the risk of having incorrect information that 380 // in the embedder process, at the risk of having incorrect information that
337 // can lead to broken back/forward logic in apps. 381 // 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 382 // 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 383 // 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 384 // 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 385 // 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 386 // the changes are not always obvious. For example, there is a maximum
343 // number of entries and earlier ones will automatically be pruned. 387 // number of entries and earlier ones will automatically be pruned.
344 int current_nav_entry_index_; 388 int current_nav_entry_index_;
345 int nav_entry_count_; 389 int nav_entry_count_;
346 390
347 // Used for HW compositing. 391 // Used for HW compositing.
348 bool compositing_enabled_; 392 bool compositing_enabled_;
349 scoped_refptr<BrowserPluginCompositingHelper> compositing_helper_; 393 scoped_refptr<BrowserPluginCompositingHelper> compositing_helper_;
350 394
395 // Weak factory used in v8 |MakeWeak| callback, since the v8 callback might
396 // get called after BrowserPlugin has been destroyed.
397 base::WeakPtrFactory<BrowserPlugin> weak_ptr_factory_;
398
351 DISALLOW_COPY_AND_ASSIGN(BrowserPlugin); 399 DISALLOW_COPY_AND_ASSIGN(BrowserPlugin);
352 }; 400 };
353 401
354 } // namespace content 402 } // namespace content
355 403
356 #endif // CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_H_ 404 #endif // CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698