![electron-roller[bot]](/assets/img/avatar_default.png)
* chore: bump chromium in DEPS to 136.0.7081.1 * chore: bump chromium in DEPS to 136.0.7083.1 * chore: bump chromium in DEPS to 136.0.7085.1 * chore: bump chromium in DEPS to 136.0.7087.1 * chore: bump chromium in DEPS to 136.0.7089.0 * chore: bump chromium in DEPS to 136.0.7091.0 * chore: bump chromium in DEPS to 136.0.7092.0 * chore: bump chromium in DEPS to 136.0.7093.1 * chore: bump chromium in DEPS to 136.0.7095.1 * chore: bump chromium in DEPS to 136.0.7097.1 * chore: bump chromium in DEPS to 136.0.7099.1 * chore: bump chromium in DEPS to 136.0.7101.0 * chore: bump chromium in DEPS to 136.0.7103.0 * chore: bump chromium in DEPS to 136.0.7103.15 * chore: bump chromium in DEPS to 136.0.7103.17 * chore: bump chromium to 136.0.7095.0 (main) (#46118) * chore: bump chromium in DEPS to 136.0.7076.0 * chore: bump chromium in DEPS to 136.0.7077.0 * 6368856: Migrate absl variant.h and utility.h in content (part 2/2) |6368856
* 6356528: Clean up LegacyRenderWidgetHostHWND code |6356528
* chore: export patches * 6339113: [Viewport Segments] Add CDP commands to override Viewport Segments without overriding other device properties. |6339113
* 6352169: [DevTools][MultiInstance] Support new tab in another window on Android |6352169
* 6368856: Migrate absl variant.h and utility.h in content (part 2/2) |6368856
* 6360858:Clickiness: Wire response from URLLoader to DB, add e2e tests|6360858
* chore: bump chromium in DEPS to 136.0.7079.0 * chore: export patches * chore: bump chromium in DEPS to 136.0.7081.0 * chore: export patches * chore: bump chromium in DEPS to 136.0.7083.0 * 6361987: Remove double-declaration with gfx::NativeView and gfx::NativeWindow |6361987
* chore: export patches * chore: bump chromium in DEPS to 136.0.7087.0 * chore: export patches * fix: include node patch for missing AtomicsWaitEvent6385540
* build: add depot_tools python to path * fix: cppgc init and unregistering v8 isolate6333562
CppGc is now initialized earlier so Node can skip reinitializing it. Additionally, gin::IsolateHandle was attempting to destruct an already destructed v8::Isolate upon electron::JavaScriptEnvironment destruction. By removing the call to NodePlatform::UnregisterIsolate, this fixes the crash on app shutdown. * fix: unregister isolate after destruction See code comment. * chore: bump chromium in DEPS to 136.0.7095.0 * chore: sync patches * fix: add script_parsing::ContentScriptType parameter6298395
* fix: migrate content::BrowserAccessibilityState methods6401437
6383275
* feat: enableHappyEyeballs option for host resolver6332599
* fix: add new cookie exclusion reason6343479
* fix: add new url loader method6337340
* fix: add new cppgc header file for electron_node headers6348644
* fix: disable CREL on Linux ARM64 https://chromium-review.googlesource.com/q/I3a62f02f564f07be63173b0773b4ecaffbe939b9 * fixup! fix: add new cppgc header file for electron_node headers6348644
* chore: update corner smoothing patch * fixup! chore: update corner smoothing patch * chore: disable NAN weak tests These two tests are incompatible with a V8 change that disallows running JS code from a weak finalizer callback. Ref:4733273
* test: fix task starvation in node test A V8 change makes these contexts get collected in a task that is posted and run asynchronously. The tests were synchronously GC'ing in an infinite loop, preventing the task loop from running the task that would GC these contexts. This change should be upstreamed in some way. Ref:4733273
--------- Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com> Co-authored-by: alice <alice@makenotion.com> Co-authored-by: Samuel Maddock <smaddock@slack-corp.com> Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org> Co-authored-by: clavin <clavin@electronjs.org> (cherry picked from commit9c019b6147
) * Remove file-wide unsafe buffer suppression from content/ [3 of N]6341711
--------- Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com> Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
145 lines
5.1 KiB
C++
145 lines
5.1 KiB
C++
// Copyright (c) 2014 The Chromium Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE-CHROMIUM file.
|
|
|
|
#include "shell/browser/ui/devtools_manager_delegate.h"
|
|
|
|
#include <memory>
|
|
#include <utility>
|
|
|
|
#include "base/command_line.h"
|
|
#include "base/files/file_path.h"
|
|
#include "base/functional/bind.h"
|
|
#include "base/path_service.h"
|
|
#include "base/strings/string_number_conversions.h"
|
|
#include "content/public/browser/browser_thread.h"
|
|
#include "content/public/browser/devtools_agent_host.h"
|
|
#include "content/public/browser/devtools_frontend_host.h"
|
|
#include "content/public/browser/devtools_socket_factory.h"
|
|
#include "content/public/browser/favicon_status.h"
|
|
#include "content/public/browser/navigation_entry.h"
|
|
#include "content/public/common/content_switches.h"
|
|
#include "content/public/common/url_constants.h"
|
|
#include "electron/grit/electron_resources.h"
|
|
#include "net/base/net_errors.h"
|
|
#include "net/socket/stream_socket.h"
|
|
#include "net/socket/tcp_server_socket.h"
|
|
#include "shell/browser/browser.h"
|
|
#include "shell/browser/electron_browser_context.h"
|
|
#include "shell/common/electron_paths.h"
|
|
#include "third_party/inspector_protocol/crdtp/dispatch.h"
|
|
#include "ui/base/resource/resource_bundle.h"
|
|
|
|
namespace electron {
|
|
|
|
namespace {
|
|
|
|
class TCPServerSocketFactory : public content::DevToolsSocketFactory {
|
|
public:
|
|
TCPServerSocketFactory(const std::string& address, int port)
|
|
: address_(address), port_(port) {}
|
|
|
|
// disable copy
|
|
TCPServerSocketFactory(const TCPServerSocketFactory&) = delete;
|
|
TCPServerSocketFactory& operator=(const TCPServerSocketFactory&) = delete;
|
|
|
|
private:
|
|
// content::ServerSocketFactory.
|
|
std::unique_ptr<net::ServerSocket> CreateForHttpServer() override {
|
|
auto socket =
|
|
std::make_unique<net::TCPServerSocket>(nullptr, net::NetLogSource());
|
|
if (socket->ListenWithAddressAndPort(address_, port_, 10) != net::OK)
|
|
return {};
|
|
|
|
return socket;
|
|
}
|
|
std::unique_ptr<net::ServerSocket> CreateForTethering(
|
|
std::string* name) override {
|
|
return {};
|
|
}
|
|
|
|
std::string address_;
|
|
uint16_t port_;
|
|
};
|
|
|
|
std::unique_ptr<content::DevToolsSocketFactory> CreateSocketFactory() {
|
|
auto& command_line = *base::CommandLine::ForCurrentProcess();
|
|
// See if the user specified a port on the command line (useful for
|
|
// automation). If not, use an ephemeral port by specifying 0.
|
|
int port = 0;
|
|
if (command_line.HasSwitch(switches::kRemoteDebuggingPort)) {
|
|
int temp_port;
|
|
std::string port_str =
|
|
command_line.GetSwitchValueASCII(switches::kRemoteDebuggingPort);
|
|
if (base::StringToInt(port_str, &temp_port) && temp_port >= 0 &&
|
|
temp_port < 65535) {
|
|
port = temp_port;
|
|
} else {
|
|
DLOG(WARNING) << "Invalid http debugger port number " << temp_port;
|
|
}
|
|
}
|
|
return std::make_unique<TCPServerSocketFactory>("127.0.0.1", port);
|
|
}
|
|
|
|
const char kBrowserCloseMethod[] = "Browser.close";
|
|
|
|
} // namespace
|
|
|
|
// DevToolsManagerDelegate ---------------------------------------------------
|
|
|
|
// static
|
|
void DevToolsManagerDelegate::StartHttpHandler() {
|
|
base::FilePath session_data;
|
|
base::PathService::Get(DIR_SESSION_DATA, &session_data);
|
|
content::DevToolsAgentHost::StartRemoteDebuggingServer(
|
|
CreateSocketFactory(), session_data, base::FilePath());
|
|
}
|
|
|
|
DevToolsManagerDelegate::DevToolsManagerDelegate() = default;
|
|
|
|
DevToolsManagerDelegate::~DevToolsManagerDelegate() = default;
|
|
|
|
void DevToolsManagerDelegate::Inspect(content::DevToolsAgentHost* agent_host) {}
|
|
|
|
void DevToolsManagerDelegate::HandleCommand(
|
|
content::DevToolsAgentHostClientChannel* channel,
|
|
base::span<const uint8_t> message,
|
|
NotHandledCallback callback) {
|
|
crdtp::Dispatchable dispatchable(crdtp::SpanFrom(message));
|
|
DCHECK(dispatchable.ok());
|
|
if (crdtp::SpanEquals(crdtp::SpanFrom(kBrowserCloseMethod),
|
|
dispatchable.Method())) {
|
|
// In theory, we should respond over the protocol saying that the
|
|
// Browser.close was handled. But doing so requires instantiating the
|
|
// protocol UberDispatcher and generating proper protocol handlers.
|
|
// Since we only have one method and it is supposed to close Electron,
|
|
// we don't need to add this complexity. Should we decide to support
|
|
// methods like Browser.setWindowBounds, we'll need to do it though.
|
|
content::GetUIThreadTaskRunner({})->PostTask(
|
|
FROM_HERE, base::BindOnce([]() { Browser::Get()->Quit(); }));
|
|
return;
|
|
}
|
|
std::move(callback).Run(message);
|
|
}
|
|
|
|
scoped_refptr<content::DevToolsAgentHost>
|
|
DevToolsManagerDelegate::CreateNewTarget(const GURL& url,
|
|
TargetType target_type,
|
|
bool new_window) {
|
|
return nullptr;
|
|
}
|
|
|
|
std::string DevToolsManagerDelegate::GetDiscoveryPageHTML() {
|
|
return ui::ResourceBundle::GetSharedInstance().LoadDataResourceString(
|
|
IDR_CONTENT_SHELL_DEVTOOLS_DISCOVERY_PAGE);
|
|
}
|
|
|
|
bool DevToolsManagerDelegate::HasBundledFrontendResources() {
|
|
return true;
|
|
}
|
|
|
|
content::BrowserContext* DevToolsManagerDelegate::GetDefaultBrowserContext() {
|
|
return ElectronBrowserContext::GetDefaultBrowserContext();
|
|
}
|
|
|
|
} // namespace electron
|