Chromium Code Reviews| Index: chrome/browser/guest_view/guest_view_base.h |
| diff --git a/chrome/browser/guest_view/guest_view_base.h b/chrome/browser/guest_view/guest_view_base.h |
| index 0987b7a5279e28edb6d5579e8309de1504a5ff66..891ed094497b0b9eda4bf7c8e0caeb4eb524baa2 100644 |
| --- a/chrome/browser/guest_view/guest_view_base.h |
| +++ b/chrome/browser/guest_view/guest_view_base.h |
| @@ -10,6 +10,7 @@ |
| #include "base/memory/weak_ptr.h" |
| #include "base/values.h" |
| #include "content/public/browser/browser_plugin_guest_delegate.h" |
| +#include "content/public/browser/render_process_host_observer.h" |
| #include "content/public/browser/web_contents.h" |
| #include "content/public/browser/web_contents_delegate.h" |
| #include "content/public/browser/web_contents_observer.h" |
| @@ -21,6 +22,7 @@ struct RendererContentSettingRules; |
| // WebContents and an embedder WebContents. It receives events issued from |
| // the guest and relays them to the embedder. |
| class GuestViewBase : public content::BrowserPluginGuestDelegate, |
| + public content::RenderProcessHostObserver, |
| public content::WebContentsDelegate, |
| public content::WebContentsObserver { |
| public: |
| @@ -48,8 +50,6 @@ class GuestViewBase : public content::BrowserPluginGuestDelegate, |
| } |
| static GuestViewBase* Create(int guest_instance_id, |
| - content::WebContents* guest_web_contents, |
| - const std::string& embedder_extension_id, |
| const std::string& view_type); |
| static GuestViewBase* FromWebContents(content::WebContents* web_contents); |
| @@ -74,12 +74,6 @@ class GuestViewBase : public content::BrowserPluginGuestDelegate, |
| // the initial set of frames within the page have completed loading. |
| virtual void DidStopLoading() {} |
| - // This method is called when the guest WebContents is about to be destroyed. |
| - // |
| - // This method can be overridden by subclasses. This gives the derived class |
| - // an opportunity to perform some cleanup prior to destruction. |
| - virtual void WillDestroy() {} |
| - |
| // This method is called when the guest's embedder WebContents has been |
| // destroyed and the guest will be destroyed shortly. |
| // |
| @@ -91,18 +85,46 @@ class GuestViewBase : public content::BrowserPluginGuestDelegate, |
| // object will be destroyed after this call returns. |
| // |
| // This method can be overridden by subclasses. This gives the derived class |
| - // opportunity to perform some cleanup. |
| + // an opportunity to perform some cleanup. |
| virtual void GuestDestroyed() {} |
| + // This method is called after this GuestViewBase has been initiated. |
| + // |
| + // This method can be overriden by subclasses. This gives the derived class |
|
lazyboy
2014/06/17 23:46:45
"This method can be overriden by subclasses." -> I
Fady Samuel
2014/06/18 21:08:33
Done.
|
| + // an opportunity to perform additional initialization. |
| + virtual void Init() {} |
| + |
| // This method queries whether drag-and-drop is enabled for this particular |
| // view. By default, drag-and-drop is disabled. Derived classes can override |
| // this behavior to enable drag-and-drop. |
| virtual bool IsDragAndDropEnabled() const; |
| - // Once a guest WebContents is ready, this initiates the association of |this| |
| - // GuestView with |guest_web_contents|. |
| - void Init(content::WebContents* guest_web_contents, |
| - const std::string& embedder_extension_id); |
| + // This method is called when the guest WebContents is about to be destroyed. |
| + // |
| + // This method can be overridden by subclasses. This gives the derived class |
| + // an opportunity to perform some cleanup prior to destruction. |
| + virtual void WillDestroy() {} |
| + |
| + // This method is to be implemented by the derived class. Given a set of |
| + // initialization parameters, a concrete subclass of GuestViewBase can |
| + // create a specialized WebContents that it returns back to GuestViewBase. |
| + typedef base::Callback<void(content::WebContents*)> WebContentsCallback; |
|
lazyboy
2014/06/17 23:46:45
WebContentsCreatedCallback
Fady Samuel
2014/06/18 21:08:33
Done.
|
| + virtual void CreateWebContents( |
| + const std::string& embedder_extension_id, |
| + content::RenderProcessHost* embedder_render_process_host, |
| + const base::DictionaryValue& create_params, |
| + const WebContentsCallback& callback) = 0; |
| + |
| + // This creates a WebContents and initializes |this| GuestViewBase to use the |
| + // newly created WebContents. |
| + void Init(const std::string& embedder_extension_id, |
|
lazyboy
2014/06/17 23:46:45
I found this function very confusing with the virt
Fady Samuel
2014/06/18 21:08:33
This pattern is used elsewhere: See DidStopLoading
lazyboy
2014/06/19 16:17:31
Since the parameterless Init() is called after ini
Fady Samuel
2014/06/20 15:16:35
Good idea! Done!
|
| + content::RenderProcessHost* embedder_render_process_host, |
| + const base::DictionaryValue& create_params); |
| + |
| + void InitWithWebContents( |
| + const std::string& embedder_extension_id, |
| + content::RenderProcessHost* embedder_render_process_host, |
| + content::WebContents* guest_web_contents); |
| bool IsViewType(const char* const view_type) const { |
| return !strcmp(GetViewType(), view_type); |
| @@ -110,6 +132,8 @@ class GuestViewBase : public content::BrowserPluginGuestDelegate, |
| base::WeakPtr<GuestViewBase> AsWeakPtr(); |
| + bool initialized() const { return initialized_; } |
| + |
| content::WebContents* embedder_web_contents() const { |
| return embedder_web_contents_; |
| } |
| @@ -154,11 +178,18 @@ class GuestViewBase : public content::BrowserPluginGuestDelegate, |
| void SetOpener(GuestViewBase* opener); |
| + // RenderProcessHostObserver implementation |
| + virtual void RenderProcessExited(content::RenderProcessHost* host, |
| + base::ProcessHandle handle, |
| + base::TerminationStatus status, |
| + int exit_code) OVERRIDE; |
| + |
| // BrowserPluginGuestDelegate implementation. |
| virtual void Destroy() OVERRIDE FINAL; |
| virtual void DidAttach( |
| content::WebContents* embedder_web_contents, |
| const base::DictionaryValue& extra_params) OVERRIDE FINAL; |
| + virtual int GetGuestInstanceID() const OVERRIDE; |
| virtual void RegisterDestructionCallback( |
| const DestructionCallback& callback) OVERRIDE FINAL; |