Remove devtools window runner abstraction (see #3685)

Remove code abstractions that are no longer required after deletion of
the Alloy bootstrap. This is a functional no-op.
This commit is contained in:
Marshall Greenblatt
2024-07-02 14:27:11 -04:00
parent cd3f617171
commit 1cdf02815e
7 changed files with 31 additions and 73 deletions

View File

@@ -0,0 +1,73 @@
// 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/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 CefDevToolsWindowRunner::ShowDevTools(
CefBrowserHostBase* opener,
std::unique_ptr<CefShowDevToolsParams> params) {
CEF_REQUIRE_UIT();
auto* web_contents = opener->GetWebContents();
if (!web_contents) {
return;
}
auto* profile = CefRequestContextImpl::GetProfile(opener->request_context());
if (!DevToolsWindow::AllowDevToolsFor(profile, web_contents)) {
LOG(WARNING) << "DevTools is not allowed for this browser";
return;
}
auto inspect_element_at = params->inspect_element_at_;
if (!browser_host_) {
// Configure parameters for ChromeBrowserDelegate::CreateDevToolsBrowser
// which will be called indirectly to create the DevTools window.
DCHECK(!pending_params_);
pending_params_ = std::move(params);
}
// Focus the existing DevTools window or create a new one.
if (!inspect_element_at.IsEmpty()) {
DevToolsWindow::InspectElement(web_contents->GetPrimaryMainFrame(),
inspect_element_at.x, inspect_element_at.y);
} else {
DevToolsWindow::OpenDevToolsWindow(web_contents, profile,
DevToolsOpenedByAction::kUnknown);
}
// The DevTools browser host should now exist.
DCHECK(browser_host_);
}
void CefDevToolsWindowRunner::CloseDevTools() {
CEF_REQUIRE_UIT();
if (browser_host_) {
browser_host_->TryCloseBrowser();
browser_host_ = nullptr;
}
}
bool CefDevToolsWindowRunner::HasDevTools() {
CEF_REQUIRE_UIT();
return !!browser_host_;
}
std::unique_ptr<CefShowDevToolsParams>
CefDevToolsWindowRunner::TakePendingParams() {
CEF_REQUIRE_UIT();
return std::move(pending_params_);
}
void CefDevToolsWindowRunner::SetDevToolsBrowserHost(
base::WeakPtr<ChromeBrowserHostImpl> browser_host) {
CEF_REQUIRE_UIT();
DCHECK(!browser_host_);
browser_host_ = browser_host;
}

View File

@@ -8,9 +8,11 @@
#include <memory>
#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<CefDevToolsWindowRunner> Create();
CefDevToolsWindowRunner() = default;
// See documentation on CefBrowserHost methods of the same name.
virtual void ShowDevTools(CefBrowserHostBase* opener,
std::unique_ptr<CefShowDevToolsParams> 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<CefShowDevToolsParams> params);
void CloseDevTools();
bool HasDevTools();
std::unique_ptr<CefShowDevToolsParams> TakePendingParams();
void SetDevToolsBrowserHost(
base::WeakPtr<ChromeBrowserHostImpl> browser_host);
private:
std::unique_ptr<CefShowDevToolsParams> pending_params_;
base::WeakPtr<ChromeBrowserHostImpl> browser_host_;
};
#endif // CEF_LIBCEF_BROWSER_DEVTOOLS_DEVTOOLS_WINDOW_RUNNER_H_

View File

@@ -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> CefDevToolsWindowRunner::Create() {
return std::make_unique<ChromeDevToolsWindowRunner>();
}