Skip to content

Commit

Permalink
Client hints overrides: simplifies the patch and enables sending in t…
Browse files Browse the repository at this point in the history
…he network
  • Loading branch information
uazo committed Sep 2, 2024
1 parent 071c46d commit ccbfff0
Showing 1 changed file with 32 additions and 46 deletions.
78 changes: 32 additions & 46 deletions build/patches/Client-hints-overrides.patch
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,22 @@ 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 | 17 +++++++++++------
.../loader/navigation_url_loader_impl.cc | 5 +++++
.../about_flags_cc/Client-hints-overrides.inc | 9 +++++++++
.../features_cc/Client-hints-overrides.inc | 1 +
.../cpp/features_cc/Client-hints-overrides.inc | 1 +
net/http/http_network_transaction.cc | 1 +
services/network/public/cpp/client_hints.cc | 1 +
.../blink/common/client_hints/client_hints.cc | 6 ++++--
.../common/client_hints/enabled_client_hints.cc | 4 +++-
.../blink/renderer/core/frame/navigator_ua.idl | 4 +++-
.../renderer/core/frame/navigator_ua_data.cc | 1 +
.../renderer/core/frame/navigator_ua_data.idl | 5 ++++-
.../renderer/core/loader/base_fetch_context.cc | 6 ++++--
.../platform/runtime_enabled_features.json5 | 5 +++++
15 files changed, 54 insertions(+), 16 deletions(-)
components/embedder_support/user_agent_utils.cc | 4 +---
content/browser/client_hints/client_hints.cc | 15 ++++++++++-----
.../browser/loader/navigation_url_loader_impl.cc | 5 +++++
.../about_flags_cc/Client-hints-overrides.inc | 9 +++++++++
.../common/features_cc/Client-hints-overrides.inc | 1 +
.../cpp/features_cc/Client-hints-overrides.inc | 1 +
net/http/http_network_transaction.cc | 1 +
services/network/public/cpp/client_hints.cc | 1 +
.../blink/common/client_hints/client_hints.cc | 6 ++++--
.../common/client_hints/enabled_client_hints.cc | 6 ++++++
.../blink/renderer/core/frame/navigator_ua.idl | 4 +++-
.../renderer/core/frame/navigator_ua_data.cc | 1 +
.../renderer/core/frame/navigator_ua_data.idl | 5 ++++-
.../renderer/core/loader/base_fetch_context.cc | 6 ++++--
.../platform/runtime_enabled_features.json5 | 5 +++++
15 files changed, 56 insertions(+), 14 deletions(-)
create mode 100644 cromite_flags/chrome/browser/about_flags_cc/Client-hints-overrides.inc
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
Expand Down Expand Up @@ -52,17 +52,7 @@ diff --git a/content/browser/client_hints/client_hints.cc b/content/browser/clie
#include "ui/display/display.h"
#include "ui/display/screen.h"
#include "url/origin.h"
@@ -521,7 +522,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);
}

@@ -722,7 +724,8 @@ void UpdateNavigationRequestClientUaHeadersImpl(
@@ -722,7 +723,8 @@ void UpdateNavigationRequestClientUaHeadersImpl(
// value, disable them. This overwrites previous decision from UI.
disable_due_to_custom_ua = !ua_metadata.has_value();
}
Expand All @@ -72,7 +62,7 @@ diff --git a/content/browser/client_hints/client_hints.cc b/content/browser/clie
if (!disable_due_to_custom_ua) {
if (!ua_metadata.has_value())
ua_metadata = delegate->GetUserAgentMetadata();
@@ -904,10 +907,12 @@ void AddRequestClientHintsHeaders(
@@ -904,10 +906,12 @@ void AddRequestClientHintsHeaders(
AddEctHeader(headers, network_quality_tracker, url);
}

Expand All @@ -89,6 +79,14 @@ diff --git a/content/browser/client_hints/client_hints.cc b/content/browser/clie

if (ShouldAddClientHint(data, WebClientHintsType::kPrefersColorScheme)) {
AddPrefersColorSchemeHeader(headers, frame_tree_node);
@@ -1001,6 +1005,7 @@ ParseAndPersistAcceptCHForNavigation(
BrowserContext* context,
ClientHintsControllerDelegate* delegate,
FrameTreeNode* frame_tree_node) {
+ if ((true)) return std::nullopt;
DCHECK_CURRENTLY_ON(BrowserThread::UI);
DCHECK(context);
DCHECK(parsed_headers);
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
Expand Down Expand Up @@ -181,31 +179,19 @@ diff --git a/third_party/blink/common/client_hints/client_hints.cc b/third_party
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 {
@@ -15,6 +15,12 @@ namespace {
using ::network::mojom::WebClientHintsType;

bool IsDisabledByFeature(const WebClientHintsType type) {
+ if (type == WebClientHintsType::kUA ||
+ type == WebClientHintsType::kUAMobile ||
+ type == WebClientHintsType::kUAPlatform) {
+ return false;
+ }
+ if ((true)) return true;
switch (type) {
case WebClientHintsType::kUA:
case WebClientHintsType::kUAArch:
@@ -96,7 +97,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,
@@ -107,6 +108,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/core/frame/navigator_ua.idl b/third_party/blink/renderer/core/frame/navigator_ua.idl
--- a/third_party/blink/renderer/core/frame/navigator_ua.idl
+++ b/third_party/blink/renderer/core/frame/navigator_ua.idl
Expand Down

0 comments on commit ccbfff0

Please sign in to comment.