diff --git a/ShareX.Setup/InnoSetup/ShareX-setup.iss b/ShareX.Setup/InnoSetup/ShareX-setup.iss
index a7cf126fa..de5684a5b 100644
--- a/ShareX.Setup/InnoSetup/ShareX-setup.iss
+++ b/ShareX.Setup/InnoSetup/ShareX-setup.iss
@@ -50,6 +50,8 @@ Source: "{#MyAppRootDirectory}\Licenses\*.txt"; DestDir: {app}\Licenses; Flags:
Source: "{#MyAppOutputDirectory}\Recorder-devices-setup.exe"; DestDir: {app}; Flags: ignoreversion
Source: "{#MyAppOutputDirectory}\ffmpeg.exe"; DestDir: {app}; Flags: ignoreversion
Source: "{#MyAppReleaseDirectory}\ShareX_NativeMessagingHost.exe"; DestDir: {app}; Flags: ignoreversion
+Source: "{#MyAppReleaseDirectory}\host-manifest-chrome.json"; DestDir: {app}; Flags: ignoreversion
+Source: "{#MyAppReleaseDirectory}\host-manifest-firefox.json"; DestDir: {app}; Flags: ignoreversion
Source: "{#MyAppReleaseDirectory}\de\*.resources.dll"; DestDir: {app}\Languages\de; Flags: ignoreversion
Source: "{#MyAppReleaseDirectory}\es\*.resources.dll"; DestDir: {app}\Languages\es; Flags: ignoreversion
Source: "{#MyAppReleaseDirectory}\es-MX\*.resources.dll"; DestDir: {app}\Languages\es-MX; Flags: ignoreversion
diff --git a/ShareX.Setup/Program.cs b/ShareX.Setup/Program.cs
index b772a83d4..81ff8d0b0 100644
--- a/ShareX.Setup/Program.cs
+++ b/ShareX.Setup/Program.cs
@@ -378,6 +378,8 @@ namespace ShareX.Setup
FileHelpers.CopyFiles(RecorderDevicesSetupPath, destination);
FileHelpers.CopyFiles(Path.Combine(source, "ShareX_NativeMessagingHost.exe"), destination);
+ FileHelpers.CopyFiles(Path.Combine(source, "host-manifest-chrome.json"), destination);
+ FileHelpers.CopyFiles(Path.Combine(source, "host-manifest-firefox.json"), destination);
}
foreach (string directory in Directory.GetDirectories(source))
diff --git a/ShareX/ChromeManifest.cs b/ShareX/ChromeManifest.cs
deleted file mode 100644
index cd78ee143..000000000
--- a/ShareX/ChromeManifest.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-#region License Information (GPL v3)
-
-/*
- ShareX - A program that allows you to take screenshots and share any file type
- Copyright (c) 2007-2024 ShareX Team
-
- This program 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 2
- of the License, or (at your option) any later version.
-
- This program 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 this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-
- Optionally you can also view the license at .
-*/
-
-#endregion License Information (GPL v3)
-
-namespace ShareX
-{
- public class ChromeManifest
- {
- public string name { get; set; }
- public string description { get; set; }
- public string path { get; set; }
- public string type { get; set; }
- public string[] allowed_origins { get; set; }
- }
-}
\ No newline at end of file
diff --git a/ShareX/FirefoxManifest.cs b/ShareX/FirefoxManifest.cs
deleted file mode 100644
index 2c0dcee37..000000000
--- a/ShareX/FirefoxManifest.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-#region License Information (GPL v3)
-
-/*
- ShareX - A program that allows you to take screenshots and share any file type
- Copyright (c) 2007-2024 ShareX Team
-
- This program 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 2
- of the License, or (at your option) any later version.
-
- This program 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 this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-
- Optionally you can also view the license at .
-*/
-
-#endregion License Information (GPL v3)
-
-namespace ShareX
-{
- public class FirefoxManifest
- {
- public string name { get; set; }
- public string description { get; set; }
- public string path { get; set; }
- public string type { get; set; }
- public string[] allowed_extensions { get; set; }
- }
-}
\ No newline at end of file
diff --git a/ShareX/IntegrationHelpers.cs b/ShareX/IntegrationHelpers.cs
index b8243d5a7..83d8de856 100644
--- a/ShareX/IntegrationHelpers.cs
+++ b/ShareX/IntegrationHelpers.cs
@@ -23,12 +23,10 @@
#endregion License Information (GPL v3)
-using Newtonsoft.Json;
using ShareX.HelpersLib;
using ShareX.Properties;
using System;
using System.IO;
-using System.Text;
using System.Windows.Forms;
namespace ShareX
@@ -73,6 +71,8 @@ namespace ShareX
private static readonly string ChromeNativeMessagingHosts = @"SOFTWARE\Google\Chrome\NativeMessagingHosts\com.getsharex.sharex";
private static readonly string FirefoxNativeMessagingHosts = @"SOFTWARE\Mozilla\NativeMessagingHosts\ShareX";
+ private static readonly string ChromeHostManifestFilePath = FileHelpers.GetAbsolutePath("host-manifest-chrome.json");
+ private static readonly string FirefoxHostManifestFilePath = FileHelpers.GetAbsolutePath("host-manifest-firefox.json");
public static bool CheckShellContextMenuButton()
{
@@ -278,8 +278,7 @@ namespace ShareX
{
try
{
- return RegistryHelpers.CheckStringValue(ChromeNativeMessagingHosts, null, Program.ChromeHostManifestFilePath) &&
- File.Exists(Program.ChromeHostManifestFilePath);
+ return RegistryHelpers.CheckStringValue(ChromeNativeMessagingHosts, null, ChromeHostManifestFilePath) && File.Exists(ChromeHostManifestFilePath);
}
catch (Exception e)
{
@@ -309,38 +308,13 @@ namespace ShareX
}
}
- private static void CreateChromeHostManifest(string filePath)
- {
- FileHelpers.CreateDirectoryFromFilePath(filePath);
-
- ChromeManifest manifest = new ChromeManifest()
- {
- name = "com.getsharex.sharex",
- description = "ShareX",
- path = Program.NativeMessagingHostFilePath,
- type = "stdio",
- allowed_origins = new string[] { "chrome-extension://nlkoigbdolhchiicbonbihbphgamnaoc/" }
- };
-
- string json = JsonConvert.SerializeObject(manifest, Formatting.Indented);
-
- File.WriteAllText(filePath, json, Encoding.UTF8);
- }
-
private static void RegisterChromeExtensionSupport()
{
- CreateChromeHostManifest(Program.ChromeHostManifestFilePath);
-
- RegistryHelpers.CreateRegistry(ChromeNativeMessagingHosts, Program.ChromeHostManifestFilePath);
+ RegistryHelpers.CreateRegistry(ChromeNativeMessagingHosts, ChromeHostManifestFilePath);
}
private static void UnregisterChromeExtensionSupport()
{
- if (File.Exists(Program.ChromeHostManifestFilePath))
- {
- File.Delete(Program.ChromeHostManifestFilePath);
- }
-
RegistryHelpers.RemoveRegistry(ChromeNativeMessagingHosts);
}
@@ -348,8 +322,7 @@ namespace ShareX
{
try
{
- return RegistryHelpers.CheckStringValue(FirefoxNativeMessagingHosts, null, Program.FirefoxHostManifestFilePath) &&
- File.Exists(Program.FirefoxHostManifestFilePath);
+ return RegistryHelpers.CheckStringValue(FirefoxNativeMessagingHosts, null, FirefoxHostManifestFilePath) && File.Exists(FirefoxHostManifestFilePath);
}
catch (Exception e)
{
@@ -379,38 +352,13 @@ namespace ShareX
}
}
- private static void CreateFirefoxHostManifest(string filePath)
- {
- FileHelpers.CreateDirectoryFromFilePath(filePath);
-
- FirefoxManifest manifest = new FirefoxManifest()
- {
- name = "ShareX",
- description = "ShareX",
- path = Program.NativeMessagingHostFilePath,
- type = "stdio",
- allowed_extensions = new string[] { "firefox@getsharex.com" }
- };
-
- string json = JsonConvert.SerializeObject(manifest, Formatting.Indented);
-
- File.WriteAllText(filePath, json, Encoding.UTF8);
- }
-
private static void RegisterFirefoxAddonSupport()
{
- CreateFirefoxHostManifest(Program.FirefoxHostManifestFilePath);
-
- RegistryHelpers.CreateRegistry(FirefoxNativeMessagingHosts, Program.FirefoxHostManifestFilePath);
+ RegistryHelpers.CreateRegistry(FirefoxNativeMessagingHosts, FirefoxHostManifestFilePath);
}
private static void UnregisterFirefoxAddonSupport()
{
- if (File.Exists(Program.FirefoxHostManifestFilePath))
- {
- File.Delete(Program.FirefoxHostManifestFilePath);
- }
-
RegistryHelpers.RemoveRegistry(FirefoxNativeMessagingHosts);
}
@@ -463,6 +411,8 @@ namespace ShareX
CreateCustomUploaderExtension(false);
CreateImageEffectExtension(false);
CreateSendToMenuButton(false);
+ UnregisterChromeExtensionSupport();
+ UnregisterFirefoxAddonSupport();
}
}
}
\ No newline at end of file
diff --git a/ShareX/Program.cs b/ShareX/Program.cs
index 7f5fa3a94..464e168cc 100644
--- a/ShareX/Program.cs
+++ b/ShareX/Program.cs
@@ -161,7 +161,6 @@ namespace ShareX
AppName, PersonalPathConfigFileName);
private static readonly string PortableCheckFilePath = FileHelpers.GetAbsolutePath("Portable");
- public static readonly string NativeMessagingHostFilePath = FileHelpers.GetAbsolutePath("ShareX_NativeMessagingHost.exe");
public static readonly string SteamInAppFilePath = FileHelpers.GetAbsolutePath("Steam");
private static string CustomPersonalPath { get; set; }
@@ -255,10 +254,7 @@ namespace ShareX
}
}
- public static string ToolsFolder => Path.Combine(PersonalFolder, "Tools");
public static string ImageEffectsFolder => Path.Combine(PersonalFolder, "ImageEffects");
- public static string ChromeHostManifestFilePath => Path.Combine(ToolsFolder, "Chrome-host-manifest.json");
- public static string FirefoxHostManifestFilePath => Path.Combine(ToolsFolder, "Firefox-host-manifest.json");
private static string PersonalPathDetectionMethod;
@@ -527,7 +523,6 @@ namespace ShareX
FileHelpers.CreateDirectory(SettingManager.BackupFolder);
FileHelpers.CreateDirectory(ImageEffectsFolder);
FileHelpers.CreateDirectory(ScreenshotsParentFolder);
- FileHelpers.CreateDirectory(ToolsFolder);
}
}
diff --git a/ShareX/ShareX.csproj b/ShareX/ShareX.csproj
index 9f5f68bbe..9f3f50da2 100644
--- a/ShareX/ShareX.csproj
+++ b/ShareX/ShareX.csproj
@@ -26,4 +26,12 @@
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
\ No newline at end of file
diff --git a/ShareX/host-manifest-chrome.json b/ShareX/host-manifest-chrome.json
new file mode 100644
index 000000000..fe763be69
--- /dev/null
+++ b/ShareX/host-manifest-chrome.json
@@ -0,0 +1,9 @@
+{
+ "name": "com.getsharex.sharex",
+ "description": "ShareX",
+ "path": "ShareX_NativeMessagingHost.exe",
+ "type": "stdio",
+ "allowed_origins": [
+ "chrome-extension://nlkoigbdolhchiicbonbihbphgamnaoc/"
+ ]
+}
\ No newline at end of file
diff --git a/ShareX/host-manifest-firefox.json b/ShareX/host-manifest-firefox.json
new file mode 100644
index 000000000..1a0d4df3d
--- /dev/null
+++ b/ShareX/host-manifest-firefox.json
@@ -0,0 +1,9 @@
+{
+ "name": "ShareX",
+ "description": "ShareX",
+ "path": "ShareX_NativeMessagingHost.exe",
+ "type": "stdio",
+ "allowed_extensions": [
+ "firefox@getsharex.com"
+ ]
+}
\ No newline at end of file