diff --git a/BUILD.gn b/BUILD.gn index e95b745e0..bf8edc9f7 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -514,8 +514,6 @@ source_set("libcef_static") { "libcef/browser/chrome/chrome_content_browser_client_cef.h", "libcef/browser/chrome/chrome_context_menu_handler.cc", "libcef/browser/chrome/chrome_context_menu_handler.h", - "libcef/browser/chrome/chrome_devtools_window_runner.cc", - "libcef/browser/chrome/chrome_devtools_window_runner.h", "libcef/browser/chrome/chrome_startup_browser_creator.cc", "libcef/browser/chrome/chrome_startup_browser_creator.h", "libcef/browser/chrome/chrome_web_contents_view_delegate_cef.h", @@ -548,8 +546,8 @@ source_set("libcef_static") { "libcef/browser/devtools/devtools_controller.h", "libcef/browser/devtools/devtools_protocol_manager.cc", "libcef/browser/devtools/devtools_protocol_manager.h", + "libcef/browser/devtools/devtools_window_runner.cc", "libcef/browser/devtools/devtools_window_runner.h", - "libcef/browser/devtools/devtools_window_runner_create.cc", "libcef/browser/download_item_impl.cc", "libcef/browser/download_item_impl.h", "libcef/browser/download_manager_delegate.cc", diff --git a/libcef/browser/browser_host_base.cc b/libcef/browser/browser_host_base.cc index 5f6680697..e49444d1b 100644 --- a/libcef/browser/browser_host_base.cc +++ b/libcef/browser/browser_host_base.cc @@ -1360,7 +1360,7 @@ CefMediaStreamRegistrar* CefBrowserHostBase::GetMediaStreamRegistrar() { CefDevToolsWindowRunner* CefBrowserHostBase::GetDevToolsWindowRunner() { if (!devtools_window_runner_) { - devtools_window_runner_ = CefDevToolsWindowRunner::Create(); + devtools_window_runner_ = std::make_unique(); } return devtools_window_runner_.get(); } diff --git a/libcef/browser/chrome/chrome_browser_delegate.cc b/libcef/browser/chrome/chrome_browser_delegate.cc index c934cd1eb..7a0f17dd0 100644 --- a/libcef/browser/chrome/chrome_browser_delegate.cc +++ b/libcef/browser/chrome/chrome_browser_delegate.cc @@ -12,9 +12,9 @@ #include "cef/libcef/browser/browser_platform_delegate.h" #include "cef/libcef/browser/chrome/chrome_browser_context.h" #include "cef/libcef/browser/chrome/chrome_browser_host_impl.h" -#include "cef/libcef/browser/chrome/chrome_devtools_window_runner.h" #include "cef/libcef/browser/chrome/views/chrome_browser_view.h" #include "cef/libcef/browser/chrome/views/chrome_child_window.h" +#include "cef/libcef/browser/devtools/devtools_window_runner.h" #include "cef/libcef/browser/hang_monitor.h" #include "cef/libcef/browser/media_access_query.h" #include "cef/libcef/browser/request_context_impl.h" @@ -98,8 +98,7 @@ Browser* ChromeBrowserDelegate::CreateDevToolsBrowser( CefBrowserCreateParams create_params; CefWindowInfo window_info; - auto* devtools_window_runner = static_cast( - opener_browser_host->GetDevToolsWindowRunner()); + auto* devtools_window_runner = opener_browser_host->GetDevToolsWindowRunner(); auto pending_show_devtools_params = devtools_window_runner->TakePendingParams(); diff --git a/libcef/browser/chrome/chrome_devtools_window_runner.h b/libcef/browser/chrome/chrome_devtools_window_runner.h deleted file mode 100644 index c4d33e8db..000000000 --- a/libcef/browser/chrome/chrome_devtools_window_runner.h +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2024 The Chromium Embedded Framework Authors. All rights 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_CHROME_CHROME_DEVTOOLS_WINDOW_RUNNER_H_ -#define CEF_LIBCEF_BROWSER_CHROME_CHROME_DEVTOOLS_WINDOW_RUNNER_H_ -#pragma once - -#include "base/memory/weak_ptr.h" -#include "cef/libcef/browser/devtools/devtools_window_runner.h" - -class ChromeBrowserHostImpl; - -// Creates and runs a DevTools window instance. Only accessed on the UI thread. -class ChromeDevToolsWindowRunner : public CefDevToolsWindowRunner { - public: - ChromeDevToolsWindowRunner() = default; - - ChromeDevToolsWindowRunner(const ChromeDevToolsWindowRunner&) = delete; - ChromeDevToolsWindowRunner& operator=(const ChromeDevToolsWindowRunner&) = - delete; - - // CefDevToolsWindowRunner methods: - void ShowDevTools(CefBrowserHostBase* opener, - std::unique_ptr params) override; - void CloseDevTools() override; - bool HasDevTools() override; - - std::unique_ptr TakePendingParams(); - - void SetDevToolsBrowserHost( - base::WeakPtr browser_host); - - private: - std::unique_ptr pending_params_; - - base::WeakPtr browser_host_; -}; - -#endif // CEF_LIBCEF_BROWSER_CHROME_CHROME_DEVTOOLS_WINDOW_RUNNER_H_ diff --git a/libcef/browser/chrome/chrome_devtools_window_runner.cc b/libcef/browser/devtools/devtools_window_runner.cc similarity index 86% rename from libcef/browser/chrome/chrome_devtools_window_runner.cc rename to libcef/browser/devtools/devtools_window_runner.cc index e247e9171..266d2b830 100644 --- a/libcef/browser/chrome/chrome_devtools_window_runner.cc +++ b/libcef/browser/devtools/devtools_window_runner.cc @@ -2,14 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "cef/libcef/browser/chrome/chrome_devtools_window_runner.h" +#include "cef/libcef/browser/devtools/devtools_window_runner.h" #include "cef/libcef/browser/chrome/chrome_browser_host_impl.h" #include "cef/libcef/browser/request_context_impl.h" #include "cef/libcef/browser/thread_util.h" #include "chrome/browser/devtools/devtools_window.h" -void ChromeDevToolsWindowRunner::ShowDevTools( +void CefDevToolsWindowRunner::ShowDevTools( CefBrowserHostBase* opener, std::unique_ptr params) { CEF_REQUIRE_UIT(); @@ -46,7 +46,7 @@ void ChromeDevToolsWindowRunner::ShowDevTools( DCHECK(browser_host_); } -void ChromeDevToolsWindowRunner::CloseDevTools() { +void CefDevToolsWindowRunner::CloseDevTools() { CEF_REQUIRE_UIT(); if (browser_host_) { browser_host_->TryCloseBrowser(); @@ -54,18 +54,18 @@ void ChromeDevToolsWindowRunner::CloseDevTools() { } } -bool ChromeDevToolsWindowRunner::HasDevTools() { +bool CefDevToolsWindowRunner::HasDevTools() { CEF_REQUIRE_UIT(); return !!browser_host_; } std::unique_ptr -ChromeDevToolsWindowRunner::TakePendingParams() { +CefDevToolsWindowRunner::TakePendingParams() { CEF_REQUIRE_UIT(); return std::move(pending_params_); } -void ChromeDevToolsWindowRunner::SetDevToolsBrowserHost( +void CefDevToolsWindowRunner::SetDevToolsBrowserHost( base::WeakPtr browser_host) { CEF_REQUIRE_UIT(); DCHECK(!browser_host_); diff --git a/libcef/browser/devtools/devtools_window_runner.h b/libcef/browser/devtools/devtools_window_runner.h index b94f9b818..1e3d2da37 100644 --- a/libcef/browser/devtools/devtools_window_runner.h +++ b/libcef/browser/devtools/devtools_window_runner.h @@ -8,9 +8,11 @@ #include +#include "base/memory/weak_ptr.h" #include "cef/include/cef_client.h" class CefBrowserHostBase; +class ChromeBrowserHostImpl; // Parameters passed to ShowDevTools. struct CefShowDevToolsParams { @@ -30,18 +32,28 @@ struct CefShowDevToolsParams { }; // Creates and runs a DevTools window instance. Only accessed on the UI thread. -class CefDevToolsWindowRunner { +class CefDevToolsWindowRunner final { public: - // Creates the appropriate runner type based on the current runtime. - static std::unique_ptr Create(); + CefDevToolsWindowRunner() = default; - // See documentation on CefBrowserHost methods of the same name. - virtual void ShowDevTools(CefBrowserHostBase* opener, - std::unique_ptr params) = 0; - virtual void CloseDevTools() = 0; - virtual bool HasDevTools() = 0; + CefDevToolsWindowRunner(const CefDevToolsWindowRunner&) = delete; + CefDevToolsWindowRunner& operator=(const CefDevToolsWindowRunner&) = + delete; - virtual ~CefDevToolsWindowRunner() = default; + void ShowDevTools(CefBrowserHostBase* opener, + std::unique_ptr params); + void CloseDevTools(); + bool HasDevTools(); + + std::unique_ptr TakePendingParams(); + + void SetDevToolsBrowserHost( + base::WeakPtr browser_host); + + private: + std::unique_ptr pending_params_; + + base::WeakPtr browser_host_; }; #endif // CEF_LIBCEF_BROWSER_DEVTOOLS_DEVTOOLS_WINDOW_RUNNER_H_ diff --git a/libcef/browser/devtools/devtools_window_runner_create.cc b/libcef/browser/devtools/devtools_window_runner_create.cc deleted file mode 100644 index 01bd37a3c..000000000 --- a/libcef/browser/devtools/devtools_window_runner_create.cc +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2024 The Chromium Embedded Framework Authors. All rights 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/chrome/chrome_devtools_window_runner.h" -#include "cef/libcef/browser/devtools/devtools_window_runner.h" - -// static -std::unique_ptr CefDevToolsWindowRunner::Create() { - return std::make_unique(); -}