| 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" |
| 11 #include "base/values.h" | 11 #include "base/values.h" |
| 12 #include "components/ui/zoom/zoom_observer.h" | 12 #include "components/ui/zoom/zoom_observer.h" |
| 13 #include "content/public/browser/browser_plugin_guest_delegate.h" | 13 #include "content/public/browser/browser_plugin_guest_delegate.h" |
| 14 #include "content/public/browser/guest_sizer.h" | 14 #include "content/public/browser/guest_proxy_host.h" |
| 15 #include "content/public/browser/render_process_host_observer.h" | 15 #include "content/public/browser/render_process_host_observer.h" |
| 16 #include "content/public/browser/web_contents.h" | 16 #include "content/public/browser/web_contents.h" |
| 17 #include "content/public/browser/web_contents_delegate.h" | 17 #include "content/public/browser/web_contents_delegate.h" |
| 18 #include "content/public/browser/web_contents_observer.h" | 18 #include "content/public/browser/web_contents_observer.h" |
| 19 #include "extensions/common/guest_view/guest_view_constants.h" | 19 #include "extensions/common/guest_view/guest_view_constants.h" |
| 20 | 20 |
| 21 struct RendererContentSettingRules; | 21 struct RendererContentSettingRules; |
| 22 | 22 |
| 23 namespace extensions { | 23 namespace extensions { |
| 24 | 24 |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 bool initialized() const { return initialized_; } | 209 bool initialized() const { return initialized_; } |
| 210 | 210 |
| 211 content::WebContents* embedder_web_contents() const { | 211 content::WebContents* embedder_web_contents() const { |
| 212 return attached() ? owner_web_contents_ : nullptr; | 212 return attached() ? owner_web_contents_ : nullptr; |
| 213 } | 213 } |
| 214 | 214 |
| 215 content::WebContents* owner_web_contents() const { | 215 content::WebContents* owner_web_contents() const { |
| 216 return owner_web_contents_; | 216 return owner_web_contents_; |
| 217 } | 217 } |
| 218 | 218 |
| 219 content::GuestProxyHost* proxy_host() const { |
| 220 return guest_proxy_host_; |
| 221 } |
| 222 |
| 219 // Returns the parameters associated with the element hosting this GuestView | 223 // Returns the parameters associated with the element hosting this GuestView |
| 220 // passed in from JavaScript. | 224 // passed in from JavaScript. |
| 221 base::DictionaryValue* attach_params() const { return attach_params_.get(); } | 225 base::DictionaryValue* attach_params() const { return attach_params_.get(); } |
| 222 | 226 |
| 223 // Returns whether this guest has an associated embedder. | 227 // Returns whether this guest has an associated embedder. |
| 224 bool attached() const { | 228 bool attached() const { |
| 225 return element_instance_id_ != guestview::kInstanceIDNone; | 229 return element_instance_id_ != guestview::kInstanceIDNone; |
| 226 } | 230 } |
| 227 | 231 |
| 228 // Returns the instance ID of the <*view> element. | 232 // Returns the instance ID of the <*view> element. |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 // Destroy this guest. | 264 // Destroy this guest. |
| 261 void Destroy(); | 265 void Destroy(); |
| 262 | 266 |
| 263 // Saves the attach state of the custom element hosting this GuestView. | 267 // Saves the attach state of the custom element hosting this GuestView. |
| 264 void SetAttachParams(const base::DictionaryValue& params); | 268 void SetAttachParams(const base::DictionaryValue& params); |
| 265 void SetOpener(GuestViewBase* opener); | 269 void SetOpener(GuestViewBase* opener); |
| 266 | 270 |
| 267 // BrowserPluginGuestDelegate implementation. | 271 // BrowserPluginGuestDelegate implementation. |
| 268 content::WebContents* CreateNewGuestWindow( | 272 content::WebContents* CreateNewGuestWindow( |
| 269 const content::WebContents::CreateParams& create_params) final; | 273 const content::WebContents::CreateParams& create_params) final; |
| 270 void DidAttach(int guest_proxy_routing_id) final; | 274 void DidAttach() final; |
| 271 void DidDetach() final; | 275 void DidDetach() final; |
| 272 content::WebContents* GetOwnerWebContents() const final; | 276 content::WebContents* GetOwnerWebContents() const final; |
| 273 void GuestSizeChanged(const gfx::Size& new_size) final; | 277 void GuestSizeChanged(const gfx::Size& new_size) final; |
| 274 void RegisterDestructionCallback(const DestructionCallback& callback) final; | 278 void SetGuestProxyHost(content::GuestProxyHost* guest_proxy_host) final; |
| 275 void SetGuestSizer(content::GuestSizer* guest_sizer) final; | |
| 276 void WillAttach(content::WebContents* embedder_web_contents, | 279 void WillAttach(content::WebContents* embedder_web_contents, |
| 277 int browser_plugin_instance_id, | 280 int browser_plugin_instance_id, |
| 278 bool is_full_page_plugin) final; | 281 bool is_full_page_plugin) final; |
| 279 | 282 |
| 280 // ui_zoom::ZoomObserver implementation. | 283 // ui_zoom::ZoomObserver implementation. |
| 281 void OnZoomChanged( | 284 void OnZoomChanged( |
| 282 const ui_zoom::ZoomController::ZoomChangedEventData& data) override; | 285 const ui_zoom::ZoomController::ZoomChangedEventData& data) override; |
| 283 | 286 |
| 284 // Dispatches an event to the guest proxy. | 287 // Dispatches an event to the guest proxy. |
| 285 void DispatchEventToGuestProxy(Event* event); | 288 void DispatchEventToGuestProxy(Event* event); |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 // Indicates that this guest is in the process of being destroyed. | 392 // Indicates that this guest is in the process of being destroyed. |
| 390 bool is_being_destroyed_; | 393 bool is_being_destroyed_; |
| 391 | 394 |
| 392 // This is a queue of Events that are destined to be sent to the embedder once | 395 // This is a queue of Events that are destined to be sent to the embedder once |
| 393 // the guest is attached to a particular embedder. | 396 // the guest is attached to a particular embedder. |
| 394 std::deque<linked_ptr<Event> > pending_events_; | 397 std::deque<linked_ptr<Event> > pending_events_; |
| 395 | 398 |
| 396 // The opener guest view. | 399 // The opener guest view. |
| 397 base::WeakPtr<GuestViewBase> opener_; | 400 base::WeakPtr<GuestViewBase> opener_; |
| 398 | 401 |
| 399 DestructionCallback destruction_callback_; | |
| 400 | |
| 401 // The parameters associated with the element hosting this GuestView that | 402 // The parameters associated with the element hosting this GuestView that |
| 402 // are passed in from JavaScript. This will typically be the view instance ID, | 403 // are passed in from JavaScript. This will typically be the view instance ID, |
| 403 // and element-specific parameters. These parameters are passed along to new | 404 // and element-specific parameters. These parameters are passed along to new |
| 404 // guests that are created from this guest. | 405 // guests that are created from this guest. |
| 405 scoped_ptr<base::DictionaryValue> attach_params_; | 406 scoped_ptr<base::DictionaryValue> attach_params_; |
| 406 | 407 |
| 407 // This observer ensures that this guest self-destructs if the embedder goes | 408 // This observer ensures that this guest self-destructs if the embedder goes |
| 408 // away. | 409 // away. |
| 409 scoped_ptr<OwnerLifetimeObserver> owner_lifetime_observer_; | 410 scoped_ptr<OwnerLifetimeObserver> owner_lifetime_observer_; |
| 410 | 411 |
| 411 // This observer ensures that if the guest is unattached and its opener goes | 412 // This observer ensures that if the guest is unattached and its opener goes |
| 412 // away then this guest also self-destructs. | 413 // away then this guest also self-destructs. |
| 413 scoped_ptr<OpenerLifetimeObserver> opener_lifetime_observer_; | 414 scoped_ptr<OpenerLifetimeObserver> opener_lifetime_observer_; |
| 414 | 415 |
| 415 // The size of the guest content. Note: In autosize mode, the container | 416 // The size of the guest content. Note: In autosize mode, the container |
| 416 // element may not match the size of the guest. | 417 // element may not match the size of the guest. |
| 417 gfx::Size guest_size_; | 418 gfx::Size guest_size_; |
| 418 | 419 |
| 419 // A pointer to the guest_sizer. | 420 // A pointer to the guest_proxy_host. |
| 420 content::GuestSizer* guest_sizer_; | 421 content::GuestProxyHost* guest_proxy_host_; |
| 421 | 422 |
| 422 // Indicates whether autosize mode is enabled or not. | 423 // Indicates whether autosize mode is enabled or not. |
| 423 bool auto_size_enabled_; | 424 bool auto_size_enabled_; |
| 424 | 425 |
| 425 // The maximum size constraints of the container element in autosize mode. | 426 // The maximum size constraints of the container element in autosize mode. |
| 426 gfx::Size max_auto_size_; | 427 gfx::Size max_auto_size_; |
| 427 | 428 |
| 428 // The minimum size constraints of the container element in autosize mode. | 429 // The minimum size constraints of the container element in autosize mode. |
| 429 gfx::Size min_auto_size_; | 430 gfx::Size min_auto_size_; |
| 430 | 431 |
| 431 // The size that will be used when autosize mode is disabled. | 432 // The size that will be used when autosize mode is disabled. |
| 432 gfx::Size normal_size_; | 433 gfx::Size normal_size_; |
| 433 | 434 |
| 434 // Whether the guest view is inside a plugin document. | 435 // Whether the guest view is inside a plugin document. |
| 435 bool is_full_page_plugin_; | 436 bool is_full_page_plugin_; |
| 436 | 437 |
| 437 // This is used to ensure pending tasks will not fire after this object is | 438 // This is used to ensure pending tasks will not fire after this object is |
| 438 // destroyed. | 439 // destroyed. |
| 439 base::WeakPtrFactory<GuestViewBase> weak_ptr_factory_; | 440 base::WeakPtrFactory<GuestViewBase> weak_ptr_factory_; |
| 440 | 441 |
| 441 DISALLOW_COPY_AND_ASSIGN(GuestViewBase); | 442 DISALLOW_COPY_AND_ASSIGN(GuestViewBase); |
| 442 }; | 443 }; |
| 443 | 444 |
| 444 } // namespace extensions | 445 } // namespace extensions |
| 445 | 446 |
| 446 #endif // EXTENSIONS_BROWSER_GUEST_VIEW_GUEST_VIEW_BASE_H_ | 447 #endif // EXTENSIONS_BROWSER_GUEST_VIEW_GUEST_VIEW_BASE_H_ |
| OLD | NEW |