Commit 43e4b9e8 authored by Nicolas Ouellet-Payeur's avatar Nicolas Ouellet-Payeur Committed by Commit Bot

[BrowserSwitcher] Add ${edge} preset browser

On Windows, the AlternativeBrowserPath policy can now be set to
"${edge}", to open Microsoft Edge instead of IE.

This will display the browser name as "Microsoft Edge" on the
interstitial before opening it:

https://i.imgur.com/Qr1rPs4.png

Bug: 1124758
Change-Id: Ibe3c24b209c1054510cceb4b0237cf068acb84ef
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2414621
Commit-Queue: Nicolas Ouellet-Payeur <nicolaso@chromium.org>
Reviewed-by: default avatarJulian Pastarmov <pastarmovj@chromium.org>
Cr-Commit-Position: refs/heads/master@{#807979}
parent 1d375794
......@@ -21,7 +21,8 @@ namespace browser_switcher {
class BrowserSwitcherPrefs;
// Used for UMA metrics.
// Used for UMA metrics, so do NOT change the order and the numbers. If you want
// to add a new type, only append/increment.
enum class BrowserType {
kUnknown = 0,
kIE = 1,
......@@ -29,7 +30,8 @@ enum class BrowserType {
kOpera = 3,
kSafari = 4,
kChrome = 5,
kMaxValue = kChrome,
kEdge = 6,
kMaxValue = kEdge,
};
// Interface for a helper class that does I/O operations for an
......
......@@ -31,6 +31,9 @@ using LaunchCallback = AlternativeBrowserDriver::LaunchCallback;
const char kUrlVarName[] = "${url}";
// TODO(crbug.com/1124758): add ${edge} on macOS/Linux once it's released on
// those platforms.
#if defined(OS_MAC)
const char kChromeExecutableName[] = "Google Chrome";
const char kFirefoxExecutableName[] = "Firefox";
......
......@@ -119,6 +119,10 @@ TEST_F(AlternativeBrowserDriverTest, GetBrowserName) {
SetBrowserPath("${ie}");
actual = driver()->GetBrowserName();
EXPECT_EQ("Internet Explorer", actual);
SetBrowserPath("${edge}");
actual = driver()->GetBrowserName();
EXPECT_EQ("Microsoft Edge", actual);
#endif
#if defined(OS_WIN) || defined(OS_MAC)
......@@ -173,6 +177,10 @@ TEST_F(AlternativeBrowserDriverTest, GetBrowserType) {
"C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe");
actual = driver()->GetBrowserType();
EXPECT_EQ(BrowserType::kChrome, actual);
SetBrowserPath("${edge}");
actual = driver()->GetBrowserType();
EXPECT_EQ(BrowserType::kEdge, actual);
#endif
#if defined(OS_WIN) || defined(OS_MAC)
......
......@@ -44,6 +44,8 @@ const wchar_t kSafariKey[] =
L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\safari.exe";
const wchar_t kChromeKey[] =
L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\chrome.exe";
const wchar_t kEdgeKey[] =
L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\msedge.exe";
const wchar_t kIExploreDdeHost[] = L"IExplore";
......@@ -52,12 +54,14 @@ const wchar_t kIEVarName[] = L"${ie}";
const wchar_t kFirefoxVarName[] = L"${firefox}";
const wchar_t kOperaVarName[] = L"${opera}";
const wchar_t kSafariVarName[] = L"${safari}";
const wchar_t kEdgeVarName[] = L"${edge}";
// Case-insensitive, typical filenames for popular browsers' executables.
const wchar_t kChromeTypicalExecutable[] = L"chrome.exe";
const wchar_t kIETypicalExecutable[] = L"iexplore.exe";
const wchar_t kFirefoxTypicalExecutable[] = L"firefox.exe";
const wchar_t kOperaTypicalExecutable[] = L"launcher.exe";
const wchar_t kEdgeTypicalExecutable[] = L"msedge.exe";
struct BrowserVarMapping {
const wchar_t* var_name;
......@@ -77,6 +81,8 @@ const BrowserVarMapping kBrowserVarMappings[] = {
{kOperaVarName, kOperaKey, kOperaTypicalExecutable, "Opera",
BrowserType::kOpera},
{kSafariVarName, kSafariKey, L"", "Safari", BrowserType::kSafari},
{kEdgeVarName, kEdgeKey, kEdgeTypicalExecutable, "Microsoft Edge",
BrowserType::kEdge},
};
// DDE Callback function which is not used in our case at all.
......
......@@ -8598,6 +8598,7 @@ Called by update_bad_message_reasons.py.-->
<int value="3" label="Opera"/>
<int value="4" label="Safari"/>
<int value="5" label="Chrome"/>
<int value="6" label="Edge"/>
</enum>
<enum name="BrowsingDataRemoverTasks">
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment