LibWebView: Add a command line option to override the User-Agent

This commit just adds a command line option to case-insensitively accept
a User-Agent name to use as the UA override. The UIs will individually
need to make use of this option.
This commit is contained in:
Timothy Flynn 2024-08-28 10:26:11 -04:00 committed by Tim Ledbetter
commit a04327a0c9
Notes: github-actions[bot] 2024-08-29 12:06:59 +00:00
4 changed files with 27 additions and 0 deletions

View file

@ -19,4 +19,14 @@ OrderedHashMap<StringView, StringView> const user_agents = {
{ "Safari iOS Mobile"sv, "Mozilla/5.0 (iPhone; CPU iPhone OS 17_5_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.5 Mobile/15E148 Safari/604.1"sv },
};
Optional<StringView> normalize_user_agent_name(StringView name)
{
for (auto const& user_agent : user_agents) {
if (user_agent.key.equals_ignoring_ascii_case(name))
return user_agent.key;
}
return {};
}
}