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

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

Issue 272573005: <webview>: Move NewWindow API to chrome (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@guestview_manager_rename
Patch Set: Merge with ToT Created 6 years, 7 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
« no previous file with comments | « chrome/browser/guest_view/guest_view_base.h ('k') | chrome/browser/guest_view/guest_view_manager.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
« no previous file with comments | « chrome/browser/guest_view/guest_view_base.h ('k') | chrome/browser/guest_view/guest_view_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698