|
| 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()))) { |
0 commit comments