]> gitweb.stoutner.com Git - PrivacyBrowserPC.git/blobdiff - src/helpers/UserAgentHelper.cpp
Add search engine options.
[PrivacyBrowserPC.git] / src / helpers / UserAgentHelper.cpp
diff --git a/src/helpers/UserAgentHelper.cpp b/src/helpers/UserAgentHelper.cpp
new file mode 100644 (file)
index 0000000..960305b
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * Copyright © 2022 Soren Stoutner <soren@stoutner.com>.
+ *
+ * This file is part of Privacy Browser PC <https://www.stoutner.com/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 <http://www.gnu.org/licenses/>.
+ */
+
+// 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;
+    }
+}