blob: 745dd7a6a2b554c30be593ca09eb1624bb75e592 [file] [log] [blame]
[email protected]945604a2014-04-28 12:29:591// Copyright 2014 The Chromium Authors. All rights reserved.
[email protected]0533cc6d2013-06-27 22:44:052// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
fsamuel8dfa19a2015-05-05 01:00:395#ifndef COMPONENTS_GUEST_VIEW_BROWSER_GUEST_VIEW_BASE_H_
6#define COMPONENTS_GUEST_VIEW_BROWSER_GUEST_VIEW_BASE_H_
[email protected]0533cc6d2013-06-27 22:44:057
[email protected]738f57a2013-06-29 21:06:548#include <queue>
9
avi26062922015-12-26 00:14:1810#include "base/macros.h"
dcheng258894122016-02-02 17:42:2411#include "base/memory/scoped_ptr.h"
[email protected]f21d36e2014-01-16 19:24:0412#include "base/memory/weak_ptr.h"
[email protected]0533cc6d2013-06-27 22:44:0513#include "base/values.h"
fsamuel8dfa19a2015-05-05 01:00:3914#include "components/guest_view/common/guest_view_constants.h"
wjmacleanec6bd522014-12-12 16:17:5015#include "components/ui/zoom/zoom_observer.h"
[email protected]4c0e8272013-07-03 23:39:2216#include "content/public/browser/browser_plugin_guest_delegate.h"
fsamuel60b42282015-03-10 03:29:1417#include "content/public/browser/guest_host.h"
[email protected]4858e432014-06-23 18:14:1718#include "content/public/browser/render_process_host_observer.h"
[email protected]0533cc6d2013-06-27 22:44:0519#include "content/public/browser/web_contents.h"
[email protected]aec80ed2014-05-27 00:01:1520#include "content/public/browser/web_contents_delegate.h"
[email protected]70ab2642014-05-30 08:06:5821#include "content/public/browser/web_contents_observer.h"
[email protected]0533cc6d2013-06-27 22:44:0522
[email protected]06153f02013-12-04 03:01:2823struct RendererContentSettingRules;
[email protected]0533cc6d2013-06-27 22:44:0524
fsamuel8dfa19a2015-05-05 01:00:3925namespace guest_view {
[email protected]140d6cd92014-08-12 18:26:4626
fsamuelb535c742015-04-15 18:56:5427class GuestViewEvent;
28
paulmeyereb98f9112015-01-23 17:13:3829// A struct of parameters for SetSize(). The parameters are all declared as
30// scoped pointers since they are all optional. Null pointers indicate that the
31// parameter has not been provided, and the last used value should be used. Note
32// that when |enable_auto_size| is true, providing |normal_size| is not
33// meaningful. This is because the normal size of the guestview is overridden
34// whenever autosizing occurs.
35struct SetSizeParams {
36 SetSizeParams();
37 ~SetSizeParams();
38
39 scoped_ptr<bool> enable_auto_size;
40 scoped_ptr<gfx::Size> min_size;
41 scoped_ptr<gfx::Size> max_size;
42 scoped_ptr<gfx::Size> normal_size;
43};
44
[email protected]0e99fdc2014-04-30 05:10:3345// A GuestViewBase is the base class browser-side API implementation for a
46// <*view> tag. GuestViewBase maintains an association between a guest
fsamuelfe20ffac2014-12-02 01:51:2247// WebContents and an owner WebContents. It receives events issued from
48// the guest and relays them to the owner. GuestViewBase tracks the lifetime
49// of its owner. A GuestViewBase's owner is referred to as an embedder if
50// it is attached to a container within the owner's WebContents.
[email protected]aec80ed2014-05-27 00:01:1551class GuestViewBase : public content::BrowserPluginGuestDelegate,
[email protected]70ab2642014-05-30 08:06:5852 public content::WebContentsDelegate,
wjmacleanec6bd522014-12-12 16:17:5053 public content::WebContentsObserver,
54 public ui_zoom::ZoomObserver {
[email protected]0533cc6d2013-06-27 22:44:0555 public:
[email protected]0e99fdc2014-04-30 05:10:3356 // Returns a *ViewGuest if this GuestView is of the given view type.
57 template <typename T>
58 T* As() {
[email protected]24569262014-05-06 03:31:3059 if (IsViewType(T::Type))
[email protected]0e99fdc2014-04-30 05:10:3360 return static_cast<T*>(this);
[email protected]24569262014-05-06 03:31:3061
fsamuel003b8cc2015-01-27 15:08:3862 return nullptr;
[email protected]0e99fdc2014-04-30 05:10:3363 }
[email protected]50c827d2013-09-13 21:36:0964
paulmeyer598af4c2015-06-10 20:11:5865 // Cleans up state when this GuestView is being destroyed.
66 // Note that this cannot be done in the destructor since a GuestView could
67 // potentially be created and destroyed in JavaScript before getting a
68 // GuestViewBase instance. This method can be hidden by a CleanUp() method in
69 // a derived class, in which case the derived method should call this one.
paulmeyerbc4600a2015-07-21 15:41:3170 static void CleanUp(content::BrowserContext* browser_context,
71 int embedder_process_id,
72 int view_instance_id);
paulmeyer598af4c2015-06-10 20:11:5873
lazyboye2021e62015-03-20 22:17:3474 static GuestViewBase* FromWebContents(
75 const content::WebContents* web_contents);
[email protected]0533cc6d2013-06-27 22:44:0576
fsamuel4a5c5992015-01-20 19:21:4977 static GuestViewBase* From(int owner_process_id, int instance_id);
[email protected]0533cc6d2013-06-27 22:44:0578
paulmeyerf8bf58392015-04-21 20:56:2879 // Given a |web_contents|, returns the top level owner WebContents. If
80 // |web_contents| does not belong to a GuestView, it will be returned
81 // unchanged.
82 static content::WebContents* GetTopLevelWebContents(
83 content::WebContents* web_contents);
84
[email protected]a24efc22014-05-26 15:50:2585 static bool IsGuest(content::WebContents* web_contents);
86
paulmeyerd7523c2b2015-10-21 22:58:0587 // Returns the name of the derived type of this GuestView.
[email protected]38fe4372014-05-01 08:38:3288 virtual const char* GetViewType() const = 0;
[email protected]06153f02013-12-04 03:01:2889
[email protected]5ca06862014-08-06 19:09:5590 // This method queries whether autosize is supported for this particular view.
91 // By default, autosize is not supported. Derived classes can override this
92 // behavior to support autosize.
93 virtual bool IsAutoSizeSupported() const;
94
kalmanc2c78842015-01-09 23:57:3595 // This method queries whether preferred size events are enabled for this
96 // view. By default, preferred size events are disabled, since they add a
97 // small amount of overhead.
98 virtual bool IsPreferredSizeModeEnabled() const;
99
paulmeyerd7523c2b2015-10-21 22:58:05100 // This indicates whether zoom should propagate from the embedder to the guest
101 // content.
fsamuel67993a92014-12-17 01:33:20102 virtual bool ZoomPropagatesFromEmbedderToGuest() const;
103
paulmeyerd7523c2b2015-10-21 22:58:05104 // Access to guest views are determined by the availability of the internal
105 // extension API used to implement the guest view.
[email protected]755211fe2014-08-08 19:01:49106 //
107 // This should be the name of the API as it appears in the _api_features.json
108 // file.
fsamuel99492be2014-08-28 03:50:27109 virtual const char* GetAPINamespace() const = 0;
110
paulmeyerd7523c2b2015-10-21 22:58:05111 // This method is the task prefix to show for a task produced by this
112 // GuestViewBase's derived type.
fsamuel99492be2014-08-28 03:50:27113 virtual int GetTaskPrefix() const = 0;
[email protected]a2be2f112014-07-12 01:10:05114
paulmeyerd7523c2b2015-10-21 22:58:05115 // Dispatches an event to the guest proxy.
dcheng258894122016-02-02 17:42:24116 void DispatchEventToGuestProxy(scoped_ptr<GuestViewEvent> event);
paulmeyerd7523c2b2015-10-21 22:58:05117
118 // Dispatches an event to the view.
dcheng258894122016-02-02 17:42:24119 void DispatchEventToView(scoped_ptr<GuestViewEvent> event);
[email protected]70ab2642014-05-30 08:06:58120
[email protected]4858e432014-06-23 18:14:17121 // This creates a WebContents and initializes |this| GuestViewBase to use the
122 // newly created WebContents.
paulmeyerd7523c2b2015-10-21 22:58:05123 using WebContentsCreatedCallback =
124 base::Callback<void(content::WebContents*)>;
fsamuel840c1af2014-12-24 01:39:41125 void Init(const base::DictionaryValue& create_params,
[email protected]38177c32014-06-25 23:20:23126 const WebContentsCreatedCallback& callback);
[email protected]a868c6c2014-06-04 13:07:43127
fsamuel6867dde92015-01-13 02:18:19128 void InitWithWebContents(const base::DictionaryValue& create_params,
129 content::WebContents* guest_web_contents);
[email protected]d84d57b2014-06-20 22:42:39130
[email protected]24569262014-05-06 03:31:30131 bool IsViewType(const char* const view_type) const {
132 return !strcmp(GetViewType(), view_type);
133 }
134
paulmeyereb98f9112015-01-23 17:13:38135 // Used to toggle autosize mode for this GuestView, and set both the automatic
136 // and normal sizes.
137 void SetSize(const SetSizeParams& params);
[email protected]5ca06862014-08-06 19:09:55138
[email protected]4858e432014-06-23 18:14:17139 bool initialized() const { return initialized_; }
140
[email protected]0533cc6d2013-06-27 22:44:05141 content::WebContents* embedder_web_contents() const {
fsamuel003b8cc2015-01-27 15:08:38142 return attached() ? owner_web_contents_ : nullptr;
fsamuelad4f33f2014-11-28 19:32:21143 }
144
145 content::WebContents* owner_web_contents() const {
146 return owner_web_contents_;
[email protected]0533cc6d2013-06-27 22:44:05147 }
148
fsamuel60b42282015-03-10 03:29:14149 content::GuestHost* host() const {
150 return guest_host_;
151 }
152
[email protected]2101c4c2014-08-22 00:16:16153 // Returns the parameters associated with the element hosting this GuestView
154 // passed in from JavaScript.
155 base::DictionaryValue* attach_params() const { return attach_params_.get(); }
[email protected]50d326e2014-05-20 17:59:06156
[email protected]738f57a2013-06-29 21:06:54157 // Returns whether this guest has an associated embedder.
fsamuela95fef42014-12-03 20:16:52158 bool attached() const {
fsamuel8dfa19a2015-05-05 01:00:39159 return element_instance_id_ != kInstanceIDNone;
fsamuela95fef42014-12-03 20:16:52160 }
[email protected]738f57a2013-06-29 21:06:54161
[email protected]0533cc6d2013-06-27 22:44:05162 // Returns the instance ID of the <*view> element.
163 int view_instance_id() const { return view_instance_id_; }
164
[email protected]2101c4c2014-08-22 00:16:16165 // Returns the instance ID of this GuestViewBase.
166 int guest_instance_id() const { return guest_instance_id_; }
167
raymes9d460f92014-12-23 04:13:55168 // Returns the instance ID of the GuestViewBase's element.
169 int element_instance_id() const { return element_instance_id_; }
170
fsamuel6867dde92015-01-13 02:18:19171 bool can_owner_receive_events() const { return !!view_instance_id_; }
172
paulmeyer1f8c6fa62015-05-05 23:36:01173 gfx::Size size() const { return guest_size_; }
174
[email protected]0533cc6d2013-06-27 22:44:05175 // Returns the user browser context of the embedder.
176 content::BrowserContext* browser_context() const { return browser_context_; }
177
[email protected]50d326e2014-05-20 17:59:06178 GuestViewBase* GetOpener() const {
179 return opener_.get();
180 }
181
fsamuelfe20ffac2014-12-02 01:51:22182 // Returns the URL of the owner WebContents.
183 const GURL& GetOwnerSiteURL() const;
184
fsamuel9a3c81e2015-04-24 12:30:11185 // Returns the host of the owner WebContents. For extensions, this is the
186 // extension ID.
187 std::string owner_host() const { return owner_host_; }
188
sammce2092512014-11-24 22:18:24189 // Whether the guest view is inside a plugin document.
paulmeyercd7a39a2015-04-11 02:14:39190 bool is_full_page_plugin() const { return is_full_page_plugin_; }
sammce2092512014-11-24 22:18:24191
fsamuel60b42282015-03-10 03:29:14192 // Returns the routing ID of the guest proxy in the owner's renderer process.
193 // This value is only valid after attachment or first navigation.
194 int proxy_routing_id() const { return guest_proxy_routing_id_; }
195
fsamuela8484dd2014-10-02 00:51:33196 // Destroy this guest.
197 void Destroy();
198
199 // Saves the attach state of the custom element hosting this GuestView.
[email protected]2101c4c2014-08-22 00:16:16200 void SetAttachParams(const base::DictionaryValue& params);
[email protected]50d326e2014-05-20 17:59:06201 void SetOpener(GuestViewBase* opener);
202
[email protected]0533cc6d2013-06-27 22:44:05203 protected:
fsamuelc75dc1d2015-01-27 06:22:15204 explicit GuestViewBase(content::WebContents* owner_web_contents);
[email protected]d84d57b2014-06-20 22:42:39205
dcheng9168b2f2014-10-21 12:38:24206 ~GuestViewBase() override;
[email protected]0533cc6d2013-06-27 22:44:05207
paulmeyerd7523c2b2015-10-21 22:58:05208 // BrowserPluginGuestDelegate implementation.
209 void SetContextMenuPosition(const gfx::Point& position) override;
210
211 // WebContentsDelegate implementation.
212 void HandleKeyboardEvent(
213 content::WebContents* source,
214 const content::NativeWebKeyboardEvent& event) override;
215 bool PreHandleGestureEvent(content::WebContents* source,
216 const blink::WebGestureEvent& event) override;
217 void FindReply(content::WebContents* source,
218 int request_id,
219 int number_of_matches,
220 const gfx::Rect& selection_rect,
221 int active_match_ordinal,
222 bool final_update) override;
223
224 // WebContentsObserver implementation.
225 void DidNavigateMainFrame(
226 const content::LoadCommittedDetails& details,
227 const content::FrameNavigateParams& params) override;
228
229 // Given a set of initialization parameters, a concrete subclass of
230 // GuestViewBase can create a specialized WebContents that it returns back to
231 // GuestViewBase.
232 virtual void CreateWebContents(
233 const base::DictionaryValue& create_params,
234 const WebContentsCreatedCallback& callback) = 0;
235
236 // This method is called after the guest has been attached to an embedder and
237 // suspended resource loads have been resumed.
238 //
239 // This method can be overriden by subclasses. This gives the derived class
240 // an opportunity to perform setup actions after attachment.
241 virtual void DidAttachToEmbedder() {}
242
243 // This method is called after this GuestViewBase has been initiated.
244 //
245 // This gives the derived class an opportunity to perform additional
246 // initialization.
247 virtual void DidInitialize(const base::DictionaryValue& create_params) {}
248
249 // This method is called when embedder WebContents's fullscreen is toggled.
250 //
251 // If the guest asked the embedder to enter fullscreen, the guest uses this
252 // signal to exit fullscreen state.
253 virtual void EmbedderFullscreenToggled(bool entered_fullscreen) {}
254
255 // This method is called when the initial set of frames within the page have
256 // completed loading.
257 virtual void GuestViewDidStopLoading() {}
258
259 // This method is called when the guest WebContents has been destroyed. This
260 // object will be destroyed after this call returns.
261 //
262 // This gives the derived class an opportunity to perform some cleanup.
263 virtual void GuestDestroyed() {}
264
265 // This method is invoked when the guest RenderView is ready, e.g. because we
266 // recreated it after a crash or after reattachment.
267 //
268 // This gives the derived class an opportunity to perform some initialization
269 // work.
270 virtual void GuestReady() {}
271
272 // This method is called when the guest's zoom changes.
273 virtual void GuestZoomChanged(double old_zoom_level, double new_zoom_level) {}
274
275 // This method is invoked when the contents auto-resized to give the container
276 // an opportunity to match it if it wishes.
277 //
278 // This gives the derived class an opportunity to inform its container element
279 // or perform other actions.
280 virtual void GuestSizeChangedDueToAutoSize(const gfx::Size& old_size,
281 const gfx::Size& new_size) {}
282
283 // This method is invoked when the contents preferred size changes. This will
284 // only ever fire if IsPreferredSizeSupported returns true.
285 virtual void OnPreferredSizeChanged(const gfx::Size& pref_size) {}
286
287 // Signals that the guest view is ready. The default implementation signals
288 // immediately, but derived class can override this if they need to do
289 // asynchronous setup.
290 virtual void SignalWhenReady(const base::Closure& callback);
291
292 // Returns true if this guest should handle find requests for its
293 // embedder. This should generally be true for guests that make up the
294 // entirety of the embedder's content.
295 virtual bool ShouldHandleFindRequestsForEmbedder() const;
296
297 // This method is called immediately before suspended resource loads have been
298 // resumed on attachment to an embedder.
299 //
300 // This method can be overriden by subclasses. This gives the derived class
301 // an opportunity to perform setup actions before attachment.
302 virtual void WillAttachToEmbedder() {}
303
304 // This method is called when the guest WebContents is about to be destroyed.
305 //
306 // This gives the derived class an opportunity to perform some cleanup prior
307 // to destruction.
308 virtual void WillDestroy() {}
309
310 void LoadURLWithParams(
311 const content::NavigationController::LoadURLParams& load_params);
312
paulmeyerf018aaa2015-02-19 19:55:31313 // Convert sizes in pixels from logical to physical numbers of pixels.
314 // Note that a size can consist of a fractional number of logical pixels
315 // (hence |logical_pixels| is represented as a double), but will always
316 // consist of an integral number of physical pixels (hence the return value
317 // is represented as an int).
paulmeyercd7a39a2015-04-11 02:14:39318 int LogicalPixelsToPhysicalPixels(double logical_pixels) const;
paulmeyerf018aaa2015-02-19 19:55:31319
320 // Convert sizes in pixels from physical to logical numbers of pixels.
321 // Note that a size can consist of a fractional number of logical pixels
322 // (hence the return value is represented as a double), but will always
323 // consist of an integral number of physical pixels (hence |physical_pixels|
324 // is represented as an int).
paulmeyercd7a39a2015-04-11 02:14:39325 double PhysicalPixelsToLogicalPixels(int physical_pixels) const;
paulmeyerf018aaa2015-02-19 19:55:31326
paulmeyerd7523c2b2015-10-21 22:58:05327 void SetGuestZoomLevelToMatchEmbedder();
328
329 private:
330 friend class GuestViewMessageFilter;
331
332 class OwnerContentsObserver;
333 class OpenerLifetimeObserver;
334
335 // BrowserPluginGuestDelegate implementation.
336 content::WebContents* CreateNewGuestWindow(
337 const content::WebContents::CreateParams& create_params) final;
338 void DidAttach(int guest_proxy_routing_id) final;
339 void DidDetach() final;
340 content::WebContents* GetOwnerWebContents() const final;
341 bool HandleFindForEmbedder(int request_id,
342 const base::string16& search_text,
343 const blink::WebFindOptions& options) final;
344 bool HandleStopFindingForEmbedder(content::StopFindAction action) final;
345 void GuestSizeChanged(const gfx::Size& new_size) final;
346 void SetGuestHost(content::GuestHost* guest_host) final;
347 void WillAttach(content::WebContents* embedder_web_contents,
348 int browser_plugin_instance_id,
349 bool is_full_page_plugin,
350 const base::Closure& callback) final;
fsamuel4a1650f2015-01-23 21:57:49351
352 // WebContentsDelegate implementation.
353 void ActivateContents(content::WebContents* contents) final;
fsamuel67ef1b02015-01-30 22:09:22354 void ContentsMouseEvent(content::WebContents* source,
355 const gfx::Point& location,
mgiuca1c92cab42016-01-07 03:18:27356 bool motion,
357 bool exited) final;
paulmeyerd7523c2b2015-10-21 22:58:05358 void ContentsZoomChange(bool zoom_in) final;
fsamuel67ef1b02015-01-30 22:09:22359 void LoadingStateChanged(content::WebContents* source,
360 bool to_different_document) final;
fsamuel9549ee32015-01-31 00:09:30361 content::ColorChooser* OpenColorChooser(
362 content::WebContents* web_contents,
363 SkColor color,
paulmeyerd7523c2b2015-10-21 22:58:05364 const std::vector<content::ColorSuggestion>& suggestions) final;
lazyboya9206822015-09-16 20:07:20365 void ResizeDueToAutoResize(content::WebContents* web_contents,
paulmeyerd7523c2b2015-10-21 22:58:05366 const gfx::Size& new_size) final;
fsamuel4a1650f2015-01-23 21:57:49367 void RunFileChooser(content::WebContents* web_contents,
paulmeyerd7523c2b2015-10-21 22:58:05368 const content::FileChooserParams& params) final;
fsamuel4a1650f2015-01-23 21:57:49369 bool ShouldFocusPageAfterCrash() final;
fsamuel4a1650f2015-01-23 21:57:49370 void UpdatePreferredSize(content::WebContents* web_contents,
371 const gfx::Size& pref_size) final;
paulmeyerd7523c2b2015-10-21 22:58:05372 void UpdateTargetURL(content::WebContents* source, const GURL& url) final;
373 bool ShouldResumeRequestsForCreatedWindow() final;
fsamuel4a1650f2015-01-23 21:57:49374
paulmeyerd7523c2b2015-10-21 22:58:05375 // WebContentsObserver implementation.
376 void DidStopLoading() final;
377 void RenderViewReady() final;
378 void WebContentsDestroyed() final;
wjmacleand99eafd2015-03-26 15:27:17379
paulmeyerd7523c2b2015-10-21 22:58:05380 // ui_zoom::ZoomObserver implementation.
381 void OnZoomChanged(
382 const ui_zoom::ZoomController::ZoomChangedEventData& data) final;
fsamuel87161f872014-11-07 23:00:36383
[email protected]738f57a2013-06-29 21:06:54384 void SendQueuedEvents();
385
fsamuel6867dde92015-01-13 02:18:19386 void CompleteInit(scoped_ptr<base::DictionaryValue> create_params,
387 const WebContentsCreatedCallback& callback,
[email protected]3d888fa2014-07-11 19:27:16388 content::WebContents* guest_web_contents);
[email protected]38177c32014-06-25 23:20:23389
paulmeyer1b61eb242015-01-22 19:13:00390 // Dispatches the onResize event to the embedder.
391 void DispatchOnResizeEvent(const gfx::Size& old_size,
392 const gfx::Size& new_size);
393
paulmeyercd7a39a2015-04-11 02:14:39394 // Returns the default size of the guestview.
395 gfx::Size GetDefaultSize() const;
396
paulmeyer1451fda2015-02-18 14:30:36397 // Get the zoom factor for the embedder's web contents.
paulmeyercd7a39a2015-04-11 02:14:39398 double GetEmbedderZoomFactor() const;
paulmeyer1451fda2015-02-18 14:30:36399
paulmeyereb98f9112015-01-23 17:13:38400 void SetUpSizing(const base::DictionaryValue& params);
paulmeyer70fcd542015-01-09 19:26:54401
fsamuel67993a92014-12-17 01:33:20402 void StartTrackingEmbedderZoomLevel();
403 void StopTrackingEmbedderZoomLevel();
wjmacleanec6bd522014-12-12 16:17:50404
lazyboya9206822015-09-16 20:07:20405 void UpdateGuestSize(const gfx::Size& new_size, bool due_to_auto_resize);
406
fsamuelfe20ffac2014-12-02 01:51:22407 // This guest tracks the lifetime of the WebContents specified by
408 // |owner_web_contents_|. If |owner_web_contents_| is destroyed then this
409 // guest will also self-destruct.
fsamuelad4f33f2014-11-28 19:32:21410 content::WebContents* owner_web_contents_;
fsamuel9a3c81e2015-04-24 12:30:11411 std::string owner_host_;
fsamuel09525e32015-01-21 22:23:39412 content::BrowserContext* const browser_context_;
fsamuel212c6da2014-09-18 16:16:15413
[email protected]0533cc6d2013-06-27 22:44:05414 // |guest_instance_id_| is a profile-wide unique identifier for a guest
415 // WebContents.
416 const int guest_instance_id_;
fsamuel212c6da2014-09-18 16:16:15417
[email protected]0533cc6d2013-06-27 22:44:05418 // |view_instance_id_| is an identifier that's unique within a particular
419 // embedder RenderViewHost for a particular <*view> instance.
[email protected]738f57a2013-06-29 21:06:54420 int view_instance_id_;
421
fsamuelad4f33f2014-11-28 19:32:21422 // |element_instance_id_| is an identifer that's unique to a particular
fsamuel212c6da2014-09-18 16:16:15423 // GuestViewContainer element.
424 int element_instance_id_;
425
fsamuelad4f33f2014-11-28 19:32:21426 // |initialized_| indicates whether GuestViewBase::Init has been called for
427 // this object.
[email protected]d84d57b2014-06-20 22:42:39428 bool initialized_;
429
fsamuel87161f872014-11-07 23:00:36430 // Indicates that this guest is in the process of being destroyed.
431 bool is_being_destroyed_;
432
[email protected]738f57a2013-06-29 21:06:54433 // This is a queue of Events that are destined to be sent to the embedder once
434 // the guest is attached to a particular embedder.
dcheng258894122016-02-02 17:42:24435 std::deque<scoped_ptr<GuestViewEvent>> pending_events_;
[email protected]0533cc6d2013-06-27 22:44:05436
[email protected]24569262014-05-06 03:31:30437 // The opener guest view.
438 base::WeakPtr<GuestViewBase> opener_;
439
[email protected]2101c4c2014-08-22 00:16:16440 // The parameters associated with the element hosting this GuestView that
441 // are passed in from JavaScript. This will typically be the view instance ID,
442 // and element-specific parameters. These parameters are passed along to new
443 // guests that are created from this guest.
444 scoped_ptr<base::DictionaryValue> attach_params_;
[email protected]50d326e2014-05-20 17:59:06445
fsamuel87161f872014-11-07 23:00:36446 // This observer ensures that this guest self-destructs if the embedder goes
447 // away.
lazyboy6d745d62015-03-19 03:21:01448 scoped_ptr<OwnerContentsObserver> owner_contents_observer_;
fsamuel87161f872014-11-07 23:00:36449
450 // This observer ensures that if the guest is unattached and its opener goes
451 // away then this guest also self-destructs.
452 scoped_ptr<OpenerLifetimeObserver> opener_lifetime_observer_;
[email protected]70ab2642014-05-30 08:06:58453
[email protected]5ca06862014-08-06 19:09:55454 // The size of the guest content. Note: In autosize mode, the container
455 // element may not match the size of the guest.
456 gfx::Size guest_size_;
457
fsamuel60b42282015-03-10 03:29:14458 // A pointer to the guest_host.
459 content::GuestHost* guest_host_;
paulmeyer0968abad2015-01-10 00:02:45460
[email protected]5ca06862014-08-06 19:09:55461 // Indicates whether autosize mode is enabled or not.
462 bool auto_size_enabled_;
463
464 // The maximum size constraints of the container element in autosize mode.
465 gfx::Size max_auto_size_;
466
467 // The minimum size constraints of the container element in autosize mode.
468 gfx::Size min_auto_size_;
469
paulmeyereb98f9112015-01-23 17:13:38470 // The size that will be used when autosize mode is disabled.
471 gfx::Size normal_size_;
472
sammce2092512014-11-24 22:18:24473 // Whether the guest view is inside a plugin document.
474 bool is_full_page_plugin_;
475
fsamuel60b42282015-03-10 03:29:14476 // The routing ID of the proxy to the guest in the owner's renderer process.
477 int guest_proxy_routing_id_;
478
[email protected]f21d36e2014-01-16 19:24:04479 // This is used to ensure pending tasks will not fire after this object is
480 // destroyed.
[email protected]0e99fdc2014-04-30 05:10:33481 base::WeakPtrFactory<GuestViewBase> weak_ptr_factory_;
[email protected]f21d36e2014-01-16 19:24:04482
[email protected]0e99fdc2014-04-30 05:10:33483 DISALLOW_COPY_AND_ASSIGN(GuestViewBase);
[email protected]0533cc6d2013-06-27 22:44:05484};
485
fsamuel8dfa19a2015-05-05 01:00:39486} // namespace guest_view
[email protected]140d6cd92014-08-12 18:26:46487
fsamuel8dfa19a2015-05-05 01:00:39488#endif // COMPONENTS_GUEST_VIEW_BROWSER_GUEST_VIEW_BASE_H_