blob: 44ed710032597aba67ec513cd822df9354684535 [file] [log] [blame]
[email protected]7a846df2012-09-20 19:17:391// 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
3// found in the LICENSE file.
4
[email protected]a7fac9a2012-12-18 23:26:075// A BrowserPluginGuest is the browser side of a browser <--> embedder
6// renderer channel. A BrowserPlugin (a WebPlugin) is on the embedder
7// renderer side of browser <--> embedder renderer communication.
[email protected]7a846df2012-09-20 19:17:398//
[email protected]864297a2013-10-30 19:25:319// BrowserPluginGuest lives on the UI thread of the browser process. Any
10// messages about the guest render process that the embedder might be interested
11// in receiving should be listened for here.
[email protected]7a846df2012-09-20 19:17:3912//
[email protected]aec80ed2014-05-27 00:01:1513// BrowserPluginGuest is a WebContentsObserver for the guest WebContents.
14// BrowserPluginGuest operates under the assumption that the guest will be
15// accessible through only one RenderViewHost for the lifetime of
[email protected]a7fac9a2012-12-18 23:26:0716// the guest WebContents. Thus, cross-process navigation is not supported.
[email protected]7a846df2012-09-20 19:17:3917
18#ifndef CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_
19#define CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_
20
avib7348942015-12-25 20:57:1021#include <stdint.h>
22
[email protected]7a846df2012-09-20 19:17:3923#include <map>
limasdf85735f42016-10-21 02:24:5524#include <memory>
[email protected]7a846df2012-09-20 19:17:3925
26#include "base/compiler_specific.h"
Brett Wilsoncc8623d2017-09-12 03:28:1027#include "base/containers/circular_deque.h"
avib7348942015-12-25 20:57:1028#include "base/macros.h"
[email protected]e4a55a52013-03-09 01:32:4929#include "base/memory/weak_ptr.h"
[email protected]738f57a2013-06-29 21:06:5430#include "base/values.h"
avib7348942015-12-25 20:57:1031#include "build/build_config.h"
Fady Samuel84d8a1f72018-11-08 00:26:1732#include "components/viz/common/surfaces/local_surface_id_allocation.h"
Chris Blume12a26462018-04-22 02:00:1233#include "components/viz/common/surfaces/scoped_surface_id_allocator.h"
Albert J. Wongeb28e7e2018-10-12 00:57:4334#include "content/browser/renderer_host/input_event_shim.h"
[email protected]b77fac52013-06-01 01:03:4635#include "content/common/edit_command.h"
[email protected]4c0e8272013-07-03 23:39:2236#include "content/public/browser/browser_plugin_guest_delegate.h"
fsamuel60b42282015-03-10 03:29:1437#include "content/public/browser/guest_host.h"
[email protected]7a846df2012-09-20 19:17:3938#include "content/public/browser/web_contents_observer.h"
Dave Tapuska66c183b22017-10-23 16:04:3539#include "content/public/common/input_event_ack_state.h"
Fady Samuel85a1bf72017-10-27 14:30:2040#include "content/public/common/screen_info.h"
Blink Reformata30d4232018-04-07 15:31:0641#include "third_party/blink/public/platform/web_drag_operation.h"
42#include "third_party/blink/public/platform/web_focus_type.h"
43#include "third_party/blink/public/platform/web_input_event.h"
44#include "third_party/blink/public/web/web_drag_status.h"
45#include "third_party/blink/public/web/web_ime_text_span.h"
[email protected]d260f042013-12-14 01:31:3646#include "ui/base/ime/text_input_mode.h"
47#include "ui/base/ime/text_input_type.h"
tfarina3b0452d2014-12-31 15:20:0948#include "ui/gfx/geometry/rect.h"
[email protected]7a846df2012-09-20 19:17:3949
[email protected]4b4ed582013-05-01 00:16:2350struct BrowserPluginHostMsg_Attach_Params;
ekaramadb62c3432017-03-15 21:59:4651struct BrowserPluginHostMsg_SetComposition_Params;
fsamuel7310a4262014-12-05 05:06:4452
[email protected]4f89d9d2012-12-12 01:38:4853#if defined(OS_MACOSX)
avi485e5fd62014-08-25 23:26:1454struct FrameHostMsg_ShowPopup_Params;
[email protected]4f89d9d2012-12-12 01:38:4855#endif
[email protected]7a846df2012-09-20 19:17:3956
[email protected]d260f042013-12-14 01:31:3657namespace gfx {
58class Range;
fsamuel04a6f5f2014-09-04 22:42:1459} // namespace gfx
[email protected]d260f042013-12-14 01:31:3660
Fady Samuele392fd52018-05-11 17:16:4361namespace cc {
62class RenderFrameMetadata;
63} // namespace cc
64
Fady Samueld5c26182017-07-12 02:43:3365namespace viz {
Fady Samuel84d8a1f72018-11-08 00:26:1766class LocalSurfaceIdAllocation;
Fady Samueld5c26182017-07-12 02:43:3367} // namespace viz
68
[email protected]7a846df2012-09-20 19:17:3969namespace content {
70
[email protected]139355f2014-05-11 14:21:2871class BrowserPluginGuestManager;
Rakina Zata Amni3d10bb3c2019-04-19 03:12:0772class RenderFrameHostImpl;
[email protected]a24efc22014-05-26 15:50:2573class RenderViewHostImpl;
fsamuel9e3d9ad2014-09-11 00:59:3074class RenderWidgetHost;
ekaramad51ca2092016-11-17 06:05:5875class RenderWidgetHostImpl;
[email protected]44327692013-02-26 21:21:2276class RenderWidgetHostView;
lazyboya34ff622015-04-07 02:21:1777class RenderWidgetHostViewBase;
[email protected]dbbce92c2013-10-31 16:51:1978class SiteInstance;
[email protected]dc293a72013-07-01 11:11:2279struct DropData;
Fady Samuel799e72192018-04-25 21:16:5780struct FrameVisualProperties;
Fady Samuel85a1bf72017-10-27 14:30:2081struct ScreenInfo;
ekaramad9053e57b2016-04-26 20:00:3882struct TextInputState;
[email protected]7a846df2012-09-20 19:17:3983
84// A browser plugin guest provides functionality for WebContents to operate in
[email protected]c4538072013-03-18 02:17:5585// the guest role and implements guest-specific overrides for ViewHostMsg_*
[email protected]7a846df2012-09-20 19:17:3986// messages.
87//
[email protected]c4538072013-03-18 02:17:5588// When a guest is initially created, it is in an unattached state. That is,
89// it is not visible anywhere and has no embedder WebContents assigned.
90// A BrowserPluginGuest is said to be "attached" if it has an embedder.
91// A BrowserPluginGuest can also create a new unattached guest via
92// CreateNewWindow. The newly created guest will live in the same partition,
93// which means it can share storage and can script this guest.
lazyboy6ec48b2a2015-06-29 15:18:1494//
95// Note: in --site-per-process, all IPCs sent out from this class will be
96// dropped on the floor since we don't have a BrowserPlugin.
fsamuel60b42282015-03-10 03:29:1497class CONTENT_EXPORT BrowserPluginGuest : public GuestHost,
paulmeyer0968abad2015-01-10 00:02:4598 public WebContentsObserver {
[email protected]7a846df2012-09-20 19:17:3999 public:
dchengc2282aa2014-10-21 12:07:58100 ~BrowserPluginGuest() override;
[email protected]7a846df2012-09-20 19:17:39101
[email protected]dbbce92c2013-10-31 16:51:19102 // The WebContents passed into the factory method here has not been
103 // initialized yet and so it does not yet hold a SiteInstance.
104 // BrowserPluginGuest must be constructed and installed into a WebContents
105 // prior to its initialization because WebContents needs to determine what
106 // type of WebContentsView to construct on initialization. The content
107 // embedder needs to be aware of |guest_site_instance| on the guest's
108 // construction and so we pass it in here.
Albert J. Wongc55cc64d2018-10-12 02:50:04109 //
110 // After this, a new BrowserPluginGuest is created with ownership transferred
111 // into the |web_contents|.
112 static void CreateInWebContents(WebContentsImpl* web_contents,
113 BrowserPluginGuestDelegate* delegate);
[email protected]0c6d41752013-05-01 15:49:09114
[email protected]a24efc22014-05-26 15:50:25115 // Returns whether the given WebContents is a BrowserPlugin guest.
116 static bool IsGuest(WebContentsImpl* web_contents);
117
118 // Returns whether the given RenderviewHost is a BrowserPlugin guest.
119 static bool IsGuest(RenderViewHostImpl* render_view_host);
120
fsamuel7310a4262014-12-05 05:06:44121 // BrowserPluginGuest::Init is called after the associated guest WebContents
122 // initializes. If this guest cannot navigate without being attached to a
123 // container, then this call is a no-op. For guest types that can be
124 // navigated, this call adds the associated RenderWdigetHostViewGuest to the
Leon Hanc819dc62019-01-28 04:30:19125 // view hierarchy and sets up the appropriate
126 // blink::mojom::RendererPreferences so that this guest can navigate and
127 // resize offscreen.
fsamuel7310a4262014-12-05 05:06:44128 void Init();
129
Albert J. Wongeb28e7e2018-10-12 00:57:43130 // Returns an InputEventShim if this BrowserPluginGuest needs to intercept
131 // input events normally handled by a RenderWidgetHost.
132 InputEventShim* GetInputEventShim();
133
[email protected]8fb60c32014-02-02 17:46:40134 // Returns a WeakPtr to this BrowserPluginGuest.
135 base::WeakPtr<BrowserPluginGuest> AsWeakPtr();
136
fsamuel9e3d9ad2014-09-11 00:59:30137 // Sets the focus state of the current RenderWidgetHostView.
fsamuel5ec049d2015-01-19 16:57:41138 void SetFocus(RenderWidgetHost* rwh,
139 bool focused,
140 blink::WebFocusType focus_type);
fsamuel9e3d9ad2014-09-11 00:59:30141
[email protected]660f18e2014-05-15 20:53:05142 // Sets the lock state of the pointer. Returns true if |allowed| is true and
143 // the mouse has been successfully locked.
144 bool LockMouse(bool allowed);
145
[email protected]0b094002014-08-20 18:28:10146 // Return true if the mouse is locked.
147 bool mouse_locked() const { return mouse_locked_; }
148
[email protected]e0c6dc92013-10-10 21:17:51149 // Called when the embedder WebContents changes visibility.
Francois Dorayfe4a1772018-02-17 04:17:09150 void EmbedderVisibilityChanged(Visibility visibility);
[email protected]e0c6dc92013-10-10 21:17:51151
[email protected]4858e432014-06-23 18:14:17152 // Creates a new guest WebContentsImpl with the provided |params| with |this|
153 // as the |opener|.
154 WebContentsImpl* CreateNewGuestWindow(
155 const WebContents::CreateParams& params);
156
[email protected]c4538072013-03-18 02:17:55157 // Returns the identifier that uniquely identifies a browser plugin guest
158 // within an embedder.
[email protected]2101c4c2014-08-22 00:16:16159 int browser_plugin_instance_id() const { return browser_plugin_instance_id_; }
[email protected]7a846df2012-09-20 19:17:39160
Fady Samuel85a1bf72017-10-27 14:30:20161 // Returns the ScreenInfo used by the guest to render.
162 const ScreenInfo& screen_info() const { return screen_info_; }
163
164 // Returns the current rect used by the guest to render.
165 const gfx::Rect& frame_rect() const { return frame_rect_; }
166
[email protected]3997b1b22012-12-20 01:02:54167 bool OnMessageReceivedFromEmbedder(const IPC::Message& message);
168
[email protected]ca61ce142012-11-27 21:32:57169 WebContentsImpl* embedder_web_contents() const {
fsamuel7df36b22015-01-21 20:13:07170 return attached_ ? owner_web_contents_ : nullptr;
[email protected]ca61ce142012-11-27 21:32:57171 }
[email protected]e17b7c62012-09-21 21:05:46172
[email protected]68d5ab72014-01-23 22:22:57173 // Returns the embedder's RenderWidgetHostView if it is available.
fsamuel7df36b22015-01-21 20:13:07174 // Returns nullptr otherwise.
fsamuelad4f33f2014-11-28 19:32:21175 RenderWidgetHostView* GetOwnerRenderWidgetHostView();
[email protected]44327692013-02-26 21:21:22176
Rakina Zata Amni3d10bb3c2019-04-19 03:12:07177 // Returns the embedder frame.
178 RenderFrameHostImpl* GetEmbedderFrame() const;
179
[email protected]6a121f22012-10-30 03:19:48180 bool focused() const { return focused_; }
[email protected]93564f72013-02-15 13:26:19181 bool visible() const { return guest_visible_; }
Fady Samuelf3f9b832017-09-01 17:11:17182
Fady Samuel84d8a1f72018-11-08 00:26:17183 // Returns the viz::LocalSurfaceIdAllocation propagated from the parent to be
184 // used by this guest.
185 const viz::LocalSurfaceIdAllocation& local_surface_id_allocation() const {
186 return local_surface_id_allocation_;
Fady Samuelb655f452018-11-06 00:48:34187 }
188
[email protected]3f6fa6d42013-08-16 21:19:49189 bool is_in_destruction() { return is_in_destruction_; }
[email protected]6a13c9f2012-10-08 16:25:08190
[email protected]3997b1b22012-12-20 01:02:54191 void UpdateVisibility();
192
[email protected]139355f2014-05-11 14:21:28193 BrowserPluginGuestManager* GetBrowserPluginGuestManager() const;
[email protected]24569262014-05-06 03:31:30194
Fady Samueld4e14c82018-04-04 00:56:29195 void EnableAutoResize(const gfx::Size& min_size, const gfx::Size& max_size);
196 void DisableAutoResize();
Fady Samuele392fd52018-05-11 17:16:43197 void DidUpdateVisualProperties(const cc::RenderFrameMetadata& metadata);
Fady Samueld10aadd82017-11-03 18:23:57198
Albert J. Wongeb28e7e2018-10-12 00:57:43199 // Methods to handle events from InputEventShim.
200 void DidSetHasTouchEventHandlers(bool accept);
201 void DidTextInputStateChange(const TextInputState& params);
202 void DidLockMouse(bool user_gesture, bool privileged);
203 void DidUnlockMouse();
204
[email protected]7a846df2012-09-20 19:17:39205 // WebContentsObserver implementation.
jambe380482017-01-27 01:01:09206 void DidFinishNavigation(NavigationHandle* navigation_handle) override;
[email protected]eb92f632012-10-19 00:56:12207
dchengc2282aa2014-10-21 12:07:58208 void RenderViewReady() override;
209 void RenderProcessGone(base::TerminationStatus status) override;
210 bool OnMessageReceived(const IPC::Message& message) override;
211 bool OnMessageReceived(const IPC::Message& message,
212 RenderFrameHost* render_frame_host) override;
[email protected]a7fac9a2012-12-18 23:26:07213
fsamuel60b42282015-03-10 03:29:14214 // GuestHost implementation.
215 int LoadURLWithParams(
216 const NavigationController::LoadURLParams& load_params) override;
paulmeyer0968abad2015-01-10 00:02:45217 void SizeContents(const gfx::Size& new_size) override;
fsamuel60b42282015-03-10 03:29:14218 void WillDestroy() override;
paulmeyer0968abad2015-01-10 00:02:45219
[email protected]e17b7c62012-09-21 21:05:46220 // Exposes the protected web_contents() from WebContentsObserver.
[email protected]24569262014-05-06 03:31:30221 WebContentsImpl* GetWebContents() const;
[email protected]e17b7c62012-09-21 21:05:46222
[email protected]ca61ce142012-11-27 21:32:57223 gfx::Point GetScreenCoordinates(const gfx::Point& relative_position) const;
224
fsamuel6c1dfeb2014-12-18 19:21:33225 // Helper to send messages to embedder. If this guest is not yet attached,
226 // then IPCs will be queued until attachment.
limasdf85735f42016-10-21 02:24:55227 void SendMessageToEmbedder(std::unique_ptr<IPC::Message> msg);
[email protected]747c30652012-12-18 20:35:53228
[email protected]c4538072013-03-18 02:17:55229 // Returns whether the guest is attached to an embedder.
fsamuelad4f33f2014-11-28 19:32:21230 bool attached() const { return attached_; }
[email protected]c4538072013-03-18 02:17:55231
232 // Attaches this BrowserPluginGuest to the provided |embedder_web_contents|
233 // and initializes the guest with the provided |params|. Attaching a guest
234 // to an embedder implies that this guest's lifetime is no longer managed
[email protected]2101c4c2014-08-22 00:16:16235 // by its opener, and it can begin loading resources.
236 void Attach(int browser_plugin_instance_id,
237 WebContentsImpl* embedder_web_contents,
238 const BrowserPluginHostMsg_Attach_Params& params);
[email protected]c4538072013-03-18 02:17:55239
[email protected]8eb04562013-03-06 03:41:14240 // Returns whether BrowserPluginGuest is interested in receiving the given
241 // |message|.
242 static bool ShouldForwardToBrowserPluginGuest(const IPC::Message& message);
243
Ella Ge80a52dce2017-11-15 18:01:52244 void DragSourceEndedAt(float client_x,
245 float client_y,
246 float screen_x,
247 float screen_y,
248 blink::WebDragOperation operation);
[email protected]cf200a562013-05-03 16:24:29249
[email protected]cf200a562013-05-03 16:24:29250 // Called when the drag started by this guest ends at an OS-level.
lazyboyf569b4f62015-02-03 17:22:54251 void EmbedderSystemDragEnded();
252 void EndSystemDragIfApplicable();
[email protected]cf200a562013-05-03 16:24:29253
[email protected]af1718c2013-08-12 19:59:19254 void RespondToPermissionRequest(int request_id,
255 bool should_allow,
256 const std::string& user_input);
257
[email protected]7a1280892014-04-16 17:18:25258 void PointerLockPermissionResponse(bool allow);
259
wjmaclean73b15a22015-09-25 15:56:40260 void ResendEventToEmbedder(const blink::WebInputEvent& event);
261
ekaramadaeddbee2017-01-26 21:17:24262 gfx::Point GetCoordinatesInEmbedderWebContents(
263 const gfx::Point& relative_point);
264
wjmaclean53032adf2015-06-15 16:49:22265 protected:
[email protected]e17b7c62012-09-21 21:05:46266
[email protected]c61b317c72013-11-14 06:40:46267 // BrowserPluginGuest is a WebContentsObserver of |web_contents| and
268 // |web_contents| has to stay valid for the lifetime of BrowserPluginGuest.
wjmaclean53032adf2015-06-15 16:49:22269 // Constructor protected for testing.
[email protected]2101c4c2014-08-22 00:16:16270 BrowserPluginGuest(bool has_render_view,
[email protected]4858e432014-06-23 18:14:17271 WebContentsImpl* web_contents,
272 BrowserPluginGuestDelegate* delegate);
[email protected]e17b7c62012-09-21 21:05:46273
wjmaclean321584d2015-06-30 19:21:56274 void set_attached_for_test(bool attached) {
275 attached_ = attached;
276 }
277
wjmaclean53032adf2015-06-15 16:49:22278 private:
279 class EmbedderVisibilityObserver;
280
Albert J. Wongeb28e7e2018-10-12 00:57:43281 // InputEventShim implementation.
282 class InputEventShimImpl : public InputEventShim {
283 public:
284 explicit InputEventShimImpl(BrowserPluginGuest* browser_plugin_guest);
285 ~InputEventShimImpl() override;
286
287 void DidSetHasTouchEventHandlers(bool accept) override;
288 void DidTextInputStateChange(const TextInputState& params) override;
289 void DidLockMouse(bool user_gesture, bool privileged) override;
290 void DidUnlockMouse() override;
291
292 private:
293 BrowserPluginGuest* browser_plugin_guest_;
294 };
295
ekaramad51ca2092016-11-17 06:05:58296 // The RenderWidgetHostImpl corresponding to the owner frame of BrowserPlugin.
297 RenderWidgetHostImpl* GetOwnerRenderWidgetHost() const;
298
fsamuel7310a4262014-12-05 05:06:44299 void InitInternal(const BrowserPluginHostMsg_Attach_Params& params,
300 WebContentsImpl* owner_web_contents);
[email protected]10b21b32014-06-07 09:54:33301
[email protected]c4538072013-03-18 02:17:55302 // Message handlers for messages from embedder.
fsamuela95fef42014-12-03 20:16:52303 void OnDetach(int instance_id);
[email protected]3997b1b22012-12-20 01:02:54304 // Handles drag events from the embedder.
305 // When dragging, the drag events go to the embedder first, and if the drag
306 // happens on the browser plugin, then the plugin sends a corresponding
307 // drag-message to the guest. This routes the drag-message to the guest
308 // renderer.
309 void OnDragStatusUpdate(int instance_id,
[email protected]180ef242013-11-07 06:50:46310 blink::WebDragStatus drag_status,
[email protected]dc293a72013-07-01 11:11:22311 const DropData& drop_data,
[email protected]180ef242013-11-07 06:50:46312 blink::WebDragOperationsMask drag_mask,
Ella Ge80a52dce2017-11-15 18:01:52313 const gfx::PointF& location);
[email protected]6dd17a8a2013-05-01 05:50:10314 // Instructs the guest to execute an edit command decoded in the embedder.
315 void OnExecuteEditCommand(int instance_id,
316 const std::string& command);
[email protected]b0030b72013-11-15 20:35:53317
[email protected]861f9782013-03-05 03:29:54318 void OnLockMouseAck(int instance_id, bool succeeded);
[email protected]5501d5df2014-04-29 09:12:54319 // Resizes the guest's web contents.
fsamuel5ec049d2015-01-19 16:57:41320 void OnSetFocus(int instance_id,
321 bool focused,
322 blink::WebFocusType focus_type);
[email protected]204deb52014-05-23 07:17:15323 // Sets the name of the guest so that other guests in the same partition can
324 // access it.
325 void OnSetName(int instance_id, const std::string& name);
[email protected]3997b1b22012-12-20 01:02:54326 // Updates the size state of the guest.
[email protected]b77fac52013-06-01 01:03:46327 void OnSetEditCommandsForNextKeyEvent(
328 int instance_id,
329 const std::vector<EditCommand>& edit_commands);
[email protected]3997b1b22012-12-20 01:02:54330 // The guest WebContents is visible if both its embedder is visible and
331 // the browser plugin element is visible. If either one is not then the
332 // WebContents is marked as hidden. A hidden WebContents will consume
333 // fewer GPU and CPU resources.
334 //
335 // When every WebContents in a RenderProcessHost is hidden, it will lower
Bo Liueb218ee2018-03-21 20:24:35336 // the priority of the process (see
337 // RenderProcessHostImpl::UpdateClientPriority).
[email protected]3997b1b22012-12-20 01:02:54338 //
339 // It will also send a message to the guest renderer process to cleanup
340 // resources such as dropping back buffers and adjusting memory limits (if in
341 // compositing mode, see CCLayerTreeHost::setVisible).
342 //
343 // Additionally, it will slow down Javascript execution and garbage
344 // collection. See RenderThreadImpl::IdleHandler (executed when hidden) and
345 // RenderThreadImpl::IdleHandlerInForegroundTab (executed when visible).
346 void OnSetVisibility(int instance_id, bool visible);
[email protected]861f9782013-03-05 03:29:54347 void OnUnlockMouseAck(int instance_id);
Fady Samuel799e72192018-04-25 21:16:57348 void OnSynchronizeVisualProperties(
349 int instance_id,
Fady Samuel799e72192018-04-25 21:16:57350 const FrameVisualProperties& visual_properties);
[email protected]3997b1b22012-12-20 01:02:54351
[email protected]d260f042013-12-14 01:31:36352 void OnImeSetComposition(
353 int instance_id,
ekaramadb62c3432017-03-15 21:59:46354 const BrowserPluginHostMsg_SetComposition_Params& params);
Ryan Landay9e42fd742017-08-12 01:59:11355 void OnImeCommitText(int instance_id,
356 const base::string16& text,
357 const std::vector<blink::WebImeTextSpan>& ime_text_spans,
358 const gfx::Range& replacement_range,
359 int relative_cursor_pos);
ekaramadf035886c2017-05-23 18:10:13360 void OnImeFinishComposingText(int instance_id, bool keep_selection);
[email protected]d260f042013-12-14 01:31:36361 void OnExtendSelectionAndDelete(int instance_id, int before, int after);
[email protected]3997b1b22012-12-20 01:02:54362
363 // Message handlers for messages from guest.
[email protected]a7fac9a2012-12-18 23:26:07364 void OnHandleInputEventAck(
[email protected]180ef242013-11-07 06:50:46365 blink::WebInputEvent::Type event_type,
[email protected]a7fac9a2012-12-18 23:26:07366 InputEventAckState ack_result);
[email protected]a7fac9a2012-12-18 23:26:07367#if defined(OS_MACOSX)
avi485e5fd62014-08-25 23:26:14368 // On MacOS X popups are painted by the browser process. We handle them here
369 // so that they are positioned correctly.
370 void OnShowPopup(RenderFrameHost* render_frame_host,
371 const FrameHostMsg_ShowPopup_Params& params);
[email protected]a7fac9a2012-12-18 23:26:07372#endif
Albert J. Wongf6e13ed2018-09-18 15:25:47373 void OnShowWidget(int widget_route_id, const gfx::Rect& initial_rect);
[email protected]204deb52014-05-23 07:17:15374 void OnTakeFocus(bool reverse);
375 void OnUpdateFrameName(int frame_id,
376 bool is_top_level,
377 const std::string& name);
[email protected]a7fac9a2012-12-18 23:26:07378
hanxi9bd85fa2015-05-05 19:55:00379 // Called when WillAttach is complete.
380 void OnWillAttachComplete(WebContentsImpl* embedder_web_contents,
381 const BrowserPluginHostMsg_Attach_Params& params);
382
wjmaclean6f639182015-10-16 19:57:24383 // Returns identical message with current browser_plugin_instance_id() if
384 // the input was created with browser_plugin::kInstanceIdNone, else it returns
385 // the input message unmodified. If no current browser_plugin_instance_id()
386 // is set, or anything goes wrong, the input message is returned.
limasdf85735f42016-10-21 02:24:55387 std::unique_ptr<IPC::Message> UpdateInstanceIdIfNecessary(
388 std::unique_ptr<IPC::Message> msg) const;
wjmaclean6f639182015-10-16 19:57:24389
[email protected]697f16b52013-05-10 06:01:18390 // Forwards all messages from the |pending_messages_| queue to the embedder.
391 void SendQueuedMessages();
392
lazyboya34ff622015-04-07 02:21:17393 void SendTextInputTypeChangedToView(RenderWidgetHostViewBase* guest_rwhv);
394
arthursonzogniba36c212019-05-21 08:09:00395 // Creates, if necessary, and returns the routing ID of a render view for the
396 // guest in the owner's renderer process.
397 int GetGuestRenderViewRoutingID();
398
paulmeyere80cfc92014-10-10 03:37:43399 // The last tooltip that was set with SetTooltipText().
400 base::string16 current_tooltip_text_;
401
Albert J. Wongeb28e7e2018-10-12 00:57:43402 InputEventShimImpl input_event_shim_impl_;
403
dcheng59716272016-04-09 05:19:08404 std::unique_ptr<EmbedderVisibilityObserver> embedder_visibility_observer_;
fsamuelad4f33f2014-11-28 19:32:21405 WebContentsImpl* owner_web_contents_;
406
407 // Indicates whether this guest has been attached to a container.
408 bool attached_;
[email protected]40974d02013-04-09 22:11:19409
[email protected]2101c4c2014-08-22 00:16:16410 // An identifier that uniquely identifies a browser plugin within an embedder.
411 int browser_plugin_instance_id_;
Fady Samuel85a1bf72017-10-27 14:30:20412 gfx::Rect frame_rect_;
[email protected]6a121f22012-10-30 03:19:48413 bool focused_;
[email protected]861f9782013-03-05 03:29:54414 bool mouse_locked_;
[email protected]a25acea72013-03-10 23:41:28415 bool pending_lock_request_;
[email protected]93564f72013-02-15 13:26:19416 bool guest_visible_;
Francois Dorayfe4a1772018-02-17 04:17:09417 Visibility embedder_visibility_;
raymes0fa0be52014-10-13 20:38:09418 // Whether the browser plugin is inside a plugin document.
419 bool is_full_page_plugin_;
[email protected]7a846df2012-09-20 19:17:39420
[email protected]0c6d41752013-05-01 15:49:09421 // Indicates that this BrowserPluginGuest has associated renderer-side state.
422 // This is used to determine whether or not to create a new RenderView when
[email protected]d84d57b2014-06-20 22:42:39423 // this guest is attached. A BrowserPluginGuest would have renderer-side state
424 // prior to attachment if it is created via a call to window.open and
425 // maintains a JavaScript reference to its opener.
[email protected]0c6d41752013-05-01 15:49:09426 bool has_render_view_;
427
[email protected]3f6fa6d42013-08-16 21:19:49428 bool is_in_destruction_;
429
fsamuel7310a4262014-12-05 05:06:44430 // BrowserPluginGuest::Init can only be called once. This flag allows it to
431 // exit early if it's already been called.
432 bool initialized_;
433
[email protected]63c33bd62014-02-08 04:45:40434 // Text input type states.
shuchenf93c2972015-09-11 01:52:37435 // Using scoped_ptr to avoid including the header file: view_messages.h.
ekaramad9053e57b2016-04-26 20:00:38436 std::unique_ptr<const TextInputState> last_text_input_state_;
[email protected]63c33bd62014-02-08 04:45:40437
fsamuela8484dd2014-10-02 00:51:33438 // The is the routing ID for a swapped out RenderView for the guest
439 // WebContents in the embedder's process.
arthursonzogniba36c212019-05-21 08:09:00440 int guest_render_view_routing_id_;
lazyboyf569b4f62015-02-03 17:22:54441 // Last seen state of drag status update.
442 blink::WebDragStatus last_drag_status_;
443 // Whether or not our embedder has seen a SystemDragEnded() call.
444 bool seen_embedder_system_drag_ended_;
445 // Whether or not our embedder has seen a DragSourceEndedAt() call.
446 bool seen_embedder_drag_source_ended_at_;
fsamuela8484dd2014-10-02 00:51:33447
hush8915b502016-06-15 19:32:23448 // Ignore the URL dragged into guest that is coming from guest.
449 bool ignore_dragged_url_;
fsamuelbdfc1ad2015-02-24 02:10:02450
[email protected]697f16b52013-05-10 06:01:18451 // This is a queue of messages that are destined to be sent to the embedder
452 // once the guest is attached to a particular embedder.
Brett Wilsoncc8623d2017-09-12 03:28:10453 base::circular_deque<std::unique_ptr<IPC::Message>> pending_messages_;
[email protected]697f16b52013-05-10 06:01:18454
[email protected]4858e432014-06-23 18:14:17455 BrowserPluginGuestDelegate* const delegate_;
[email protected]4c0e8272013-07-03 23:39:22456
Fady Samuel84d8a1f72018-11-08 00:26:17457 viz::LocalSurfaceIdAllocation local_surface_id_allocation_;
Fady Samuel85a1bf72017-10-27 14:30:20458 ScreenInfo screen_info_;
akabac6bd1212018-06-25 20:10:48459 double zoom_level_ = 0.0;
Vladimir Levin98d76dad2018-04-21 00:21:29460 uint32_t capture_sequence_number_ = 0u;
Fady Samuelf3f9b832017-09-01 17:11:17461
[email protected]f21d36e2014-01-16 19:24:04462 // Weak pointer used to ask GeolocationPermissionContext about geolocation
463 // permission.
Jeremy Roman3bca4bf2019-07-11 03:41:25464 base::WeakPtrFactory<BrowserPluginGuest> weak_ptr_factory_{this};
[email protected]f21d36e2014-01-16 19:24:04465
[email protected]7a846df2012-09-20 19:17:39466 DISALLOW_COPY_AND_ASSIGN(BrowserPluginGuest);
467};
468
469} // namespace content
470
471#endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_