From f1b212c54b1cc35ce99c3d642c86ab41c19e2f03 Mon Sep 17 00:00:00 2001 From: Andy Locascio Date: Wed, 18 Mar 2020 16:12:43 -0700 Subject: [PATCH] update to use new webcontents delegate methods --- .../browser/api/electron_api_web_contents.cc | 25 +++++++++++-------- shell/browser/api/electron_api_web_contents.h | 14 ++++++----- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/shell/browser/api/electron_api_web_contents.cc b/shell/browser/api/electron_api_web_contents.cc index 32272aab2dd27..d2fde8c08ae2e 100644 --- a/shell/browser/api/electron_api_web_contents.cc +++ b/shell/browser/api/electron_api_web_contents.cc @@ -648,23 +648,28 @@ void WebContents::WebContentsCreated(content::WebContents* source_contents, tracker->frame_name = frame_name; } -bool WebContents::ShouldCreateWebContents( - content::WebContents* web_contents, - content::RenderFrameHost* opener, +bool WebContents::IsWebContentsCreationOverridden( content::SiteInstance* source_site_instance, - int32_t route_id, - int32_t main_frame_route_id, - int32_t main_frame_widget_route_id, content::mojom::WindowContainerType window_container_type, const GURL& opener_url, const std::string& frame_name, + const GURL& target_url) { + if (Emit("-will-add-new-contents", target_url, frame_name)) { + return true; + } + return false; +} + +content::WebContents* WebContents::CreateCustomWebContents( + content::RenderFrameHost* opener, + content::SiteInstance* source_site_instance, + bool is_new_browsing_instance, + const GURL& opener_url, + const std::string& frame_name, const GURL& target_url, const std::string& partition_id, content::SessionStorageNamespace* session_storage_namespace) { - if (Emit("-will-add-new-contents", target_url, frame_name)) { - return false; - } - return true; + return nullptr; } void WebContents::AddNewContents( diff --git a/shell/browser/api/electron_api_web_contents.h b/shell/browser/api/electron_api_web_contents.h index 9b3bd7d962c37..17cf91196e503 100644 --- a/shell/browser/api/electron_api_web_contents.h +++ b/shell/browser/api/electron_api_web_contents.h @@ -364,16 +364,18 @@ class WebContents : public mate::TrackableObject, const base::string16& message, int32_t line_no, const base::string16& source_id) override; - bool ShouldCreateWebContents( - content::WebContents* web_contents, - content::RenderFrameHost* opener, + bool IsWebContentsCreationOverridden( content::SiteInstance* source_site_instance, - int32_t route_id, - int32_t main_frame_route_id, - int32_t main_frame_widget_route_id, content::mojom::WindowContainerType window_container_type, const GURL& opener_url, const std::string& frame_name, + const GURL& target_url) override; + content::WebContents* CreateCustomWebContents( + content::RenderFrameHost* opener, + content::SiteInstance* source_site_instance, + bool is_new_browsing_instance, + const GURL& opener_url, + const std::string& frame_name, const GURL& target_url, const std::string& partition_id, content::SessionStorageNamespace* session_storage_namespace) override;