b0036ea43a
* chore: bump chromium in DEPS to 107.0.5286.0 * 3866335: media: Rename KeySystemProperties to KeySystemInfo - file renaming https://chromium-review.googlesource.com/c/chromium/src/+/3866335 * 3864686: [PA] Introduce *Scan buildflag https://chromium-review.googlesource.com/c/chromium/src/+/3864686 * chore: fixup patch indices * 3849359: Remove unused PrefValueStore::Delegate https://chromium-review.googlesource.com/c/chromium/src/+/3849359 * 3873005: [CodeHealth] Modernising extensions Tab utils https://chromium-review.googlesource.com/c/chromium/src/+/3873005 * 3846595: Auto-select PipeWire target once selection is made https://chromium-review.googlesource.com/c/chromium/src/+/3846595 * 3826169: [json-schema-compiler] Support abs::optional<bool> https://chromium-review.googlesource.com/c/chromium/src/+/3826169 * fixup! Remove unused PrefValueStore::Delegate Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> Co-authored-by: deepak1556 <hop2deep@gmail.com>
90 lines
4.5 KiB
Diff
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 14c71cc69388da46f62d9835e2a06fef0870da02..9481ea08401ae29ae9c1d960491b05b364257cc8 100644
|
|
--- a/net/url_request/static_http_user_agent_settings.h
|
|
+++ b/net/url_request/static_http_user_agent_settings.h
|
|
@@ -30,13 +30,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_;
|
|
};
|
|
|
|
} // namespace net
|
|
diff --git a/services/network/network_context.cc b/services/network/network_context.cc
|
|
index 8c29d366ec2c3cc61ec121163e3549472964653c..3363d15a38cb1849a0ccd11077f2e7b4ef9c8865 100644
|
|
--- a/services/network/network_context.cc
|
|
+++ b/services/network/network_context.cc
|
|
@@ -1412,6 +1412,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 572f555b32eb4e38bdcd23b4725c3b4df38316ad..56d27025f215910c40f5dabc41ac61e0b46df784 100644
|
|
--- a/services/network/network_context.h
|
|
+++ b/services/network/network_context.h
|
|
@@ -300,6 +300,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;
|
|
void SetEnablePreconnect(bool enable_preconnect) override;
|
|
diff --git a/services/network/public/mojom/network_context.mojom b/services/network/public/mojom/network_context.mojom
|
|
index e1685a8406794f855fe7f87ec0ecf1f11fb57e21..fce85b23ecdc4b6736d37e4fa976905bf6914e13 100644
|
|
--- a/services/network/public/mojom/network_context.mojom
|
|
+++ b/services/network/public/mojom/network_context.mojom
|
|
@@ -1106,6 +1106,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 1e90e50caa90e30b082998ade4b9bbf249cc93f2..2befed3d50e9569f7ba86db5858444843bd5dd2a 100644
|
|
--- a/services/network/test/test_network_context.h
|
|
+++ b/services/network/test/test_network_context.h
|
|
@@ -134,6 +134,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 {}
|
|
void SetEnablePreconnect(bool enable_preconnect) override {}
|