Skip to content

Instantly share code, notes, and snippets.

@fmarier
Last active December 8, 2022 01:03
Show Gist options
  • Save fmarier/6d2ad0fa3da798375eb82a112783b8e9 to your computer and use it in GitHub Desktop.
Save fmarier/6d2ad0fa3da798375eb82a112783b8e9 to your computer and use it in GitHub Desktop.
commit 821011f88341c997a1f8e365cbbb99d3656a0342
Author: Francois Marier <[email protected]>
Date: Thu Nov 24 12:21:38 2022 -0800
Hide Twitter's tracking parameter from Service Workers (fixes brave/brave-browser#26910)
WIP: DO NOT MERGE!
diff --git a/browser/net/brave_site_hacks_network_delegate_helper.cc b/browser/net/brave_site_hacks_network_delegate_helper.cc
index ccda9c5cfa..a5ad26a583 100644
--- a/browser/net/brave_site_hacks_network_delegate_helper.cc
+++ b/browser/net/brave_site_hacks_network_delegate_helper.cc
@@ -47,13 +47,16 @@ void ApplyPotentialQueryStringFilter(std::shared_ptr<BraveRequestInfo> ctx) {
// Same-site redirects are exempted.
return;
}
- } else if (ctx->initiator_url.is_valid() &&
- net::registry_controlled_domains::SameDomainOrHost(
+ } else if (ctx->initiator_url.is_valid()) {
+ LOG(ERROR) << "[1] SITE_HACKS URL=" << ctx->request_url
+ << "; INITIATOR_URL=" << ctx->initiator_url;
+ if (net::registry_controlled_domains::SameDomainOrHost(
ctx->initiator_url, ctx->request_url,
net::registry_controlled_domains::
INCLUDE_PRIVATE_REGISTRIES)) {
- // Same-site requests are exempted.
- return;
+ // Same-site requests are exempted.
+ return;
+ }
}
auto filtered_url = ApplyQueryFilter(ctx->request_url);
if (filtered_url.has_value()) {
diff --git a/patches/content-browser-loader-navigation_url_loader_impl.cc.patch b/patches/content-browser-loader-navigation_url_loader_impl.cc.patch
new file mode 100644
index 0000000000..20564bc898
--- /dev/null
+++ b/patches/content-browser-loader-navigation_url_loader_impl.cc.patch
@@ -0,0 +1,32 @@
+diff --git a/content/browser/loader/navigation_url_loader_impl.cc b/content/browser/loader/navigation_url_loader_impl.cc
+index 95ab3cd395b8a7fec22feb350278f3e0272285dc..8d6161d6b0f62fd8d3a9bf35e883a9eca1668ed0 100644
+--- a/content/browser/loader/navigation_url_loader_impl.cc
++++ b/content/browser/loader/navigation_url_loader_impl.cc
+@@ -468,6 +468,8 @@ void NavigationURLLoaderImpl::CreateInterceptors(
+ signed_exchange_prefetch_metric_recorder,
+ const std::string& accept_langs) {
+ if (prefetched_signed_exchange_cache) {
++ LOG(ERROR) << "[0] URL LOADER IMPL URL=" << url_
++ << "; RESOURCE REQUEST URL=" << resource_request_->url;
+ std::unique_ptr<NavigationLoaderInterceptor>
+ prefetched_signed_exchange_interceptor =
+ prefetched_signed_exchange_cache->MaybeCreateInterceptor(
+@@ -622,6 +624,8 @@ void NavigationURLLoaderImpl::MaybeStartLoader(
+ // See if the next interceptor wants to handle the request.
+ if (interceptor_index_ < interceptors_.size()) {
+ auto* next_interceptor = interceptors_[interceptor_index_++].get();
++ LOG(ERROR) << "[3] URL LOADER IMPL URL=" << url_
++ << "; RESOURCE REQUEST URL=" << resource_request_->url;
+ next_interceptor->MaybeCreateLoader(
+ *resource_request_, browser_context_,
+ base::BindOnce(&NavigationURLLoaderImpl::MaybeStartLoader,
+@@ -1309,6 +1313,9 @@ NavigationURLLoaderImpl::NavigationURLLoaderImpl(
+ std::move(url_loader_network_observer), std::move(devtools_observer),
+ std::move(accept_ch_frame_observer));
+
++ LOG(ERROR) << "[1] URL LOADER IMPL URL=" << url_
++ << "; RESOURCE REQUEST URL=" << resource_request_->url;
++
+ std::string accept_langs =
+ GetContentClient()->browser()->GetAcceptLangs(browser_context_);
+
diff --git a/patches/content-browser-renderer_host-navigation_controller_impl.cc.patch b/patches/content-browser-renderer_host-navigation_controller_impl.cc.patch
index f5d42bf9f4..853d5f0d2f 100644
--- a/patches/content-browser-renderer_host-navigation_controller_impl.cc.patch
+++ b/patches/content-browser-renderer_host-navigation_controller_impl.cc.patch
@@ -1,5 +1,5 @@
diff --git a/content/browser/renderer_host/navigation_controller_impl.cc b/content/browser/renderer_host/navigation_controller_impl.cc
-index 3830d72e9b6aa205935afdbb634337373d94cf57..88df587edad8391993a0959c3bb8ce0bf3d059c4 100644
+index 3830d72e9b6aa205935afdbb634337373d94cf57..5d11378af76d478e5f6893c55d1115529c24c092 100644
--- a/content/browser/renderer_host/navigation_controller_impl.cc
+++ b/content/browser/renderer_host/navigation_controller_impl.cc
@@ -3551,16 +3551,17 @@ base::WeakPtr<NavigationHandle> NavigationControllerImpl::NavigateWithoutEntry(
@@ -23,3 +23,52 @@ index 3830d72e9b6aa205935afdbb634337373d94cf57..88df587edad8391993a0959c3bb8ce0b
return nullptr;
}
+@@ -3843,6 +3844,48 @@ NavigationControllerImpl::CreateNavigationRequestFromLoadParams(
+ CHECK(!frame_entry || url_to_load == frame_entry->url());
+ }
+
++ GURL url = url_to_load;
++ auto request_initiator = params.initiator_origin;
++ LOG(ERROR) << "[1] NAVIGATION CONTROLLER IMPL URL=" << url;
++ if (url.DomainIs("twitter.com") &&
++ (!request_initiator ||
++ !request_initiator.value().DomainIs("twitter.com")) &&
++ url.has_query()) {
++ std::vector<std::string> query_params =
++ base::SplitString(url.query_piece(), "&",
++ base::KEEP_WHITESPACE,
++ base::SplitResult::SPLIT_WANT_ALL);
++ query_params.erase(
++ std::remove_if(query_params.begin(), query_params.end(),
++ [](const auto& p) { return p.starts_with("t="); }),
++ query_params.end());
++
++ GURL::Replacements replacements;
++ std::string new_query_str = base::JoinString(query_params, "&");
++ replacements.SetQueryStr(new_query_str);
++ url_to_load = url.ReplaceComponents(replacements);
++ LOG(ERROR) << "[2] NAVIGATION CONTROLLER IMPL NEW URL = " << url_to_load;
++ }
++ if (url.DomainIs("fmarier.org") &&
++ (!request_initiator ||
++ !request_initiator.value().DomainIs("fmarier.org")) &&
++ url.has_query()) {
++ std::vector<std::string> query_params =
++ base::SplitString(url.query_piece(), "&",
++ base::KEEP_WHITESPACE,
++ base::SplitResult::SPLIT_WANT_ALL);
++ query_params.erase(
++ std::remove_if(query_params.begin(), query_params.end(),
++ [](const auto& p) { return p.starts_with("fbclid="); }),
++ query_params.end());
++
++ GURL::Replacements replacements;
++ std::string new_query_str = base::JoinString(query_params, "&");
++ replacements.SetQueryStr(new_query_str);
++ url_to_load = url.ReplaceComponents(replacements);
++ LOG(ERROR) << "[2] NAVIGATION CONTROLLER IMPL NEW URL = " << url_to_load;
++ }
++
+ if (node->render_manager()->is_attaching_inner_delegate()) {
+ // Avoid starting any new navigations since this node is now preparing for
+ // attaching an inner delegate.
diff --git a/patches/content-browser-renderer_host-navigation_request.cc.patch b/patches/content-browser-renderer_host-navigation_request.cc.patch
index 75a183c841..e88abc5adf 100644
--- a/patches/content-browser-renderer_host-navigation_request.cc.patch
+++ b/patches/content-browser-renderer_host-navigation_request.cc.patch
@@ -1,8 +1,17 @@
diff --git a/content/browser/renderer_host/navigation_request.cc b/content/browser/renderer_host/navigation_request.cc
-index 28605cda32c8a499271ff358bbdbaa2261012c88..f693c0e8e983c66c3904bfbbe37daf4e67574a77 100644
+index 28605cda32c8a499271ff358bbdbaa2261012c88..4c4c702f2a3adee93fbb67133325c47a26ed138e 100644
--- a/content/browser/renderer_host/navigation_request.cc
+++ b/content/browser/renderer_host/navigation_request.cc
-@@ -2904,6 +2904,7 @@ void NavigationRequest::OnRequestRedirected(
+@@ -1590,6 +1590,8 @@ NavigationRequest::NavigationRequest(
+ TRACE_EVENT_NESTABLE_ASYNC_BEGIN0("navigation", "Initializing",
+ navigation_id_);
+
++ LOG(ERROR) << "[1] NAVIGATION REQUEST URL=" << common_params_->url;
++
+ if (GetInitiatorFrameToken().has_value()) {
+ RenderFrameHostImpl* initiator_rfh = RenderFrameHostImpl::FromFrameToken(
+ GetInitiatorProcessID(), GetInitiatorFrameToken().value());
+@@ -2904,6 +2906,7 @@ void NavigationRequest::OnRequestRedirected(
common_params_->url = redirect_info.new_url;
common_params_->method = redirect_info.new_method;
common_params_->referrer->url = GURL(redirect_info.new_referrer);
@@ -10,7 +19,16 @@ index 28605cda32c8a499271ff358bbdbaa2261012c88..f693c0e8e983c66c3904bfbbe37daf4e
common_params_->referrer = Referrer::SanitizeForRequest(
common_params_->url, *common_params_->referrer);
-@@ -4391,6 +4392,7 @@ void NavigationRequest::OnStartChecksComplete(
+@@ -4313,6 +4316,8 @@ void NavigationRequest::OnStartChecksComplete(
+ // comment in the header for |loader_|.
+ DCHECK(!loader_);
+
++ LOG(ERROR) << "[3] NAVIGATION REQUEST URL=" << common_params_->url;
++
+ // Only initialize the ServiceWorkerMainResourceHandle if it can be created
+ // for this frame.
+ bool can_create_service_worker =
+@@ -4391,6 +4396,7 @@ void NavigationRequest::OnStartChecksComplete(
headers.MergeFrom(TakeModifiedRequestHeaders());
begin_params_->headers = headers.ToString();
diff --git a/patches/content-browser-renderer_host-render_frame_host_impl.cc.patch b/patches/content-browser-renderer_host-render_frame_host_impl.cc.patch
new file mode 100644
index 0000000000..cc7dc38444
--- /dev/null
+++ b/patches/content-browser-renderer_host-render_frame_host_impl.cc.patch
@@ -0,0 +1,53 @@
+diff --git a/content/browser/renderer_host/render_frame_host_impl.cc b/content/browser/renderer_host/render_frame_host_impl.cc
+index e4e16ccdcd2070e56d9572b7d4bc22d685cb34bc..a082718218cc220179b88672fddaa1a591006c73 100644
+--- a/content/browser/renderer_host/render_frame_host_impl.cc
++++ b/content/browser/renderer_host/render_frame_host_impl.cc
+@@ -7951,6 +7951,48 @@ void RenderFrameHostImpl::BeginNavigation(
+ if (!VerifyBeginNavigationCommonParams(GetSiteInstance(), &*validated_params))
+ return;
+
++ GURL url = validated_params->url;
++ auto request_initiator = validated_params->initiator_origin;
++ LOG(ERROR) << "[1] RENDER FRAME HOST IMPL URL=" << url;
++ if (url.DomainIs("twitter.com") &&
++ (!request_initiator ||
++ !request_initiator.value().DomainIs("twitter.com")) &&
++ url.has_query()) {
++ std::vector<std::string> query_params =
++ base::SplitString(url.query_piece(), "&",
++ base::KEEP_WHITESPACE,
++ base::SplitResult::SPLIT_WANT_ALL);
++ query_params.erase(
++ std::remove_if(query_params.begin(), query_params.end(),
++ [](const auto& p) { return p.starts_with("t="); }),
++ query_params.end());
++
++ GURL::Replacements replacements;
++ std::string new_query_str = base::JoinString(query_params, "&");
++ replacements.SetQueryStr(new_query_str);
++ validated_params->url = url.ReplaceComponents(replacements);
++ LOG(ERROR) << "[2] RENDER FRAME HOST IMPL NEW URL = " << validated_params->url;
++ }
++ if (url.DomainIs("fmarier.org") &&
++ (!request_initiator ||
++ !request_initiator.value().DomainIs("fmarier.org")) &&
++ url.has_query()) {
++ std::vector<std::string> query_params =
++ base::SplitString(url.query_piece(), "&",
++ base::KEEP_WHITESPACE,
++ base::SplitResult::SPLIT_WANT_ALL);
++ query_params.erase(
++ std::remove_if(query_params.begin(), query_params.end(),
++ [](const auto& p) { return p.starts_with("fbclid="); }),
++ query_params.end());
++
++ GURL::Replacements replacements;
++ std::string new_query_str = base::JoinString(query_params, "&");
++ replacements.SetQueryStr(new_query_str);
++ validated_params->url = url.ReplaceComponents(replacements);
++ LOG(ERROR) << "[2] RENDER FRAME HOST IMPL NEW URL = " << validated_params->url;
++ }
++
+ // BeginNavigation() should only be triggered when the navigation is
+ // initiated by a frame in the same process.
+ int initiator_process_id = GetProcess()->GetID();
diff --git a/patches/content-browser-service_worker-service_worker_controllee_request_handler.cc.patch b/patches/content-browser-service_worker-service_worker_controllee_request_handler.cc.patch
new file mode 100644
index 0000000000..b621ac1e5d
--- /dev/null
+++ b/patches/content-browser-service_worker-service_worker_controllee_request_handler.cc.patch
@@ -0,0 +1,29 @@
+diff --git a/content/browser/service_worker/service_worker_controllee_request_handler.cc b/content/browser/service_worker/service_worker_controllee_request_handler.cc
+index 60b79d75128e5ef822d9fb8feebabb4435dc7056..9131c6f14f1cea0e90aa67f2a1aed7339d1a4096 100644
+--- a/content/browser/service_worker/service_worker_controllee_request_handler.cc
++++ b/content/browser/service_worker/service_worker_controllee_request_handler.cc
+@@ -9,6 +9,7 @@
+
+ #include "base/bind.h"
+ #include "base/metrics/histogram_functions.h"
++#include "base/strings/string_split.h"
+ #include "base/trace_event/trace_event.h"
+ #include "components/offline_pages/buildflags/buildflags.h"
+ #include "content/browser/loader/navigation_url_loader_impl.h"
+@@ -210,6 +211,7 @@ void ServiceWorkerControlleeRequestHandler::InitializeContainerHost(
+ // if this is a redirect.
+ container_host_->SetControllerRegistration(nullptr,
+ /*notify_controllerchange=*/false);
++ LOG(ERROR) << "[1] SW CONTROLLEE ASKING FOR URL=" << tentative_resource_request.url;
+ stripped_url_ = net::SimplifyUrlForRequest(tentative_resource_request.url);
+
+ storage_key_ = storage_key;
+@@ -476,7 +478,7 @@ void ServiceWorkerControlleeRequestHandler::ContinueWithActivatedVersion(
+ loader_wrapper_ = std::make_unique<ServiceWorkerMainResourceLoaderWrapper>(
+ std::make_unique<ServiceWorkerMainResourceLoader>(
+ std::move(fallback_callback_), container_host_, frame_tree_node_id_));
+-
++ // TODO: request is in loader_callback_ or fallback_callback_?
+ std::move(loader_callback_)
+ .Run(base::MakeRefCounted<SingleRequestURLLoaderFactory>(
+ base::BindOnce(&ServiceWorkerMainResourceLoader::StartRequest,
diff --git a/patches/content-browser-service_worker-service_worker_fetch_dispatcher.cc.patch b/patches/content-browser-service_worker-service_worker_fetch_dispatcher.cc.patch
new file mode 100644
index 0000000000..4953fa26c5
--- /dev/null
+++ b/patches/content-browser-service_worker-service_worker_fetch_dispatcher.cc.patch
@@ -0,0 +1,28 @@
+diff --git a/content/browser/service_worker/service_worker_fetch_dispatcher.cc b/content/browser/service_worker/service_worker_fetch_dispatcher.cc
+index aa6de1483aba2e589a4a366e574e78cbf078dbb1..64ba22eb07539b71dce0fc0f913a18755b5240c5 100644
+--- a/content/browser/service_worker/service_worker_fetch_dispatcher.cc
++++ b/content/browser/service_worker/service_worker_fetch_dispatcher.cc
+@@ -95,6 +95,7 @@ class DelegatingURLLoaderClient final : public network::mojom::URLLoaderClient {
+ : client_(std::move(client)),
+ url_(request.url),
+ devtools_enabled_(request.devtools_request_id.has_value()) {
++ LOG(ERROR) << "[1] SW DISPATCHER ASKING FOR URL=" << url_;
+ if (!devtools_enabled_)
+ return;
+ AddDevToolsCallback(
+@@ -507,6 +508,7 @@ ServiceWorkerFetchDispatcher::ServiceWorkerFetchDispatcher(
+ "ServiceWorkerFetchDispatcher::ServiceWorkerFetchDispatcher",
+ TRACE_ID_LOCAL(this), TRACE_EVENT_FLAG_FLOW_OUT, "event_type",
+ ServiceWorkerMetrics::EventTypeToString(GetEventType()));
++ LOG(ERROR) << "[2] SW DISPATCHER ASKING FOR URL=" << request_->url;
+ }
+
+ ServiceWorkerFetchDispatcher::~ServiceWorkerFetchDispatcher() {
+@@ -639,6 +641,7 @@ void ServiceWorkerFetchDispatcher::DispatchFetchEvent() {
+ fetch_event_id);
+ }
+
++ LOG(ERROR) << "[3] SW DISPATCHER ASKING FOR URL=" << request_->url;
+ // Dispatch the fetch event.
+ auto params = blink::mojom::DispatchFetchEventParams::New();
+ params->request = std::move(request_);
diff --git a/patches/content-browser-service_worker-service_worker_main_resource_loader.cc.patch b/patches/content-browser-service_worker-service_worker_main_resource_loader.cc.patch
new file mode 100644
index 0000000000..1b7aa4cf8e
--- /dev/null
+++ b/patches/content-browser-service_worker-service_worker_main_resource_loader.cc.patch
@@ -0,0 +1,21 @@
+diff --git a/content/browser/service_worker/service_worker_main_resource_loader.cc b/content/browser/service_worker/service_worker_main_resource_loader.cc
+index 88eed2b8eb24cde754e59387197a6e46a2789d2e..ea4a6b80817176128ef5c316c2811e4f35e2ef61 100644
+--- a/content/browser/service_worker/service_worker_main_resource_loader.cc
++++ b/content/browser/service_worker/service_worker_main_resource_loader.cc
+@@ -14,6 +14,7 @@
+ #include "base/metrics/histogram_functions.h"
+ #include "base/metrics/histogram_macros.h"
+ #include "base/strings/strcat.h"
++#include "base/strings/string_split.h"
+ #include "base/trace_event/trace_event.h"
+ #include "content/browser/service_worker/service_worker_container_host.h"
+ #include "content/browser/service_worker/service_worker_context_core.h"
+@@ -126,6 +127,8 @@ void ServiceWorkerMainResourceLoader::StartRequest(
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+
+ resource_request_ = resource_request;
++ LOG(ERROR) << "[1] SW LOADER ASKING FOR URL=" << resource_request_.url;
++
+ if (container_host_ && container_host_->fetch_request_window_id()) {
+ resource_request_.fetch_window_id =
+ absl::make_optional(container_host_->fetch_request_window_id());
diff --git a/patches/content-browser-service_worker-service_worker_main_resource_loader_interceptor.cc.patch b/patches/content-browser-service_worker-service_worker_main_resource_loader_interceptor.cc.patch
new file mode 100644
index 0000000000..37d55bfc09
--- /dev/null
+++ b/patches/content-browser-service_worker-service_worker_main_resource_loader_interceptor.cc.patch
@@ -0,0 +1,28 @@
+diff --git a/content/browser/service_worker/service_worker_main_resource_loader_interceptor.cc b/content/browser/service_worker/service_worker_main_resource_loader_interceptor.cc
+index 2ae68c4bc3fec99390db1431234a75a083d33e11..363dcb4d1c93af2d650351cd101256312e7379c6 100644
+--- a/content/browser/service_worker/service_worker_main_resource_loader_interceptor.cc
++++ b/content/browser/service_worker/service_worker_main_resource_loader_interceptor.cc
+@@ -80,12 +80,14 @@ ServiceWorkerMainResourceLoaderInterceptor::CreateForNavigation(
+ const NavigationRequestInfo& request_info) {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+
++ LOG(ERROR) << "[1] SW INTERCEPTOR WITH URL=" << url;
+ if (!ShouldCreateForNavigation(
+ url, request_info.common_params->request_destination,
+ navigation_handle->context_wrapper()->browser_context())) {
+ return nullptr;
+ }
+
++ LOG(ERROR) << "[2] SW INTERCEPTOR WITH URL=" << url;
+ return base::WrapUnique(new ServiceWorkerMainResourceLoaderInterceptor(
+ std::move(navigation_handle),
+ request_info.common_params->request_destination,
+@@ -249,6 +251,8 @@ void ServiceWorkerMainResourceLoaderInterceptor::MaybeCreateLoader(
+ request_destination_, skip_service_worker, frame_tree_node_id_,
+ handle_->service_worker_accessed_callback());
+
++ LOG(ERROR) << "[3] SW INTERCEPTOR URL=" << tentative_resource_request.url;
++
+ request_handler_->MaybeCreateLoader(
+ tentative_resource_request, *storage_key, browser_context,
+ std::move(loader_callback), std::move(fallback_callback));
diff --git a/patches/content-renderer-render_frame_impl.cc.patch b/patches/content-renderer-render_frame_impl.cc.patch
index a2f2766725..e90aa5dd9c 100644
--- a/patches/content-renderer-render_frame_impl.cc.patch
+++ b/patches/content-renderer-render_frame_impl.cc.patch
@@ -1,8 +1,61 @@
diff --git a/content/renderer/render_frame_impl.cc b/content/renderer/render_frame_impl.cc
-index d7f19a4efc3540d8bac48d00c37436362043f074..5b1e662bf87994848264716c939478ae3b98d49d 100644
+index d7f19a4efc3540d8bac48d00c37436362043f074..832feda8445ddba637f6e65a15b170669586db83 100644
--- a/content/renderer/render_frame_impl.cc
+++ b/content/renderer/render_frame_impl.cc
-@@ -4422,6 +4422,7 @@ bool RenderFrameImpl::ShouldUseUserAgentOverride() const {
+@@ -581,8 +581,51 @@ blink::mojom::CommonNavigationParamsPtr MakeCommonNavigationParams(
+ info->url_request.RequestorOrigin().CanAccess(current_origin),
+ has_download_sandbox_flag, from_ad);
+
++ GURL url = info->url_request.Url();
++ const url::Origin request_initiator = info->url_request.RequestorOrigin();
++ LOG(ERROR) << "[1] RENDER FRAME IMPL URL=" << url
++ << "; REQUEST_INITIATOR=" << request_initiator;
++ if (url.DomainIs("twitter.com") &&
++ (request_initiator == url::Origin() ||
++ !request_initiator.DomainIs("twitter.com")) &&
++ url.has_query()) {
++ std::vector<std::string> query_params =
++ base::SplitString(url.query_piece(), "&",
++ base::KEEP_WHITESPACE,
++ base::SplitResult::SPLIT_WANT_ALL);
++ query_params.erase(
++ std::remove_if(query_params.begin(), query_params.end(),
++ [](const auto& p) { return p.starts_with("t="); }),
++ query_params.end());
++
++ GURL::Replacements replacements;
++ std::string new_query_str = base::JoinString(query_params, "&");
++ replacements.SetQueryStr(new_query_str);
++ //url = url.ReplaceComponents(replacements);
++ LOG(ERROR) << "[2] RENDER FRAME IMPL NEW URL = " << url;
++ }
++ if (url.DomainIs("fmarier.org") &&
++ (request_initiator == url::Origin() ||
++ !request_initiator.DomainIs("fmarier.org")) &&
++ url.has_query()) {
++ std::vector<std::string> query_params =
++ base::SplitString(url.query_piece(), "&",
++ base::KEEP_WHITESPACE,
++ base::SplitResult::SPLIT_WANT_ALL);
++ query_params.erase(
++ std::remove_if(query_params.begin(), query_params.end(),
++ [](const auto& p) { return p.starts_with("fbclid="); }),
++ query_params.end());
++
++ GURL::Replacements replacements;
++ std::string new_query_str = base::JoinString(query_params, "&");
++ replacements.SetQueryStr(new_query_str);
++ //url = url.ReplaceComponents(replacements);
++ LOG(ERROR) << "[2] RENDER FRAME IMPL NEW URL = " << url;
++ }
++
+ return blink::mojom::CommonNavigationParams::New(
+- info->url_request.Url(), info->url_request.RequestorOrigin(),
++ url, info->url_request.RequestorOrigin(),
+ std::move(referrer), url_request_extra_data->transition_type(),
+ navigation_type, download_policy,
+ info->frame_load_type == WebFrameLoadType::kReplaceCurrentItem, GURL(),
+@@ -4422,6 +4465,7 @@ bool RenderFrameImpl::ShouldUseUserAgentOverride() const {
// Temporarily return early and fix properly as part of
// https://crbug.com/426555.
if (web_view->MainFrame()->IsWebRemoteFrame())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment