Repository navigation
fix: make ServiceWorkers respect the session-wide User Agent override - #17650
MarshallOfSound wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
It would be better if ContentBrowserClient::GetUserAgent passed the browser context as a parameter, that way we can return session specific agent with lesser patch. Also this style mimics the ContentBrowserClient::CreateNetworkContext api and we can upstream it too.
c884d8a to
06b1b59
Compare
|
Following discussions with @deepak1556 I've updated the patch to be much more upstreamable. It is now slightly larger but we should be able to upstream and remove 👍 |
nornagon
left a comment
There was a problem hiding this comment.
Seems reasonable to me; I'd recommend opening a CL upstream to get feedback there before merging (though that wouldn't necessarily block this from landing)
deepak1556
left a comment
There was a problem hiding this comment.
LGTM for landing, agree with @nornagon on getting feedback from upstream.
| params->script_url = script_url_; | ||
| params->script_type = script_type_; | ||
| - params->user_agent = GetContentClient()->browser()->GetUserAgent(); | ||
| + params->user_agent = context_->process_manager()->GetUserAgent(GetContentClient()->browser()); |
There was a problem hiding this comment.
GetContentClient()->browser() can be accessed directly in ServiceWorkerProcessManager, since its a per process variable. Pass it as an argument isn't the usual style :)
There was a problem hiding this comment.
@deepak1556 That's what I thought but the thing failed to build when I tried to use it directly. I'll try again when I try to upstream
|
For the code path that sets useragent on network context params, its sufficient to pass |
|
@MarshallOfSound just wanted to say thank you so much for taking a shot at this 🙏! |
|
Closing due to the new |
Description of Change
This adds a patch that exposes our
GetUserAgentAPI oncontent::BrowserContextand then safely tries to fetch it during service worker initialization. If no override has been set it falls back to the original technique.Fixes #16196
Release Notes
Notes: Fixed issue where
session.setUserAgentdid not override the user agent for service workers.