mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Fix opening of popups from sandboxed iframes (issue #2121)
This commit is contained in:
@@ -2244,10 +2244,13 @@ bool CefBrowserHostImpl::CanDragEnter(
|
||||
void CefBrowserHostImpl::GetCustomWebContentsView(
|
||||
content::WebContents* web_contents,
|
||||
const GURL& target_url,
|
||||
int opener_render_process_id,
|
||||
int opener_render_frame_id,
|
||||
content::WebContentsView** view,
|
||||
content::RenderViewHostDelegateView** delegate_view) {
|
||||
CefBrowserInfoManager::GetInstance()->GetCustomWebContentsView(
|
||||
web_contents, target_url, view, delegate_view);
|
||||
target_url, opener_render_process_id, opener_render_frame_id, view,
|
||||
delegate_view);
|
||||
}
|
||||
|
||||
void CefBrowserHostImpl::WebContentsCreated(
|
||||
@@ -2262,8 +2265,8 @@ void CefBrowserHostImpl::WebContentsCreated(
|
||||
std::unique_ptr<CefBrowserPlatformDelegate> platform_delegate;
|
||||
|
||||
CefBrowserInfoManager::GetInstance()->WebContentsCreated(
|
||||
source_contents, target_url, new_contents, settings, client,
|
||||
platform_delegate);
|
||||
target_url, opener_render_process_id, opener_render_frame_id, settings,
|
||||
client, platform_delegate);
|
||||
|
||||
scoped_refptr<CefBrowserInfo> info =
|
||||
CefBrowserInfoManager::GetInstance()->CreatePopupBrowserInfo(
|
||||
|
@@ -405,6 +405,8 @@ class CefBrowserHostImpl : public CefBrowserHost,
|
||||
void GetCustomWebContentsView(
|
||||
content::WebContents* web_contents,
|
||||
const GURL& target_url,
|
||||
int opener_render_process_id,
|
||||
int opener_render_frame_id,
|
||||
content::WebContentsView** view,
|
||||
content::RenderViewHostDelegateView** delegate_view) override;
|
||||
void WebContentsCreated(content::WebContents* source_contents,
|
||||
|
@@ -256,15 +256,14 @@ bool CefBrowserInfoManager::CanCreateWindow(
|
||||
}
|
||||
|
||||
void CefBrowserInfoManager::GetCustomWebContentsView(
|
||||
content::WebContents* web_contents,
|
||||
const GURL& target_url,
|
||||
int opener_render_process_id,
|
||||
int opener_render_frame_id,
|
||||
content::WebContentsView** view,
|
||||
content::RenderViewHostDelegateView** delegate_view) {
|
||||
content::RenderFrameHost* host =
|
||||
web_contents->GetRenderViewHost()->GetMainFrame();
|
||||
std::unique_ptr<CefBrowserInfoManager::PendingPopup> pending_popup =
|
||||
PopPendingPopup(CefBrowserInfoManager::PendingPopup::CAN_CREATE_WINDOW,
|
||||
host->GetProcess()->GetID(), host->GetRoutingID(),
|
||||
opener_render_process_id, opener_render_frame_id,
|
||||
target_url);
|
||||
DCHECK(pending_popup.get());
|
||||
DCHECK(pending_popup->platform_delegate.get());
|
||||
@@ -280,22 +279,16 @@ void CefBrowserInfoManager::GetCustomWebContentsView(
|
||||
}
|
||||
|
||||
void CefBrowserInfoManager::WebContentsCreated(
|
||||
content::WebContents* source_contents,
|
||||
const GURL& target_url,
|
||||
content::WebContents* new_contents,
|
||||
int opener_render_process_id,
|
||||
int opener_render_frame_id,
|
||||
CefBrowserSettings& settings,
|
||||
CefRefPtr<CefClient>& client,
|
||||
std::unique_ptr<CefBrowserPlatformDelegate>& platform_delegate) {
|
||||
DCHECK(source_contents);
|
||||
DCHECK(new_contents);
|
||||
|
||||
content::RenderFrameHost* host =
|
||||
source_contents->GetRenderViewHost()->GetMainFrame();
|
||||
std::unique_ptr<CefBrowserInfoManager::PendingPopup> pending_popup =
|
||||
PopPendingPopup(
|
||||
CefBrowserInfoManager::PendingPopup::GET_CUSTOM_WEB_CONTENTS_VIEW,
|
||||
host->GetProcess()->GetID(), host->GetRoutingID(),
|
||||
target_url);
|
||||
opener_render_process_id, opener_render_frame_id, target_url);
|
||||
DCHECK(pending_popup.get());
|
||||
DCHECK(pending_popup->platform_delegate.get());
|
||||
|
||||
|
@@ -74,17 +74,18 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
|
||||
// Called from CefBrowserHostImpl::GetCustomWebContentsView. See comments on
|
||||
// PendingPopup for more information.
|
||||
void GetCustomWebContentsView(
|
||||
content::WebContents* web_contents,
|
||||
const GURL& target_url,
|
||||
int opener_render_process_id,
|
||||
int opener_render_frame_id,
|
||||
content::WebContentsView** view,
|
||||
content::RenderViewHostDelegateView** delegate_view);
|
||||
|
||||
// Called from CefBrowserHostImpl::WebContentsCreated. See comments on
|
||||
// PendingPopup for more information.
|
||||
void WebContentsCreated(
|
||||
content::WebContents* source_contents,
|
||||
const GURL& target_url,
|
||||
content::WebContents* new_contents,
|
||||
int opener_render_process_id,
|
||||
int opener_render_frame_id,
|
||||
CefBrowserSettings& settings,
|
||||
CefRefPtr<CefClient>& client,
|
||||
std::unique_ptr<CefBrowserPlatformDelegate>& platform_delegate);
|
||||
|
@@ -1,5 +1,5 @@
|
||||
diff --git content/browser/web_contents/web_contents_impl.cc content/browser/web_contents/web_contents_impl.cc
|
||||
index ea0069b..acc6d10 100644
|
||||
index ea0069b..6954229 100644
|
||||
--- content/browser/web_contents/web_contents_impl.cc
|
||||
+++ content/browser/web_contents/web_contents_impl.cc
|
||||
@@ -1563,6 +1563,12 @@ void WebContentsImpl::Init(const WebContents::CreateParams& params) {
|
||||
@@ -23,12 +23,15 @@ index ea0069b..acc6d10 100644
|
||||
|
||||
if (browser_plugin_guest_ && !GuestMode::IsCrossProcessFrameGuest(this)) {
|
||||
view_.reset(new WebContentsViewGuest(this, browser_plugin_guest_.get(),
|
||||
@@ -2078,6 +2085,12 @@ void WebContentsImpl::CreateNewWindow(
|
||||
@@ -2078,6 +2085,15 @@ void WebContentsImpl::CreateNewWindow(
|
||||
create_params.renderer_initiated_creation =
|
||||
main_frame_route_id != MSG_ROUTING_NONE;
|
||||
|
||||
+ if (delegate_) {
|
||||
+ delegate_->GetCustomWebContentsView(this, params.target_url,
|
||||
+ delegate_->GetCustomWebContentsView(this,
|
||||
+ params.target_url,
|
||||
+ render_process_id,
|
||||
+ params.opener_render_frame_id,
|
||||
+ &create_params.view,
|
||||
+ &create_params.delegate_view);
|
||||
+ }
|
||||
@@ -36,7 +39,7 @@ index ea0069b..acc6d10 100644
|
||||
WebContentsImpl* new_contents = NULL;
|
||||
if (!is_guest) {
|
||||
create_params.context = view_->GetNativeView();
|
||||
@@ -2107,7 +2120,7 @@ void WebContentsImpl::CreateNewWindow(
|
||||
@@ -2107,7 +2123,7 @@ void WebContentsImpl::CreateNewWindow(
|
||||
// TODO(brettw): It seems bogus that we have to call this function on the
|
||||
// newly created object and give it one of its own member variables.
|
||||
new_view->CreateViewForWidget(
|
||||
@@ -45,7 +48,7 @@ index ea0069b..acc6d10 100644
|
||||
}
|
||||
// Save the created window associated with the route so we can show it
|
||||
// later.
|
||||
@@ -5003,7 +5016,7 @@ NavigationEntry*
|
||||
@@ -5003,7 +5019,7 @@ NavigationEntry*
|
||||
void WebContentsImpl::CreateRenderWidgetHostViewForRenderManager(
|
||||
RenderViewHost* render_view_host) {
|
||||
RenderWidgetHostViewBase* rwh_view =
|
||||
@@ -97,7 +100,7 @@ index 041c883..34aff7a 100644
|
||||
|
||||
// Creates a new WebContents.
|
||||
diff --git content/public/browser/web_contents_delegate.h content/public/browser/web_contents_delegate.h
|
||||
index 6456878..339f9b8 100644
|
||||
index 6456878..80371ba 100644
|
||||
--- content/public/browser/web_contents_delegate.h
|
||||
+++ content/public/browser/web_contents_delegate.h
|
||||
@@ -42,11 +42,13 @@ class ColorChooser;
|
||||
@@ -114,13 +117,15 @@ index 6456878..339f9b8 100644
|
||||
struct ColorSuggestion;
|
||||
struct ContextMenuParams;
|
||||
struct DropData;
|
||||
@@ -325,6 +327,12 @@ class CONTENT_EXPORT WebContentsDelegate {
|
||||
@@ -325,6 +327,14 @@ class CONTENT_EXPORT WebContentsDelegate {
|
||||
const std::string& partition_id,
|
||||
SessionStorageNamespace* session_storage_namespace);
|
||||
|
||||
+ virtual void GetCustomWebContentsView(
|
||||
+ WebContents* web_contents,
|
||||
+ const GURL& target_url,
|
||||
+ int opener_render_process_id,
|
||||
+ int opener_render_frame_id,
|
||||
+ content::WebContentsView** view,
|
||||
+ content::RenderViewHostDelegateView** delegate_view) {}
|
||||
+
|
||||
|
Reference in New Issue
Block a user