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

Side by Side Diff: content/browser/browser_plugin/browser_plugin_guest.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: Fix header guard name. 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 // A BrowserPluginGuest is the browser side of a browser <--> embedder 5 // A BrowserPluginGuest is the browser side of a browser <--> embedder
6 // renderer channel. A BrowserPlugin (a WebPlugin) is on the embedder 6 // renderer channel. A BrowserPlugin (a WebPlugin) is on the embedder
7 // renderer side of browser <--> embedder renderer communication. 7 // renderer side of browser <--> embedder renderer communication.
8 // 8 //
9 // BrowserPluginGuest lives on the UI thread of the browser process. It has a 9 // BrowserPluginGuest lives on the UI thread of the browser process. It has a
10 // helper, BrowserPluginGuestHelper, which is a RenderViewHostObserver. The 10 // helper, BrowserPluginGuestHelper, which is a RenderViewHostObserver. The
11 // helper object intercepts messages (ViewHostMsg_*) directed at the browser 11 // helper object intercepts messages (ViewHostMsg_*) directed at the browser
12 // process and redirects them to this class. Any messages about the guest render 12 // process and redirects them to this class. Any messages about the guest render
13 // process that the embedder might be interested in receiving should be listened 13 // process that the embedder might be interested in receiving should be listened
14 // for here. 14 // for here.
15 // 15 //
16 // BrowserPluginGuest is a WebContentsDelegate and WebContentsObserver for the 16 // BrowserPluginGuest is a WebContentsDelegate and WebContentsObserver for the
17 // guest WebContents. BrowserPluginGuest operates under the assumption that the 17 // guest WebContents. BrowserPluginGuest operates under the assumption that the
18 // guest will be accessible through only one RenderViewHost for the lifetime of 18 // guest will be accessible through only one RenderViewHost for the lifetime of
19 // the guest WebContents. Thus, cross-process navigation is not supported. 19 // the guest WebContents. Thus, cross-process navigation is not supported.
20 20
21 #ifndef CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_ 21 #ifndef CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_
22 #define CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_ 22 #define CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_
23 23
24 #include <map> 24 #include <map>
25 25
26 #include "base/compiler_specific.h" 26 #include "base/compiler_specific.h"
27 #include "base/id_map.h" 27 #include "base/id_map.h"
28 #include "base/shared_memory.h" 28 #include "base/shared_memory.h"
29 #include "base/time.h" 29 #include "base/time.h"
30 #include "content/common/browser_plugin_message_enums.h"
30 #include "content/port/common/input_event_ack_state.h" 31 #include "content/port/common/input_event_ack_state.h"
31 #include "content/public/browser/notification_observer.h" 32 #include "content/public/browser/notification_observer.h"
32 #include "content/public/browser/notification_registrar.h" 33 #include "content/public/browser/notification_registrar.h"
33 #include "content/public/browser/web_contents_delegate.h" 34 #include "content/public/browser/web_contents_delegate.h"
34 #include "content/public/browser/web_contents_observer.h" 35 #include "content/public/browser/web_contents_observer.h"
35 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDragOperation.h" 36 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDragOperation.h"
36 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDragStatus.h" 37 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDragStatus.h"
37 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" 38 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
38 #include "ui/gfx/rect.h" 39 #include "ui/gfx/rect.h"
39 #include "ui/surface/transport_dib.h" 40 #include "ui/surface/transport_dib.h"
(...skipping 11 matching lines...) Expand all
51 52
52 namespace WebKit { 53 namespace WebKit {
53 class WebInputEvent; 54 class WebInputEvent;
54 } 55 }
55 56
56 namespace content { 57 namespace content {
57 58
58 class BrowserPluginHostFactory; 59 class BrowserPluginHostFactory;
59 class BrowserPluginEmbedder; 60 class BrowserPluginEmbedder;
60 class RenderProcessHost; 61 class RenderProcessHost;
62 struct MediaStreamRequest;
61 63
62 // A browser plugin guest provides functionality for WebContents to operate in 64 // A browser plugin guest provides functionality for WebContents to operate in
63 // the guest role and implements guest specific overrides for ViewHostMsg_* 65 // the guest role and implements guest specific overrides for ViewHostMsg_*
64 // messages. 66 // messages.
65 // 67 //
66 // BrowserPluginEmbedder is responsible for creating and destroying a guest. 68 // BrowserPluginEmbedder is responsible for creating and destroying a guest.
67 class CONTENT_EXPORT BrowserPluginGuest : public NotificationObserver, 69 class CONTENT_EXPORT BrowserPluginGuest : public NotificationObserver,
68 public WebContentsDelegate, 70 public WebContentsDelegate,
69 public WebContentsObserver { 71 public WebContentsObserver {
70 public: 72 public:
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 // WebContentsDelegate implementation. 143 // WebContentsDelegate implementation.
142 virtual bool CanDownload(RenderViewHost* render_view_host, 144 virtual bool CanDownload(RenderViewHost* render_view_host,
143 int request_id, 145 int request_id,
144 const std::string& request_method) OVERRIDE; 146 const std::string& request_method) OVERRIDE;
145 virtual bool HandleContextMenu(const ContextMenuParams& params) OVERRIDE; 147 virtual bool HandleContextMenu(const ContextMenuParams& params) OVERRIDE;
146 virtual void RendererUnresponsive(WebContents* source) OVERRIDE; 148 virtual void RendererUnresponsive(WebContents* source) OVERRIDE;
147 virtual void RendererResponsive(WebContents* source) OVERRIDE; 149 virtual void RendererResponsive(WebContents* source) OVERRIDE;
148 virtual void RunFileChooser(WebContents* web_contents, 150 virtual void RunFileChooser(WebContents* web_contents,
149 const FileChooserParams& params) OVERRIDE; 151 const FileChooserParams& params) OVERRIDE;
150 virtual bool ShouldFocusPageAfterCrash() OVERRIDE; 152 virtual bool ShouldFocusPageAfterCrash() OVERRIDE;
153 virtual void RequestMediaAccessPermission(
154 WebContents* web_contents,
155 const content::MediaStreamRequest& request,
156 const content::MediaResponseCallback& callback) OVERRIDE;
151 157
152 // Exposes the protected web_contents() from WebContentsObserver. 158 // Exposes the protected web_contents() from WebContentsObserver.
153 WebContents* GetWebContents(); 159 WebContents* GetWebContents();
154 160
155 // Kill the guest process. 161 // Kill the guest process.
156 void Terminate(); 162 void Terminate();
157 163
158 // Overridden in tests. 164 // Overridden in tests.
159 virtual void SetDamageBuffer( 165 virtual void SetDamageBuffer(
160 const BrowserPluginHostMsg_ResizeGuest_Params& params); 166 const BrowserPluginHostMsg_ResizeGuest_Params& params);
(...skipping 11 matching lines...) Expand all
172 int instance_id() const { return instance_id_; } 178 int instance_id() const { return instance_id_; }
173 179
174 // Allow the embedder to call this for unhandled messages when 180 // Allow the embedder to call this for unhandled messages when
175 // BrowserPluginGuest is already destroyed. 181 // BrowserPluginGuest is already destroyed.
176 static void AcknowledgeBufferPresent(int route_id, 182 static void AcknowledgeBufferPresent(int route_id,
177 int gpu_host_id, 183 int gpu_host_id,
178 const std::string& mailbox_name, 184 const std::string& mailbox_name,
179 uint32 sync_point); 185 uint32 sync_point);
180 186
181 private: 187 private:
188 typedef std::pair<content::MediaStreamRequest, content::MediaResponseCallback>
189 MediaStreamRequestAndCallbackPair;
190 typedef std::map<int, MediaStreamRequestAndCallbackPair>
191 MediaStreamRequestsMap;
192
182 friend class TestBrowserPluginGuest; 193 friend class TestBrowserPluginGuest;
183 194
184 BrowserPluginGuest(int instance_id, 195 BrowserPluginGuest(int instance_id,
185 WebContentsImpl* embedder_web_contents, 196 WebContentsImpl* embedder_web_contents,
186 WebContentsImpl* web_contents, 197 WebContentsImpl* web_contents,
187 const BrowserPluginHostMsg_CreateGuest_Params& params); 198 const BrowserPluginHostMsg_CreateGuest_Params& params);
188 199
189 base::SharedMemory* damage_buffer() const { return damage_buffer_.get(); } 200 base::SharedMemory* damage_buffer() const { return damage_buffer_.get(); }
190 const gfx::Size& damage_view_size() const { return damage_view_size_; } 201 const gfx::Size& damage_view_size() const { return damage_view_size_; }
191 float damage_buffer_scale_factor() const { 202 float damage_buffer_scale_factor() const {
192 return damage_buffer_scale_factor_; 203 return damage_buffer_scale_factor_;
193 } 204 }
194 // Returns the damage buffer corresponding to the handle in resize |params|. 205 // Returns the damage buffer corresponding to the handle in resize |params|.
195 base::SharedMemory* GetDamageBufferFromEmbedder( 206 base::SharedMemory* GetDamageBufferFromEmbedder(
196 const BrowserPluginHostMsg_ResizeGuest_Params& params); 207 const BrowserPluginHostMsg_ResizeGuest_Params& params);
197 208
198 // Called when a redirect notification occurs. 209 // Called when a redirect notification occurs.
199 void LoadRedirect(const GURL& old_url, 210 void LoadRedirect(const GURL& old_url,
200 const GURL& new_url, 211 const GURL& new_url,
201 bool is_top_level); 212 bool is_top_level);
202 213
203 bool InAutoSizeBounds(const gfx::Size& size) const; 214 bool InAutoSizeBounds(const gfx::Size& size) const;
204 215
205 // Message handlers for messsages from embedder. 216 // Message handlers for messsages from embedder.
206 217
218 // Allows or denies a permission request access, after the embedder has had a
219 // chance to decide.
220 void OnAllowPermission(int instance_id,
221 BrowserPluginPermissionType permission_type,
222 int request_id,
223 bool should_allow);
207 // Handles drag events from the embedder. 224 // Handles drag events from the embedder.
208 // When dragging, the drag events go to the embedder first, and if the drag 225 // When dragging, the drag events go to the embedder first, and if the drag
209 // happens on the browser plugin, then the plugin sends a corresponding 226 // happens on the browser plugin, then the plugin sends a corresponding
210 // drag-message to the guest. This routes the drag-message to the guest 227 // drag-message to the guest. This routes the drag-message to the guest
211 // renderer. 228 // renderer.
212 void OnDragStatusUpdate(int instance_id, 229 void OnDragStatusUpdate(int instance_id,
213 WebKit::WebDragStatus drag_status, 230 WebKit::WebDragStatus drag_status,
214 const WebDropData& drop_data, 231 const WebDropData& drop_data,
215 WebKit::WebDragOperationsMask drag_mask, 232 WebKit::WebDragOperationsMask drag_mask,
216 const gfx::Point& location); 233 const gfx::Point& location);
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 gfx::Rect guest_screen_rect_; 330 gfx::Rect guest_screen_rect_;
314 base::TimeDelta guest_hang_timeout_; 331 base::TimeDelta guest_hang_timeout_;
315 bool focused_; 332 bool focused_;
316 bool guest_visible_; 333 bool guest_visible_;
317 bool embedder_visible_; 334 bool embedder_visible_;
318 std::string name_; 335 std::string name_;
319 bool auto_size_enabled_; 336 bool auto_size_enabled_;
320 gfx::Size max_auto_size_; 337 gfx::Size max_auto_size_;
321 gfx::Size min_auto_size_; 338 gfx::Size min_auto_size_;
322 339
340 // A counter to generate unique request id for a media access request.
341 // We only need the ids to be unique for a given BrowserPluginGuest.
342 int current_media_access_request_id_;
343 // A map to store WebContents's media request object and callback.
344 // We need to store these because we need a roundtrip to the embedder to know
345 // if we allow or disallow the request. The key of the map is unique only for
346 // a given BrowserPluginGuest.
347 MediaStreamRequestsMap media_requests_map_;
348
323 DISALLOW_COPY_AND_ASSIGN(BrowserPluginGuest); 349 DISALLOW_COPY_AND_ASSIGN(BrowserPluginGuest);
324 }; 350 };
325 351
326 } // namespace content 352 } // namespace content
327 353
328 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_ 354 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698