diff --git a/SLBr/.editorconfig b/SLBr/.editorconfig new file mode 100644 index 0000000..f12eadd --- /dev/null +++ b/SLBr/.editorconfig @@ -0,0 +1,4 @@ +[*.cs] + +# CS0618: Type or member is obsolete +dotnet_diagnostic.CS0618.severity = silent diff --git a/SLBr/SLBr.sln b/SLBr/SLBr.sln new file mode 100644 index 0000000..6e7385c --- /dev/null +++ b/SLBr/SLBr.sln @@ -0,0 +1,45 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30907.101 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{497AA70B-948C-485D-9BDC-D4079761233F}" + ProjectSection(SolutionItems) = preProject + .editorconfig = .editorconfig + EndProjectSection +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SLBr", "SLBr\SLBr.csproj", "{7816736D-3C43-4D68-9A4D-9F0825372E97}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {7816736D-3C43-4D68-9A4D-9F0825372E97}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7816736D-3C43-4D68-9A4D-9F0825372E97}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7816736D-3C43-4D68-9A4D-9F0825372E97}.Debug|x64.ActiveCfg = Debug|x64 + {7816736D-3C43-4D68-9A4D-9F0825372E97}.Debug|x64.Build.0 = Debug|x64 + {7816736D-3C43-4D68-9A4D-9F0825372E97}.Debug|x86.ActiveCfg = Debug|Win32 + {7816736D-3C43-4D68-9A4D-9F0825372E97}.Debug|x86.Build.0 = Debug|Win32 + {7816736D-3C43-4D68-9A4D-9F0825372E97}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7816736D-3C43-4D68-9A4D-9F0825372E97}.Release|Any CPU.Build.0 = Release|Any CPU + {7816736D-3C43-4D68-9A4D-9F0825372E97}.Release|x64.ActiveCfg = Release|x64 + {7816736D-3C43-4D68-9A4D-9F0825372E97}.Release|x64.Build.0 = Release|x64 + {7816736D-3C43-4D68-9A4D-9F0825372E97}.Release|x86.ActiveCfg = Release|Win32 + {7816736D-3C43-4D68-9A4D-9F0825372E97}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {7816736D-3C43-4D68-9A4D-9F0825372E97} = {497AA70B-948C-485D-9BDC-D4079761233F} + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {7AEF2092-FFC4-4819-97A3-CC8862806680} + EndGlobalSection +EndGlobal diff --git a/SLBr/SLBr/App.config b/SLBr/SLBr/App.config new file mode 100644 index 0000000..5754728 --- /dev/null +++ b/SLBr/SLBr/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/SLBr/SLBr/App.xaml b/SLBr/SLBr/App.xaml new file mode 100644 index 0000000..1256a79 --- /dev/null +++ b/SLBr/SLBr/App.xaml @@ -0,0 +1,9 @@ + + + + + diff --git a/SLBr/SLBr/App.xaml.cs b/SLBr/SLBr/App.xaml.cs new file mode 100644 index 0000000..cf97143 --- /dev/null +++ b/SLBr/SLBr/App.xaml.cs @@ -0,0 +1,117 @@ +// Copyright © 2022 SLT World. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Data; +using System.Diagnostics; +using System.Linq; +using System.Reflection; +using System.Runtime.InteropServices; +using System.Threading; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Shell; + +namespace SLBr +{ + /// + /// Interaction logic for App.xaml + /// + public partial class App : Application + { + /*[DllImport("user32.dll")] + private static extern bool ShowWindow(IntPtr hWnd, int cmdShow); + private const int SW_MAXIMIZE = 3; + private const int SW_SHOWNORMAL = 1;*/ + + //private static Mutex SingleInstanceMutex; + + private void Application_Startup(object sender, StartupEventArgs e) + { + /*if (e.Args.Count() > 0) + { + MessageBox.Show("You have the latest version."); + Shutdown(); + }*/ + + JumpTask OpenTask = new JumpTask + { + Title = "Open", + Arguments = "", + //Description = "Open SLBr", + CustomCategory = "Actions", + ApplicationPath = Assembly.GetExecutingAssembly().Location, + IconResourcePath = Assembly.GetExecutingAssembly().Location + }; + JumpTask PrivateOpenTask = new JumpTask + { + Title = "Open in private mode", + Arguments = "Private", + //Description = "No browsing history will be saved, in memory cache will be used (Incognito)", + CustomCategory = "Actions", + ApplicationPath = Assembly.GetExecutingAssembly().Location, + IconResourcePath = Assembly.GetExecutingAssembly().Location + }; + JumpTask DeveloperOpenTask = new JumpTask + { + Title = "Open in developer mode", + Arguments = "Developer", + //Description = "Access to developer features of SLBr and bypass the i5 processor check", + CustomCategory = "Actions", + ApplicationPath = Assembly.GetExecutingAssembly().Location, + IconResourcePath = Assembly.GetExecutingAssembly().Location + }; + JumpTask ChromiumOpenTask = new JumpTask + { + Title = "Open in chromium mode", + Arguments = "Chromium", + //Description = "Access to developer features of SLBr and bypass the i5 processor check", + CustomCategory = "Actions", + ApplicationPath = Assembly.GetExecutingAssembly().Location, + IconResourcePath = Assembly.GetExecutingAssembly().Location + }; + JumpTask IEOpenTask = new JumpTask + { + Title = "Open in Internet Explorer mode", + Arguments = "IE", + //Description = "Access to developer features of SLBr and bypass the i5 processor check", + CustomCategory = "Actions", + ApplicationPath = Assembly.GetExecutingAssembly().Location, + IconResourcePath = Assembly.GetExecutingAssembly().Location + }; + + JumpList jumpList = new JumpList(); + jumpList.JumpItems.Add(OpenTask); + jumpList.JumpItems.Add(PrivateOpenTask); + jumpList.JumpItems.Add(DeveloperOpenTask); + jumpList.JumpItems.Add(ChromiumOpenTask); + jumpList.JumpItems.Add(IEOpenTask); + jumpList.ShowFrequentCategory = false; + jumpList.ShowRecentCategory = false; + + JumpList.SetJumpList(Current, jumpList); + + + Process _Process = Process.GetCurrentProcess(); + List Processes = Process.GetProcesses().Where(p => + p.ProcessName == _Process.ProcessName && !_Process.HasExited).ToList(); + + int count = Processes.Count(); + + if (count > 1) + { + //ShowWindow(Processes[0].MainWindowHandle, SW_MAXIMIZE); + MessageBox.Show("An instance is already running... Relaunch the application if you think something is wrong.");//BUG, Relaunching in SLBr shows this message + Current.Shutdown(); + } + /*bool IsNewInstance = false; + SingleInstanceMutex = new Mutex(true, "SLBrSLTBrowser", out IsNewInstance); + if (!IsNewInstance) + { + MessageBox.Show("Already an instance is running..."); + Current.Shutdown(); + }*/ + } + } +} diff --git a/SLBr/SLBr/Favourite.cs b/SLBr/SLBr/Favourite.cs new file mode 100644 index 0000000..bab64f7 --- /dev/null +++ b/SLBr/SLBr/Favourite.cs @@ -0,0 +1,16 @@ +// Copyright © 2022 SLT World. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SLBr +{ + public class Favourite + { + public string Name { get; set; } + public string Arguments { get; set; } + } +} diff --git a/SLBr/SLBr/FileAssociation.cs b/SLBr/SLBr/FileAssociation.cs new file mode 100644 index 0000000..b9b69e0 --- /dev/null +++ b/SLBr/SLBr/FileAssociation.cs @@ -0,0 +1,207 @@ +// Copyright © 2022 SLT World. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +using Microsoft.Win32; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SLBr +{ + public class FileAssociation + { + public string Extension { get; set; } + public string ProgId { get; set; } + public string FileTypeDescription { get; set; } + public string ExecutableFilePath { get; set; } + } + + public class FileAssociations + { + // needed so that Explorer windows get refreshed after the registry is updated + [System.Runtime.InteropServices.DllImport("Shell32.dll")] + private static extern int SHChangeNotify(int eventId, int flags, IntPtr item1, IntPtr item2); + + private const int SHCNE_ASSOCCHANGED = 0x8000000; + private const int SHCNF_FLUSH = 0x1000; + + public static void EnsureAssociationsSet() + { + var filePath = Process.GetCurrentProcess().MainModule.FileName; + EnsureAssociationsSet( + /*new FileAssociation + { + Extension = ".htm", + ProgId = "SLBr", + FileTypeDescription = "SLBr HTML Document", + ExecutableFilePath = filePath + },*/ + new FileAssociation + { + Extension = ".html", + ProgId = "SLBr", + FileTypeDescription = "SLBr HTML Document", + ExecutableFilePath = filePath + } + /*new FileAssociation + { + Extension = ".shtml", + ProgId = "SLBr", + FileTypeDescription = "SLBr HTML Document", + ExecutableFilePath = filePath + }, + /*new FileAssociation + { + Extension = ".mht", + ProgId = "SLBr", + FileTypeDescription = "SLBr HTML Document", + ExecutableFilePath = filePath + }, + /*new FileAssociation + { + Extension = ".mhtml", + ProgId = "SLBr", + FileTypeDescription = "SLBr HTML Document", + ExecutableFilePath = filePath + }, + /*new FileAssociation + { + Extension = ".xht", + ProgId = "SLBr", + FileTypeDescription = "SLBr HTML Document", + ExecutableFilePath = filePath + }, + /*new FileAssociation + { + Extension = ".xhtml", + ProgId = "SLBr", + FileTypeDescription = "SLBr HTML Document", + ExecutableFilePath = filePath + }, + new FileAssociation + { + Extension = ".php", + ProgId = "SLBr", + FileTypeDescription = "SLBr PHP Document", + ExecutableFilePath = filePath + }, + new FileAssociation + { + Extension = ".pdf", + ProgId = "SLBr", + FileTypeDescription = "SLBr PDF Document", + ExecutableFilePath = filePath + },*/ + /*new FileAssociation + { + Extension = ".asp", + ProgId = "SLBr", + FileTypeDescription = "SLBr ASP Document", + ExecutableFilePath = filePath + }, + new FileAssociation + { + Extension = "FTP", + ProgId = "SLBr", + FileTypeDescription = "URL:File Transfer Protocol", + ExecutableFilePath = filePath + },*/ + /*new FileAssociation + { + Extension = "HTTP", + ProgId = "SLBr", + FileTypeDescription = "URL:HyperText Transfer Protocol", + ExecutableFilePath = filePath + }, + new FileAssociation + { + Extension = "HTTPS", + ProgId = "SLBr", + FileTypeDescription = "URL:HyperText Transfer Protocol with Privacy", + ExecutableFilePath = filePath + }*/ + ); + } + + public static void EnsureAssociationsSet(params FileAssociation[] associations) + { + bool madeChanges = false; + foreach (var association in associations) + { + madeChanges |= SetAssociation( + association.Extension, + association.ProgId, + association.FileTypeDescription, + association.ExecutableFilePath); + } + + if (madeChanges) + { + SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_FLUSH, IntPtr.Zero, IntPtr.Zero); + } + } + + public static bool SetAssociation(string extension, string progId, string fileTypeDescription, string applicationFilePath) + { + /*bool madeChanges = false; + madeChanges |= SetKeyDefaultValue(@"Software\Classes\" + extension, progId); + madeChanges |= SetKeyDefaultValue(@"Software\Classes\" + progId, fileTypeDescription); + madeChanges |= SetKeyDefaultValue($@"Software\Classes\{progId}\shell\open\command", "\"" + applicationFilePath + "\" \"%1\""); + return madeChanges;*/ + bool madeChanges = false; + //madeChanges |= SetKeyDefaultValue(@"Software\Classes\" + extension, progId); + //madeChanges |= SetKeyDefaultValue(@"Software\Classes\" + progId, fileTypeDescription); + //madeChanges |= SetKeyDefaultValue($@"Software\Classes\{progId}\shell\open\command", $"\"{applicationFilePath}\" %1");/*\"*//*\"*/ + //madeChanges |= SetKeyDefaultValue($@"Software\Classes\{extension}\shell\open\command", $"\"{applicationFilePath}\" \"%1\""); + madeChanges |= NewSetKeyDefaultValue(".html", "SLBr"); + return madeChanges; + } + + private static bool NewSetKeyDefaultValue(string ExtensionName, string ApplicationName, string Value = "") + { + RegistryKey _rk = Registry.ClassesRoot.OpenSubKey(ExtensionName); + //string _defaultapp = _rk.GetValue("").ToString(); + string[] _subkeys = _rk.GetSubKeyNames(); + for (int i = 0; i < _subkeys.Length; i++) + { + if (_subkeys[i] == "OpenWithProgids") + { + RegistryKey _rkh = _rk.OpenSubKey(_subkeys[i], true); + _rkh.SetValue(ApplicationName, Value); + return true; + //string[] _names = _rkh.GetValueNames(); + //for (int j = 0; j < _names.Length; j++) + //{ + // if (_names[j] == "") + // continue; + + // Microsoft.Win32.RegistryKey _rhelp = Microsoft.Win32.Registry.ClassesRoot.OpenSubKey(_names[j] + "\\shell\\open\\command"); + + // _ret.Add(_rhelp.GetValue("").ToString()); + // _rhelp.Close(); + //} + + } + } + _rk.Close(); + + return false; + } + + private static bool OldSetKeyDefaultValue(string keyPath, string value) + { + using (var key = Registry.CurrentUser.CreateSubKey(keyPath)) + { + if (key.GetValue(null) as string != value) + { + key.SetValue(null, value); + return true; + } + } + + return false; + } + } +} \ No newline at end of file diff --git a/SLBr/SLBr/Handlers/ContextMenuHandler.cs b/SLBr/SLBr/Handlers/ContextMenuHandler.cs new file mode 100644 index 0000000..da326f4 --- /dev/null +++ b/SLBr/SLBr/Handlers/ContextMenuHandler.cs @@ -0,0 +1,141 @@ +// Copyright © 2022 SLT World. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. + +using CefSharp; +using CefSharp.Wpf; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Net; +using System.Text; +using System.Threading.Tasks; +using System.Windows; + +namespace SLBr +{ + class ContextMenuHandler : IContextMenuHandler + { + public void OnBeforeContextMenu(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IContextMenuParams parameters, IMenuModel model) + { + if (parameters.MediaType != ContextMenuMediaType.Image)//parameters.MediaType == ContextMenuMediaType.None + { + if (!string.IsNullOrEmpty(parameters.SelectionText)) + { + model.AddItem((CefMenuCommand)26501, "Search for text in new tab"); + model.AddSeparator(); + model.AddItem(CefMenuCommand.NotFound, "Close Menu"); + /*model.AddItem(CefMenuCommand.NotFound, "Close Menu"); + model.AddSeparator(); + model.Clear(); + model.AddItem(CefMenuCommand.Copy, "Copy"); + model.AddItem((CefMenuCommand)26501, "Save as");*/ + } + else + { + model.Remove(CefMenuCommand.Print); + model.Remove(CefMenuCommand.ViewSource); + model.AddItem(CefMenuCommand.Reload, "Refresh"); + model.AddSeparator(); + model.AddItem(CefMenuCommand.NotFound, "Close Menu"); + model.AddSeparator(); + model.AddItem((CefMenuCommand)26501, "Zoom In"); + model.AddItem((CefMenuCommand)26502, "Zoom Out"); + model.AddItem((CefMenuCommand)26503, "Reset Zoom Level"); + model.AddSeparator(); + model.AddItem((CefMenuCommand)26506, "Take a screenshot"); + model.AddSeparator(); + IMenuModel _EditSubMenuModel = model.AddSubMenu(CefMenuCommand.NotFound, "Edit"); + _EditSubMenuModel.AddItem(CefMenuCommand.Undo, "Undo"); + _EditSubMenuModel.AddItem(CefMenuCommand.Redo, "Redo"); + _EditSubMenuModel.AddSeparator(); + _EditSubMenuModel.AddItem(CefMenuCommand.Cut, "Cut"); + _EditSubMenuModel.AddItem(CefMenuCommand.Copy, "Copy"); + _EditSubMenuModel.AddItem(CefMenuCommand.Paste, "Paste"); + _EditSubMenuModel.AddItem(CefMenuCommand.Delete, "Delete"); + _EditSubMenuModel.AddSeparator(); + _EditSubMenuModel.AddItem(CefMenuCommand.SelectAll, "Select All"); + model.AddSeparator(); + model.AddItem((CefMenuCommand)26507, "Search page on SafeBrowsing"); + model.AddItem((CefMenuCommand)26504, "View page source"); + model.AddItem((CefMenuCommand)26505, "Inspect"); + } + } + else + { + model.AddItem(CefMenuCommand.NotFound, "Close Menu"); + model.AddSeparator(); + model.Clear(); + model.AddItem(CefMenuCommand.Copy, "Copy"); + model.AddItem((CefMenuCommand)26501, "Save as"); + //model.AddItem((CefMenuCommand)26502, "Open in paintbrush"); + } + } + + public bool OnContextMenuCommand(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IContextMenuParams parameters, CefMenuCommand commandId, CefEventFlags eventFlags) + { + if (commandId == CefMenuCommand.NotFound) + return false; + if (parameters.MediaType != ContextMenuMediaType.Image)//parameters.MediaType == ContextMenuMediaType.None + { + string SelectedText = parameters.SelectionText; + Application.Current.Dispatcher.BeginInvoke(new Action(delegate + { + if (!string.IsNullOrEmpty(SelectedText)) + { + if (commandId == (CefMenuCommand)26501) + MainWindow.Instance.CreateTab(MainWindow.Instance.CreateWebBrowser(string.Format(MainWindow.Instance.MainSave.Get("Search_Engine"), SelectedText.Trim().Replace(" ", "+")))); + } + else + { + if (commandId == (CefMenuCommand)26501) + MainWindow.Instance.ZoomIn(); + else if (commandId == (CefMenuCommand)26502) + MainWindow.Instance.ZoomOut(); + else if (commandId == (CefMenuCommand)26503) + MainWindow.Instance.ResetZoomLevel(); + else if (commandId == (CefMenuCommand)26504) + MainWindow.Instance.ViewSource(); + else if (commandId == (CefMenuCommand)26505) + MainWindow.Instance.DevTools(); + else if (commandId == (CefMenuCommand)26506) + MainWindow.Instance.Screenshot(); + else if (commandId == (CefMenuCommand)26507) + MainWindow.Instance.CreateTab(MainWindow.Instance.CreateWebBrowser($"https://transparencyreport.google.com/safe-browsing/search?url={chromiumWebBrowser.Address}")); + } + })); + } + else + { + if (commandId == CefMenuCommand.Copy) + Clipboard.SetText(parameters.SourceUrl); + else if (commandId == (CefMenuCommand)26501) + chromiumWebBrowser.StartDownload(parameters.SourceUrl); + /*else if (commandId == (CefMenuCommand)26502) + { + chromiumWebBrowser.StartDownload(parameters.SourceUrl); + //string DownloadPath = MainWindow.Instance.MainSave.Get("DownloadPath"); + //string FileName = Path.Combine(DownloadPath, Path.GetFileName(parameters.SourceUrl)); + Process.Start(FileName); + }*/ + } + return false; + } + + public void OnContextMenuDismissed(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame) + { + /*var webBrowser = (ChromiumWebBrowser)chromiumWebBrowser; + + webBrowser.Dispatcher.Invoke(() => + { + webBrowser.ContextMenu = null; + });*/ + } + + public bool RunContextMenu(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IContextMenuParams parameters, IMenuModel model, IRunContextMenuCallback callback) + { + //callback.Cancel(); + return false; + } + } +} diff --git a/SLBr/SLBr/Handlers/DownloadHandler.cs b/SLBr/SLBr/Handlers/DownloadHandler.cs new file mode 100644 index 0000000..8dd291c --- /dev/null +++ b/SLBr/SLBr/Handlers/DownloadHandler.cs @@ -0,0 +1,163 @@ +// Copyright © 2022 SLT World. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +using CefSharp; +//using Microsoft.Win32; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Forms; +using System.Windows.Threading; + +namespace SLBr +{ + class DownloadHandler : IDownloadHandler + { + bool _allowDownload = true; + + float DownloadUpdatePeriod = 2.5f; + float DownloadUpdateTime; + + public void OnBeforeDownload(IWebBrowser chromiumWebBrowser, IBrowser browser, DownloadItem downloadItem, IBeforeDownloadCallback callback) + { + if (!callback.IsDisposed) + { + using (callback) + { + if (_allowDownload) + { + bool Download = false; + if (bool.Parse(MainWindow.Instance.MainSave.Get("AFDP"))) + { + SaveFileDialog saveFileDialog = new SaveFileDialog(); + saveFileDialog.InitialDirectory = MainWindow.Instance.MainSave.Get("DownloadPath"); + saveFileDialog.FileName = downloadItem.SuggestedFileName; + saveFileDialog.Filter = "|*" + System.IO.Path.GetExtension(saveFileDialog.FileName); + + if (saveFileDialog.ShowDialog() == DialogResult.OK && saveFileDialog.FileName != "") + { + downloadItem.SuggestedFileName = saveFileDialog.FileName; + Download = true; + } + else + downloadItem.IsCancelled = _allowDownload; + } + else + { + downloadItem.SuggestedFileName = Path.Combine(MainWindow.Instance.MainSave.Get("DownloadPath"), Path.GetFileName(downloadItem.SuggestedFileName)); + Download = true; + } + if (Download) + { + MainWindow.Instance.Dispatcher.BeginInvoke(new Action(delegate + { + string FileName = Path.GetFileName(downloadItem.SuggestedFileName); + MainWindow.Instance.DownloadContainer.Visibility = Visibility.Visible; + MainWindow.Instance.DownloadFileName.Text = FileName; + //MainWindow.Instance.DownloadProgressBar.Maximum = downloadItem.TotalBytes; + System.Windows.Controls.MenuItem DownloadMenuItem = MainWindow.CreateMenuItemForList(Path.GetFileName(downloadItem.SuggestedFileName), $"13<,>{downloadItem.SuggestedFileName}", new RoutedEventHandler(MainWindow.Instance.ButtonAction)); + MainWindow.Instance.DownloadListMenuItem.Items.Insert(0, DownloadMenuItem); + if (MainWindow.Instance.DownloadListMenuItem.Items.Count > 10) + MainWindow.Instance.DownloadListMenuItem.Items.RemoveAt(10); + })); + } + } + else + downloadItem.IsCancelled = !_allowDownload; + + callback.Continue(downloadItem.SuggestedFileName, showDialog: false); + } + + } + } + + public void OnDownloadUpdated(IWebBrowser chromiumWebBrowser, IBrowser browser, DownloadItem downloadItem, IDownloadItemCallback callback) + { + MainWindow.Instance.Dispatcher.BeginInvoke(new Action(delegate + { + if (downloadItem.IsComplete) + { + MainWindow.Instance.DownloadProgressText.Visibility = Visibility.Collapsed; + MainWindow.Instance.DownloadProgressBar.Visibility = Visibility.Collapsed; + //browser.CloseBrowser(true); + MainWindow.Instance.DownloadOpenFileButton.Visibility = Visibility.Visible; + MainWindow.Instance.DownloadOpenFileButton.Tag = $"13<,>{downloadItem.FullPath}"; + } + else + { + if ((DateTime.UtcNow - Process.GetCurrentProcess().StartTime.ToUniversalTime()).TotalSeconds > DownloadUpdateTime) + { + MainWindow.Instance.DownloadProgressText.Visibility = Visibility.Visible; + MainWindow.Instance.DownloadProgressBar.Visibility = Visibility.Visible; + MainWindow.Instance.DownloadOpenFileButton.Visibility = Visibility.Collapsed; + if (downloadItem.IsCancelled) + MainWindow.Instance.DownloadProgressText.Text = "Cancelled"; + else if (downloadItem.IsInProgress) + { + MainWindow.Instance.DownloadProgressText.Text = $"{downloadItem.CurrentSpeed} bytes ({downloadItem.PercentComplete}%)";/*{(downloadItem.EndTime - downloadItem.StartTime).Value.TotalSeconds} seconds left.{downloadItem.ReceivedBytes}/{downloadItem.TotalBytes} bytes, */ + MainWindow.Instance.DownloadProgressBar.Value = downloadItem.PercentComplete; + //MainWindow.Instance.DownloadProgressBar.Value = downloadItem.ReceivedBytes; + DownloadUpdateTime = ((float)(DateTime.UtcNow - Process.GetCurrentProcess().StartTime.ToUniversalTime()).TotalSeconds) + DownloadUpdatePeriod; + } + + } + } + })); + } + + /*public event EventHandler OnBeforeDownloadFired; + + public event EventHandler OnDownloadUpdatedFired; + + public void OnBeforeDownload(IWebBrowser chromiumWebBrowser, IBrowser browser, DownloadItem downloadItem, IBeforeDownloadCallback callback) + { + if (downloadItem.IsValid) + { + Console.WriteLine("== File information ========================"); + Console.WriteLine(" File URL: {0}", downloadItem.Url); + Console.WriteLine(" Suggested FileName: {0}", downloadItem.SuggestedFileName); + Console.WriteLine(" MimeType: {0}", downloadItem.MimeType); + Console.WriteLine(" Content Disposition: {0}", downloadItem.ContentDisposition); + Console.WriteLine(" Total Size: {0}", downloadItem.TotalBytes); + Console.WriteLine("============================================"); + } + + OnBeforeDownloadFired?.Invoke(this, downloadItem); + + if (!callback.IsDisposed) + { + using (callback) + { + callback.Continue( + downloadItem.SuggestedFileName, + showDialog: true + ); + } + } + } + + public void OnDownloadUpdated(IWebBrowser chromiumWebBrowser, IBrowser browser, DownloadItem downloadItem, IDownloadItemCallback callback) + { + OnDownloadUpdatedFired?.Invoke(this, downloadItem); + + if (downloadItem.IsValid) + { + if (downloadItem.IsInProgress && (downloadItem.PercentComplete != 0)) + { + Console.WriteLine( + "Current Download Speed: {0} bytes ({1}%)", + downloadItem.CurrentSpeed, + downloadItem.PercentComplete + ); + } + + if (downloadItem.IsComplete) + Console.WriteLine("The download has been finished!"); + } + }*/ + } +} diff --git a/SLBr/SLBr/Handlers/JSBindingHandler.cs b/SLBr/SLBr/Handlers/JSBindingHandler.cs new file mode 100644 index 0000000..ea05614 --- /dev/null +++ b/SLBr/SLBr/Handlers/JSBindingHandler.cs @@ -0,0 +1,69 @@ +// Copyright © 2022 SLT World. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +using CefSharp; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; + +namespace SLBr +{ + class JSBindingHandler + { + //Functions in this script are accessible by JS using the code `slbr.FUNCTION()` + + /*public string executableLocation() => + MainWindow.Instance.ExecutableLocation; + public string chromiumVersion => + Cef.ChromiumVersion; + + public bool hasDebugger() => + Utils.HasDebugger(); + public string cleanUrl(string Url) => + Utils.CleanUrl(Url);*/ + + public string SearchProviderPrefix() + { + return MainWindow.Instance.MainSave.Get("Search_Engine"); + //return "Bruh"; + } + public string SayHello(string name) { return $"Hello {name}!"; } + + public void Back() + { + Application.Current.Dispatcher.BeginInvoke(new Action(delegate + { + MainWindow.Instance.Undo(); + })); + } + public void Forward() + { + Application.Current.Dispatcher.BeginInvoke(new Action(delegate + { + MainWindow.Instance.Redo(); + })); + } + public void Refresh() + { + Application.Current.Dispatcher.BeginInvoke(new Action(delegate + { + MainWindow.Instance.Refresh(); + })); + } + + public void PromptExample() + { + Prompt("Example Message", "", ""); + } + + public void Prompt(string Message, string ButtonUrl, string ButtonMessage) + { + Application.Current.Dispatcher.BeginInvoke(new Action(delegate + { + MainWindow.Instance.Prompt(Message, ButtonMessage.Trim().Length > 0 ? true : false, ButtonMessage, $"24<,>{ButtonUrl}"); + })); + } + } +} diff --git a/SLBr/SLBr/Handlers/KeyboardHandler.cs b/SLBr/SLBr/Handlers/KeyboardHandler.cs new file mode 100644 index 0000000..8c5e575 --- /dev/null +++ b/SLBr/SLBr/Handlers/KeyboardHandler.cs @@ -0,0 +1,74 @@ +// Copyright © 2022 SLT World. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +using CefSharp; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; + +namespace SLBr +{ + class HotKey + { + public HotKey(Action _Callback, int _KeyCode, bool HasControl, bool HasShift, bool HasAlt) + { + Callback = _Callback; + KeyCode = _KeyCode; + Control = HasControl; + Shift = HasShift; + Alt = HasAlt; + } + + public int KeyCode; + public bool Control; + public bool Shift; + public bool Alt; + + public Action Callback;//Function + } + + class KeyboardHandler : IKeyboardHandler + { + List Keys = new List(); + + public void AddKey(Action Function, int _KeyCode, bool HasControl = false, bool HasShift = false, bool HasAlt = false) + { + Keys.Add(new HotKey(Function, _KeyCode, HasControl, HasShift, HasAlt)); + } + + public bool OnKeyEvent(IWebBrowser chromiumWebBrowser, IBrowser browser, KeyType type, int windowsKeyCode, int nativeKeyCode, CefEventFlags modifiers, bool isSystemKey) + { + if (type == KeyType.RawKeyDown) + { + bool HasControl = modifiers == CefEventFlags.ControlDown; + bool HasShift = modifiers == CefEventFlags.ShiftDown; + bool HasAlt = modifiers == CefEventFlags.AltDown; + + //MessageBox.Show($"{windowsKeyCode},{HasControl},{HasShift},{HasAlt}"); + foreach (HotKey Key in Keys) + { + //MessageBox.Show($"{Key.KeyCode},{Key.Control},{Key.Shift},{Key.Alt}"); + if (Key.KeyCode == windowsKeyCode && Key.Control == HasControl && Key.Shift == HasShift && Key.Alt == HasAlt) + { + MainWindow.Instance.Dispatcher.BeginInvoke(new Action(delegate + { + Key.Callback(); + })); + } + } + + //MessageBox.Show($"{windowsKeyCode},{HasControl},{HasShift},{HasAlt}"); + + } + + return false; + } + + public bool OnPreKeyEvent(IWebBrowser chromiumWebBrowser, IBrowser browser, KeyType type, int windowsKeyCode, int nativeKeyCode, CefEventFlags modifiers, bool isSystemKey, ref bool isKeyboardShortcut) + { + return false; + } + } +} diff --git a/SLBr/SLBr/Handlers/LifeSpanHandler.cs b/SLBr/SLBr/Handlers/LifeSpanHandler.cs new file mode 100644 index 0000000..4e0f2e6 --- /dev/null +++ b/SLBr/SLBr/Handlers/LifeSpanHandler.cs @@ -0,0 +1,46 @@ +// Copyright © 2022 SLT World. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +using CefSharp; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Threading; + +namespace SLBr +{ + public class LifeSpanHandler : ILifeSpanHandler + { + public bool OnBeforePopup(IWebBrowser browserControl, IBrowser browser, IFrame frame, string targetUrl, string targetFrameName, + WindowOpenDisposition targetDisposition, bool userGesture, IPopupFeatures popupFeatures, IWindowInfo windowInfo, + IBrowserSettings browserSettings, ref bool noJavascriptAccess, out IWebBrowser newBrowser) + { + Application.Current.Dispatcher.BeginInvoke(new Action(delegate + { + MainWindow.Instance.CreateTab(MainWindow.Instance.CreateWebBrowser(targetUrl)); + })); + //Program.Form.Invoke(new Action(() => Program.Form.newPage(targetUrl))); + //browser.MainFrame.LoadUrl(targetUrl); + newBrowser = null; + return true; + } + + public void OnAfterCreated(IWebBrowser browserControl, IBrowser browser) + { + // + } + + public bool DoClose(IWebBrowser browserControl, IBrowser browser) + { + //if (browserControl.GetMainFrame().Url.Equals("devtools://devtools/devtools_app.html")) + return false; + } + + public void OnBeforeClose(IWebBrowser browserControl, IBrowser browser) + { + //nothing + } + } +} diff --git a/SLBr/SLBr/Handlers/RequestHandler.cs b/SLBr/SLBr/Handlers/RequestHandler.cs new file mode 100644 index 0000000..2991f15 --- /dev/null +++ b/SLBr/SLBr/Handlers/RequestHandler.cs @@ -0,0 +1,111 @@ +// Copyright © 2022 SLT World. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +using CefSharp; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Security.Cryptography.X509Certificates; +using System.Text; +using System.Threading.Tasks; +using System.Windows; + +namespace SLBr +{ + public class RequestHandler : IRequestHandler + { + public bool GetAuthCredentials(IWebBrowser chromiumWebBrowser, IBrowser browser, string originUrl, bool isProxy, string host, int port, string realm, string scheme, IAuthCallback callback) + { + return false; + } + + public bool OnBeforeBrowse(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IRequest request, bool userGesture, bool isRedirect) + { + if (request.Url.Contains("roblox.com")) + return true; + if ((isRedirect || userGesture || frame.IsMain) && !Utils.IsSystemUrl(request.Url) && !Utils.IsProgramUrl(request.Url)) + { + string Response = MainWindow.Instance._SafeBrowsing.Response(request.Url.Replace("https://googleweblight.com/?lite_url=", "")); + Utils.SafeBrowsing.ThreatType _ThreatType = Utils.CheckForInternetConnection() ? MainWindow.Instance._SafeBrowsing.GetThreatType(Response) : Utils.SafeBrowsing.ThreatType.Unknown; + if (_ThreatType == Utils.SafeBrowsing.ThreatType.Malware || _ThreatType == Utils.SafeBrowsing.ThreatType.Unwanted_Software) + { + //chromiumWebBrowser.LoadHtml(File.ReadAllText(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Resources", "Malware.html")), request.Url); + frame.LoadUrl("slbr://malware"/* + "?url=" + request.Url*/); + } + else if (_ThreatType == Utils.SafeBrowsing.ThreatType.Social_Engineering) + { + frame.LoadUrl("slbr://deception"/* + "?url=" + request.Url*/); + } + /*else + { + if (bool.Parse(MainWindow.Instance.MainSave.Get("Weblight")) && !request.Url.Contains("googleweblight.com/?lite_url=")) + { + frame.LoadUrl(Utils.FixUrl(request.Url, true)); + } + }*/ + //if (request.Url.EndsWith(".pdf")) + // frame.LoadUrl(request.Url + "#toolbar=0"); + } + return false; + } + public bool OnCertificateError(IWebBrowser browserControl, IBrowser browser, CefErrorCode errorCode, string requestUrl, ISslInfo sslInfo, IRequestCallback callback) + { + return true; + } + public bool OnOpenUrlFromTab(IWebBrowser browserControl, IBrowser browser, IFrame frame, string targetUrl, WindowOpenDisposition targetDisposition, bool userGesture) + { + if (targetDisposition == WindowOpenDisposition.NewBackgroundTab) + { + Application.Current.Dispatcher.BeginInvoke(new Action(delegate + { + MainWindow.Instance.CreateTab(MainWindow.Instance.CreateWebBrowser(targetUrl), false, MainWindow.Instance.Tabs.SelectedIndex + 1, true); + })); + return true; + } + // else + //{ + // if (Utils.IsAboutUrl(targetUrl)) + // { + // MessageBox.Show("slbr://" + targetUrl.Substring(6)); + // frame.LoadUrl("slbr://" + targetUrl.Substring(6)); + // //return true; + // } + //} + return false; + } + + public void OnPluginCrashed(IWebBrowser browserControl, IBrowser browser, string pluginPath) + { + } + + public bool OnQuotaRequest(IWebBrowser browserControl, IBrowser browser, string originUrl, long newSize, IRequestCallback callback) + { + callback.Continue(true); + return true; + } + + public void OnRenderProcessTerminated(IWebBrowser browserControl, IBrowser browser, CefTerminationStatus status) + { + } + + public void OnRenderViewReady(IWebBrowser browserControl, IBrowser browser) + { + } + + public IResourceRequestHandler GetResourceRequestHandler(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IRequest request, bool isNavigation, bool isDownload, string requestInitiator, ref bool disableDefaultHandling) + { + var rh = new ResourceRequestHandler(); + return rh; + } + + public bool OnSelectClientCertificate(IWebBrowser chromiumWebBrowser, IBrowser browser, bool isProxy, string host, int port, X509Certificate2Collection certificates, ISelectClientCertificateCallback callback) + { + return false; + } + + public void OnDocumentAvailableInMainFrame(IWebBrowser chromiumWebBrowser, IBrowser browser) + { + } + } +} diff --git a/SLBr/SLBr/Handlers/ResourceRequestHandler.cs b/SLBr/SLBr/Handlers/ResourceRequestHandler.cs new file mode 100644 index 0000000..46e39b7 --- /dev/null +++ b/SLBr/SLBr/Handlers/ResourceRequestHandler.cs @@ -0,0 +1,105 @@ +// Copyright © 2022 SLT World. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +using CefSharp; +using Newtonsoft.Json.Linq; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Net; +using System.Security.Cryptography.X509Certificates; +using System.Text; +using System.Threading.Tasks; +using System.Windows; + +namespace SLBr +{ + public class ResourceRequestHandler : IResourceRequestHandler + { + public void Dispose() + { + } + + public ICookieAccessFilter GetCookieAccessFilter(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IRequest request) + { + return null; + } + + public IResourceHandler GetResourceHandler(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IRequest request) + { + return null; + } + + public IResponseFilter GetResourceResponseFilter(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IRequest request, IResponse response) + { + return null; + } + + public CefReturnValue OnBeforeResourceLoad(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IRequest request, IRequestCallback callback) + { + //Chrome Web Store Experiment + //request.SetHeaderByName("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36 Edg/98.0.1108.62", false); + //request.SetHeaderByName("sec-ch-ua", "\" Not A; Brand\";v=\"99\", \"Chromium\";v=\"98\", \"Microsoft Edge\";v=\"98\"", false); + //request.SetHeaderByName("cookie", "1P_JAR=2022-02-28-01; NID=511=WF7xnRY3fmPoA8KW27PerWOTOjQrw1MMhOIK3-B1hIT0zDunpoEaSN5p4x0sTx7gPBuJ8UlVHtDvHbZTqtDop0fPvTQYKwaVDK-DfHKzTYn2BhDLM_Xmw2E6LY_G89d2WO1xYeOmfV-0vvixbyJonM-OtnhNMHyLMoAS7nDtItdu8bSI92GP_Nk_fCjldDyD0KminbX_bpVF; __utma=73091649.1413177246.1600596546.1645953634.1646110777.3; __utmc=73091649; __utmz=73091649.1646110777.3.2.utmcsr=bing|utmccn=(organic)|utmcmd=organic|utmctr=(not provided); __utmt=1; __utmb=73091649.91.9.1646112576592", false); + return CefReturnValue.Continue; + } + + public bool OnProtocolExecution(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IRequest request) + { + return true; + } + + public void OnResourceLoadComplete(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IRequest request, IResponse response, UrlRequestStatus status, long receivedContentLength) + { + int code = response.StatusCode; + if (!frame.IsValid || frame.Url != request.Url) + return; + if (request.Url.StartsWith("file:///")) + { + //string _Path = request.Url/*.Substring(8)*/; + //if (File.Exists(_Path) || Directory.Exists(_Path)) + // return; + //else + //{ + // frame.LoadUrl("slbr://cannotconnect" + "?url=" + request.Url); + //} + } + /*else if (code == 404) + { + string Url = request.Url; + if (!Utils.CleanUrl(Url).StartsWith("web.archive.org")) + { + Application.Current.Dispatcher.BeginInvoke(new Action(delegate + { + MainWindow.Instance.NewMessage("This page is missing, do you want to check if there's a saved version on the Wayback Machine?", $"https://web.archive.org/{Url}", "Check for saved version");*/ + //dynamic Data = JObject.Parse(MainWindow.Instance.TinyDownloader.DownloadString($"https://archive.org/wayback/available?url={request.Url}")); + /*try + { + dynamic archived_snapshots = Data.archived_snapshots; + archived_snapshots. + } + catch { }*/ + /*})); + } + //frame.LoadUrl("slbr://notfound" + "?url=" + request.Url); + }*/ + // else if (request.Url.StartsWith("file:///")) + // { + // string _Path = request.Url.Substring(8); + // if (!File.Exists(_Path)) + // frame.LoadUrl("slbr://notfound" + "?url=" + _Path); + // } + else if (code == 0 || code == 444 || (code >= 500 && code <= 599)) + frame.LoadUrl("slbr://cannotconnect" + "?url=" + request.Url); + } + + public void OnResourceRedirect(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IRequest request, IResponse response, ref string newUrl) + { + } + + public bool OnResourceResponse(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IRequest request, IResponse response) + { + return false; + } + } +} diff --git a/SLBr/SLBr/MainWindow.xaml b/SLBr/SLBr/MainWindow.xaml new file mode 100644 index 0000000..49ad10f --- /dev/null +++ b/SLBr/SLBr/MainWindow.xaml @@ -0,0 +1,229 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/SLBr/SLBr/Resources/Dino.html b/SLBr/SLBr/Resources/Dino.html new file mode 100644 index 0000000..699aba1 --- /dev/null +++ b/SLBr/SLBr/Resources/Dino.html @@ -0,0 +1,191 @@ + + + + + + Dino Game + + + + + + +
+ + + \ No newline at end of file diff --git a/SLBr/SLBr/Resources/GeolocationTest.html b/SLBr/SLBr/Resources/GeolocationTest.html new file mode 100644 index 0000000..5c02028 --- /dev/null +++ b/SLBr/SLBr/Resources/GeolocationTest.html @@ -0,0 +1,32 @@ + + + + + + + SLBr Geolocation Test + + + + +
+ + + diff --git a/SLBr/SLBr/Resources/HTMLEditor.html b/SLBr/SLBr/Resources/HTMLEditor.html new file mode 100644 index 0000000..5da81eb --- /dev/null +++ b/SLBr/SLBr/Resources/HTMLEditor.html @@ -0,0 +1,60 @@ + + + + + HTML Editor + + + + + + + + + + + +
+
+
+
+ + +
+
+ + + +
+ +
+
+
+ + diff --git a/SLBr/SLBr/Resources/License.html b/SLBr/SLBr/Resources/License.html new file mode 100644 index 0000000..7078fc6 --- /dev/null +++ b/SLBr/SLBr/Resources/License.html @@ -0,0 +1,27 @@ + + + + + + + + License + + + +
+// SLBr. The new, clean and lightweight .NET Web browser.
+// Copyright (C) 2022 SLT World
+//
+// 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 3 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.
+ + \ No newline at end of file diff --git a/SLBr/SLBr/Resources/Malware.html b/SLBr/SLBr/Resources/Malware.html new file mode 100644 index 0000000..d7f7055 --- /dev/null +++ b/SLBr/SLBr/Resources/Malware.html @@ -0,0 +1,30 @@ + + + + + + + Malware Warning + + + +

The site ahead contains malware

+

The site you are trying to visit contains malware, which is used by attackers to install dangerous programs on your computer that steals, leaks or deletes your information (for example, photons, passwords, messages, credit cards and personal information)

+ + + \ No newline at end of file diff --git a/SLBr/SLBr/Resources/NewTab.html b/SLBr/SLBr/Resources/NewTab.html new file mode 100644 index 0000000..0abd09b --- /dev/null +++ b/SLBr/SLBr/Resources/NewTab.html @@ -0,0 +1,46 @@ + + + + + + New Tab + + + + +
+
+

SLBr

+ +
+
+ + + \ No newline at end of file diff --git a/SLBr/SLBr/Resources/Plans.html b/SLBr/SLBr/Resources/Plans.html new file mode 100644 index 0000000..3296223 --- /dev/null +++ b/SLBr/SLBr/Resources/Plans.html @@ -0,0 +1,69 @@ + + + + + + + + SLBr Major Planned Features + + + +

List of major planned features

+

The features here are what the user should expect for the next updates

+

Any of the features listed in here could be potentially delayed or made early

+
+

Unspecified

+
    +
  • Full Smooth Scrolling Support without raising too much cpu

  • +
  • Default System Browser

  • +
  • Better HTML File Association

  • +
  • Tab Grouping

  • +
  • Draggable Tabs

  • +
  • User Credential Cache

  • +
  • History Tree & History Per Tab

  • +
  • Customizable Flags/Command Line Arguments

  • +
  • Print Preview

  • +
  • CHM Support

  • +
  • Multi-Users

  • +
  • Plug-ins/Add-ons/Extensions

  • +
  • Tor Connection

  • +
  • FTP Client

  • +
  • Easter Eggs

  • +
  • Tab Hover Cards to view content

  • +
  • SLBr Support Forum

  • +
  • OpenH264 Implementation

  • +
  • Touch Mode

  • +
  • Caret Browsing

  • +
  • Adobe Flash

  • +
+

SLBr 4

+
    +
  • Customizable Tab Bar Position

  • +
  • Speech API

  • +
  • Translation API

  • +
  • Font Settings

  • +
+

SLBr 3

+
    +
  • Custom Themes/Skins

  • +
  • Full WebGL Support [Toggle WebGL Toggle in the Menu, the page will reload]

  • +
  • Improved Security

  • +
  • Force Dark Mode on Web Contents

  • +
  • Dark Mode syncing with OS Theme

  • +
  • prefers-color-scheme Media Query Support

  • +
  • Loading Screen Color

  • +
+ + + +
+ + \ No newline at end of file diff --git a/SLBr/SLBr/Resources/SLBr-Urls.html b/SLBr/SLBr/Resources/SLBr-Urls.html new file mode 100644 index 0000000..85a3c05 --- /dev/null +++ b/SLBr/SLBr/Resources/SLBr-Urls.html @@ -0,0 +1,15 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/SLBr/SLBr/Resources/SLBrUADetector.html b/SLBr/SLBr/Resources/SLBrUADetector.html new file mode 100644 index 0000000..e174aa7 --- /dev/null +++ b/SLBr/SLBr/Resources/SLBrUADetector.html @@ -0,0 +1,43 @@ + + + + + + + SLBr UA Detector + + + +

This shows that SLBr is possible to be detectable with only the simplest way possible, by using the user agent only. Code below

+ const SLBr = window.navigator.userAgent.toLowerCase() && /slbr/i.test(window.navigator.userAgent.toLowerCase()) +
+ + + \ No newline at end of file diff --git a/SLBr/SLBr/Resources/Updates.html b/SLBr/SLBr/Resources/Updates.html new file mode 100644 index 0000000..cf17912 --- /dev/null +++ b/SLBr/SLBr/Resources/Updates.html @@ -0,0 +1,156 @@ + + + + + + + SLBr Updates + + + + +
+

VERSIONHERE - SLBr's Second Update

+
    +
  • What are the new features?

  • +
  • Improved Performance [Disabling Proxy Servers, Limiting callbacks that calls more than ones, Removing features that don't generally help out with anything (i.e. Smooth Scrolling)]

  • +
  • Pinning and Unpinning tabs

  • +
  • Sharp Text

  • +
  • Code Cleanup

  • +
  • Google Weblight Loading

  • +
  • Keyboard Shortcuts

  • + +
  • More context menus

  • +
  • Javascript Binding Support (Functions are accessible by JS using the code `slbr.FUNCTION()`)

  • +
  • Settings will notify if the change is made.

  • + +
  • Hide Tabs

  • +
  • Website parameters are hidden unless you click or hover over the address bar

  • +
  • No proxy server slightly improves initialization time as it won't attempt to resolve a proxy

  • +
  • Slightly improved performance by utilizing the same instance for multiple small tasks

  • +
  • Modes (Pin SLBr on the taskbar, close SLBr, right click on SLBr and click on one of the "Open in ----" actions)

  • +
  • Default Mode

  • +
  • Private Mode (Incognito) [No browsing history will be saved, in-memory cache will be used]

  • +
  • Developer Mode [Developer/Experimental features & functionalities]

  • +
  • Chromium Mode [API Keys will not be assigned, some functionalities will be disabled and the useragent will be chromium's]

  • +
  • Internet Explorer Mode [Javascript will not function properly and much of SLBr's functionalities will be disabled/broken. There will also be unexpected crashes and lots of errors. But hey, at least you can test out a website and see how bad it's styling gets.]

  • +
  • What are the changes?

  • +
  • Dark Theme will be enabled for default

  • +
  • Menu/Tools/Tests is now only accessible by using the developer mode

  • +
  • UI improvements

  • +
  • Message Panel

  • +
  • Dark mode will be forced into web contents

  • +
  • The address bar will allow text to be dragged into it

  • +
  • Instead of the built-in 404 page, the browser will show a message asking to check if there's a saved version on Wayback Machine (Idea inspired by Brave)

  • +
  • What are the supported features of this update?

  • +
  • Full AdBlock Support
  • +
  • Weblight Loading
  • +
  • Full WebGL Support
  • +
  • Set as Default Browser Option
  • +
  • Account Sign-In (Browser)
  • +
  • Proprietary Codecs
  • +
  • Javascript Binding
  • +
  • Extensions, Plug-Ins, Add-ons
  • +
  • Proxy
  • +
  • Tor Network (The Onion Router Network)
  • +
+

2020.2.25.0 - The Start of SLBr

+
    +
  • What are the new features?

  • +
  • Basic Functions [Back, Forward, Refresh, Stop Loading, Home]

  • +
  • Basic Needs [Tabs, Settings, Favourites, History, Downloads (with Download Location Dialog), Cache]

  • +
  • User-friendly UI

  • +
  • Fast Lightweight Rendering Engine

  • +
  • Security Functions [SSL Certificate Checker, Anti-malware & Anti-phishing]

  • +
  • Built-in pages [Error Pages, Warning Pages, Information pages (slbr://urls)]

  • +
  • Include "search:" in front of a text containing a dot (Which is seen as a domain by SLBr)

  • +
  • Customizable Features [Homepage, Search Provider, Download Path]

  • +
  • Other Features [Dark Theme, Restore tabs from previous session, Block keywords, Ask for download path, Ask to set as default search provider]

  • +
  • If you're interested in some country news, you can use the News Feed tool

  • +
  • The browser doesn't support saving the back and forth history

  • +
  • Keywords such as gacha and roblox are blocked for default, you can disable or change it in settings

  • +
  • HTML File Association

  • +
  • What are the changes?

  • +
  • -

  • +
  • What are the supported features of this update?

  • +
  • AdBlock Support
  • + + +
  • Minor WebGL Support
  • +
  • Cache
  • +
  • Set as Default Browser Option
  • +
  • Google Account Sign-In (Website)
  • +
  • Account Sign-In (Browser)
  • +
  • Safe Browsing API
  • +
  • PDF Viewer
  • +
  • Proprietary Codecs
  • +
  • Javascript Binding
  • +
  • Extensions
  • +
  • Proxy
  • +
  • Tor Network (The Onion Router Network)
  • +
  • ARM Build
  • +
+
+ +

SLBr was made possible by Windows Presentation Forms, The Chromium Project, Chromium Embedded Framework and CEFSharp. If you can, please donate and support them. It will contribute greatly to SLBr and every developer using them as well.

+ + + + \ No newline at end of file diff --git a/SLBr/SLBr/Resources/Urls.html b/SLBr/SLBr/Resources/Urls.html new file mode 100644 index 0000000..986ec0d --- /dev/null +++ b/SLBr/SLBr/Resources/Urls.html @@ -0,0 +1,31 @@ + + +waa + + + + + SLBr URLs + + + +

List of SLBr Urls

+ + + diff --git a/SLBr/SLBr/Resources/Version.html b/SLBr/SLBr/Resources/Version.html new file mode 100644 index 0000000..0a94a8f --- /dev/null +++ b/SLBr/SLBr/Resources/Version.html @@ -0,0 +1,271 @@ + + + + + + + SLBr Version + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SLBr + + Version + (Official Build) + Bit Process + + +
Chromium + Chromium Version +
Internet Explorer + IE Version +
Operating System + Operating System + + +
JavaScript + V8 + Javascript Version +
User Agent + User Agent +
Command Line + Command Line +
Executable Path + Executable Path +
Cache Path + Cache Path +
+
+ + + + \ No newline at end of file diff --git a/SLBr/SLBr/Resources/Welcome.html b/SLBr/SLBr/Resources/Welcome.html new file mode 100644 index 0000000..035d990 --- /dev/null +++ b/SLBr/SLBr/Resources/Welcome.html @@ -0,0 +1,14 @@ + + + + + + + Welcome to SLBr + + + +

SLBr

+ + \ No newline at end of file diff --git a/SLBr/SLBr/Resources/WhatsNew.html b/SLBr/SLBr/Resources/WhatsNew.html new file mode 100644 index 0000000..cfd65ed --- /dev/null +++ b/SLBr/SLBr/Resources/WhatsNew.html @@ -0,0 +1,94 @@ + + + + + + + + About SLBr + + + + + + +
+

SLBr

+

The new, clean and lightweight .NET Web browser

+
+ +
+

What's New in SLBr 2022.3.13.0

+

+ Every update of SLBr delivers many new features. +

+
+

UI Changes

+
    +
  • The settings tab/window will notify if a change is made successfully.
  • +
  • Find box and new tab button added to the top control bar
  • +
  • An improved context menu
  • +
  • Sharper Text
  • +
  • Tab pinning
  • +
  • URL Eliding (Meaning the "https://" and "www." will be hidden. There's an option to show the full URL in the Settings tab/window)
  • +
  • Dark mode will be forced into web contents
  • +
  • Text are now draggable into the address bar
  • +
  • PDF Viewer controls made visible
  • +
  • Native Built-in Prompts
  • +
  • When a request returns 404, SLBr will prompt a question asking to check if there's a saved version on Wayback Machine instead of displaying a 404 page
  • +
+

New developer features

+
    +
  • Javascript Binding (Various functions are accessible by JS using the code `slbr.FUNCTION()`)
  • +
  • Faster website loading with Google Weblight
  • +
  • Screenshot feature (Still in development)
  • +
  • Tests menu
  • +
  • Developer mode, Developer/Experimental features & functionalities will be enabled.
  • +
  • Chromium mode, API Keys will not be assigned, some functionalities will be disabled and the useragent will be chromium's.
  • +
  • Internet Explorer mode, Javascript will not function properly and much of SLBr's functionalities will be disabled/broken. There will also be unexpected crashes and lots of errors.
  • +
+

Other new features

+
    +
  • More URL Schemes Supported
  • +
  • Performance slightly improved

  • +
  • +
      +
    • Code Cleanup
    • +
    • Tab Unloading - 12/3/2022
    • +
    • Limited renderer processes
    • +
    • Disabled lots of unused, untouched and unnoticed features of the Chromium of SLBr, features that SLBr doesn't have to support (i.e. Smooth Scrolling, Low Resolution Tiling, Plugins/Add-ons/Extensions, Proxies)
    • +
    • Disabled some parts of the GPU Acceleration because using the gpu is noticeably unreliable, but kept the rest for a limited WebGL support
    • +
    • No plugins/add-ons/extensions are needed to be initialized since SLBr does not support these
    • +
    • Without Proxy servers slightly improve the initialization time of SLBr as it won't attempt to resolve a proxy
    • +
    • Utilized a single instance for multiple small tasks
    • +
    • Removed callbacks that returns more than once.
    • +
    +
  • Keyboard Shortcuts

  • +
  • +
      +
    • Ctrl+R, F5 (Refresh)
    • +
    • Ctrl+T (New Tab)
    • +
    • Ctrl+W (Close Tab)
    • +
    • Ctrl+S (Screenshot)
    • +
    • F12 (Developer Tools)
    • +
    +
  • +
  • Modes

  • +
  • +
      +
    • Private mode (Incognito), No browsing history will be saved, in-memory cache will be used.
    • +
    • Developer mode, Developer/Experimental features & functionalities will be enabled.
    • +
    • Chromium mode, API Keys will not be assigned, some functionalities will be disabled and the useragent will be chromium's.
    • +
    • Internet Explorer mode, Javascript will not function properly and much of SLBr's functionalities will be disabled/broken. There will also be unexpected crashes and lots of errors.
    • +
    +
  • +
+
+
+ + \ No newline at end of file diff --git a/SLBr/SLBr/Resources/style.css b/SLBr/SLBr/Resources/style.css new file mode 100644 index 0000000..f3f08d4 --- /dev/null +++ b/SLBr/SLBr/Resources/style.css @@ -0,0 +1,123 @@ +html { + background: white; +} + +body { + font-family: 'Segoe UI', Tahoma, sans-serif; +} + +/*#checkboxes { + float: left; +}*/ + +#checkboxes ul { + /*margin: 0;*/ + padding: 0; + list-style: none; + /*float: left;*/ +} + +#checkboxes ul li input { + vertical-align: -1px; + padding: 0; + margin-right: 7.5px; + /*vertical-align: middle;*/ + overflow: visible; +} + +#checkboxes ul li p { + padding: 0; + margin: 0; + margin-left: 5px; + overflow: visible; +} + +h3 { + margin: 7.5px 0px; +} + +h4 { + margin: 7.5px 0px; +} + +.AboutHeader { + padding: 60px; + text-align: center; + background: #F5F5F5; + /*color: white;*/ + font-size: 30px; +} + +.AboutContent { + padding: 20px; +} + +.AboutContent p { + margin: 1px; +} + +a { + text-decoration: none; + color: #646464; +} +a:hover { + color: #808080; +} + +.NewTabSearchContainer { + /*margin-top: 20%;*/ + position: absolute; + top: 0; + left: 0; + right: 0; + bottom: 0; + overflow: auto; +} + +.Center { + /*position: absolute; + top: 50%; + -ms-transform: translateY(-50%); + transform: translateY(-50%);*/ + display: flex; + align-items: center; + justify-content: center; +} + +.SearchInput { + display: flex; + align-items: center; + border: 1px solid lightgray; + height: 30px; + padding: 2.5px 20px; + border-radius: 999px; + width: 75vw; + margin: 0 auto; + max-width: 560px; + +} + +.SearchInput input { + flex: 1; + padding: 10px 0;/*20px*/ + border: none; + outline: none; +} + +.SearchInput .material-icons { + color: gray; +} + +.List ul { + margin: 0; + padding: 0; + list-style: none; + /*float: left;*/ +} + +.List ul li { + padding: 0; + margin: 0; + margin-left: 15px; + overflow: visible; +} \ No newline at end of file diff --git a/SLBr/SLBr/SLBr.csproj b/SLBr/SLBr/SLBr.csproj new file mode 100644 index 0000000..bc5315c --- /dev/null +++ b/SLBr/SLBr/SLBr.csproj @@ -0,0 +1,285 @@ + + + + + Debug + AnyCPU + {7816736D-3C43-4D68-9A4D-9F0825372E97} + WinExe + SLBr + SLBr + v4.7.2 + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 + true + true + + + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + app.manifest + + + true + bin\x64\Debug\ + DEBUG;TRACE + full + x64 + 7.3 + prompt + true + + + bin\x64\Release\ + TRACE + true + pdbonly + x64 + 7.3 + prompt + true + + + true + bin\x86\Debug\ + DEBUG;TRACE + full + x86 + 7.3 + prompt + true + + + bin\x86\Release\ + TRACE + true + pdbonly + x86 + 7.3 + prompt + true + + + SLBr.App + + + + + + + + + + + + + + + + 4.0 + + + + + + + + MSBuild:Compile + Designer + + + + + + + + + + + + + NewsPage.xaml + + + + SettingsPage.xaml + + + SettingsWindow.xaml + + + + + + MSBuild:Compile + Designer + + + App.xaml + Code + + + MainWindow.xaml + Code + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + PreserveNewest + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + + + Code + + + True + True + Resources.resx + + + True + Settings.settings + True + + + ResXFileCodeGenerator + Resources.Designer.cs + + + .editorconfig + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + + + + + + 99.2.90 + + + 1.11.42 + + + 10.0.22000.196 + + + 13.0.1 + + + 6.0.0 + + + 4.7.0 + + + 4.7.0 + + + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + + PreserveNewest + + + PreserveNewest + + + + + + + + + + \ No newline at end of file diff --git a/SLBr/SLBr/SLBrBrowserModel.cs b/SLBr/SLBr/SLBrBrowserModel.cs new file mode 100644 index 0000000..a91f556 --- /dev/null +++ b/SLBr/SLBr/SLBrBrowserModel.cs @@ -0,0 +1,293 @@ +// Copyright © 2022 SLT World. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. + +using CefSharp; +using CefSharp.Wpf; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +//using Microsoft.mshtml; + +namespace SLBr +{ + public class SLBrBrowserModel + { + public enum EngineType + { + Blink, + Trident, + Gecko, + EdgeHTML, + WebKit, + } + + public EngineType _EngineType; + public ChromiumWebBrowser _Blink; + public WebBrowser _Trident; + public float ZoomLevel; + public float ZoomLevelIncrement; + + public SLBrBrowserModel(EngineType _EngineType, string Url, float _ZoomLevelIncrement = 0, object Custom = null) + { + this._EngineType = _EngineType; + ZoomLevelIncrement = _ZoomLevelIncrement; + switch (_EngineType) + { + case EngineType.Blink: + if (Custom != null) + _Blink = Custom as ChromiumWebBrowser; + else + Application.Current.Dispatcher.BeginInvoke(new Action(delegate + { + _Blink = new ChromiumWebBrowser(); + })); + //MessageBox.Show(_Blink.ActualWidth.ToString()); + _Blink.Address = Url; + //_Blink.BeginInit(); + //ZoomLevel = float.Parse(_Blink.ZoomLevel.ToString()); + //_Blink.ZoomLevelIncrement = ZoomLevelIncrement; + break; + case EngineType.Trident: + _Trident = new WebBrowser(); + //_Trident.Navigate(Url); + break; + } + //MessageBox.Show(_Blink.Address); + //Navigate(Url); + } + + public string Url() + { + switch (_EngineType) + { + case EngineType.Blink: + return _Blink.Address; + case EngineType.Trident: + return _Trident.Source.AbsoluteUri; + } + return string.Empty; + } + public string Title() + { + switch (_EngineType) + { + case EngineType.Blink: + return _Blink.Title; + case EngineType.Trident: + return /*((dynamic)_Trident.Document).Title;-*/(string)_Trident.InvokeScript("eval", "document.title.toString()"); + } + return string.Empty; + } + + /*public object GetEngine() + { + switch (_BrowserType) + { + case EngineType.Blink: + return _Blink; + case EngineType.Trident: + return _Trident; + } + return null; + }*/ + + + public void Dispose() + { + switch (_EngineType) + { + case EngineType.Blink: + _Blink.Dispose(); + break; + case EngineType.Trident: + _Trident.Dispose(); + break; + } + } + + public void Navigate(string Url) + { + switch (_EngineType) + { + case EngineType.Blink: + _Blink.Address = Url; + break; + case EngineType.Trident: + _Trident.Navigate(Url); + break; + } + } + public void Back() + { + switch (_EngineType) + { + case EngineType.Blink: + _Blink.Back(); + break; + case EngineType.Trident: + _Trident.GoBack(); + break; + } + } + public void Forward() + { + switch (_EngineType) + { + case EngineType.Blink: + _Blink.Forward(); + break; + case EngineType.Trident: + _Trident.GoForward(); + break; + } + } + public void Refresh() + { + switch (_EngineType) + { + case EngineType.Blink: + _Blink.Reload(); + break; + case EngineType.Trident: + _Trident.Refresh(); + break; + } + } + public void Stop() + { + switch (_EngineType) + { + case EngineType.Blink: + if (_Blink.IsBrowserInitialized) + _Blink.Stop(); + break; + case EngineType.Trident: + _Trident.InvokeScript("eval", "document.execCommand('Stop');"); + break; + } + } + public void Print() + { + switch (_EngineType) + { + case EngineType.Blink: + _Blink.Print(); + break; + /*case EngineType.Trident: + mshtml.IHTMLDocument2 doc = _Trident.Document as mshtml.IHTMLDocument2; + doc.execCommand("Print", true, null); + break;*/ + } + } + public void ShowDevTools() + { + //MessageBox.Show("e"); + switch (_EngineType) + { + case EngineType.Blink: + if (_Blink.IsBrowserInitialized) + _Blink.ShowDevTools(); + break; + /*case EngineType.Trident: + mshtml.IHTMLDocument2 doc = _Trident.Document as mshtml.IHTMLDocument2; + doc.execCommand("Print", true, null); + break;*/ + } + } + + public bool CanGoBack() + { + switch (_EngineType) + { + case EngineType.Blink: + return _Blink.CanGoBack; + case EngineType.Trident: + return _Trident.CanGoBack; + } + return true; + } + public bool CanGoForward() + { + switch (_EngineType) + { + case EngineType.Blink: + return _Blink.CanGoForward; + case EngineType.Trident: + return _Trident.CanGoForward; + } + return true; + } + public bool IsLoaded() + { + switch (_EngineType) + { + case EngineType.Blink: + return _Blink.IsLoaded; + case EngineType.Trident: + return _Trident.IsLoaded; + } + return true; + } + + public void SetZoom(float Value) + { + switch (_EngineType) + { + case EngineType.Blink: + ZoomLevel = Value; + _Blink.SetZoomLevel(Value); + break; + /*case EngineType.Trident: + mshtml.IHTMLDocument2 doc = _Trident.Document as mshtml.IHTMLDocument2; + doc.parentWindow.execScript("document.body.style.zoom=" + Value.ToString().Replace(",", ".") + ";"); + break;*/ + } + } + public void Find(string Text, bool Forward, bool MatchCase, bool FindNext) + { + switch (_EngineType) + { + case EngineType.Blink: + _Blink.Find(Text, Forward, MatchCase, FindNext); + break; + } + } + public void StopFinding(bool ClearSelection) + { + switch (_EngineType) + { + case EngineType.Blink: + _Blink.StopFinding(ClearSelection); + break; + } + } + + public string Source() + { + switch (_EngineType) + { + case EngineType.Blink: + string Source = string.Empty; + Application.Current.Dispatcher.BeginInvoke(new Action(delegate + { + _Blink.GetMainFrame().EvaluateScriptAsync(@"document.getElementsByTagName('html')[0]").ContinueWith(t => + { + if (t.Result != null && t.Result.Result != null) + { + var result = t.Result.Result.ToString(); + Source = result; + } + }); + })); + return Source; + /*case EngineType.Trident: + return (_Trident.Document as mshtml.IHTMLDocument2).body.outerHTML;*/ + } + return ""; + } + } +} diff --git a/SLBr/SLBr/SettingsPage.xaml b/SLBr/SLBr/SettingsPage.xaml new file mode 100644 index 0000000..e1467d3 --- /dev/null +++ b/SLBr/SLBr/SettingsPage.xaml @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + + Search Provider + + + + + + + + + + + + + + + + + + + + Download + + + + + + + + + Blocked Keywords + + + + + + + + + + + + + +