summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMoonchild <moonchild@palemoon.org>2020-11-15 23:10:49 +0000
committerMoonchild <moonchild@palemoon.org>2020-11-15 23:11:24 +0000
commit3abb8e28add1be2c2ec2f53a20bd105bde64a5b2 (patch)
tree465194ef093f1dd4cdc1fc8ec848b9361b0555a3
parent18df01eb5498c954044f96c346026da0238d2e61 (diff)
downloaduxp-3abb8e28add1be2c2ec2f53a20bd105bde64a5b2.tar.gz
Revert "Issue #1684 - Remove global UA override preference and supporting code."
This reverts commit 18df01eb5498c954044f96c346026da0238d2e61. Backed out for devtools breakage.
-rw-r--r--netwerk/base/RequestContextService.cpp16
-rw-r--r--netwerk/base/nsIRequestContext.idl6
-rw-r--r--netwerk/protocol/http/nsHttpHandler.cpp12
-rw-r--r--netwerk/protocol/http/nsHttpHandler.h1
4 files changed, 34 insertions, 1 deletions
diff --git a/netwerk/base/RequestContextService.cpp b/netwerk/base/RequestContextService.cpp
index 362c9ea476..7edda18457 100644
--- a/netwerk/base/RequestContextService.cpp
+++ b/netwerk/base/RequestContextService.cpp
@@ -33,6 +33,7 @@ private:
char mCID[NSID_LENGTH];
Atomic<uint32_t> mBlockingTransactionCount;
nsAutoPtr<SpdyPushCache> mSpdyCache;
+ nsCString mUserAgentOverride;
};
NS_IMPL_ISUPPORTS(RequestContext, nsIRequestContext)
@@ -94,6 +95,21 @@ RequestContext::GetID(nsID *outval)
return NS_OK;
}
+NS_IMETHODIMP
+RequestContext::GetUserAgentOverride(nsACString& aUserAgentOverride)
+{
+ aUserAgentOverride = mUserAgentOverride;
+ return NS_OK;
+}
+
+NS_IMETHODIMP
+RequestContext::SetUserAgentOverride(const nsACString& aUserAgentOverride)
+{
+ mUserAgentOverride = aUserAgentOverride;
+ return NS_OK;
+}
+
+
//nsIRequestContextService
RequestContextService *RequestContextService::sSelf = nullptr;
diff --git a/netwerk/base/nsIRequestContext.idl b/netwerk/base/nsIRequestContext.idl
index a582752169..b40ba7d18f 100644
--- a/netwerk/base/nsIRequestContext.idl
+++ b/netwerk/base/nsIRequestContext.idl
@@ -24,7 +24,7 @@ class SpdyPushCache;
*
* This used to be known as nsILoadGroupConnectionInfo and nsISchedulingContext.
*/
-[scriptable, uuid(a1b5c243-ab9b-41a7-a208-f8a9c0c43dc2)]
+[scriptable, uuid(658e3e6e-8633-4b1a-8d66-fa9f72293e63)]
interface nsIRequestContext : nsISupports
{
/**
@@ -58,6 +58,10 @@ interface nsIRequestContext : nsISupports
*/
[noscript] attribute SpdyPushCachePtr spdyPushCache;
+ /**
+ * This holds a cached value of the user agent override.
+ */
+ [noscript] attribute ACString userAgentOverride;
};
/**
diff --git a/netwerk/protocol/http/nsHttpHandler.cpp b/netwerk/protocol/http/nsHttpHandler.cpp
index 0ae5891517..7a29e041ba 100644
--- a/netwerk/protocol/http/nsHttpHandler.cpp
+++ b/netwerk/protocol/http/nsHttpHandler.cpp
@@ -685,6 +685,11 @@ nsHttpHandler::BuildAppVersion()
const nsAFlatCString &
nsHttpHandler::UserAgent()
{
+ if (mUserAgentOverride) {
+ LOG(("using general.useragent.override : %s\n", mUserAgentOverride.get()));
+ return mUserAgentOverride;
+ }
+
if (mUserAgentIsDirty) {
BuildUserAgent();
mUserAgentIsDirty = false;
@@ -986,6 +991,13 @@ nsHttpHandler::PrefsChanged(nsIPrefBranch *prefs, const char *pref)
mUserAgentIsDirty = true;
}
+ // general.useragent.override
+ if (PREF_CHANGED(UA_PREF("override"))) {
+ prefs->GetCharPref(UA_PREF("override"),
+ getter_Copies(mUserAgentOverride));
+ mUserAgentIsDirty = true;
+ }
+
//
// HTTP options
//
diff --git a/netwerk/protocol/http/nsHttpHandler.h b/netwerk/protocol/http/nsHttpHandler.h
index 549b822057..4f632e0784 100644
--- a/netwerk/protocol/http/nsHttpHandler.h
+++ b/netwerk/protocol/http/nsHttpHandler.h
@@ -506,6 +506,7 @@ private:
nsCString mDeviceModelId;
nsCString mUserAgent;
+ nsXPIDLCString mUserAgentOverride;
bool mUserAgentIsDirty; // true if mUserAgent should be rebuilt
bool mAcceptLanguagesIsDirty;