Commit a1491a1c authored by Yang Guo's avatar Yang Guo Committed by Commit Bot

DevTools: fix --custom-devtools-frontend=file:// for Windows

Fixed: 1028931
Change-Id: Ib26155ca9769495458f4fa0e1a5ba0bfc77b8e47
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1939288Reviewed-by: default avatarAndrey Kosyakov <caseq@chromium.org>
Reviewed-by: default avatarDmitry Gozman <dgozman@chromium.org>
Commit-Queue: Dmitry Gozman <dgozman@chromium.org>
Auto-Submit: Yang Guo <yangguo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#721607}
parent 53c4bd97
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include "content/public/browser/devtools_frontend_host.h" #include "content/public/browser/devtools_frontend_host.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "content/public/common/url_constants.h" #include "content/public/common/url_constants.h"
#include "net/base/filename_util.h"
#include "net/base/load_flags.h" #include "net/base/load_flags.h"
#include "net/traffic_annotation/network_traffic_annotation.h" #include "net/traffic_annotation/network_traffic_annotation.h"
#include "services/network/public/cpp/resource_request.h" #include "services/network/public/cpp/resource_request.h"
...@@ -302,7 +303,10 @@ void DevToolsDataSource::StartFileRequest(const std::string& path, ...@@ -302,7 +303,10 @@ void DevToolsDataSource::StartFileRequest(const std::string& path,
base::FilePath base_path; base::FilePath base_path;
GURL custom_devtools_frontend = GetCustomDevToolsFrontendURL(); GURL custom_devtools_frontend = GetCustomDevToolsFrontendURL();
if (custom_devtools_frontend.SchemeIsFile()) { if (custom_devtools_frontend.SchemeIsFile()) {
base_path = base_path.AppendASCII(custom_devtools_frontend.GetContent()); if (!net::FileURLToFilePath(custom_devtools_frontend, &base_path)) {
std::move(callback).Run(CreateNotFoundResponse());
return;
}
} else { } else {
#if BUILDFLAG(DEBUG_DEVTOOLS) #if BUILDFLAG(DEBUG_DEVTOOLS)
// Use default path for unbundled files when debug_devtools=true // Use default path for unbundled files when debug_devtools=true
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "base/bind.h" #include "base/bind.h"
#include "base/memory/ref_counted_memory.h" #include "base/memory/ref_counted_memory.h"
#include "base/strings/strcat.h" #include "base/strings/strcat.h"
#include "build/build_config.h"
#include "chrome/common/chrome_switches.h" #include "chrome/common/chrome_switches.h"
#include "chrome/common/url_constants.h" #include "chrome/common/url_constants.h"
#include "content/public/browser/url_data_source.h" #include "content/public/browser/url_data_source.h"
...@@ -128,8 +129,13 @@ TEST_F(DevToolsUIDataSourceTest, TestDevToolsBundledURLWithQueryParam) { ...@@ -128,8 +129,13 @@ TEST_F(DevToolsUIDataSourceTest, TestDevToolsBundledURLWithQueryParam) {
} }
TEST_F(DevToolsUIDataSourceTest, TestDevToolsBundledURLWithSwitch) { TEST_F(DevToolsUIDataSourceTest, TestDevToolsBundledURLWithSwitch) {
#if defined(OS_WIN)
const char* flag_value = "file://C:/tmp/";
#else
const char* flag_value = "file://tmp/";
#endif
base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
switches::kCustomDevtoolsFrontend, "file://tmp/"); switches::kCustomDevtoolsFrontend, flag_value);
const GURL path = const GURL path =
DevToolsUrl().Resolve(DevToolsBundledPath(kDevToolsUITestFrontEndUrl)); DevToolsUrl().Resolve(DevToolsBundledPath(kDevToolsUITestFrontEndUrl));
StartRequest(path.path()); StartRequest(path.path());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment