From 057108882f06185813faeb14f1c539c635ee9d32 Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Thu, 1 Aug 2019 20:52:50 +1000 Subject: [PATCH 1/4] Open URL in new window browser --- Plugins/Wox.Plugin.Url/Main.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Plugins/Wox.Plugin.Url/Main.cs b/Plugins/Wox.Plugin.Url/Main.cs index 6cd486919b..78cb13fac2 100644 --- a/Plugins/Wox.Plugin.Url/Main.cs +++ b/Plugins/Wox.Plugin.Url/Main.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Diagnostics; using System.Text.RegularExpressions; @@ -85,7 +85,7 @@ namespace Wox.Plugin.Url } else { - Process.Start(_settings.BrowserPath,raw); + Process.Start(_settings.BrowserPath,"--new-window" + raw); } return true; From e18e923ac6aeff795c0163c672758dbdc3b1e3a9 Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Fri, 2 Aug 2019 22:14:08 +1000 Subject: [PATCH 2/4] Bugfix and update Fix bug when no browser path specified will be null instead of .Length == 0. Add open url in new browser window by default --- Plugins/Wox.Plugin.Url/Main.cs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/Plugins/Wox.Plugin.Url/Main.cs b/Plugins/Wox.Plugin.Url/Main.cs index 78cb13fac2..c3229064e1 100644 --- a/Plugins/Wox.Plugin.Url/Main.cs +++ b/Plugins/Wox.Plugin.Url/Main.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using System.Linq; using System.Text.RegularExpressions; using System.Windows.Controls; using Wox.Infrastructure.Storage; @@ -79,14 +80,14 @@ namespace Wox.Plugin.Url } try { - if (_settings.BrowserPath.Length == 0) - { - Process.Start(raw); - } - else - { - Process.Start(_settings.BrowserPath,"--new-window" + raw); - } + var browserExecutableName = _settings.BrowserPath?.Split(new[] { System.IO.Path.DirectorySeparatorChar }, StringSplitOptions.None).Last(); + + var browser = string.IsNullOrEmpty(browserExecutableName) ? "chrome" : _settings.BrowserPath; + + // Internet Explorer will open url in new browser window, and does not take the --new-window parameter + var browserArguements = browserExecutableName == "iexplore.exe" ? raw : "--new-window " + raw; + + Process.Start(browser, browserArguements); return true; } From 07060a8584bd862b1d18e4096b6418378959722b Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Tue, 6 Aug 2019 21:27:54 +1000 Subject: [PATCH 3/4] Add shared commands for plugins to use --- Wox.Plugin/SharedCommands/SearchWeb.cs | 27 ++++++++++++++++++++++++++ Wox.Plugin/Wox.Plugin.csproj | 2 ++ 2 files changed, 29 insertions(+) create mode 100644 Wox.Plugin/SharedCommands/SearchWeb.cs diff --git a/Wox.Plugin/SharedCommands/SearchWeb.cs b/Wox.Plugin/SharedCommands/SearchWeb.cs new file mode 100644 index 0000000000..7c2cc31813 --- /dev/null +++ b/Wox.Plugin/SharedCommands/SearchWeb.cs @@ -0,0 +1,27 @@ +using System; +using System.Diagnostics; +using System.IO; +using System.Linq; + +namespace Wox.Plugin.WebSearch.Commands +{ + internal static class SearchWeb + { + /// Opens search in a new browser. If no browser path is passed in then Chrome is used. + /// Leave browser path blank to use Chrome. + /// + internal static void NewBrowserWindow(this string url, string browserPath) + { + var browserExecutableName = browserPath? + .Split(new[] { Path.DirectorySeparatorChar }, StringSplitOptions.None) + .Last(); + + var browser = string.IsNullOrEmpty(browserExecutableName) ? "chrome" : browserPath; + + // Internet Explorer will open url in new browser window, and does not take the --new-window parameter + var browserArguements = browserExecutableName == "iexplore.exe" ? url : "--new-window " + url; + + Process.Start(browser, browserArguements); + } + } +} diff --git a/Wox.Plugin/Wox.Plugin.csproj b/Wox.Plugin/Wox.Plugin.csproj index 1acfef9491..8b1e9f0ca7 100644 --- a/Wox.Plugin/Wox.Plugin.csproj +++ b/Wox.Plugin/Wox.Plugin.csproj @@ -76,6 +76,7 @@ + @@ -84,6 +85,7 @@ + From 7d9e848edb23ec6dae5b3679f5d69e43cbc41afc Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Tue, 6 Aug 2019 21:58:46 +1000 Subject: [PATCH 4/4] use shared commands --- Plugins/Wox.Plugin.Url/Main.cs | 12 ++---------- Wox.Plugin/SharedCommands/SearchWeb.cs | 6 +++--- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/Plugins/Wox.Plugin.Url/Main.cs b/Plugins/Wox.Plugin.Url/Main.cs index c3229064e1..1c3a708c84 100644 --- a/Plugins/Wox.Plugin.Url/Main.cs +++ b/Plugins/Wox.Plugin.Url/Main.cs @@ -1,10 +1,9 @@ using System; using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; using System.Text.RegularExpressions; using System.Windows.Controls; using Wox.Infrastructure.Storage; +using Wox.Plugin.SharedCommands; namespace Wox.Plugin.Url { @@ -80,15 +79,8 @@ namespace Wox.Plugin.Url } try { - var browserExecutableName = _settings.BrowserPath?.Split(new[] { System.IO.Path.DirectorySeparatorChar }, StringSplitOptions.None).Last(); - - var browser = string.IsNullOrEmpty(browserExecutableName) ? "chrome" : _settings.BrowserPath; + raw.NewBrowserWindow(_settings.BrowserPath); - // Internet Explorer will open url in new browser window, and does not take the --new-window parameter - var browserArguements = browserExecutableName == "iexplore.exe" ? raw : "--new-window " + raw; - - Process.Start(browser, browserArguements); - return true; } catch(Exception ex) diff --git a/Wox.Plugin/SharedCommands/SearchWeb.cs b/Wox.Plugin/SharedCommands/SearchWeb.cs index 7c2cc31813..0dc03ee6d5 100644 --- a/Wox.Plugin/SharedCommands/SearchWeb.cs +++ b/Wox.Plugin/SharedCommands/SearchWeb.cs @@ -3,14 +3,14 @@ using System.Diagnostics; using System.IO; using System.Linq; -namespace Wox.Plugin.WebSearch.Commands +namespace Wox.Plugin.SharedCommands { - internal static class SearchWeb + public static class SearchWeb { /// Opens search in a new browser. If no browser path is passed in then Chrome is used. /// Leave browser path blank to use Chrome. /// - internal static void NewBrowserWindow(this string url, string browserPath) + public static void NewBrowserWindow(this string url, string browserPath) { var browserExecutableName = browserPath? .Split(new[] { Path.DirectorySeparatorChar }, StringSplitOptions.None)