Skip to content

Commit e33aedd

Browse files
Add flag for referrer header directive (#1949)
* Add flag for referrer header directive * Update add-flag-for-referrer-header.patch for version 102.0.5005.61 Co-authored-by: networkException <git@nwex.de>
1 parent 970f6b1 commit e33aedd

File tree

3 files changed

+68
-0
lines changed

3 files changed

+68
-0
lines changed

docs/flags.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ If a switch requires a value, you must specify it with an `=` sign; e.g. flag `-
2222
`--max-connections-per-host` | (from Bromite) Configure the maximum allowed connections per host. Valid values are `6` and `15`
2323
`--omnibox-autocomplete-filtering` | Restrict omnibox autocomplete results to a combination of search suggestions (if enabled), bookmarks, and internal chrome pages. Accepts `search`, `search-bookmarks`, `search-chrome`, and `search-bookmarks-chrome`.
2424
`--popups-to-tabs` | Makes popups open in new tabs.
25+
`--referrer-directive` | Allows setting a custom directive for referrer headers. Accepts `nocrossorigin`, `minimal`, and `noreferrers`. The no cross-origin referrer option removes all cross-origin referrers, the minimal option removes all cross-origin referrers and strips same-origin referrers down to the origin, and the no referrers option removes all referrers.
2526

2627
- ### Available only on desktop
2728

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
--- a/chrome/browser/ungoogled_flag_choices.h
2+
+++ b/chrome/browser/ungoogled_flag_choices.h
3+
@@ -79,4 +79,16 @@ const FeatureEntry::Choice kTabHoverCard
4+
"tab-hover-cards",
5+
"tooltip"},
6+
};
7+
+const FeatureEntry::Choice kReferrerDirective[] = {
8+
+ {flags_ui::kGenericExperimentChoiceDefault, "", ""},
9+
+ {"No cross-origin referrer",
10+
+ "referrer-directive",
11+
+ "nocrossorigin"},
12+
+ {"Minimal referrer",
13+
+ "referrer-directive",
14+
+ "minimal"},
15+
+ {"No referrers",
16+
+ "referrer-directive",
17+
+ "noreferrers"},
18+
+};
19+
#endif // CHROME_BROWSER_UNGOOGLED_FLAG_CHOICES_H_
20+
--- a/chrome/browser/ungoogled_flag_entries.h
21+
+++ b/chrome/browser/ungoogled_flag_entries.h
22+
@@ -88,4 +88,8 @@
23+
"Hide tab close buttons",
24+
"Hides the close buttons on tabs. ungoogled-chromium flag.",
25+
kOsDesktop, SINGLE_VALUE_TYPE("hide-tab-close-buttons")},
26+
+ {"referrer-directive",
27+
+ "Referrer directive",
28+
+ "Allows setting a custom directive for referrer headers. The no cross-origin referrer option removes all cross-origin referrers, the minimal option removes all cross-origin referrers and strips same-origin referrers down to the origin, and the no referrers option removes all referrers. ungoogled-chromium flag.",
29+
+ kOsAll, MULTI_VALUE_TYPE(kReferrerDirective)},
30+
#endif // CHROME_BROWSER_UNGOOGLED_FLAG_ENTRIES_H_
31+
--- a/content/browser/utility_process_host.cc
32+
+++ b/content/browser/utility_process_host.cc
33+
@@ -225,6 +225,7 @@ bool UtilityProcessHost::StartProcess()
34+
35+
// Browser command-line switches to propagate to the utility process.
36+
static const char* const kSwitchNames[] = {
37+
+ "referrer-directive",
38+
network::switches::kAdditionalTrustTokenKeyCommitments,
39+
network::switches::kForceEffectiveConnectionType,
40+
network::switches::kHostResolverRules,
41+
--- a/services/network/network_service_network_delegate.cc
42+
+++ b/services/network/network_service_network_delegate.cc
43+
@@ -7,6 +7,7 @@
44+
#include <string>
45+
46+
#include "base/bind.h"
47+
+#include "base/command_line.h"
48+
#include "base/debug/dump_without_crashing.h"
49+
#include "base/strings/utf_string_conversions.h"
50+
#include "build/build_config.h"
51+
@@ -62,6 +63,15 @@ void NetworkServiceNetworkDelegate::Mayb
52+
return;
53+
}
54+
55+
+ if (base::CommandLine::ForCurrentProcess()->HasSwitch("referrer-directive")) {
56+
+ std::string option = base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII("referrer-directive");
57+
+ if (!url::IsSameOriginWith(effective_url, GURL(request->referrer())) || option == "noreferrers")
58+
+ request->SetReferrer(std::string());
59+
+ if (option == "minimal")
60+
+ request->SetReferrer(url::Origin::Create(GURL(request->referrer())).GetURL().spec());
61+
+ return;
62+
+ }
63+
+
64+
if (base::FeatureList::IsEnabled(
65+
net::features::kCapReferrerToOriginOnCrossOrigin)) {
66+
if (!url::IsSameOriginWith(effective_url, GURL(request->referrer()))) {

patches/series

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ extra/ungoogled-chromium/add-flag-for-custom-ntp.patch
9393
extra/ungoogled-chromium/add-flag-for-tab-hover-cards.patch
9494
extra/ungoogled-chromium/add-flag-to-hide-tab-close-buttons.patch
9595
extra/ungoogled-chromium/disable-remote-optimization-guide.patch
96+
extra/ungoogled-chromium/add-flag-for-referrer-header.patch
9697
extra/bromite/fingerprinting-flags-client-rects-and-measuretext.patch
9798
extra/bromite/flag-max-connections-per-host.patch
9899
extra/bromite/flag-fingerprinting-canvas-image-data-noise.patch

0 commit comments

Comments
 (0)