From 86eb141c533e6d6ade820b09f651f37fa56bd0a5 Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Thu, 4 Jan 2018 18:52:30 -0500 Subject: [PATCH] Return Chrome 'Browser' value for DevTools remote debugging (issue #2300) --- libcef/common/content_client.cc | 4 ++++ libcef/common/content_client.h | 1 + patch/patch.cfg | 5 ++++ patch/patches/devtools_product_2300.patch | 28 +++++++++++++++++++++++ 4 files changed, 38 insertions(+) create mode 100644 patch/patches/devtools_product_2300.patch diff --git a/libcef/common/content_client.cc b/libcef/common/content_client.cc index b787daa39..81a4185ad 100644 --- a/libcef/common/content_client.cc +++ b/libcef/common/content_client.cc @@ -235,6 +235,10 @@ std::string CefContentClient::GetProduct() const { if (command_line->HasSwitch(switches::kProductVersion)) return command_line->GetSwitchValueASCII(switches::kProductVersion); + return GetChromeProduct(); +} + +std::string CefContentClient::GetChromeProduct() const { return base::StringPrintf("Chrome/%d.%d.%d.%d", CHROME_VERSION_MAJOR, CHROME_VERSION_MINOR, CHROME_VERSION_BUILD, CHROME_VERSION_PATCH); diff --git a/libcef/common/content_client.h b/libcef/common/content_client.h index f155dcc77..e3272942f 100644 --- a/libcef/common/content_client.h +++ b/libcef/common/content_client.h @@ -35,6 +35,7 @@ class CefContentClient : public content::ContentClient, std::vector* plugins) override; void AddAdditionalSchemes(Schemes* schemes) override; std::string GetProduct() const override; + std::string GetChromeProduct() const override; std::string GetUserAgent() const override; base::string16 GetLocalizedString(int message_id) const override; base::StringPiece GetDataResource( diff --git a/patch/patch.cfg b/patch/patch.cfg index 9fa63293d..95f2ee0a9 100644 --- a/patch/patch.cfg +++ b/patch/patch.cfg @@ -331,6 +331,11 @@ patches = [ # https://bitbucket.org/chromiumembedded/cef/issues/2274 'name': 'win_rt_2274', }, + { + # Always return the Chrome product value for DevTools. + # https://bitbucket.org/chromiumembedded/cef/issues/2300 + 'name': 'devtools_product_2300', + }, { # macOS: Fix build of widevinecdmadapter.plugin. # https://bitbucket.org/chromiumembedded/cef/issues/2314 diff --git a/patch/patches/devtools_product_2300.patch b/patch/patches/devtools_product_2300.patch new file mode 100644 index 000000000..526d1bfe4 --- /dev/null +++ b/patch/patches/devtools_product_2300.patch @@ -0,0 +1,28 @@ +diff --git content/browser/devtools/devtools_http_handler.cc content/browser/devtools/devtools_http_handler.cc +index 4468bc4be351..f154f439aa19 100644 +--- content/browser/devtools/devtools_http_handler.cc ++++ content/browser/devtools/devtools_http_handler.cc +@@ -509,7 +509,7 @@ void DevToolsHttpHandler::OnJsonRequest( + version.SetString("Protocol-Version", + DevToolsAgentHost::GetProtocolVersion()); + version.SetString("WebKit-Version", GetWebKitVersion()); +- version.SetString("Browser", GetContentClient()->GetProduct()); ++ version.SetString("Browser", GetContentClient()->GetChromeProduct()); + version.SetString("User-Agent", GetContentClient()->GetUserAgent()); + version.SetString("V8-Version", V8_VERSION_STRING); + std::string host = info.headers["host"]; +diff --git content/public/common/content_client.h content/public/common/content_client.h +index 48ca775aa88e..cb268f412f61 100644 +--- content/public/common/content_client.h ++++ content/public/common/content_client.h +@@ -138,6 +138,10 @@ class CONTENT_EXPORT ContentClient { + // Used as part of the user agent string. + virtual std::string GetProduct() const; + ++ // Returns the Chrome-specific product string. This is used for compatibility ++ // purposes with external tools like Selenium. ++ virtual std::string GetChromeProduct() const { return GetProduct(); } ++ + // Returns the user agent. Content may cache this value. + virtual std::string GetUserAgent() const; +