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. Any | 9 // BrowserPluginGuest lives on the UI thread of the browser process. Any |
10 // messages about the guest render process that the embedder might be interested | 10 // messages about the guest render process that the embedder might be interested |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 // container, then this call is a no-op. For guest types that can be | 113 // container, then this call is a no-op. For guest types that can be |
114 // navigated, this call adds the associated RenderWdigetHostViewGuest to the | 114 // navigated, this call adds the associated RenderWdigetHostViewGuest to the |
115 // view hierachy and sets up the appropriate RendererPreferences so that this | 115 // view hierachy and sets up the appropriate RendererPreferences so that this |
116 // guest can navigate and resize offscreen. | 116 // guest can navigate and resize offscreen. |
117 void Init(); | 117 void Init(); |
118 | 118 |
119 // Returns a WeakPtr to this BrowserPluginGuest. | 119 // Returns a WeakPtr to this BrowserPluginGuest. |
120 base::WeakPtr<BrowserPluginGuest> AsWeakPtr(); | 120 base::WeakPtr<BrowserPluginGuest> AsWeakPtr(); |
121 | 121 |
122 // Sets the focus state of the current RenderWidgetHostView. | 122 // Sets the focus state of the current RenderWidgetHostView. |
123 void SetFocus(RenderWidgetHost* rwh, | 123 void SetFocusForRenderWidgetHost(RenderWidgetHost* rwh, |
124 bool focused, | 124 bool focused, |
125 blink::WebFocusType focus_type); | 125 blink::WebFocusType focus_type); |
126 | 126 |
127 // Sets the tooltip text. | 127 // Sets the tooltip text. |
128 void SetTooltipText(const base::string16& tooltip_text); | 128 void SetTooltipText(const base::string16& tooltip_text); |
129 | 129 |
130 // Sets the lock state of the pointer. Returns true if |allowed| is true and | 130 // Sets the lock state of the pointer. Returns true if |allowed| is true and |
131 // the mouse has been successfully locked. | 131 // the mouse has been successfully locked. |
132 bool LockMouse(bool allowed); | 132 bool LockMouse(bool allowed); |
133 | 133 |
134 // Return true if the mouse is locked. | 134 // Return true if the mouse is locked. |
135 bool mouse_locked() const { return mouse_locked_; } | 135 bool mouse_locked() const { return mouse_locked_; } |
(...skipping 18 matching lines...) Expand all Loading... |
154 | 154 |
155 WebContentsImpl* embedder_web_contents() const { | 155 WebContentsImpl* embedder_web_contents() const { |
156 return attached_ ? owner_web_contents_ : nullptr; | 156 return attached_ ? owner_web_contents_ : nullptr; |
157 } | 157 } |
158 | 158 |
159 // Returns the embedder's RenderWidgetHostView if it is available. | 159 // Returns the embedder's RenderWidgetHostView if it is available. |
160 // Returns nullptr otherwise. | 160 // Returns nullptr otherwise. |
161 RenderWidgetHostView* GetOwnerRenderWidgetHostView(); | 161 RenderWidgetHostView* GetOwnerRenderWidgetHostView(); |
162 | 162 |
163 bool focused() const { return focused_; } | 163 bool focused() const { return focused_; } |
164 bool visible() const { return guest_visible_; } | 164 bool container_visible() const { return container_visible_; } |
165 bool is_in_destruction() { return is_in_destruction_; } | 165 bool is_in_destruction() { return is_in_destruction_; } |
166 | 166 |
167 void UpdateVisibility(); | 167 void UpdateVisibility(); |
168 | 168 |
169 BrowserPluginGuestManager* GetBrowserPluginGuestManager() const; | 169 BrowserPluginGuestManager* GetBrowserPluginGuestManager() const; |
170 | 170 |
171 // WebContentsObserver implementation. | 171 // WebContentsObserver implementation. |
172 void DidCommitProvisionalLoadForFrame( | 172 void DidCommitProvisionalLoadForFrame( |
173 RenderFrameHost* render_frame_host, | 173 RenderFrameHost* render_frame_host, |
174 const GURL& url, | 174 const GURL& url, |
175 ui::PageTransition transition_type) override; | 175 ui::PageTransition transition_type) override; |
176 | 176 |
177 void RenderViewReady() override; | 177 void RenderViewReady() override; |
178 void RenderProcessGone(base::TerminationStatus status) override; | 178 void RenderProcessGone(base::TerminationStatus status) override; |
179 bool OnMessageReceived(const IPC::Message& message) override; | 179 bool OnMessageReceived(const IPC::Message& message) override; |
180 bool OnMessageReceived(const IPC::Message& message, | 180 bool OnMessageReceived(const IPC::Message& message, |
181 RenderFrameHost* render_frame_host) override; | 181 RenderFrameHost* render_frame_host) override; |
182 | 182 |
183 // GuestHost implementation. | 183 // GuestHost implementation. |
| 184 void Attach(int element_instance_id, |
| 185 WebContents* embedder_web_contents, |
| 186 const GuestAttachParams& attach_params) override; |
184 int LoadURLWithParams( | 187 int LoadURLWithParams( |
185 const NavigationController::LoadURLParams& load_params) override; | 188 const NavigationController::LoadURLParams& load_params) override; |
186 void GuestResizeDueToAutoResize(const gfx::Size& new_size) override; | 189 void GuestResizeDueToAutoResize(const gfx::Size& new_size) override; |
| 190 void SetContainerVisible(bool visible) override; |
| 191 void SetFocus(bool focused, blink::WebFocusType focus_type) override; |
187 void SizeContents(const gfx::Size& new_size) override; | 192 void SizeContents(const gfx::Size& new_size) override; |
| 193 void ForwardInputEvent(const blink::WebInputEvent* event) override; |
188 void WillDestroy() override; | 194 void WillDestroy() override; |
189 | 195 |
190 // Exposes the protected web_contents() from WebContentsObserver. | 196 // Exposes the protected web_contents() from WebContentsObserver. |
191 WebContentsImpl* GetWebContents() const; | 197 WebContentsImpl* GetWebContents() const; |
192 | 198 |
193 gfx::Point GetScreenCoordinates(const gfx::Point& relative_position) const; | 199 gfx::Point GetScreenCoordinates(const gfx::Point& relative_position) const; |
194 | 200 |
195 // This method is called by the RenderWidgetHostViewGuest to inform the | 201 // This method is called by the RenderWidgetHostViewGuest to inform the |
196 // BrowserPlugin of the potential location of the context menu event (to | 202 // BrowserPlugin of the potential location of the context menu event (to |
197 // come). The need for this (hack) is that the input events when passed on to | 203 // come). The need for this (hack) is that the input events when passed on to |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 has_attached_since_surface_set_ = has_attached; | 280 has_attached_since_surface_set_ = has_attached; |
275 } | 281 } |
276 | 282 |
277 void set_attached_for_test(bool attached) { | 283 void set_attached_for_test(bool attached) { |
278 attached_ = attached; | 284 attached_ = attached; |
279 } | 285 } |
280 | 286 |
281 private: | 287 private: |
282 class EmbedderVisibilityObserver; | 288 class EmbedderVisibilityObserver; |
283 | 289 |
284 void InitInternal(const BrowserPluginHostMsg_Attach_Params& params, | 290 void InitInternal(const GuestAttachParams& params, |
285 WebContentsImpl* owner_web_contents); | 291 WebContentsImpl* owner_web_contents); |
286 | 292 |
287 void OnSatisfySequence(int instance_id, const cc::SurfaceSequence& sequence); | 293 void OnSatisfySequence(int instance_id, const cc::SurfaceSequence& sequence); |
288 void OnRequireSequence(int instance_id, | 294 void OnRequireSequence(int instance_id, |
289 const cc::SurfaceId& id, | 295 const cc::SurfaceId& id, |
290 const cc::SurfaceSequence& sequence); | 296 const cc::SurfaceSequence& sequence); |
291 // Message handlers for messages from embedder. | 297 // Message handlers for messages from embedder. |
292 void OnCompositorFrameSwappedACK( | 298 void OnCompositorFrameSwappedACK( |
293 int instance_id, | 299 int instance_id, |
294 const FrameHostMsg_CompositorFrameSwappedACK_Params& params); | 300 const FrameHostMsg_CompositorFrameSwappedACK_Params& params); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 const FrameHostMsg_ShowPopup_Params& params); | 385 const FrameHostMsg_ShowPopup_Params& params); |
380 #endif | 386 #endif |
381 void OnShowWidget(int route_id, const gfx::Rect& initial_rect); | 387 void OnShowWidget(int route_id, const gfx::Rect& initial_rect); |
382 void OnTakeFocus(bool reverse); | 388 void OnTakeFocus(bool reverse); |
383 void OnUpdateFrameName(int frame_id, | 389 void OnUpdateFrameName(int frame_id, |
384 bool is_top_level, | 390 bool is_top_level, |
385 const std::string& name); | 391 const std::string& name); |
386 | 392 |
387 // Called when WillAttach is complete. | 393 // Called when WillAttach is complete. |
388 void OnWillAttachComplete(WebContentsImpl* embedder_web_contents, | 394 void OnWillAttachComplete(WebContentsImpl* embedder_web_contents, |
389 const BrowserPluginHostMsg_Attach_Params& params); | 395 const GuestAttachParams& params); |
390 | 396 |
391 // Returns identical message with current browser_plugin_instance_id() if | 397 // Returns identical message with current browser_plugin_instance_id() if |
392 // the input was created with browser_plugin::kInstanceIdNone, else it returns | 398 // the input was created with browser_plugin::kInstanceIdNone, else it returns |
393 // the input message unmodified. If no current browser_plugin_instance_id() | 399 // the input message unmodified. If no current browser_plugin_instance_id() |
394 // is set, or anything goes wrong, the input message is returned. | 400 // is set, or anything goes wrong, the input message is returned. |
395 IPC::Message* UpdateInstanceIdIfNecessary(IPC::Message* msg) const; | 401 IPC::Message* UpdateInstanceIdIfNecessary(IPC::Message* msg) const; |
396 | 402 |
397 // Forwards all messages from the |pending_messages_| queue to the embedder. | 403 // Forwards all messages from the |pending_messages_| queue to the embedder. |
398 void SendQueuedMessages(); | 404 void SendQueuedMessages(); |
399 | 405 |
(...skipping 11 matching lines...) Expand all Loading... |
411 // Used to signal if a browser plugin has been attached since the last time | 417 // Used to signal if a browser plugin has been attached since the last time |
412 // the compositing surface was set. | 418 // the compositing surface was set. |
413 bool has_attached_since_surface_set_; | 419 bool has_attached_since_surface_set_; |
414 | 420 |
415 // An identifier that uniquely identifies a browser plugin within an embedder. | 421 // An identifier that uniquely identifies a browser plugin within an embedder. |
416 int browser_plugin_instance_id_; | 422 int browser_plugin_instance_id_; |
417 gfx::Rect guest_window_rect_; | 423 gfx::Rect guest_window_rect_; |
418 bool focused_; | 424 bool focused_; |
419 bool mouse_locked_; | 425 bool mouse_locked_; |
420 bool pending_lock_request_; | 426 bool pending_lock_request_; |
421 bool guest_visible_; | 427 bool container_visible_; |
422 bool embedder_visible_; | 428 bool embedder_visible_; |
423 // Whether the browser plugin is inside a plugin document. | 429 // Whether the browser plugin is inside a plugin document. |
424 bool is_full_page_plugin_; | 430 bool is_full_page_plugin_; |
425 | 431 |
426 // Indicates that this BrowserPluginGuest has associated renderer-side state. | 432 // Indicates that this BrowserPluginGuest has associated renderer-side state. |
427 // This is used to determine whether or not to create a new RenderView when | 433 // This is used to determine whether or not to create a new RenderView when |
428 // this guest is attached. A BrowserPluginGuest would have renderer-side state | 434 // this guest is attached. A BrowserPluginGuest would have renderer-side state |
429 // prior to attachment if it is created via a call to window.open and | 435 // prior to attachment if it is created via a call to window.open and |
430 // maintains a JavaScript reference to its opener. | 436 // maintains a JavaScript reference to its opener. |
431 bool has_render_view_; | 437 bool has_render_view_; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
474 // Weak pointer used to ask GeolocationPermissionContext about geolocation | 480 // Weak pointer used to ask GeolocationPermissionContext about geolocation |
475 // permission. | 481 // permission. |
476 base::WeakPtrFactory<BrowserPluginGuest> weak_ptr_factory_; | 482 base::WeakPtrFactory<BrowserPluginGuest> weak_ptr_factory_; |
477 | 483 |
478 DISALLOW_COPY_AND_ASSIGN(BrowserPluginGuest); | 484 DISALLOW_COPY_AND_ASSIGN(BrowserPluginGuest); |
479 }; | 485 }; |
480 | 486 |
481 } // namespace content | 487 } // namespace content |
482 | 488 |
483 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_ | 489 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_ |
OLD | NEW |