electron/patches/chromium/expose_setuseragent_on_networkcontext.patch
Electron Bot a4de915b74
chore: bump chromium to d66c2e32380bf5d1eb5e1fe37faef (master) (#23791)
* chore: bump chromium in DEPS to db7d7b3e7cb2bc925f2abfde526280cfdfc21a41

* Update patches

* chore: bump chromium in DEPS to 5613e1b99a44fcbe22f3910f803ca76903a77ec1

* Update patches

* Network service: Remove primary_network_context bool.

https://chromium-review.googlesource.com/c/chromium/src/+/2204678

* WebContentsObserver now implements OnRendererResponsive

https://chromium-review.googlesource.com/c/chromium/src/+/2211066

* update patches

* Fixup printing patch

* chore: bump chromium in DEPS to e387b972cdd7160c416fa6c64a724e2258aa0218

* update patches

* [printing] Move PrintHostMsg_DidPrintContent_Params to print.mojom

https://chromium-review.googlesource.com/c/chromium/src/+/2212110

* [XProto] Move items from ::x11::XProto to ::x11

https://chromium-review.googlesource.com/c/chromium/src/+/2218476

* revert Add IChromeAccessible

This was added in https://chromium-review.googlesource.com/c/chromium/src/+/2206224 but it breaks WOA builds because third_party/win_build_output/midl/ui/accessibility/platform/arm64 does not exist. The link above says that the new interface is behind a feature flag which is disabled by default so it is safe to remove for now.

* rebaseline ichromeaccessible for Windows arm64

This patch will not be needed once we get the next roll.

* Update to 1b9e01844e8bf1aaafc4a52c0c62af7f56d9637b to get arm64 fix

* update patches

* chore: bump chromium in DEPS to 096aefa04092ea00f7b68d8d19345883f20db3c3

* chore: bump chromium in DEPS to a524a45ffd1d6fd46a7a86138fe2b22df5b6651a

* chore: update patches

* Window Placement: Gate cross-screen fullscreen behavior on permission

https://chromium-review.googlesource.com/c/chromium/src/+/2203268

* chore: add spec for https://crbug.com/1085836

* chore: bump chromium in DEPS to ff6c4f4b826d66c2e32380bf5d1eb5e1fe37faef

* update patches

Co-authored-by: John Kleinschmidt <jkleinsc@github.com>
Co-authored-by: Electron Bot <anonymous@electronjs.org>
Co-authored-by: deepak1556 <hop2deep@gmail.com>
2020-06-01 16:34:34 -04:00

90 lines
4.5 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jeremy Apthorp <nornagon@nornagon.net>
Date: Wed, 28 Aug 2019 12:21:25 -0700
Subject: expose SetUserAgent on NetworkContext
Applying
https://chromium-review.googlesource.com/c/chromium/src/+/1585083 before
it's merged. There may end up being a better way of doing this, or the
patch may be merged upstream, at which point this patch should be
removed.
diff --git a/net/url_request/static_http_user_agent_settings.h b/net/url_request/static_http_user_agent_settings.h
index 0ccfe130f00ec3b6c75cd8ee04d5a2777e1fd00c..653829457d58bf92057cc36aa8a289703d8b0577 100644
--- a/net/url_request/static_http_user_agent_settings.h
+++ b/net/url_request/static_http_user_agent_settings.h
@@ -26,13 +26,17 @@ class NET_EXPORT StaticHttpUserAgentSettings : public HttpUserAgentSettings {
accept_language_ = new_accept_language;
}
+ void set_user_agent(const std::string& new_user_agent) {
+ user_agent_ = new_user_agent;
+ }
+
// HttpUserAgentSettings implementation
std::string GetAcceptLanguage() const override;
std::string GetUserAgent() const override;
private:
std::string accept_language_;
- const std::string user_agent_;
+ std::string user_agent_;
DISALLOW_COPY_AND_ASSIGN(StaticHttpUserAgentSettings);
};
diff --git a/services/network/network_context.cc b/services/network/network_context.cc
index 5f2feba6f09327088badc56d76872d2c3920866f..803315067b4ceccd3ceb3c97ea186b5de7f64f1f 100644
--- a/services/network/network_context.cc
+++ b/services/network/network_context.cc
@@ -1009,6 +1009,13 @@ void NetworkContext::SetNetworkConditions(
std::move(network_conditions));
}
+void NetworkContext::SetUserAgent(const std::string& new_user_agent) {
+ // This may only be called on NetworkContexts created with a constructor that
+ // calls ApplyContextParamsToBuilder.
+ DCHECK(user_agent_settings_);
+ user_agent_settings_->set_user_agent(new_user_agent);
+}
+
void NetworkContext::SetAcceptLanguage(const std::string& new_accept_language) {
// This may only be called on NetworkContexts created with the constructor
// that calls MakeURLRequestContext().
diff --git a/services/network/network_context.h b/services/network/network_context.h
index 0bc906026e988819f66554749c8d6aa2f2accc49..b76ab13a2c02b5d61ff931564af743260fbeeae8 100644
--- a/services/network/network_context.h
+++ b/services/network/network_context.h
@@ -235,6 +235,7 @@ class COMPONENT_EXPORT(NETWORK_SERVICE) NetworkContext
void CloseIdleConnections(CloseIdleConnectionsCallback callback) override;
void SetNetworkConditions(const base::UnguessableToken& throttling_profile_id,
mojom::NetworkConditionsPtr conditions) override;
+ void SetUserAgent(const std::string& new_user_agent) override;
void SetAcceptLanguage(const std::string& new_accept_language) override;
void SetEnableReferrers(bool enable_referrers) override;
#if defined(OS_CHROMEOS)
diff --git a/services/network/public/mojom/network_context.mojom b/services/network/public/mojom/network_context.mojom
index 248108042a5be07a3ddf6a11880ddbf04470d673..2001e6202cf61d1c70bf81334b62d0502ea8c9ba 100644
--- a/services/network/public/mojom/network_context.mojom
+++ b/services/network/public/mojom/network_context.mojom
@@ -1031,6 +1031,9 @@ interface NetworkContext {
SetNetworkConditions(mojo_base.mojom.UnguessableToken throttling_profile_id,
NetworkConditions? conditions);
+ // Updates the user agent to be used for requests.
+ SetUserAgent(string new_user_agent);
+
// Updates the Accept-Language header to be used for requests.
SetAcceptLanguage(string new_accept_language);
diff --git a/services/network/test/test_network_context.h b/services/network/test/test_network_context.h
index eff66d994c5c416a672405226172e640b65278ff..34e8182ad2b33598d7c91a63202516c5b7e42257 100644
--- a/services/network/test/test_network_context.h
+++ b/services/network/test/test_network_context.h
@@ -105,6 +105,7 @@ class TestNetworkContext : public mojom::NetworkContext {
void CloseIdleConnections(CloseIdleConnectionsCallback callback) override {}
void SetNetworkConditions(const base::UnguessableToken& throttling_profile_id,
mojom::NetworkConditionsPtr conditions) override {}
+ void SetUserAgent(const std::string& new_user_agent) override {}
void SetAcceptLanguage(const std::string& new_accept_language) override {}
void SetEnableReferrers(bool enable_referrers) override {}
#if defined(OS_CHROMEOS)