Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5859)

Unified Diff: chrome/browser/guest_view/guest_view_base.h

Issue 336283002: Remove GuestWebContentsCreated (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@simplify_creation
Patch Set: Merge with ToT Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 1dff75cad3d1dcc8ad74390f0e280fdaf33a9643..8bd4671777c9536fe2deebbad37ab3eeb9c6e2f8 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"
@@ -19,8 +20,12 @@ struct RendererContentSettingRules;
// A GuestViewBase is the base class browser-side API implementation for a
// <*view> tag. GuestViewBase maintains an association between a guest
// WebContents and an embedder WebContents. It receives events issued from
-// the guest and relays them to the embedder.
+// the guest and relays them to the embedder. GuestViewBase tracks the lifetime
+// of its embedder render process until it is attached to a particular embedder
+// WebContents. At that point, its lifetime is restricted in scope to the
+// lifetime of its embedder WebContents.
class GuestViewBase : public content::BrowserPluginGuestDelegate,
+ public content::RenderProcessHostObserver,
public content::WebContentsDelegate,
public content::WebContentsObserver {
public:
@@ -48,8 +53,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);
@@ -71,35 +74,27 @@ class GuestViewBase : public content::BrowserPluginGuestDelegate,
// an opportunity to perform setup actions after attachment.
virtual void DidAttachToEmbedder() {}
- // This method can be overridden by subclasses. This method is called when
- // the initial set of frames within the page have completed loading.
- virtual void DidStopLoading() {}
-
- // This method is called immediately before suspended resource loads have been
- // resumed on attachment to an embedder.
+ // This method is called after this GuestViewBase has been initiated.
//
- // This method can be overriden by subclasses. This gives the derived class
- // an opportunity to perform setup actions before attachment.
- virtual void WillAttachToEmbedder() {}
+ // This gives the derived class an opportunity to perform additional
+ // initialization.
+ virtual void DidInitialize() {}
- // 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 initial set of frames within the page have
+ // completed loading.
+ virtual void DidStopLoading() {}
// This method is called when the guest's embedder WebContents has been
// destroyed and the guest will be destroyed shortly.
//
- // This method can be overridden by subclasses. This gives the derived class
- // an opportunity to perform some cleanup prior to destruction.
+ // This gives the derived class an opportunity to perform some cleanup prior
+ // to destruction.
virtual void EmbedderDestroyed() {}
// This method is called when the guest WebContents has been destroyed. This
// 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.
+ // This gives the derived class an opportunity to perform some cleanup.
virtual void GuestDestroyed() {}
// This method queries whether drag-and-drop is enabled for this particular
@@ -107,10 +102,40 @@ class GuestViewBase : public content::BrowserPluginGuestDelegate,
// 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 immediately before suspended resource loads have been
+ // resumed on attachment to an embedder.
+ //
+ // This method can be overriden by subclasses. This gives the derived class
+ // an opportunity to perform setup actions before attachment.
+ virtual void WillAttachToEmbedder() {}
+
+ // This method is called when the guest WebContents is about to be destroyed.
+ //
+ // 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*)>
+ WebContentsCreatedCallback;
+ virtual void CreateWebContents(
+ const std::string& embedder_extension_id,
+ int embedder_render_process_id,
+ const base::DictionaryValue& create_params,
+ const WebContentsCreatedCallback& callback) = 0;
+
+ // This creates a WebContents and initializes |this| GuestViewBase to use the
+ // newly created WebContents.
+ void Init(const std::string& embedder_extension_id,
+ int embedder_render_process_id,
+ const base::DictionaryValue& create_params);
+
+ void InitWithWebContents(
+ const std::string& embedder_extension_id,
+ int embedder_render_process_id,
+ content::WebContents* guest_web_contents);
bool IsViewType(const char* const view_type) const {
return !strcmp(GetViewType(), view_type);
@@ -118,6 +143,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_;
}
@@ -139,9 +166,6 @@ class GuestViewBase : public content::BrowserPluginGuestDelegate,
// Returns the instance ID of the <*view> element.
int view_instance_id() const { return view_instance_id_; }
- // Returns the instance ID of the guest WebContents.
- int guest_instance_id() const { return guest_instance_id_; }
-
// Returns the extension ID of the embedder.
const std::string& embedder_extension_id() const {
return embedder_extension_id_;
@@ -162,9 +186,16 @@ 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() OVERRIDE FINAL;
+ virtual int GetGuestInstanceID() const OVERRIDE;
virtual void RegisterDestructionCallback(
const DestructionCallback& callback) OVERRIDE FINAL;
virtual void WillAttach(
« no previous file with comments | « chrome/browser/extensions/api/guest_view/guest_view_internal_api.cc ('k') | chrome/browser/guest_view/guest_view_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698