[email protected] | 945604a | 2014-04-28 12:29:59 | [diff] [blame] | 1 | // Copyright 2014 The Chromium Authors. All rights reserved. |
[email protected] | 0533cc6d | 2013-06-27 22:44:05 | [diff] [blame] | 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] | 140d6cd9 | 2014-08-12 18:26:46 | [diff] [blame] | 5 | #ifndef EXTENSIONS_BROWSER_GUEST_VIEW_GUEST_VIEW_BASE_H_ |
| 6 | #define EXTENSIONS_BROWSER_GUEST_VIEW_GUEST_VIEW_BASE_H_ |
[email protected] | 0533cc6d | 2013-06-27 22:44:05 | [diff] [blame] | 7 | |
[email protected] | 738f57a | 2013-06-29 21:06:54 | [diff] [blame] | 8 | #include <queue> |
| 9 | |
[email protected] | f21d36e | 2014-01-16 19:24:04 | [diff] [blame] | 10 | #include "base/memory/weak_ptr.h" |
[email protected] | 0533cc6d | 2013-06-27 22:44:05 | [diff] [blame] | 11 | #include "base/values.h" |
[email protected] | 4c0e827 | 2013-07-03 23:39:22 | [diff] [blame] | 12 | #include "content/public/browser/browser_plugin_guest_delegate.h" |
[email protected] | 4858e43 | 2014-06-23 18:14:17 | [diff] [blame] | 13 | #include "content/public/browser/render_process_host_observer.h" |
[email protected] | 0533cc6d | 2013-06-27 22:44:05 | [diff] [blame] | 14 | #include "content/public/browser/web_contents.h" |
[email protected] | aec80ed | 2014-05-27 00:01:15 | [diff] [blame] | 15 | #include "content/public/browser/web_contents_delegate.h" |
[email protected] | 70ab264 | 2014-05-30 08:06:58 | [diff] [blame] | 16 | #include "content/public/browser/web_contents_observer.h" |
[email protected] | 0533cc6d | 2013-06-27 22:44:05 | [diff] [blame] | 17 | |
[email protected] | 06153f0 | 2013-12-04 03:01:28 | [diff] [blame] | 18 | struct RendererContentSettingRules; |
[email protected] | 0533cc6d | 2013-06-27 22:44:05 | [diff] [blame] | 19 | |
[email protected] | 140d6cd9 | 2014-08-12 18:26:46 | [diff] [blame] | 20 | namespace extensions { |
| 21 | |
[email protected] | 0e99fdc | 2014-04-30 05:10:33 | [diff] [blame] | 22 | // A GuestViewBase is the base class browser-side API implementation for a |
| 23 | // <*view> tag. GuestViewBase maintains an association between a guest |
| 24 | // WebContents and an embedder WebContents. It receives events issued from |
[email protected] | 4858e43 | 2014-06-23 18:14:17 | [diff] [blame] | 25 | // the guest and relays them to the embedder. GuestViewBase tracks the lifetime |
| 26 | // of its embedder render process until it is attached to a particular embedder |
| 27 | // WebContents. At that point, its lifetime is restricted in scope to the |
| 28 | // lifetime of its embedder WebContents. |
[email protected] | aec80ed | 2014-05-27 00:01:15 | [diff] [blame] | 29 | class GuestViewBase : public content::BrowserPluginGuestDelegate, |
[email protected] | 4858e43 | 2014-06-23 18:14:17 | [diff] [blame] | 30 | public content::RenderProcessHostObserver, |
[email protected] | 70ab264 | 2014-05-30 08:06:58 | [diff] [blame] | 31 | public content::WebContentsDelegate, |
| 32 | public content::WebContentsObserver { |
[email protected] | 0533cc6d | 2013-06-27 22:44:05 | [diff] [blame] | 33 | public: |
[email protected] | 738f57a | 2013-06-29 21:06:54 | [diff] [blame] | 34 | class Event { |
| 35 | public: |
[email protected] | 0e99fdc | 2014-04-30 05:10:33 | [diff] [blame] | 36 | Event(const std::string& name, scoped_ptr<base::DictionaryValue> args); |
| 37 | ~Event(); |
[email protected] | 738f57a | 2013-06-29 21:06:54 | [diff] [blame] | 38 | |
[email protected] | 0aad647 | 2013-12-04 18:25:38 | [diff] [blame] | 39 | const std::string& name() const { return name_; } |
[email protected] | 738f57a | 2013-06-29 21:06:54 | [diff] [blame] | 40 | |
[email protected] | cb1078de | 2013-12-23 20:04:22 | [diff] [blame] | 41 | scoped_ptr<base::DictionaryValue> GetArguments(); |
[email protected] | 738f57a | 2013-06-29 21:06:54 | [diff] [blame] | 42 | |
| 43 | private: |
[email protected] | 0aad647 | 2013-12-04 18:25:38 | [diff] [blame] | 44 | const std::string name_; |
[email protected] | cb1078de | 2013-12-23 20:04:22 | [diff] [blame] | 45 | scoped_ptr<base::DictionaryValue> args_; |
[email protected] | 738f57a | 2013-06-29 21:06:54 | [diff] [blame] | 46 | }; |
| 47 | |
[email protected] | 0e99fdc | 2014-04-30 05:10:33 | [diff] [blame] | 48 | // Returns a *ViewGuest if this GuestView is of the given view type. |
| 49 | template <typename T> |
| 50 | T* As() { |
[email protected] | 2456926 | 2014-05-06 03:31:30 | [diff] [blame] | 51 | if (IsViewType(T::Type)) |
[email protected] | 0e99fdc | 2014-04-30 05:10:33 | [diff] [blame] | 52 | return static_cast<T*>(this); |
[email protected] | 2456926 | 2014-05-06 03:31:30 | [diff] [blame] | 53 | |
[email protected] | 0e99fdc | 2014-04-30 05:10:33 | [diff] [blame] | 54 | return NULL; |
| 55 | } |
[email protected] | 50c827d | 2013-09-13 21:36:09 | [diff] [blame] | 56 | |
[email protected] | 71c63dc | 2014-07-21 22:49:53 | [diff] [blame] | 57 | typedef base::Callback<GuestViewBase*( |
| 58 | content::BrowserContext*, int)> GuestCreationCallback; |
| 59 | static void RegisterGuestViewType(const std::string& view_type, |
| 60 | const GuestCreationCallback& callback); |
| 61 | |
[email protected] | 38177c3 | 2014-06-25 23:20:23 | [diff] [blame] | 62 | static GuestViewBase* Create(content::BrowserContext* browser_context, |
| 63 | int guest_instance_id, |
[email protected] | 50d326e | 2014-05-20 17:59:06 | [diff] [blame] | 64 | const std::string& view_type); |
[email protected] | 738f57a | 2013-06-29 21:06:54 | [diff] [blame] | 65 | |
[email protected] | 0e99fdc | 2014-04-30 05:10:33 | [diff] [blame] | 66 | static GuestViewBase* FromWebContents(content::WebContents* web_contents); |
[email protected] | 0533cc6d | 2013-06-27 22:44:05 | [diff] [blame] | 67 | |
[email protected] | 0e99fdc | 2014-04-30 05:10:33 | [diff] [blame] | 68 | static GuestViewBase* From(int embedder_process_id, int instance_id); |
[email protected] | 0533cc6d | 2013-06-27 22:44:05 | [diff] [blame] | 69 | |
[email protected] | a24efc2 | 2014-05-26 15:50:25 | [diff] [blame] | 70 | static bool IsGuest(content::WebContents* web_contents); |
| 71 | |
[email protected] | 38fe437 | 2014-05-01 08:38:32 | [diff] [blame] | 72 | virtual const char* GetViewType() const = 0; |
[email protected] | 06153f0 | 2013-12-04 03:01:28 | [diff] [blame] | 73 | |
[email protected] | d84d57b | 2014-06-20 22:42:39 | [diff] [blame] | 74 | // This method is called after the guest has been attached to an embedder and |
| 75 | // suspended resource loads have been resumed. |
| 76 | // |
| 77 | // This method can be overriden by subclasses. This gives the derived class |
| 78 | // an opportunity to perform setup actions after attachment. |
| 79 | virtual void DidAttachToEmbedder() {} |
| 80 | |
[email protected] | 4858e43 | 2014-06-23 18:14:17 | [diff] [blame] | 81 | // This method is called after this GuestViewBase has been initiated. |
| 82 | // |
| 83 | // This gives the derived class an opportunity to perform additional |
| 84 | // initialization. |
| 85 | virtual void DidInitialize() {} |
| 86 | |
| 87 | // This method is called when the initial set of frames within the page have |
| 88 | // completed loading. |
[email protected] | feaa8cf | 2014-05-31 03:57:14 | [diff] [blame] | 89 | virtual void DidStopLoading() {} |
| 90 | |
[email protected] | 4858e43 | 2014-06-23 18:14:17 | [diff] [blame] | 91 | // This method is called when the guest's embedder WebContents has been |
| 92 | // destroyed and the guest will be destroyed shortly. |
| 93 | // |
| 94 | // This gives the derived class an opportunity to perform some cleanup prior |
| 95 | // to destruction. |
| 96 | virtual void EmbedderDestroyed() {} |
| 97 | |
| 98 | // This method is called when the guest WebContents has been destroyed. This |
| 99 | // object will be destroyed after this call returns. |
| 100 | // |
| 101 | // This gives the derived class an opportunity to perform some cleanup. |
| 102 | virtual void GuestDestroyed() {} |
| 103 | |
[email protected] | 5ca0686 | 2014-08-06 19:09:55 | [diff] [blame] | 104 | // This method is invoked when the guest RenderView is ready, e.g. because we |
| 105 | // recreated it after a crash. |
| 106 | // |
| 107 | // This gives the derived class an opportunity to perform some initialization |
| 108 | // work. |
| 109 | virtual void GuestReady() {} |
| 110 | |
| 111 | // This method is invoked when the contents auto-resized to give the container |
| 112 | // an opportunity to match it if it wishes. |
| 113 | // |
| 114 | // This gives the derived class an opportunity to inform its container element |
| 115 | // or perform other actions. |
| 116 | virtual void GuestSizeChangedDueToAutoSize(const gfx::Size& old_size, |
| 117 | const gfx::Size& new_size) {} |
| 118 | |
| 119 | // This method queries whether autosize is supported for this particular view. |
| 120 | // By default, autosize is not supported. Derived classes can override this |
| 121 | // behavior to support autosize. |
| 122 | virtual bool IsAutoSizeSupported() const; |
| 123 | |
[email protected] | 4858e43 | 2014-06-23 18:14:17 | [diff] [blame] | 124 | // This method queries whether drag-and-drop is enabled for this particular |
| 125 | // view. By default, drag-and-drop is disabled. Derived classes can override |
| 126 | // this behavior to enable drag-and-drop. |
| 127 | virtual bool IsDragAndDropEnabled() const; |
| 128 | |
[email protected] | d84d57b | 2014-06-20 22:42:39 | [diff] [blame] | 129 | // This method is called immediately before suspended resource loads have been |
| 130 | // resumed on attachment to an embedder. |
| 131 | // |
| 132 | // This method can be overriden by subclasses. This gives the derived class |
| 133 | // an opportunity to perform setup actions before attachment. |
| 134 | virtual void WillAttachToEmbedder() {} |
| 135 | |
[email protected] | a868c6c | 2014-06-04 13:07:43 | [diff] [blame] | 136 | // This method is called when the guest WebContents is about to be destroyed. |
| 137 | // |
[email protected] | 4858e43 | 2014-06-23 18:14:17 | [diff] [blame] | 138 | // This gives the derived class an opportunity to perform some cleanup prior |
| 139 | // to destruction. |
[email protected] | a868c6c | 2014-06-04 13:07:43 | [diff] [blame] | 140 | virtual void WillDestroy() {} |
| 141 | |
[email protected] | 755211fe | 2014-08-08 19:01:49 | [diff] [blame] | 142 | // This method is to be implemented by the derived class. Access to guest |
| 143 | // views are determined by the availability of the internal extension API |
| 144 | // used to implement the guest view. |
| 145 | // |
| 146 | // This should be the name of the API as it appears in the _api_features.json |
| 147 | // file. |
fsamuel | 99492be | 2014-08-28 03:50:27 | [diff] [blame^] | 148 | virtual const char* GetAPINamespace() const = 0; |
| 149 | |
| 150 | // This method is to be implemented by the derived class. This method is the |
| 151 | // task prefix to show for a task produced by this GuestViewBase's derived |
| 152 | // type. |
| 153 | virtual int GetTaskPrefix() const = 0; |
[email protected] | a2be2f11 | 2014-07-12 01:10:05 | [diff] [blame] | 154 | |
[email protected] | 4858e43 | 2014-06-23 18:14:17 | [diff] [blame] | 155 | // This method is to be implemented by the derived class. Given a set of |
| 156 | // initialization parameters, a concrete subclass of GuestViewBase can |
| 157 | // create a specialized WebContents that it returns back to GuestViewBase. |
| 158 | typedef base::Callback<void(content::WebContents*)> |
| 159 | WebContentsCreatedCallback; |
| 160 | virtual void CreateWebContents( |
| 161 | const std::string& embedder_extension_id, |
| 162 | int embedder_render_process_id, |
| 163 | const base::DictionaryValue& create_params, |
| 164 | const WebContentsCreatedCallback& callback) = 0; |
[email protected] | 70ab264 | 2014-05-30 08:06:58 | [diff] [blame] | 165 | |
[email protected] | 4858e43 | 2014-06-23 18:14:17 | [diff] [blame] | 166 | // This creates a WebContents and initializes |this| GuestViewBase to use the |
| 167 | // newly created WebContents. |
| 168 | void Init(const std::string& embedder_extension_id, |
[email protected] | 755211fe | 2014-08-08 19:01:49 | [diff] [blame] | 169 | content::WebContents* embedder_web_contents, |
[email protected] | 38177c3 | 2014-06-25 23:20:23 | [diff] [blame] | 170 | const base::DictionaryValue& create_params, |
| 171 | const WebContentsCreatedCallback& callback); |
[email protected] | a868c6c | 2014-06-04 13:07:43 | [diff] [blame] | 172 | |
[email protected] | 4858e43 | 2014-06-23 18:14:17 | [diff] [blame] | 173 | void InitWithWebContents( |
| 174 | const std::string& embedder_extension_id, |
| 175 | int embedder_render_process_id, |
| 176 | content::WebContents* guest_web_contents); |
[email protected] | d84d57b | 2014-06-20 22:42:39 | [diff] [blame] | 177 | |
[email protected] | 2456926 | 2014-05-06 03:31:30 | [diff] [blame] | 178 | bool IsViewType(const char* const view_type) const { |
| 179 | return !strcmp(GetViewType(), view_type); |
| 180 | } |
| 181 | |
[email protected] | 5ca0686 | 2014-08-06 19:09:55 | [diff] [blame] | 182 | // Toggles autosize mode for this GuestView. |
| 183 | void SetAutoSize(bool enabled, |
| 184 | const gfx::Size& min_size, |
| 185 | const gfx::Size& max_size); |
| 186 | |
[email protected] | 2456926 | 2014-05-06 03:31:30 | [diff] [blame] | 187 | base::WeakPtr<GuestViewBase> AsWeakPtr(); |
| 188 | |
[email protected] | 4858e43 | 2014-06-23 18:14:17 | [diff] [blame] | 189 | bool initialized() const { return initialized_; } |
| 190 | |
[email protected] | 0533cc6d | 2013-06-27 22:44:05 | [diff] [blame] | 191 | content::WebContents* embedder_web_contents() const { |
| 192 | return embedder_web_contents_; |
| 193 | } |
| 194 | |
| 195 | // Returns the guest WebContents. |
[email protected] | 738f57a | 2013-06-29 21:06:54 | [diff] [blame] | 196 | content::WebContents* guest_web_contents() const { |
[email protected] | 70ab264 | 2014-05-30 08:06:58 | [diff] [blame] | 197 | return web_contents(); |
[email protected] | 738f57a | 2013-06-29 21:06:54 | [diff] [blame] | 198 | } |
| 199 | |
[email protected] | 2101c4c | 2014-08-22 00:16:16 | [diff] [blame] | 200 | // Returns the parameters associated with the element hosting this GuestView |
| 201 | // passed in from JavaScript. |
| 202 | base::DictionaryValue* attach_params() const { return attach_params_.get(); } |
[email protected] | 50d326e | 2014-05-20 17:59:06 | [diff] [blame] | 203 | |
[email protected] | 738f57a | 2013-06-29 21:06:54 | [diff] [blame] | 204 | // Returns whether this guest has an associated embedder. |
| 205 | bool attached() const { return !!embedder_web_contents_; } |
| 206 | |
[email protected] | 0533cc6d | 2013-06-27 22:44:05 | [diff] [blame] | 207 | // Returns the instance ID of the <*view> element. |
| 208 | int view_instance_id() const { return view_instance_id_; } |
| 209 | |
[email protected] | 2101c4c | 2014-08-22 00:16:16 | [diff] [blame] | 210 | // Returns the instance ID of this GuestViewBase. |
| 211 | int guest_instance_id() const { return guest_instance_id_; } |
| 212 | |
[email protected] | 0533cc6d | 2013-06-27 22:44:05 | [diff] [blame] | 213 | // Returns the extension ID of the embedder. |
[email protected] | 880331f97 | 2014-03-05 01:42:53 | [diff] [blame] | 214 | const std::string& embedder_extension_id() const { |
| 215 | return embedder_extension_id_; |
| 216 | } |
| 217 | |
| 218 | // Returns whether this GuestView is embedded in an extension/app. |
[email protected] | 0e99fdc | 2014-04-30 05:10:33 | [diff] [blame] | 219 | bool in_extension() const { return !embedder_extension_id_.empty(); } |
[email protected] | 0533cc6d | 2013-06-27 22:44:05 | [diff] [blame] | 220 | |
| 221 | // Returns the user browser context of the embedder. |
| 222 | content::BrowserContext* browser_context() const { return browser_context_; } |
| 223 | |
| 224 | // Returns the embedder's process ID. |
| 225 | int embedder_render_process_id() const { return embedder_render_process_id_; } |
| 226 | |
[email protected] | 50d326e | 2014-05-20 17:59:06 | [diff] [blame] | 227 | GuestViewBase* GetOpener() const { |
| 228 | return opener_.get(); |
| 229 | } |
| 230 | |
[email protected] | 2101c4c | 2014-08-22 00:16:16 | [diff] [blame] | 231 | // Sets some additional chrome/ initialization parameters. |
| 232 | void SetAttachParams(const base::DictionaryValue& params); |
[email protected] | 50d326e | 2014-05-20 17:59:06 | [diff] [blame] | 233 | void SetOpener(GuestViewBase* opener); |
| 234 | |
[email protected] | 4858e43 | 2014-06-23 18:14:17 | [diff] [blame] | 235 | // RenderProcessHostObserver implementation |
| 236 | virtual void RenderProcessExited(content::RenderProcessHost* host, |
| 237 | base::ProcessHandle handle, |
| 238 | base::TerminationStatus status, |
| 239 | int exit_code) OVERRIDE; |
| 240 | |
[email protected] | aec80ed | 2014-05-27 00:01:15 | [diff] [blame] | 241 | // BrowserPluginGuestDelegate implementation. |
[email protected] | a868c6c | 2014-06-04 13:07:43 | [diff] [blame] | 242 | virtual void Destroy() OVERRIDE FINAL; |
[email protected] | d84d57b | 2014-06-20 22:42:39 | [diff] [blame] | 243 | virtual void DidAttach() OVERRIDE FINAL; |
[email protected] | 5ca0686 | 2014-08-06 19:09:55 | [diff] [blame] | 244 | virtual void ElementSizeChanged(const gfx::Size& old_size, |
| 245 | const gfx::Size& new_size) OVERRIDE FINAL; |
[email protected] | 5ca0686 | 2014-08-06 19:09:55 | [diff] [blame] | 246 | virtual void GuestSizeChanged(const gfx::Size& old_size, |
| 247 | const gfx::Size& new_size) OVERRIDE FINAL; |
[email protected] | aec80ed | 2014-05-27 00:01:15 | [diff] [blame] | 248 | virtual void RegisterDestructionCallback( |
[email protected] | a868c6c | 2014-06-04 13:07:43 | [diff] [blame] | 249 | const DestructionCallback& callback) OVERRIDE FINAL; |
[email protected] | d84d57b | 2014-06-20 22:42:39 | [diff] [blame] | 250 | virtual void WillAttach( |
[email protected] | 2101c4c | 2014-08-22 00:16:16 | [diff] [blame] | 251 | content::WebContents* embedder_web_contents) OVERRIDE FINAL; |
[email protected] | a868c6c | 2014-06-04 13:07:43 | [diff] [blame] | 252 | |
[email protected] | 7adb26a7 | 2014-07-09 17:44:35 | [diff] [blame] | 253 | // Dispatches an event |event_name| to the embedder with the |event| fields. |
| 254 | void DispatchEventToEmbedder(Event* event); |
| 255 | |
[email protected] | 0533cc6d | 2013-06-27 22:44:05 | [diff] [blame] | 256 | protected: |
[email protected] | 38177c3 | 2014-06-25 23:20:23 | [diff] [blame] | 257 | GuestViewBase(content::BrowserContext* browser_context, |
| 258 | int guest_instance_id); |
[email protected] | d84d57b | 2014-06-20 22:42:39 | [diff] [blame] | 259 | |
[email protected] | 0e99fdc | 2014-04-30 05:10:33 | [diff] [blame] | 260 | virtual ~GuestViewBase(); |
[email protected] | 0533cc6d | 2013-06-27 22:44:05 | [diff] [blame] | 261 | |
[email protected] | 0533cc6d | 2013-06-27 22:44:05 | [diff] [blame] | 262 | private: |
[email protected] | 70ab264 | 2014-05-30 08:06:58 | [diff] [blame] | 263 | class EmbedderWebContentsObserver; |
| 264 | |
[email protected] | 738f57a | 2013-06-29 21:06:54 | [diff] [blame] | 265 | void SendQueuedEvents(); |
| 266 | |
[email protected] | 3d888fa | 2014-07-11 19:27:16 | [diff] [blame] | 267 | void CompleteInit(const std::string& embedder_extension_id, |
| 268 | int embedder_render_process_id, |
| 269 | const WebContentsCreatedCallback& callback, |
| 270 | content::WebContents* guest_web_contents); |
[email protected] | 38177c3 | 2014-06-25 23:20:23 | [diff] [blame] | 271 | |
[email protected] | 5226331 | 2014-07-22 17:45:13 | [diff] [blame] | 272 | static void RegisterGuestViewTypes(); |
| 273 | |
[email protected] | a868c6c | 2014-06-04 13:07:43 | [diff] [blame] | 274 | // WebContentsObserver implementation. |
| 275 | virtual void DidStopLoading( |
| 276 | content::RenderViewHost* render_view_host) OVERRIDE FINAL; |
[email protected] | 5ca0686 | 2014-08-06 19:09:55 | [diff] [blame] | 277 | virtual void RenderViewReady() OVERRIDE FINAL; |
[email protected] | a868c6c | 2014-06-04 13:07:43 | [diff] [blame] | 278 | virtual void WebContentsDestroyed() OVERRIDE FINAL; |
| 279 | |
| 280 | // WebContentsDelegate implementation. |
| 281 | virtual bool ShouldFocusPageAfterCrash() OVERRIDE FINAL; |
| 282 | virtual bool PreHandleGestureEvent( |
| 283 | content::WebContents* source, |
| 284 | const blink::WebGestureEvent& event) OVERRIDE FINAL; |
| 285 | |
[email protected] | 0533cc6d | 2013-06-27 22:44:05 | [diff] [blame] | 286 | content::WebContents* embedder_web_contents_; |
[email protected] | d84d57b | 2014-06-20 22:42:39 | [diff] [blame] | 287 | std::string embedder_extension_id_; |
[email protected] | 738f57a | 2013-06-29 21:06:54 | [diff] [blame] | 288 | int embedder_render_process_id_; |
[email protected] | d84d57b | 2014-06-20 22:42:39 | [diff] [blame] | 289 | content::BrowserContext* browser_context_; |
[email protected] | 0533cc6d | 2013-06-27 22:44:05 | [diff] [blame] | 290 | // |guest_instance_id_| is a profile-wide unique identifier for a guest |
| 291 | // WebContents. |
| 292 | const int guest_instance_id_; |
| 293 | // |view_instance_id_| is an identifier that's unique within a particular |
| 294 | // embedder RenderViewHost for a particular <*view> instance. |
[email protected] | 738f57a | 2013-06-29 21:06:54 | [diff] [blame] | 295 | int view_instance_id_; |
| 296 | |
[email protected] | d84d57b | 2014-06-20 22:42:39 | [diff] [blame] | 297 | bool initialized_; |
| 298 | |
[email protected] | 738f57a | 2013-06-29 21:06:54 | [diff] [blame] | 299 | // This is a queue of Events that are destined to be sent to the embedder once |
| 300 | // the guest is attached to a particular embedder. |
[email protected] | 0544ea9 | 2014-04-22 21:50:47 | [diff] [blame] | 301 | std::deque<linked_ptr<Event> > pending_events_; |
[email protected] | 0533cc6d | 2013-06-27 22:44:05 | [diff] [blame] | 302 | |
[email protected] | 2456926 | 2014-05-06 03:31:30 | [diff] [blame] | 303 | // The opener guest view. |
| 304 | base::WeakPtr<GuestViewBase> opener_; |
| 305 | |
[email protected] | 50d326e | 2014-05-20 17:59:06 | [diff] [blame] | 306 | DestructionCallback destruction_callback_; |
| 307 | |
[email protected] | 2101c4c | 2014-08-22 00:16:16 | [diff] [blame] | 308 | // The parameters associated with the element hosting this GuestView that |
| 309 | // are passed in from JavaScript. This will typically be the view instance ID, |
| 310 | // and element-specific parameters. These parameters are passed along to new |
| 311 | // guests that are created from this guest. |
| 312 | scoped_ptr<base::DictionaryValue> attach_params_; |
[email protected] | 50d326e | 2014-05-20 17:59:06 | [diff] [blame] | 313 | |
[email protected] | 70ab264 | 2014-05-30 08:06:58 | [diff] [blame] | 314 | scoped_ptr<EmbedderWebContentsObserver> embedder_web_contents_observer_; |
| 315 | |
[email protected] | 5ca0686 | 2014-08-06 19:09:55 | [diff] [blame] | 316 | // The size of the container element. |
| 317 | gfx::Size element_size_; |
| 318 | |
| 319 | // The size of the guest content. Note: In autosize mode, the container |
| 320 | // element may not match the size of the guest. |
| 321 | gfx::Size guest_size_; |
| 322 | |
| 323 | // Indicates whether autosize mode is enabled or not. |
| 324 | bool auto_size_enabled_; |
| 325 | |
| 326 | // The maximum size constraints of the container element in autosize mode. |
| 327 | gfx::Size max_auto_size_; |
| 328 | |
| 329 | // The minimum size constraints of the container element in autosize mode. |
| 330 | gfx::Size min_auto_size_; |
| 331 | |
[email protected] | f21d36e | 2014-01-16 19:24:04 | [diff] [blame] | 332 | // This is used to ensure pending tasks will not fire after this object is |
| 333 | // destroyed. |
[email protected] | 0e99fdc | 2014-04-30 05:10:33 | [diff] [blame] | 334 | base::WeakPtrFactory<GuestViewBase> weak_ptr_factory_; |
[email protected] | f21d36e | 2014-01-16 19:24:04 | [diff] [blame] | 335 | |
[email protected] | 0e99fdc | 2014-04-30 05:10:33 | [diff] [blame] | 336 | DISALLOW_COPY_AND_ASSIGN(GuestViewBase); |
[email protected] | 0533cc6d | 2013-06-27 22:44:05 | [diff] [blame] | 337 | }; |
| 338 | |
[email protected] | 140d6cd9 | 2014-08-12 18:26:46 | [diff] [blame] | 339 | } // namespace extensions |
| 340 | |
| 341 | #endif // EXTENSIONS_BROWSER_GUEST_VIEW_GUEST_VIEW_BASE_H_ |