Skip to content

Commit

Permalink
DevTools: remove usage of DEBUG_DEVTOOLS
Browse files Browse the repository at this point in the history
With a separate repository, we want to make developing DevTools frontend
as much decoupled from rest of Chromium as possible. This includes not
having to rebuild Chromium for debug mode.

Bug: 1087379
Change-Id: Ie42185dcc685f4a08f106286f0d0824dcee60a99
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2218774
Reviewed-by: Tim van der Lippe <tvanderlippe@chromium.org>
Reviewed-by: Kentaro Hara <haraken@chromium.org>
Reviewed-by: Peter Marshall <petermarshall@chromium.org>
Commit-Queue: Yang Guo <yangguo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#773172}
  • Loading branch information
hashseed authored and Commit Bot committed May 29, 2020
1 parent f8b4d19 commit 5abacc3
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 95 deletions.
6 changes: 0 additions & 6 deletions chrome/browser/devtools/device/port_forwarding_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -494,9 +494,6 @@ void PortForwardingController::Connection::SendCommand(
pending_responses_[id] =
base::Bind(&Connection::ProcessBindResponse,
base::Unretained(this), port);
#if BUILDFLAG(DEBUG_DEVTOOLS)
port_status_[port] = kStatusConnecting;
#endif // BUILDFLAG(DEBUG_DEVTOOLS)
} else {
auto it = port_status_.find(port);
if (it != port_status_.end() && it->second == kStatusError) {
Expand All @@ -508,9 +505,6 @@ void PortForwardingController::Connection::SendCommand(
pending_responses_[id] =
base::Bind(&Connection::ProcessUnbindResponse,
base::Unretained(this), port);
#if BUILDFLAG(DEBUG_DEVTOOLS)
port_status_[port] = kStatusDisconnecting;
#endif // BUILDFLAG(DEBUG_DEVTOOLS)
}

web_socket_->SendFrame(SerializeCommand(id, method, std::move(params)));
Expand Down
7 changes: 1 addition & 6 deletions chrome/browser/devtools/devtools_ui_bindings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ std::string SanitizeFrontendQueryParam(
const std::string& key,
const std::string& value) {
// Convert boolean flags to true.
if (key == "can_dock" || key == "debugFrontend" || key == "isSharedWorker" ||
if (key == "can_dock" || key == "isSharedWorker" ||
key == "v8only" || key == "remoteFrontend" || key == "nodeFrontend" ||
key == "hasOtherClients" || key == "uiDevTools")
return "true";
Expand Down Expand Up @@ -1555,12 +1555,7 @@ void DevToolsUIBindings::ReadyToCommitNavigation(
}

void DevToolsUIBindings::DocumentOnLoadCompletedInMainFrame() {
// In the DEBUG_DEVTOOLS mode, the DocumentOnLoadCompletedInMainFrame event
// arrives before the LoadCompleted event, thus it should not trigger the
// frontend load handling.
#if !BUILDFLAG(DEBUG_DEVTOOLS)
FrontendLoaded();
#endif
}

void DevToolsUIBindings::DidNavigateMainFrame() {
Expand Down
18 changes: 7 additions & 11 deletions chrome/browser/devtools/devtools_ui_bindings_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,12 @@ TEST_F(DevToolsUIBindingsTest, SanitizeFrontendURL) {
"devtools://devtools/bundled/devtools.html#hash"},
{"devtools://devtools/some/random/path",
"devtools://devtools/some/random/path"},
{"devtools://devtools/bundled/devtools.html?debugFrontend=true",
"devtools://devtools/bundled/devtools.html?debugFrontend=true"},
{"devtools://devtools/bundled/devtools.html"
"?some-flag=flag&v8only=true&debugFrontend=a"
"?some-flag=flag&v8only=true"
"&another-flag=another-flag&can_dock=false&isSharedWorker=notreally"
"&remoteFrontend=sure",
"devtools://devtools/bundled/devtools.html"
"?v8only=true&debugFrontend=true"
"&can_dock=true&isSharedWorker=true&remoteFrontend=true"},
"?v8only=true&can_dock=true&isSharedWorker=true&remoteFrontend=true"},
{"devtools://devtools/?ws=any-value-is-fine",
"devtools://devtools/?ws=any-value-is-fine"},
{"devtools://devtools/"
Expand All @@ -54,7 +51,7 @@ TEST_F(DevToolsUIBindingsTest, SanitizeFrontendURL) {
"https://chrome-devtools-frontend.appspot.com/serve_file/path/"},
{"devtools://devtools/?remoteBase="
"https://chrome-devtools-frontend.appspot.com/serve_file/"
"@123719741873/inspector.html%3FdebugFrontend%3Dfalse",
"@123719741873/inspector.html",
"devtools://devtools/?remoteBase="
"https://chrome-devtools-frontend.appspot.com/serve_file/"
"@123719741873/"},
Expand All @@ -66,10 +63,10 @@ TEST_F(DevToolsUIBindingsTest, SanitizeFrontendURL) {
"@b4907cc5d602ff470740b2eb6344b517edecb7b9/&can_dock=true"},
{"devtools://devtools/?remoteFrontendUrl="
"https://chrome-devtools-frontend.appspot.com/serve_rev/"
"@12345/inspector.html%3FdebugFrontend%3Dfalse",
"@12345/inspector.html",
"devtools://devtools/?remoteFrontendUrl="
"https%3A%2F%2Fchrome-devtools-frontend.appspot.com%2Fserve_rev"
"%2F%4012345%2Finspector.html%3FdebugFrontend%3Dtrue"},
"%2F%4012345%2Finspector.html"},
{"devtools://devtools/?remoteFrontendUrl="
"https://chrome-devtools-frontend.appspot.com/serve_rev/"
"@12345/inspector.html%22></iframe>something",
Expand All @@ -84,11 +81,10 @@ TEST_F(DevToolsUIBindingsTest, SanitizeFrontendURL) {
{"devtools://devtools/?remoteFrontendUrl="
"https://chrome-devtools-frontend.appspot.com/serve_rev/"
"@12345/devtools.html%3Fws%3Danyvalue"
"&unencoded=value&debugFrontend=true",
"&unencoded=value",
"devtools://devtools/?remoteFrontendUrl="
"https%3A%2F%2Fchrome-devtools-frontend.appspot.com%2Fserve_rev"
"%2F%4012345%2Fdevtools.html%3Fws%3Danyvalue"
"&debugFrontend=true"},
"%2F%4012345%2Fdevtools.html%3Fws%3Danyvalue"},
{"devtools://devtools/?remoteFrontendUrl="
"https://chrome-devtools-frontend.appspot.com/serve_rev/"
"@12345/inspector.html%23%27",
Expand Down
4 changes: 0 additions & 4 deletions chrome/browser/devtools/devtools_window.cc
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,6 @@ GURL DecorateFrontendURL(const GURL& base_url) {
switches::kDevToolsFlags);
}

#if BUILDFLAG(DEBUG_DEVTOOLS)
url_string += "&debugFrontend=true";
#endif // BUILDFLAG(DEBUG_DEVTOOLS)

return GURL(url_string);
}

Expand Down
13 changes: 9 additions & 4 deletions chrome/browser/devtools/remote_debugging_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
#include "content/public/browser/devtools_agent_host.h"
#include "content/public/browser/devtools_socket_factory.h"
#include "content/public/common/content_switches.h"
#include "net/base/filename_util.h"
#include "net/base/net_errors.h"
#include "net/log/net_log_source.h"
#include "net/socket/tcp_server_socket.h"
Expand Down Expand Up @@ -108,10 +110,13 @@ RemoteDebuggingServer::RemoteDebuggingServer() {
}

base::FilePath debug_frontend_dir;
#if BUILDFLAG(DEBUG_DEVTOOLS)
base::PathService::Get(chrome::DIR_INSPECTOR_DEBUG, &debug_frontend_dir);
#endif

if (command_line.HasSwitch(::switches::kCustomDevtoolsFrontend)) {
GURL custom_devtools_frontend_url(command_line.GetSwitchValueASCII(
::switches::kCustomDevtoolsFrontend));
if (custom_devtools_frontend_url.SchemeIsFile()) {
net::FileURLToFilePath(custom_devtools_frontend_url, &debug_frontend_dir);
}
}
content::DevToolsAgentHost::StartRemoteDebuggingServer(
std::make_unique<TCPServerSocketFactory>(port), output_dir,
debug_frontend_dir);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1111,14 +1111,9 @@ std::string RenderViewContextMenu::GetTargetLanguage() const {
}

void RenderViewContextMenu::AppendDeveloperItems() {
// Show Inspect Element in DevTools itself only in case of the debug
// devtools build.
// Do not Show Inspect Element for DevTools.
bool show_developer_items = !IsDevToolsURL(params_.page_url);

#if BUILDFLAG(DEBUG_DEVTOOLS)
show_developer_items = true;
#endif

if (!show_developer_items)
return;

Expand Down
35 changes: 10 additions & 25 deletions chrome/browser/ui/webui/devtools_ui_data_source.cc
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,13 @@ void DevToolsDataSource::StartDataRequest(
base::CompareCase::INSENSITIVE_ASCII));
std::string path_under_bundled =
path_without_params.substr(bundled_path_prefix.length());
#if !BUILDFLAG(DEBUG_DEVTOOLS)
if (!GetCustomDevToolsFrontendURL().SchemeIsFile()) {
if (GetCustomDevToolsFrontendURL().SchemeIsFile()) {
// Fetch from file system.
StartFileRequest(path_under_bundled, std::move(callback));
} else {
// Fetch from packaged resources.
StartBundledDataRequest(path_under_bundled, std::move(callback));
return;
}
#endif
// Fetch from file system.
StartFileRequest(path_under_bundled, std::move(callback));
return;
}

Expand Down Expand Up @@ -192,10 +190,7 @@ void DevToolsDataSource::StartBundledDataRequest(
scoped_refptr<base::RefCountedMemory> bytes =
content::DevToolsFrontendHost::GetFrontendResourceBytes(path);

DLOG_IF(WARNING, !bytes)
<< "Unable to find dev tool resource: " << path
<< ". If you compiled with debug_devtools=1, try running with "
"--debug-devtools.";
DLOG_IF(WARNING, !bytes) << "Unable to find DevTools resource: " << path;
std::move(callback).Run(bytes);
}

Expand Down Expand Up @@ -305,21 +300,11 @@ void DevToolsDataSource::StartFileRequest(const std::string& path,
GotDataCallback callback) {
base::FilePath base_path;
GURL custom_devtools_frontend = GetCustomDevToolsFrontendURL();
if (custom_devtools_frontend.SchemeIsFile()) {
if (!net::FileURLToFilePath(custom_devtools_frontend, &base_path)) {
std::move(callback).Run(CreateNotFoundResponse());
return;
}
} else {
#if BUILDFLAG(DEBUG_DEVTOOLS)
// Use default path for unbundled files when debug_devtools=true
if (!base::PathService::Get(chrome::DIR_INSPECTOR_DEBUG, &base_path)) {
std::move(callback).Run(CreateNotFoundResponse());
return;
}
#else
NOTREACHED();
#endif
DCHECK(custom_devtools_frontend.SchemeIsFile());
if (!net::FileURLToFilePath(custom_devtools_frontend, &base_path)) {
std::move(callback).Run(CreateNotFoundResponse());
LOG(WARNING) << "Unable to find DevTools resource: " << path;
return;
}

base::FilePath full_path = base_path.AppendASCII(path);
Expand Down
6 changes: 0 additions & 6 deletions chrome/common/chrome_paths.cc
Original file line number Diff line number Diff line change
Expand Up @@ -273,12 +273,6 @@ bool PathProvider(int key, base::FilePath* result) {
cur = cur.Append(FILE_PATH_LITERAL("resources"));
#endif
break;
case chrome::DIR_INSPECTOR_DEBUG:
if (!base::PathService::Get(chrome::DIR_RESOURCES, &cur))
return false;
cur = cur.Append(FILE_PATH_LITERAL("inspector"))
.Append(FILE_PATH_LITERAL("debug"));
break;
case chrome::DIR_APP_DICTIONARIES:
#if defined(OS_POSIX)
// We can't write into the EXE dir on Linux, so keep dictionaries
Expand Down
2 changes: 0 additions & 2 deletions chrome/common/chrome_paths.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ enum {
#endif
DIR_RESOURCES, // Directory containing separate file resources
// used by Chrome at runtime.
DIR_INSPECTOR_DEBUG, // Directory where non-bundled and non-minified
// web inspector is located.
DIR_APP_DICTIONARIES, // Directory where the global dictionaries are.
DIR_USER_DOCUMENTS, // Directory for a user's "My Documents".
DIR_USER_MUSIC, // Directory for a user's music.
Expand Down
24 changes: 0 additions & 24 deletions chrome/test/chromedriver/net/adb_client_socket.cc
Original file line number Diff line number Diff line change
Expand Up @@ -460,35 +460,11 @@ void AdbClientSocket::SendFile(int port,
new AdbSendFileSocket(port, serial, filename, content, callback);
}

#if BUILDFLAG(DEBUG_DEVTOOLS)
static void UseTransportQueryForDesktop(const SocketCallback& callback,
net::StreamSocket* socket,
int result) {
callback.Run(result, socket);
}
#endif // BUILDFLAG(DEBUG_DEVTOOLS)

// static
void AdbClientSocket::TransportQuery(int port,
const std::string& serial,
const std::string& socket_name,
const SocketCallback& callback) {
#if BUILDFLAG(DEBUG_DEVTOOLS)
if (serial.empty()) {
// Use plain socket for remote debugging on Desktop (debugging purposes).
int tcp_port = 0;
if (!base::StringToInt(socket_name, &tcp_port))
tcp_port = 9222;

net::AddressList address_list = net::AddressList::CreateFromIPAddress(
net::IPAddress::IPv4Localhost(), tcp_port);
net::TCPClientSocket* socket = new net::TCPClientSocket(
address_list, nullptr, nullptr, net::NetLogSource());
socket->Connect(
base::BindOnce(&UseTransportQueryForDesktop, callback, socket));
return;
}
#endif // BUILDFLAG(DEBUG_DEVTOOLS)
new AdbTransportSocket(port, serial, socket_name, callback);
}

Expand Down
1 change: 0 additions & 1 deletion third_party/blink/public/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ config("blink_headers_config") {
buildflag_header("buildflags") {
header = "public_buildflags.h"
flags = [
"DEBUG_DEVTOOLS=$debug_devtools",
"USE_MINIKIN_HYPHENATION=$use_minikin_hyphenation",
"ENABLE_UNHANDLED_TAP=$enable_unhandled_tap",
]
Expand Down

0 comments on commit 5abacc3

Please sign in to comment.