X-Git-Url: https://gitweb.stoutner.com/?p=PrivacyBrowserPC.git;a=blobdiff_plain;f=src%2Fhelpers%2FUserAgentHelper.cpp;fp=src%2Fhelpers%2FUserAgentHelper.cpp;h=960305be8469061320e20b0ffedda739b2ca419c;hp=0000000000000000000000000000000000000000;hb=68167c0aba46c4bd4c859b176824873ffd14a3e7;hpb=d37c965b5cc545db8845756ff2e059fd20a54869 diff --git a/src/helpers/UserAgentHelper.cpp b/src/helpers/UserAgentHelper.cpp new file mode 100644 index 0000000..960305b --- /dev/null +++ b/src/helpers/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") // Privacy Browser. + { + return "PrivacyBrowser/1.0"; + } + else if (userAgentName == "Firefox Linux") // Firefox Linux. + { + return "Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0"; + } + else if (userAgentName == "Chromium Linux") // 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") // 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") // 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") // 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") // 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; + } +}