diff --git a/BUILD.gn b/BUILD.gn index f9e014aea..f3427ae4c 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -479,6 +479,8 @@ source_set("libcef_static") { "libcef/browser/browser_context.h", "libcef/browser/browser_frame.cc", "libcef/browser/browser_frame.h", + "libcef/browser/browser_guest_util.cc", + "libcef/browser/browser_guest_util.h", "libcef/browser/browser_host_base.cc", "libcef/browser/browser_host_base.h", "libcef/browser/browser_host_create.cc", @@ -554,8 +556,6 @@ source_set("libcef_static") { "libcef/browser/download_manager_delegate.h", "libcef/browser/download_manager_delegate_impl.cc", "libcef/browser/download_manager_delegate_impl.h", - "libcef/browser/extensions/browser_extensions_util.cc", - "libcef/browser/extensions/browser_extensions_util.h", "libcef/browser/file_dialog_manager.cc", "libcef/browser/file_dialog_manager.h", "libcef/browser/file_dialog_runner.cc", diff --git a/libcef/browser/alloy/alloy_browser_host_impl.cc b/libcef/browser/alloy/alloy_browser_host_impl.cc index 8411b1d9a..4284730c3 100644 --- a/libcef/browser/alloy/alloy_browser_host_impl.cc +++ b/libcef/browser/alloy/alloy_browser_host_impl.cc @@ -15,11 +15,11 @@ #include "cef/libcef/browser/alloy/browser_platform_delegate_alloy.h" #include "cef/libcef/browser/audio_capturer.h" #include "cef/libcef/browser/browser_context.h" +#include "cef/libcef/browser/browser_guest_util.h" #include "cef/libcef/browser/browser_info.h" #include "cef/libcef/browser/browser_info_manager.h" #include "cef/libcef/browser/browser_platform_delegate.h" #include "cef/libcef/browser/context.h" -#include "cef/libcef/browser/extensions/browser_extensions_util.h" #include "cef/libcef/browser/hang_monitor.h" #include "cef/libcef/browser/media_access_query.h" #include "cef/libcef/browser/osr/osr_util.h" @@ -559,8 +559,8 @@ void AlloyBrowserHostImpl::CancelContextMenu() { bool AlloyBrowserHostImpl::MaybeAllowNavigation( content::RenderFrameHost* opener, const content::OpenURLParams& params) { - const bool is_guest_view = extensions::IsBrowserPluginGuest( - content::WebContents::FromRenderFrameHost(opener)); + const bool is_guest_view = + IsBrowserPluginGuest(content::WebContents::FromRenderFrameHost(opener)); if (is_guest_view && !params.is_pdf && !params.url.SchemeIs(extensions::kExtensionScheme) && !params.url.SchemeIs(content::kChromeUIScheme)) { diff --git a/libcef/browser/extensions/browser_extensions_util.cc b/libcef/browser/browser_guest_util.cc similarity index 94% rename from libcef/browser/extensions/browser_extensions_util.cc rename to libcef/browser/browser_guest_util.cc index 602583b0a..3cde4fb6a 100644 --- a/libcef/browser/extensions/browser_extensions_util.cc +++ b/libcef/browser/browser_guest_util.cc @@ -2,15 +2,13 @@ // reserved. Use of this source code is governed by a BSD-style license that // can be found in the LICENSE file. -#include "cef/libcef/browser/extensions/browser_extensions_util.h" +#include "cef/libcef/browser/browser_guest_util.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/printing/print_preview_dialog_controller.h" #include "content/browser/browser_plugin/browser_plugin_guest.h" #include "content/browser/web_contents/web_contents_impl.h" -namespace extensions { - namespace { content::WebContents* GetOwnerForBrowserPluginGuest( @@ -62,5 +60,3 @@ bool IsBrowserPluginGuest(const content::WebContents* web_contents) { bool IsPrintPreviewDialog(const content::WebContents* web_contents) { return !!GetInitiatorForPrintPreviewDialog(web_contents); } - -} // namespace extensions diff --git a/libcef/browser/extensions/browser_extensions_util.h b/libcef/browser/browser_guest_util.h similarity index 70% rename from libcef/browser/extensions/browser_extensions_util.h rename to libcef/browser/browser_guest_util.h index 693766d48..6bd021884 100644 --- a/libcef/browser/extensions/browser_extensions_util.h +++ b/libcef/browser/browser_guest_util.h @@ -2,15 +2,13 @@ // reserved. Use of this source code is governed by a BSD-style license that // can be found in the LICENSE file. -#ifndef CEF_LIBCEF_BROWSER_EXTENSIONS_BROWSER_EXTENSIONS_UTIL_H_ -#define CEF_LIBCEF_BROWSER_EXTENSIONS_BROWSER_EXTENSIONS_UTIL_H_ +#ifndef CEF_LIBCEF_BROWSER_BROWSER_GUEST_UTIL_H_ +#define CEF_LIBCEF_BROWSER_BROWSER_GUEST_UTIL_H_ namespace content { class WebContents; } // namespace content -namespace extensions { - // Returns the WebContents that owns the specified |guest|, if any. content::WebContents* GetOwnerForGuestContents( const content::WebContents* guest); @@ -19,6 +17,4 @@ content::WebContents* GetOwnerForGuestContents( bool IsBrowserPluginGuest(const content::WebContents* web_contents); bool IsPrintPreviewDialog(const content::WebContents* web_contents); -} // namespace extensions - -#endif // CEF_LIBCEF_BROWSER_EXTENSIONS_BROWSER_EXTENSIONS_UTIL_H_ +#endif // CEF_LIBCEF_BROWSER_BROWSER_GUEST_UTIL_H_ diff --git a/libcef/browser/browser_host_base.cc b/libcef/browser/browser_host_base.cc index e6b44ac18..5f6680697 100644 --- a/libcef/browser/browser_host_base.cc +++ b/libcef/browser/browser_host_base.cc @@ -7,10 +7,10 @@ #include #include "base/logging.h" +#include "cef/libcef/browser/browser_guest_util.h" #include "cef/libcef/browser/browser_info_manager.h" #include "cef/libcef/browser/browser_platform_delegate.h" #include "cef/libcef/browser/context.h" -#include "cef/libcef/browser/extensions/browser_extensions_util.h" #include "cef/libcef/browser/hang_monitor.h" #include "cef/libcef/browser/image_impl.h" #include "cef/libcef/browser/navigation_entry_impl.h" @@ -128,7 +128,7 @@ CefRefPtr CefBrowserHostBase::GetBrowserForContents( // Try the owner WebContents if |contents| originates from an excluded view // such as the PDF viewer or Print Preview. This is safe to call even if Alloy // extensions are disabled. - if (auto* owner_contents = extensions::GetOwnerForGuestContents(contents)) { + if (auto* owner_contents = GetOwnerForGuestContents(contents)) { return WebContentsUserDataAdapter::Get(owner_contents); } diff --git a/libcef/browser/browser_info_manager.cc b/libcef/browser/browser_info_manager.cc index 7d63fdfdd..cf26dc9c6 100644 --- a/libcef/browser/browser_info_manager.cc +++ b/libcef/browser/browser_info_manager.cc @@ -9,9 +9,9 @@ #include "base/command_line.h" #include "base/logging.h" #include "base/task/sequenced_task_runner.h" +#include "cef/libcef/browser/browser_guest_util.h" #include "cef/libcef/browser/browser_host_base.h" #include "cef/libcef/browser/browser_platform_delegate.h" -#include "cef/libcef/browser/extensions/browser_extensions_util.h" #include "cef/libcef/browser/thread_util.h" #include "cef/libcef/common/cef_switches.h" #include "cef/libcef/common/frame_util.h" @@ -492,10 +492,8 @@ CefRefPtr CefBrowserInfoManager::GetFrameHost( const bool is_pdf_process = rfh->GetProcess()->IsPdf(); auto* web_contents = content::WebContents::FromRenderFrameHost(rfh); - const bool is_browser_process_guest = - extensions::IsBrowserPluginGuest(web_contents); - const bool is_print_preview_dialog = - extensions::IsPrintPreviewDialog(web_contents); + const bool is_browser_process_guest = IsBrowserPluginGuest(web_contents); + const bool is_print_preview_dialog = IsPrintPreviewDialog(web_contents); bool excluded = is_pdf_process || is_browser_process_guest || is_print_preview_dialog; @@ -504,7 +502,7 @@ CefRefPtr CefBrowserInfoManager::GetFrameHost( // A BrowserHost may match an excluded RFH type. Some associations are // registered directly via CefBrowserInfo::MaybeCreateFrame and some are - // discovered indirectly via extensions::GetOwnerForGuestContents. + // discovered indirectly via GetOwnerForGuestContents. auto browser = CefBrowserHostBase::GetBrowserForHost(rfh); if (browser && !excluded) { frame = browser->browser_info()->GetFrameForHost(rfh, prefer_speculative); @@ -544,13 +542,11 @@ bool CefBrowserInfoManager::IsExcludedFrameHost(content::RenderFrameHost* rfh) { } auto* web_contents = content::WebContents::FromRenderFrameHost(rfh); - const bool is_browser_process_guest = - extensions::IsBrowserPluginGuest(web_contents); + const bool is_browser_process_guest = IsBrowserPluginGuest(web_contents); if (is_browser_process_guest) { return true; } - const bool is_print_preview_dialog = - extensions::IsPrintPreviewDialog(web_contents); + const bool is_print_preview_dialog = IsPrintPreviewDialog(web_contents); if (is_print_preview_dialog) { return true; } @@ -777,8 +773,8 @@ void CefBrowserInfoManager::TimeoutNewBrowserInfoResponse( // - When the PDF renderer is loaded in the print preview dialog. There will // be no RFH in this case. // Any additional cases should be debugged and, if possible, - // extensions::GetOwnerForGuestContents should be improved to find the - // associated CefBrowserHost. + // GetOwnerForGuestContents should be improved to find the associated + // CefBrowserHost. const bool has_rfh = !!content::RenderFrameHost::FromFrameToken(global_token); diff --git a/libcef/browser/javascript_dialog_manager.cc b/libcef/browser/javascript_dialog_manager.cc index afe6b822f..a223f6668 100644 --- a/libcef/browser/javascript_dialog_manager.cc +++ b/libcef/browser/javascript_dialog_manager.cc @@ -10,8 +10,8 @@ #include "base/functional/bind.h" #include "base/functional/callback_helpers.h" #include "base/logging.h" +#include "cef/libcef/browser/browser_guest_util.h" #include "cef/libcef/browser/browser_host_base.h" -#include "cef/libcef/browser/extensions/browser_extensions_util.h" #include "cef/libcef/browser/thread_util.h" #include "components/javascript_dialogs/tab_modal_dialog_manager.h" @@ -71,8 +71,7 @@ javascript_dialogs::TabModalDialogManager* GetTabModalDialogManager( // Try the owner WebContents if the dialog originates from an excluded view // such as the PDF viewer or Print Preview. This is safe to call even if Alloy // extensions are disabled. - if (auto* owner_contents = - extensions::GetOwnerForGuestContents(web_contents)) { + if (auto* owner_contents = GetOwnerForGuestContents(web_contents)) { return javascript_dialogs::TabModalDialogManager::FromWebContents( owner_contents); }