| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef EXTENSIONS_BROWSER_GUEST_VIEW_GUEST_VIEW_BASE_H_ | 5 #ifndef EXTENSIONS_BROWSER_GUEST_VIEW_GUEST_VIEW_BASE_H_ |
| 6 #define EXTENSIONS_BROWSER_GUEST_VIEW_GUEST_VIEW_BASE_H_ | 6 #define EXTENSIONS_BROWSER_GUEST_VIEW_GUEST_VIEW_BASE_H_ |
| 7 | 7 |
| 8 #include <queue> | 8 #include <queue> |
| 9 | 9 |
| 10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 | 185 |
| 186 content::WebContents* embedder_web_contents() const { | 186 content::WebContents* embedder_web_contents() const { |
| 187 return embedder_web_contents_; | 187 return embedder_web_contents_; |
| 188 } | 188 } |
| 189 | 189 |
| 190 // Returns the guest WebContents. | 190 // Returns the guest WebContents. |
| 191 content::WebContents* guest_web_contents() const { | 191 content::WebContents* guest_web_contents() const { |
| 192 return web_contents(); | 192 return web_contents(); |
| 193 } | 193 } |
| 194 | 194 |
| 195 // Returns the extra parameters associated with this GuestView passed | 195 // Returns the parameters associated with the element hosting this GuestView |
| 196 // in from JavaScript. | 196 // passed in from JavaScript. |
| 197 base::DictionaryValue* extra_params() const { | 197 base::DictionaryValue* attach_params() const { return attach_params_.get(); } |
| 198 return extra_params_.get(); | |
| 199 } | |
| 200 | 198 |
| 201 // Returns whether this guest has an associated embedder. | 199 // Returns whether this guest has an associated embedder. |
| 202 bool attached() const { return !!embedder_web_contents_; } | 200 bool attached() const { return !!embedder_web_contents_; } |
| 203 | 201 |
| 204 // Returns the instance ID of the <*view> element. | 202 // Returns the instance ID of the <*view> element. |
| 205 int view_instance_id() const { return view_instance_id_; } | 203 int view_instance_id() const { return view_instance_id_; } |
| 206 | 204 |
| 205 // Returns the instance ID of this GuestViewBase. |
| 206 int guest_instance_id() const { return guest_instance_id_; } |
| 207 |
| 207 // Returns the extension ID of the embedder. | 208 // Returns the extension ID of the embedder. |
| 208 const std::string& embedder_extension_id() const { | 209 const std::string& embedder_extension_id() const { |
| 209 return embedder_extension_id_; | 210 return embedder_extension_id_; |
| 210 } | 211 } |
| 211 | 212 |
| 212 // Returns whether this GuestView is embedded in an extension/app. | 213 // Returns whether this GuestView is embedded in an extension/app. |
| 213 bool in_extension() const { return !embedder_extension_id_.empty(); } | 214 bool in_extension() const { return !embedder_extension_id_.empty(); } |
| 214 | 215 |
| 215 // Returns the user browser context of the embedder. | 216 // Returns the user browser context of the embedder. |
| 216 content::BrowserContext* browser_context() const { return browser_context_; } | 217 content::BrowserContext* browser_context() const { return browser_context_; } |
| 217 | 218 |
| 218 // Returns the embedder's process ID. | 219 // Returns the embedder's process ID. |
| 219 int embedder_render_process_id() const { return embedder_render_process_id_; } | 220 int embedder_render_process_id() const { return embedder_render_process_id_; } |
| 220 | 221 |
| 221 GuestViewBase* GetOpener() const { | 222 GuestViewBase* GetOpener() const { |
| 222 return opener_.get(); | 223 return opener_.get(); |
| 223 } | 224 } |
| 224 | 225 |
| 226 // Sets some additional chrome/ initialization parameters. |
| 227 void SetAttachParams(const base::DictionaryValue& params); |
| 225 void SetOpener(GuestViewBase* opener); | 228 void SetOpener(GuestViewBase* opener); |
| 226 | 229 |
| 227 // RenderProcessHostObserver implementation | 230 // RenderProcessHostObserver implementation |
| 228 virtual void RenderProcessExited(content::RenderProcessHost* host, | 231 virtual void RenderProcessExited(content::RenderProcessHost* host, |
| 229 base::ProcessHandle handle, | 232 base::ProcessHandle handle, |
| 230 base::TerminationStatus status, | 233 base::TerminationStatus status, |
| 231 int exit_code) OVERRIDE; | 234 int exit_code) OVERRIDE; |
| 232 | 235 |
| 233 // BrowserPluginGuestDelegate implementation. | 236 // BrowserPluginGuestDelegate implementation. |
| 234 virtual void Destroy() OVERRIDE FINAL; | 237 virtual void Destroy() OVERRIDE FINAL; |
| 235 virtual void DidAttach() OVERRIDE FINAL; | 238 virtual void DidAttach() OVERRIDE FINAL; |
| 236 virtual void ElementSizeChanged(const gfx::Size& old_size, | 239 virtual void ElementSizeChanged(const gfx::Size& old_size, |
| 237 const gfx::Size& new_size) OVERRIDE FINAL; | 240 const gfx::Size& new_size) OVERRIDE FINAL; |
| 238 virtual int GetGuestInstanceID() const OVERRIDE; | |
| 239 virtual void GuestSizeChanged(const gfx::Size& old_size, | 241 virtual void GuestSizeChanged(const gfx::Size& old_size, |
| 240 const gfx::Size& new_size) OVERRIDE FINAL; | 242 const gfx::Size& new_size) OVERRIDE FINAL; |
| 241 virtual void RegisterDestructionCallback( | 243 virtual void RegisterDestructionCallback( |
| 242 const DestructionCallback& callback) OVERRIDE FINAL; | 244 const DestructionCallback& callback) OVERRIDE FINAL; |
| 243 virtual void WillAttach( | 245 virtual void WillAttach( |
| 244 content::WebContents* embedder_web_contents, | 246 content::WebContents* embedder_web_contents) OVERRIDE FINAL; |
| 245 const base::DictionaryValue& extra_params) OVERRIDE FINAL; | |
| 246 | 247 |
| 247 // Dispatches an event |event_name| to the embedder with the |event| fields. | 248 // Dispatches an event |event_name| to the embedder with the |event| fields. |
| 248 void DispatchEventToEmbedder(Event* event); | 249 void DispatchEventToEmbedder(Event* event); |
| 249 | 250 |
| 250 protected: | 251 protected: |
| 251 GuestViewBase(content::BrowserContext* browser_context, | 252 GuestViewBase(content::BrowserContext* browser_context, |
| 252 int guest_instance_id); | 253 int guest_instance_id); |
| 253 | 254 |
| 254 virtual ~GuestViewBase(); | 255 virtual ~GuestViewBase(); |
| 255 | 256 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 | 293 |
| 293 // This is a queue of Events that are destined to be sent to the embedder once | 294 // This is a queue of Events that are destined to be sent to the embedder once |
| 294 // the guest is attached to a particular embedder. | 295 // the guest is attached to a particular embedder. |
| 295 std::deque<linked_ptr<Event> > pending_events_; | 296 std::deque<linked_ptr<Event> > pending_events_; |
| 296 | 297 |
| 297 // The opener guest view. | 298 // The opener guest view. |
| 298 base::WeakPtr<GuestViewBase> opener_; | 299 base::WeakPtr<GuestViewBase> opener_; |
| 299 | 300 |
| 300 DestructionCallback destruction_callback_; | 301 DestructionCallback destruction_callback_; |
| 301 | 302 |
| 302 // The extra parameters associated with this GuestView passed | 303 // The parameters associated with the element hosting this GuestView that |
| 303 // in from JavaScript. This will typically be the view instance ID, | 304 // are passed in from JavaScript. This will typically be the view instance ID, |
| 304 // the API to use, and view-specific parameters. These parameters | 305 // and element-specific parameters. These parameters are passed along to new |
| 305 // are passed along to new guests that are created from this guest. | 306 // guests that are created from this guest. |
| 306 scoped_ptr<base::DictionaryValue> extra_params_; | 307 scoped_ptr<base::DictionaryValue> attach_params_; |
| 307 | 308 |
| 308 scoped_ptr<EmbedderWebContentsObserver> embedder_web_contents_observer_; | 309 scoped_ptr<EmbedderWebContentsObserver> embedder_web_contents_observer_; |
| 309 | 310 |
| 310 // The size of the container element. | 311 // The size of the container element. |
| 311 gfx::Size element_size_; | 312 gfx::Size element_size_; |
| 312 | 313 |
| 313 // The size of the guest content. Note: In autosize mode, the container | 314 // The size of the guest content. Note: In autosize mode, the container |
| 314 // element may not match the size of the guest. | 315 // element may not match the size of the guest. |
| 315 gfx::Size guest_size_; | 316 gfx::Size guest_size_; |
| 316 | 317 |
| 317 // Indicates whether autosize mode is enabled or not. | 318 // Indicates whether autosize mode is enabled or not. |
| 318 bool auto_size_enabled_; | 319 bool auto_size_enabled_; |
| 319 | 320 |
| 320 // The maximum size constraints of the container element in autosize mode. | 321 // The maximum size constraints of the container element in autosize mode. |
| 321 gfx::Size max_auto_size_; | 322 gfx::Size max_auto_size_; |
| 322 | 323 |
| 323 // The minimum size constraints of the container element in autosize mode. | 324 // The minimum size constraints of the container element in autosize mode. |
| 324 gfx::Size min_auto_size_; | 325 gfx::Size min_auto_size_; |
| 325 | 326 |
| 326 // This is used to ensure pending tasks will not fire after this object is | 327 // This is used to ensure pending tasks will not fire after this object is |
| 327 // destroyed. | 328 // destroyed. |
| 328 base::WeakPtrFactory<GuestViewBase> weak_ptr_factory_; | 329 base::WeakPtrFactory<GuestViewBase> weak_ptr_factory_; |
| 329 | 330 |
| 330 DISALLOW_COPY_AND_ASSIGN(GuestViewBase); | 331 DISALLOW_COPY_AND_ASSIGN(GuestViewBase); |
| 331 }; | 332 }; |
| 332 | 333 |
| 333 } // namespace extensions | 334 } // namespace extensions |
| 334 | 335 |
| 335 #endif // EXTENSIONS_BROWSER_GUEST_VIEW_GUEST_VIEW_BASE_H_ | 336 #endif // EXTENSIONS_BROWSER_GUEST_VIEW_GUEST_VIEW_BASE_H_ |
| OLD | NEW |