90af7d7fe2
* chore: bump chromium in DEPS to 110.0.5461.0 * chore: update patches * 3903024: hid: Add connection count tracking methods for HidDelegate https://chromium-review.googlesource.com/c/chromium/src/+/3903024 * 4076211: Turn FrameTreeNode::frame_tree into raw_ref. https://chromium-review.googlesource.com/c/chromium/src/+/4076211 * chore: bump chromium in DEPS to 110.0.5463.0 * chore: bump chromium in DEPS to 110.0.5465.0 * fix patches * 3835037: Add new slides media session actions to Picture-in-Picture window https://chromium-review.googlesource.com/c/chromium/src/+/3835037 * chore: update patches * chore: bump chromium in DEPS to 110.0.5467.0 * chore: update patches * chore: bump chromium in DEPS to 110.0.5469.0 * chore: bump chromium in DEPS to 110.0.5471.0 * chore: bump chromium in DEPS to 110.0.5473.0 * chore: bump chromium in DEPS to 110.0.5475.0 * chore: update patches * 4074449: Add gl::FrameData to software path https://chromium-review.googlesource.com/c/chromium/src/+/4074449 * 4065264: [Extensions] Add a new side panel view type https://chromium-review.googlesource.com/c/chromium/src/+/4065264 * 4060548: Remove base::Value::GetListDeprecated(). https://chromium-review.googlesource.com/c/chromium/src/+/4060548 * chore: add missing RefCountedMemory include * 4081108: task posting v3: remove task_runner_util{.h,_unittest.cc} https://chromium-review.googlesource.com/c/chromium/src/+/4081108 * 4072471: Rename Mixed Download Blocking to Insecure Download Blocking https://chromium-review.googlesource.com/c/chromium/src/+/4072471 * 4025927: [Code Health] Migrate e/c/manifest.cc to base::Value::Dict interface https://chromium-review.googlesource.com/c/chromium/src/+/4025927 * chore: fixup patch indices * chore: bump chromium in DEPS to 110.0.5477.0 * chore: fixup preconnect_manager.patch * chore: fixup patch indices * fixup! 4074449: Add gl::FrameData to software path * 4074449: Add gl::FrameData to software path This commit also reformatted the two files in this patch. The only change here is the addition of the |data| arg to |OnSwapBuffers|. https://chromium-review.googlesource.com/c/chromium/src/+/4074449 * 4081108: task posting v3: remove task_runner_util{.h,_unittest.cc} https://chromium-review.googlesource.com/c/chromium/src/+/4081108 * 4085814: [Test Automation] Move NativeWindowTracker to ui/views https://chromium-review.googlesource.com/c/chromium/src/+/4085814 * 4032656: hid: Abstract HidSystemTrayIcon class for profiles' HID connections https://chromium-review.googlesource.com/c/chromium/src/+/4032656 * chore: bump chromium in DEPS to 110.0.5479.0 * chore: fixup patches & simplify printing patch To be specific, I replaced some combination of line removals & commenting-out with `#if 0` blocks since they were already there for android. Should be functionally the same, just written differently for better patch maintainability. * chore: bump chromium in DEPS to 110.0.5481.0 * chore: update patch indicies * 4098946: Migrate Extension::Create() argument to base::Value::Dict (part 4 of 4) https://chromium-review.googlesource.com/c/chromium/src/+/4098946 * chore: bump chromium in DEPS to 111.0.5482.0 * chore: bump chromium in DEPS to 111.0.5484.0 * chore: bump chromium in DEPS to 111.0.5486.0 * chore: update patch indices * 4112903: Reland "Move gl::FrameData to gfx::FrameData" https://chromium-review.googlesource.com/c/chromium/src/+/4112903 * 4056216: Option to create a tab target with Target.createTarget in /json/new https://chromium-review.googlesource.com/c/chromium/src/+/4056216 * chore: bump chromium in DEPS to 111.0.5488.0 * chore: bump chromium in DEPS to 111.0.5490.0 * chore: bump chromium in DEPS to 111.0.5492.0 * chore: bump chromium in DEPS to 111.0.5494.0 * chore: bump chromium in DEPS to 111.0.5496.0 * chore: bump chromium in DEPS to 111.0.5498.0 * chore: bump chromium in DEPS to 111.0.5500.0 * chore: bump chromium in DEPS to 111.0.5502.0 * chore: update patch indices + small update to printing.patch due to: 3653941: [printing] Extract settings logic from PrintJobWorker https://chromium-review.googlesource.com/c/chromium/src/+/3653941 * 4113994: Cleanup: Rename webui_generated_resources_* to webui_resources_*. https://chromium-review.googlesource.com/c/chromium/src/+/4113994 * 4112537: Remove DictionaryPrefUpdate. https://chromium-review.googlesource.com/c/chromium/src/+/4112537 * 4072073: Remove //chrome/browser/ash dependency from pdf_extension_util.cc https://chromium-review.googlesource.com/c/chromium/src/+/4072073 * 4055223: [Remove FileSystemConnector] Remove DownloadItemRerouteInfo https://chromium-review.googlesource.com/c/chromium/src/+/4055223 * Migrate base::DictionaryValue to base::Value::Dict This relates to multiple CLs cleaning up this class in this roll, but the ones that are specifically relevant here: 4116096: [CodeHealth] Remove DictionaryValue::GetInteger https://chromium-review.googlesource.com/c/chromium/src/+/4116096 4113764: [CodeHealth] Remove deprecated DictionaryValue::SetInteger() https://chromium-review.googlesource.com/c/chromium/src/+/4113764 * 3653941: [printing] Extract settings logic from PrintJobWorker https://chromium-review.googlesource.com/c/chromium/src/+/3653941 * chore: bump chromium in DEPS to 111.0.5504.0 * chore: update patches * (WIP) 4003663: Enable Microtask queues per WindowAgent. https://chromium-review.googlesource.com/c/chromium/src/+/4003663 * chore: bump chromium in DEPS to 111.0.5506.0 * chore: update patches * fix: printing patch It was complaining that this method isn't used on windows * chore: bump chromium in DEPS to 111.0.5508.0 * chore: bump chromium in DEPS to 111.0.5510.0 * chore: bump chromium in DEPS to 111.0.5512.0 * chore: bump chromium in DEPS to 111.0.5514.0 * chore: bump chromium in DEPS to 111.0.5516.0 * chore: update patches * chore: bump chromium in DEPS to 111.0.5518.0 * chore: update patches * 4027428: [rsafor] Move rsaFor requests to a separate permission https://chromium-review.googlesource.com/c/chromium/src/+/4027428 * Revert "(WIP) 4003663: Enable Microtask queues per WindowAgent." This reverts commit cc36d226e3f3fe5f4bea6538102d55ce3203190f. * chore: disable Microtask queues per WindowAgent. see https://chromium-review.googlesource.com/c/chromium/src/+/4003663 * chore: cleanup after rebase * fixup: disable Microtask queues per WindowAgent. * chore: cleanup password from keychain after test Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com> Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org> Co-authored-by: Jeremy Rose <jeremya@chromium.org> Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> Co-authored-by: Calvin Watford <cwatford@slack-corp.com> Co-authored-by: clavin <clavin@electronjs.org>
141 lines
5 KiB
C++
141 lines
5 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/bind.h"
|
|
#include "base/command_line.h"
|
|
#include "base/files/file_path.h"
|
|
#include "base/path_service.h"
|
|
#include "base/strings/string_number_conversions.h"
|
|
#include "base/strings/stringprintf.h"
|
|
#include "base/strings/utf_string_conversions.h"
|
|
#include "chrome/common/chrome_paths.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 "content/public/common/user_agent.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/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 std::unique_ptr<net::ServerSocket>();
|
|
|
|
return socket;
|
|
}
|
|
std::unique_ptr<net::ServerSocket> CreateForTethering(
|
|
std::string* name) override {
|
|
return std::unique_ptr<net::ServerSocket>();
|
|
}
|
|
|
|
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, bool for_tab) {
|
|
return nullptr;
|
|
}
|
|
|
|
std::string DevToolsManagerDelegate::GetDiscoveryPageHTML() {
|
|
return ui::ResourceBundle::GetSharedInstance().LoadDataResourceString(
|
|
IDR_CONTENT_SHELL_DEVTOOLS_DISCOVERY_PAGE);
|
|
}
|
|
|
|
bool DevToolsManagerDelegate::HasBundledFrontendResources() {
|
|
return true;
|
|
}
|
|
|
|
} // namespace electron
|