Last active
October 7, 2017 07:08
-
-
Save miaulightouch/f8e13901f5fc0fcb8ef097b4af39d679 to your computer and use it in GitHub Desktop.
remove appname from useragent of Electron
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 9e7eeba3c65080c9c50f3f96fd28c5dcbf3d016e Mon Sep 17 00:00:00 2001 | |
From: Miau Lightouch <[email protected]> | |
Date: Sat, 7 Oct 2017 15:02:39 +0800 | |
Subject: [PATCH] remove appname from useragent | |
--- | |
atom/app/atom_content_client.cc | 4 +++- | |
atom/browser/atom_browser_context.cc | 2 ++ | |
brightray/common/content_client.cc | 3 ++- | |
3 files changed, 7 insertions(+), 2 deletions(-) | |
diff --git a/atom/app/atom_content_client.cc b/atom/app/atom_content_client.cc | |
index 09683211c..ab533859c 100644 | |
--- a/atom/app/atom_content_client.cc | |
+++ b/atom/app/atom_content_client.cc | |
@@ -191,7 +191,9 @@ std::string AtomContentClient::GetProduct() const { | |
std::string AtomContentClient::GetUserAgent() const { | |
return content::BuildUserAgentFromProduct( | |
"Chrome/" CHROME_VERSION_STRING " " | |
- ATOM_PRODUCT_NAME "/" ATOM_VERSION_STRING); | |
+ //remove <APP NAME>/%s part | |
+ //ATOM_PRODUCT_NAME "/" ATOM_VERSION_STRING); | |
+ ); | |
} | |
base::string16 AtomContentClient::GetLocalizedString(int message_id) const { | |
diff --git a/atom/browser/atom_browser_context.cc b/atom/browser/atom_browser_context.cc | |
index 76a23cdcd..249cd3463 100644 | |
--- a/atom/browser/atom_browser_context.cc | |
+++ b/atom/browser/atom_browser_context.cc | |
@@ -89,6 +89,8 @@ AtomBrowserContext::AtomBrowserContext(const std::string& partition, | |
browser->GetVersion().c_str(), | |
CHROME_VERSION_STRING); | |
} | |
+ //remove <APP NAME>/%s part | |
+ user_agent = "Chrome/" CHROME_VERSION_STRING; | |
user_agent_ = content::BuildUserAgentFromProduct(user_agent); | |
// Read options. | |
diff --git a/brightray/common/content_client.cc b/brightray/common/content_client.cc | |
index 71668e5d0..c6d95d6f3 100644 | |
--- a/brightray/common/content_client.cc | |
+++ b/brightray/common/content_client.cc | |
@@ -21,7 +21,8 @@ std::string GetProductInternal() { | |
} | |
std::string GetBrightrayUserAgent() { | |
- return content::BuildUserAgentFromProduct(GetProductInternal()); | |
+ // remove Electron/%s part | |
+ return content::BuildUserAgentFromProduct(""); | |
} | |
ContentClient::ContentClient() { | |
-- | |
2.14.2 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment