| OLD | NEW |
| 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 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 | 51 |
| 52 namespace WebKit { | 52 namespace WebKit { |
| 53 class WebInputEvent; | 53 class WebInputEvent; |
| 54 } | 54 } |
| 55 | 55 |
| 56 namespace content { | 56 namespace content { |
| 57 | 57 |
| 58 class BrowserPluginHostFactory; | 58 class BrowserPluginHostFactory; |
| 59 class BrowserPluginEmbedder; | 59 class BrowserPluginEmbedder; |
| 60 class RenderProcessHost; | 60 class RenderProcessHost; |
| 61 struct MediaStreamRequest; |
| 61 | 62 |
| 62 // A browser plugin guest provides functionality for WebContents to operate in | 63 // A browser plugin guest provides functionality for WebContents to operate in |
| 63 // the guest role and implements guest specific overrides for ViewHostMsg_* | 64 // the guest role and implements guest specific overrides for ViewHostMsg_* |
| 64 // messages. | 65 // messages. |
| 65 // | 66 // |
| 66 // BrowserPluginEmbedder is responsible for creating and destroying a guest. | 67 // BrowserPluginEmbedder is responsible for creating and destroying a guest. |
| 67 class CONTENT_EXPORT BrowserPluginGuest : public NotificationObserver, | 68 class CONTENT_EXPORT BrowserPluginGuest : public NotificationObserver, |
| 68 public WebContentsDelegate, | 69 public WebContentsDelegate, |
| 69 public WebContentsObserver { | 70 public WebContentsObserver { |
| 70 public: | 71 public: |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 // WebContentsDelegate implementation. | 141 // WebContentsDelegate implementation. |
| 141 virtual bool CanDownload(RenderViewHost* render_view_host, | 142 virtual bool CanDownload(RenderViewHost* render_view_host, |
| 142 int request_id, | 143 int request_id, |
| 143 const std::string& request_method) OVERRIDE; | 144 const std::string& request_method) OVERRIDE; |
| 144 virtual bool HandleContextMenu(const ContextMenuParams& params) OVERRIDE; | 145 virtual bool HandleContextMenu(const ContextMenuParams& params) OVERRIDE; |
| 145 virtual void RendererUnresponsive(WebContents* source) OVERRIDE; | 146 virtual void RendererUnresponsive(WebContents* source) OVERRIDE; |
| 146 virtual void RendererResponsive(WebContents* source) OVERRIDE; | 147 virtual void RendererResponsive(WebContents* source) OVERRIDE; |
| 147 virtual void RunFileChooser(WebContents* web_contents, | 148 virtual void RunFileChooser(WebContents* web_contents, |
| 148 const FileChooserParams& params) OVERRIDE; | 149 const FileChooserParams& params) OVERRIDE; |
| 149 virtual bool ShouldFocusPageAfterCrash() OVERRIDE; | 150 virtual bool ShouldFocusPageAfterCrash() OVERRIDE; |
| 151 virtual void RequestMediaAccessPermission( |
| 152 WebContents* web_contents, |
| 153 const content::MediaStreamRequest& request, |
| 154 const content::MediaResponseCallback& callback) OVERRIDE; |
| 150 | 155 |
| 151 // Exposes the protected web_contents() from WebContentsObserver. | 156 // Exposes the protected web_contents() from WebContentsObserver. |
| 152 WebContents* GetWebContents(); | 157 WebContents* GetWebContents(); |
| 153 | 158 |
| 154 // Kill the guest process. | 159 // Kill the guest process. |
| 155 void Terminate(); | 160 void Terminate(); |
| 156 | 161 |
| 162 // Allows or denies a media access request, after the embedder has had a |
| 163 // chance to decide. |
| 164 void AllowMediaAccess(WebContents* embedder_web_contents, |
| 165 int request_id, |
| 166 bool should_allow); |
| 167 |
| 157 // Overridden in tests. | 168 // Overridden in tests. |
| 158 virtual void SetDamageBuffer( | 169 virtual void SetDamageBuffer( |
| 159 const BrowserPluginHostMsg_ResizeGuest_Params& params); | 170 const BrowserPluginHostMsg_ResizeGuest_Params& params); |
| 160 | 171 |
| 161 gfx::Point GetScreenCoordinates(const gfx::Point& relative_position) const; | 172 gfx::Point GetScreenCoordinates(const gfx::Point& relative_position) const; |
| 162 | 173 |
| 163 // Helper to send messages to embedder. Overridden in test implementation | 174 // Helper to send messages to embedder. Overridden in test implementation |
| 164 // since we want to intercept certain messages for testing. | 175 // since we want to intercept certain messages for testing. |
| 165 virtual void SendMessageToEmbedder(IPC::Message* msg); | 176 virtual void SendMessageToEmbedder(IPC::Message* msg); |
| 166 | 177 |
| 167 // Returns the embedder's routing ID. | 178 // Returns the embedder's routing ID. |
| 168 int embedder_routing_id() const; | 179 int embedder_routing_id() const; |
| 169 // Returns the identifier that uniquely identifies a browser plugin guest | 180 // Returns the identifier that uniquely identifies a browser plugin guest |
| 170 // within an embedder. | 181 // within an embedder. |
| 171 int instance_id() const { return instance_id_; } | 182 int instance_id() const { return instance_id_; } |
| 172 | 183 |
| 173 private: | 184 private: |
| 185 typedef std::pair<content::MediaStreamRequest, content::MediaResponseCallback> |
| 186 MediaStreamRequestAndCallbackPair; |
| 187 typedef std::map<int, MediaStreamRequestAndCallbackPair> |
| 188 MediaStreamRequestsMap; |
| 189 |
| 174 friend class TestBrowserPluginGuest; | 190 friend class TestBrowserPluginGuest; |
| 175 | 191 |
| 176 BrowserPluginGuest(int instance_id, | 192 BrowserPluginGuest(int instance_id, |
| 177 WebContentsImpl* web_contents, | 193 WebContentsImpl* web_contents, |
| 178 const BrowserPluginHostMsg_CreateGuest_Params& params); | 194 const BrowserPluginHostMsg_CreateGuest_Params& params); |
| 179 | 195 |
| 180 base::SharedMemory* damage_buffer() const { return damage_buffer_.get(); } | 196 base::SharedMemory* damage_buffer() const { return damage_buffer_.get(); } |
| 181 const gfx::Size& damage_view_size() const { return damage_view_size_; } | 197 const gfx::Size& damage_view_size() const { return damage_view_size_; } |
| 182 float damage_buffer_scale_factor() const { | 198 float damage_buffer_scale_factor() const { |
| 183 return damage_buffer_scale_factor_; | 199 return damage_buffer_scale_factor_; |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 gfx::Rect guest_window_rect_; | 312 gfx::Rect guest_window_rect_; |
| 297 gfx::Rect guest_screen_rect_; | 313 gfx::Rect guest_screen_rect_; |
| 298 base::TimeDelta guest_hang_timeout_; | 314 base::TimeDelta guest_hang_timeout_; |
| 299 bool focused_; | 315 bool focused_; |
| 300 bool visible_; | 316 bool visible_; |
| 301 std::string name_; | 317 std::string name_; |
| 302 bool auto_size_enabled_; | 318 bool auto_size_enabled_; |
| 303 gfx::Size max_auto_size_; | 319 gfx::Size max_auto_size_; |
| 304 gfx::Size min_auto_size_; | 320 gfx::Size min_auto_size_; |
| 305 | 321 |
| 322 // A counter to generate unique request id for a media access request. |
| 323 // We only need the ids to be unique for a given BrowserPluginGuest. |
| 324 int current_media_access_request_id_; |
| 325 // A map to store WebContents's media request object and callback. |
| 326 // We need to store these because we need a roundtrip to the embedder to know |
| 327 // if we allow or disallow the request. The key of the map is unique only for |
| 328 // a given BrowserPluginGuest. |
| 329 MediaStreamRequestsMap media_requests_map_; |
| 330 |
| 306 DISALLOW_COPY_AND_ASSIGN(BrowserPluginGuest); | 331 DISALLOW_COPY_AND_ASSIGN(BrowserPluginGuest); |
| 307 }; | 332 }; |
| 308 | 333 |
| 309 } // namespace content | 334 } // namespace content |
| 310 | 335 |
| 311 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_ | 336 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_ |
| OLD | NEW |