add-flag-to-change-http-accept-header.patch 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. --- a/chrome/browser/ungoogled_flag_entries.h
  2. +++ b/chrome/browser/ungoogled_flag_entries.h
  3. @@ -92,4 +92,8 @@
  4. "Disable GREASE for TLS",
  5. "Turn off GREASE (Generate Random Extensions And Sustain Extensibility) for TLS connections. ungoogled-chromium flag.",
  6. kOsAll, SINGLE_VALUE_TYPE("disable-grease-tls")},
  7. + {"http-accept-header",
  8. + "Custom HTTP Accept Header",
  9. + "Set a custom value for the Accept header which is sent by the browser with every HTTP request. (e.g. `text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8`). ungoogled-chromium flag.",
  10. + kOsAll, ORIGIN_LIST_VALUE_TYPE("http-accept-header", "")},
  11. #endif // CHROME_BROWSER_UNGOOGLED_FLAG_ENTRIES_H_
  12. --- a/components/flags_ui/flags_state.cc
  13. +++ b/components/flags_ui/flags_state.cc
  14. @@ -223,6 +223,7 @@ std::string GetCombinedOriginListValue(c
  15. const std::string new_value =
  16. flags_storage.GetOriginListFlag(internal_entry_name);
  17. if (command_line_switch == "custom-ntp") return existing_value.empty() ? new_value : existing_value;
  18. + if (command_line_switch == "http-accept-header") return existing_value.empty() ? new_value : existing_value;
  19. return CombineAndSanitizeOriginLists(existing_value, new_value);
  20. }
  21. @@ -462,6 +463,7 @@ void FlagsState::SetOriginListFlag(const
  22. FlagsStorage* flags_storage) {
  23. const std::string new_value =
  24. internal_name == "custom-ntp" ? value :
  25. + internal_name == "http-accept-header" ? value :
  26. CombineAndSanitizeOriginLists(std::string(), value);
  27. flags_storage->SetOriginListFlag(internal_name, new_value);
  28. --- a/content/public/browser/frame_accept_header.cc
  29. +++ b/content/public/browser/frame_accept_header.cc
  30. @@ -4,6 +4,7 @@
  31. #include "content/public/browser/frame_accept_header.h"
  32. +#include "base/command_line.h"
  33. #include "content/browser/web_package/signed_exchange_consts.h"
  34. #include "content/browser/web_package/signed_exchange_utils.h"
  35. #include "content/common/content_constants_internal.h"
  36. @@ -12,6 +13,9 @@ namespace content {
  37. std::string FrameAcceptHeaderValue(bool allow_sxg_responses,
  38. BrowserContext* browser_context) {
  39. + if (base::CommandLine::ForCurrentProcess()->HasSwitch("http-accept-header"))
  40. + return base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII("http-accept-header");
  41. +
  42. std::string header_value = kFrameAcceptHeaderValue;
  43. if (allow_sxg_responses &&