diff --git a/atom/browser/api/atom_api_web_contents.cc b/atom/browser/api/atom_api_web_contents.cc index 0bab6a2e30..c1f047a239 100644 --- a/atom/browser/api/atom_api_web_contents.cc +++ b/atom/browser/api/atom_api_web_contents.cc @@ -426,10 +426,14 @@ void WebContents::AddNewContents(content::WebContents* source, } bool WebContents::ShouldResumeRequestsForCreatedWindow() { + return false; +} + +bool WebContents::IsAttached() { if (guest_delegate_) - return guest_delegate_->ShouldResumeRequestsForCreatedWindow(); + return guest_delegate_->IsAttached(); - return true; + return owner_window() != nullptr; } content::WebContents* WebContents::OpenURLFromTab( @@ -451,11 +455,12 @@ content::WebContents* WebContents::OpenURLFromTab( return nullptr; auto api_web_contents = CreateFrom(isolate(), source); - if (api_web_contents->ShouldResumeRequestsForCreatedWindow()) { + if (api_web_contents->IsAttached()) { CommonWebContentsDelegate::OpenURLFromTab(source, params); } else { api_web_contents->delayed_open_url_params_.reset( new content::OpenURLParams(params)); + return nullptr; } return source; diff --git a/atom/browser/api/atom_api_web_contents.h b/atom/browser/api/atom_api_web_contents.h index 21d191b9f5..39c008f95a 100644 --- a/atom/browser/api/atom_api_web_contents.h +++ b/atom/browser/api/atom_api_web_contents.h @@ -219,6 +219,7 @@ class WebContents : public mate::TrackableObject, bool user_gesture, bool* was_blocked) override; bool ShouldResumeRequestsForCreatedWindow() override; + bool IsAttached(); content::WebContents* OpenURLFromTab( content::WebContents* source, const content::OpenURLParams& params) override; diff --git a/atom/browser/web_view_guest_delegate.cc b/atom/browser/web_view_guest_delegate.cc index 580c0e0d01..35b1e63794 100644 --- a/atom/browser/web_view_guest_delegate.cc +++ b/atom/browser/web_view_guest_delegate.cc @@ -175,7 +175,7 @@ void WebViewGuestDelegate::DidCommitProvisionalLoadForFrame( api_web_contents_->Emit("load-commit", url, !render_frame_host->GetParent()); } -bool WebViewGuestDelegate::ShouldResumeRequestsForCreatedWindow() { +bool WebViewGuestDelegate::IsAttached() { return guest_proxy_routing_id_ != -1; } @@ -200,6 +200,10 @@ void WebViewGuestDelegate::SetGuestHost(content::GuestHost* guest_host) { guest_host_ = guest_host; } +void WebViewGuestDelegate::DidDetach() { + guest_proxy_routing_id_ = -1; +} + void WebViewGuestDelegate::WillAttach( content::WebContents* embedder_web_contents, int element_instance_id, diff --git a/atom/browser/web_view_guest_delegate.h b/atom/browser/web_view_guest_delegate.h index b921e0ec48..eea23c9047 100644 --- a/atom/browser/web_view_guest_delegate.h +++ b/atom/browser/web_view_guest_delegate.h @@ -53,7 +53,7 @@ class WebViewGuestDelegate : public content::BrowserPluginGuestDelegate, // This value is only valid after attachment or first navigation. int proxy_routing_id() const { return guest_proxy_routing_id_; } - bool ShouldResumeRequestsForCreatedWindow(); + bool IsAttached(); protected: // content::WebContentsObserver: @@ -68,6 +68,7 @@ class WebViewGuestDelegate : public content::BrowserPluginGuestDelegate, // content::BrowserPluginGuestDelegate: void DidAttach(int guest_proxy_routing_id) final; + void DidDetach() final; content::WebContents* GetOwnerWebContents() const final; void GuestSizeChanged(const gfx::Size& new_size) final; void SetGuestHost(content::GuestHost* guest_host) final;