X-Git-Url: https://gitweb.stoutner.com/?p=PrivacyBrowserPC.git;a=blobdiff_plain;f=src%2FUserAgentHelper.cpp;fp=src%2FUserAgentHelper.cpp;h=d1182ef2e20b27c18f94d0177c5c79edbaa4e7c7;hp=0000000000000000000000000000000000000000;hb=05800bafb963a10f291d2a9604dc90cd7ac37c7b;hpb=a65c9f31cc84f245da08642cefefe7a17fa941ce diff --git a/src/UserAgentHelper.cpp b/src/UserAgentHelper.cpp new file mode 100644 index 0000000..d1182ef --- /dev/null +++ b/src/UserAgentHelper.cpp @@ -0,0 +1,61 @@ +/* + * Copyright © 2022 Soren Stoutner . + * + * This file is part of Privacy Browser PC . + * + * Privacy Browser PC is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Privacy Browser PC is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Privacy Browser PC. If not, see . + */ + +// Application headers. +#include "UserAgentHelper.h" + +// The default constructor. +UserAgentHelper::UserAgentHelper() {}; + +QString UserAgentHelper::getUserAgent(const QString &userAgentName) +{ + if (userAgentName == "Privacy Browser") + { + return "PrivacyBrowser/1.0"; + } + else if (userAgentName == "Firefox Linux") + { + return "Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0"; + } + else if (userAgentName == "Chromium Linux") + { + return "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36"; + } + else if (userAgentName == "Firefox Windows") + { + return "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:94.0) Gecko/20100101 Firefox/94.0"; + } + else if (userAgentName == "Chrome Windows") + { + return "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.45 Safari/537.36"; + } + else if (userAgentName == "Edge Windows") + { + return "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.55 Safari/537.36 Edg/96.0.1054.34"; + } + else if (userAgentName == "Safari macOS") + { + return "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.1 Safari/605.1.15"; + } + else + { + // Return the custom user agent. + return userAgentName; + } +}