diff --git a/libcef/browser/net_service/proxy_url_loader_factory.cc b/libcef/browser/net_service/proxy_url_loader_factory.cc index 16d762689..c5546c29f 100644 --- a/libcef/browser/net_service/proxy_url_loader_factory.cc +++ b/libcef/browser/net_service/proxy_url_loader_factory.cc @@ -8,10 +8,12 @@ #include "libcef/browser/context.h" #include "libcef/browser/origin_whitelist_impl.h" #include "libcef/browser/thread_util.h" +#include "libcef/common/cef_switches.h" #include "libcef/common/net/scheme_registration.h" #include "libcef/common/net_service/net_service_util.h" #include "base/barrier_closure.h" +#include "base/command_line.h" #include "base/strings/string_number_conversions.h" #include "components/safe_browsing/core/common/safebrowsing_constants.h" #include "content/public/browser/browser_context.h" @@ -52,6 +54,14 @@ void CreateProxyHelper( std::move(request_handler)); } +bool DisableRequestHandlingForTesting() { + static bool disabled([]() -> bool { + return base::CommandLine::ForCurrentProcess()->HasSwitch( + switches::kDisableRequestHandlingForTesting); + }()); + return disabled; +} + } // namespace // Owns all of the ProxyURLLoaderFactorys for a given BrowserContext. Since @@ -1302,8 +1312,7 @@ void ProxyURLLoaderFactory::CreateLoaderAndStart( return; } - bool pass_through = false; - if (pass_through) { + if (DisableRequestHandlingForTesting()) { // This is the so-called pass-through, no-op option. if (target_factory_) { target_factory_->CreateLoaderAndStart(std::move(receiver), request_id, diff --git a/libcef/common/cef_switches.cc b/libcef/common/cef_switches.cc index 68cb64a1d..2b5266507 100644 --- a/libcef/common/cef_switches.cc +++ b/libcef/common/cef_switches.cc @@ -129,6 +129,11 @@ const char kDisableChromeLoginPrompt[] = "disable-chrome-login-prompt"; // Override the product component of the default User-Agent string. const char kUserAgentProductAndVersion[] = "user-agent-product"; +// Disable request handling in CEF to faciliate debugging of network-related +// issues. +const char kDisableRequestHandlingForTesting[] = + "disable-request-handling-for-testing"; + #if defined(OS_MAC) // Path to the framework directory. const char kFrameworkDirPath[] = "framework-dir-path"; diff --git a/libcef/common/cef_switches.h b/libcef/common/cef_switches.h index a2aa23afb..edc0e0f17 100644 --- a/libcef/common/cef_switches.h +++ b/libcef/common/cef_switches.h @@ -56,6 +56,7 @@ extern const char kDevToolsProtocolLogFile[]; extern const char kEnableChromeRuntime[]; extern const char kDisableChromeLoginPrompt[]; extern const char kUserAgentProductAndVersion[]; +extern const char kDisableRequestHandlingForTesting[]; #if defined(OS_MAC) extern const char kFrameworkDirPath[];