155 lines
7.3 KiB
Diff
155 lines
7.3 KiB
Diff
From: csagan5 <32685696+csagan5@users.noreply.github.com>
|
|
Date: Thu, 22 Jul 2021 23:10:52 +0200
|
|
Subject: Client hints overrides
|
|
|
|
Disable critical client hints and network early hints
|
|
Use Google Chrome branding for client hints
|
|
|
|
License: GPL-3.0-only - https://spdx.org/licenses/GPL-3.0-only.html
|
|
---
|
|
components/embedder_support/user_agent_utils.cc | 4 +---
|
|
content/browser/client_hints/client_hints.cc | 3 ++-
|
|
content/browser/loader/navigation_url_loader_impl.cc | 5 +++++
|
|
.../content/common/features_cc/Client-hints-overrides.inc | 1 +
|
|
.../public/cpp/features_cc/Client-hints-overrides.inc | 1 +
|
|
net/http/http_network_transaction.cc | 1 +
|
|
services/network/public/cpp/client_hints.cc | 1 +
|
|
third_party/blink/common/client_hints/client_hints.cc | 1 +
|
|
.../blink/common/client_hints/enabled_client_hints.cc | 4 +++-
|
|
.../blink/renderer/platform/runtime_enabled_features.json5 | 4 ++--
|
|
10 files changed, 18 insertions(+), 7 deletions(-)
|
|
create mode 100644 cromite_flags/content/common/features_cc/Client-hints-overrides.inc
|
|
create mode 100644 cromite_flags/services/network/public/cpp/features_cc/Client-hints-overrides.inc
|
|
|
|
diff --git a/components/embedder_support/user_agent_utils.cc b/components/embedder_support/user_agent_utils.cc
|
|
--- a/components/embedder_support/user_agent_utils.cc
|
|
+++ b/components/embedder_support/user_agent_utils.cc
|
|
@@ -187,9 +187,7 @@ const blink::UserAgentBrandList GetUserAgentBrandList(
|
|
bool parse_result = base::StringToInt(major_version, &major_version_number);
|
|
DCHECK(parse_result);
|
|
absl::optional<std::string> brand;
|
|
-#if !BUILDFLAG(CHROMIUM_BRANDING)
|
|
- brand = version_info::GetProductName();
|
|
-#endif
|
|
+ brand = "Google Chrome";
|
|
absl::optional<std::string> maybe_brand_override =
|
|
base::GetFieldTrialParamValueByFeature(features::kGreaseUACH,
|
|
"brand_override");
|
|
diff --git a/content/browser/client_hints/client_hints.cc b/content/browser/client_hints/client_hints.cc
|
|
--- a/content/browser/client_hints/client_hints.cc
|
|
+++ b/content/browser/client_hints/client_hints.cc
|
|
@@ -516,7 +516,8 @@ void AddPrefersReducedTransparencyHeader(net::HttpRequestHeaders* headers,
|
|
: network::kPrefersReducedTransparencyNoPreference);
|
|
}
|
|
|
|
-bool IsValidURLForClientHints(const url::Origin& origin) {
|
|
+bool IsValidURLForClientHints(const url::Origin& origin) { // disabled in Bromite
|
|
+ if ((true)) return false;
|
|
return network::IsOriginPotentiallyTrustworthy(origin);
|
|
}
|
|
|
|
diff --git a/content/browser/loader/navigation_url_loader_impl.cc b/content/browser/loader/navigation_url_loader_impl.cc
|
|
--- a/content/browser/loader/navigation_url_loader_impl.cc
|
|
+++ b/content/browser/loader/navigation_url_loader_impl.cc
|
|
@@ -1063,6 +1063,11 @@ void NavigationURLLoaderImpl::OnAcceptCHFrameReceived(
|
|
return;
|
|
}
|
|
|
|
+ if (!base::FeatureList::IsEnabled(network::features::kAcceptCHFrame)) {
|
|
+ std::move(callback).Run(net::OK);
|
|
+ return;
|
|
+ }
|
|
+
|
|
LogAcceptCHFrameStatus(AcceptCHFrameRestart::kFramePresent);
|
|
|
|
// Given that this is happening in the middle of navigation, there should
|
|
diff --git a/cromite_flags/content/common/features_cc/Client-hints-overrides.inc b/cromite_flags/content/common/features_cc/Client-hints-overrides.inc
|
|
new file mode 100644
|
|
--- /dev/null
|
|
+++ b/cromite_flags/content/common/features_cc/Client-hints-overrides.inc
|
|
@@ -0,0 +1 @@
|
|
+SET_CROMITE_FEATURE_DISABLED(kCriticalClientHint);
|
|
diff --git a/cromite_flags/services/network/public/cpp/features_cc/Client-hints-overrides.inc b/cromite_flags/services/network/public/cpp/features_cc/Client-hints-overrides.inc
|
|
new file mode 100644
|
|
--- /dev/null
|
|
+++ b/cromite_flags/services/network/public/cpp/features_cc/Client-hints-overrides.inc
|
|
@@ -0,0 +1 @@
|
|
+SET_CROMITE_FEATURE_DISABLED(kAcceptCHFrame);
|
|
diff --git a/net/http/http_network_transaction.cc b/net/http/http_network_transaction.cc
|
|
--- a/net/http/http_network_transaction.cc
|
|
+++ b/net/http/http_network_transaction.cc
|
|
@@ -100,6 +100,7 @@ const size_t kMaxRestarts = 32;
|
|
|
|
// Returns true when Early Hints are allowed on the given protocol.
|
|
bool EarlyHintsAreAllowedOn(HttpResponseInfo::ConnectionInfo connection_info) {
|
|
+ if ((true)) return false;
|
|
switch (connection_info) {
|
|
case HttpResponseInfo::ConnectionInfo::CONNECTION_INFO_HTTP0_9:
|
|
case HttpResponseInfo::ConnectionInfo::CONNECTION_INFO_HTTP1_0:
|
|
diff --git a/services/network/public/cpp/client_hints.cc b/services/network/public/cpp/client_hints.cc
|
|
--- a/services/network/public/cpp/client_hints.cc
|
|
+++ b/services/network/public/cpp/client_hints.cc
|
|
@@ -120,6 +120,7 @@ const DecodeMap& GetDecodeMap() {
|
|
|
|
absl::optional<std::vector<network::mojom::WebClientHintsType>>
|
|
ParseClientHintsHeader(const std::string& header) {
|
|
+ if ((true)) return absl::nullopt;
|
|
// Accept-CH is an sh-list of tokens; see:
|
|
// https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-header-structure-19#section-3.1
|
|
absl::optional<net::structured_headers::List> maybe_list =
|
|
diff --git a/third_party/blink/common/client_hints/client_hints.cc b/third_party/blink/common/client_hints/client_hints.cc
|
|
--- a/third_party/blink/common/client_hints/client_hints.cc
|
|
+++ b/third_party/blink/common/client_hints/client_hints.cc
|
|
@@ -105,6 +105,7 @@ const PolicyFeatureToClientHintMap& GetPolicyFeatureToClientHintMap() {
|
|
}
|
|
|
|
bool IsClientHintSentByDefault(network::mojom::WebClientHintsType type) {
|
|
+ if ((true)) return false;
|
|
switch (type) {
|
|
case network::mojom::WebClientHintsType::kSaveData:
|
|
case network::mojom::WebClientHintsType::kUA:
|
|
diff --git a/third_party/blink/common/client_hints/enabled_client_hints.cc b/third_party/blink/common/client_hints/enabled_client_hints.cc
|
|
--- a/third_party/blink/common/client_hints/enabled_client_hints.cc
|
|
+++ b/third_party/blink/common/client_hints/enabled_client_hints.cc
|
|
@@ -15,6 +15,7 @@ namespace {
|
|
using ::network::mojom::WebClientHintsType;
|
|
|
|
bool IsDisabledByFeature(const WebClientHintsType type) {
|
|
+ if ((true)) return true;
|
|
switch (type) {
|
|
case WebClientHintsType::kUA:
|
|
case WebClientHintsType::kUAArch:
|
|
@@ -99,7 +100,7 @@ bool IsDisabledByFeature(const WebClientHintsType type) {
|
|
} // namespace
|
|
|
|
bool EnabledClientHints::IsEnabled(const WebClientHintsType type) const {
|
|
- return enabled_types_[static_cast<int>(type)];
|
|
+ return false;
|
|
}
|
|
|
|
void EnabledClientHints::SetIsEnabled(const WebClientHintsType type,
|
|
@@ -110,6 +111,7 @@ void EnabledClientHints::SetIsEnabled(const WebClientHintsType type,
|
|
|
|
std::vector<WebClientHintsType> EnabledClientHints::GetEnabledHints() const {
|
|
std::vector<WebClientHintsType> hints;
|
|
+ if ((true)) return hints;
|
|
for (const auto& elem : network::GetClientHintToNameMap()) {
|
|
const auto& type = elem.first;
|
|
if (IsEnabled(type))
|
|
diff --git a/third_party/blink/renderer/platform/runtime_enabled_features.json5 b/third_party/blink/renderer/platform/runtime_enabled_features.json5
|
|
--- a/third_party/blink/renderer/platform/runtime_enabled_features.json5
|
|
+++ b/third_party/blink/renderer/platform/runtime_enabled_features.json5
|
|
@@ -4019,8 +4019,8 @@
|
|
public: true,
|
|
},
|
|
{
|
|
- name: "UserAgentClientHint",
|
|
- status: "stable",
|
|
+ name: "UserAgentClientHint", // always disabled
|
|
+ status: "experimental", // in bromite
|
|
},
|
|
{
|
|
// https://chromestatus.com/feature/5132477781245952
|
|
--
|
|
2.25.1
|