Index: chrome/browser/guest_view/guest_view_base.cc |
diff --git a/chrome/browser/guest_view/guest_view_base.cc b/chrome/browser/guest_view/guest_view_base.cc |
index 288760855b5e064f67b123216310f84d2ddbbd15..574730522f5ef44db091f2eee10946697244598d 100644 |
--- a/chrome/browser/guest_view/guest_view_base.cc |
+++ b/chrome/browser/guest_view/guest_view_base.cc |
@@ -39,17 +39,16 @@ scoped_ptr<base::DictionaryValue> GuestViewBase::Event::GetArguments() { |
return args_.Pass(); |
} |
-GuestViewBase::GuestViewBase(WebContents* guest_web_contents, |
- const std::string& embedder_extension_id, |
- const base::WeakPtr<GuestViewBase>& opener) |
+GuestViewBase::GuestViewBase(int guest_instance_id, |
+ WebContents* guest_web_contents, |
+ const std::string& embedder_extension_id) |
: guest_web_contents_(guest_web_contents), |
embedder_web_contents_(NULL), |
embedder_extension_id_(embedder_extension_id), |
embedder_render_process_id_(0), |
browser_context_(guest_web_contents->GetBrowserContext()), |
- guest_instance_id_(guest_web_contents->GetEmbeddedInstanceID()), |
+ guest_instance_id_(guest_instance_id), |
view_instance_id_(guestview::kInstanceIDNone), |
- opener_(opener), |
weak_ptr_factory_(this) { |
webcontents_guestview_map.Get().insert( |
std::make_pair(guest_web_contents, this)); |
@@ -59,14 +58,18 @@ GuestViewBase::GuestViewBase(WebContents* guest_web_contents, |
// static |
GuestViewBase* GuestViewBase::Create( |
+ int guest_instance_id, |
WebContents* guest_web_contents, |
const std::string& embedder_extension_id, |
- const std::string& view_type, |
- const base::WeakPtr<GuestViewBase>& opener) { |
+ const std::string& view_type) { |
if (view_type == "webview") { |
- return new WebViewGuest(guest_web_contents, embedder_extension_id, opener); |
+ return new WebViewGuest(guest_instance_id, |
+ guest_web_contents, |
+ embedder_extension_id); |
} else if (view_type == "adview") { |
- return new AdViewGuest(guest_web_contents, embedder_extension_id); |
+ return new AdViewGuest(guest_instance_id, |
+ guest_web_contents, |
+ embedder_extension_id); |
} |
NOTREACHED(); |
return NULL; |
@@ -148,8 +151,7 @@ void GuestViewBase::Attach(content::WebContents* embedder_web_contents, |
embedder_render_process_id_ = |
embedder_web_contents->GetRenderProcessHost()->GetID(); |
args.GetInteger(guestview::kParameterInstanceId, &view_instance_id_); |
- |
- std::pair<int, int> key(embedder_render_process_id_, guest_instance_id_); |
+ extra_params_.reset(args.DeepCopy()); |
// GuestViewBase::Attach is called prior to initialization (and initial |
// navigation) of the guest in the content layer in order to permit mapping |
@@ -167,14 +169,14 @@ void GuestViewBase::Attach(content::WebContents* embedder_web_contents, |
weak_ptr_factory_.GetWeakPtr())); |
} |
-WebContents* GuestViewBase::GetOpener() const { |
- if (!opener_) |
- return NULL; |
- return opener_->guest_web_contents(); |
+void GuestViewBase::Destroy() { |
+ if (!destruction_callback_.is_null()) |
+ destruction_callback_.Run(guest_web_contents()); |
+ delete guest_web_contents(); |
} |
-void GuestViewBase::SetOpener(WebContents* web_contents) { |
- GuestViewBase* guest = FromWebContents(web_contents); |
+ |
+void GuestViewBase::SetOpener(GuestViewBase* guest) { |
if (guest && guest->IsViewType(GetViewType())) { |
opener_ = guest->AsWeakPtr(); |
return; |
@@ -182,6 +184,11 @@ void GuestViewBase::SetOpener(WebContents* web_contents) { |
opener_ = base::WeakPtr<GuestViewBase>(); |
} |
+void GuestViewBase::RegisterDestructionCallback( |
+ const DestructionCallback& callback) { |
+ destruction_callback_ = callback; |
+} |
+ |
GuestViewBase::~GuestViewBase() { |
std::pair<int, int> key(embedder_render_process_id_, guest_instance_id_); |
@@ -226,7 +233,6 @@ void GuestViewBase::DispatchEvent(Event* event) { |
void GuestViewBase::SendQueuedEvents() { |
if (!attached()) |
return; |
- |
while (!pending_events_.empty()) { |
linked_ptr<Event> event_ptr = pending_events_.front(); |
pending_events_.pop_front(); |