diff options
author | Idan Horowitz <idan.horowitz@gmail.com> | 2021-04-14 15:13:51 +0300 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-04-14 23:06:32 +0200 |
commit | bc9cd55da45efbe382f8b3374fece4a0f7734ffc (patch) | |
tree | 2a120d70bd4c91765ffa0b6d86acb87a8b464638 /Userland/Libraries/LibWeb/Loader | |
parent | aab99d594504208c0a04261838551eacd0098c8a (diff) | |
download | serenity-bc9cd55da45efbe382f8b3374fece4a0f7734ffc.zip |
Browser+LibWeb: Add support for spoofing the browser user agent
This is helpful when testing certain sites like twitter.com which
display differently based on the user agent.
Diffstat (limited to 'Userland/Libraries/LibWeb/Loader')
-rw-r--r-- | Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/Loader/ResourceLoader.h | 3 |
2 files changed, 4 insertions, 1 deletions
diff --git a/Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp b/Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp index 4d438aadb0..cd3aaeed2d 100644 --- a/Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp +++ b/Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp @@ -48,7 +48,7 @@ ResourceLoader& ResourceLoader::the() ResourceLoader::ResourceLoader() : m_protocol_client(Protocol::Client::construct()) - , m_user_agent("Mozilla/4.0 (SerenityOS; x86) LibWeb+LibJS (Not KHTML, nor Gecko) LibWeb") + , m_user_agent(default_user_agent) { } diff --git a/Userland/Libraries/LibWeb/Loader/ResourceLoader.h b/Userland/Libraries/LibWeb/Loader/ResourceLoader.h index 02fda51250..74ac265f72 100644 --- a/Userland/Libraries/LibWeb/Loader/ResourceLoader.h +++ b/Userland/Libraries/LibWeb/Loader/ResourceLoader.h @@ -37,6 +37,8 @@ class Client; namespace Web { +constexpr auto default_user_agent = "Mozilla/4.0 (SerenityOS; x86) LibWeb+LibJS (Not KHTML, nor Gecko) LibWeb"; + class ResourceLoader : public Core::Object { C_OBJECT(ResourceLoader) public: @@ -55,6 +57,7 @@ public: Protocol::Client& protocol_client() { return *m_protocol_client; } const String& user_agent() const { return m_user_agent; } + void set_user_agent(const String& user_agent) { m_user_agent = user_agent; } void clear_cache(); |