Commit 0fff5685 authored by Nicolas Ouellet-Payeur's avatar Nicolas Ouellet-Payeur Committed by Chromium LUCI CQ

[BrowserSwitcher] Add ${edge} preset browser on macOS

Microsoft Edge is now available for download on macOS:
https://www.microsoft.com/en-us/edge

Add it to the list of preset browsers, so admins can set
AlternativeBrowserPath to ${edge} if they want to bounce users to Edge.

Also, fix an issue where Chrome tabs wouldn't close after bouncing to
the alternative browser. This affects Linux and macOS only.

Bug: 1124758
Change-Id: I71d18edd7dd9cd83fdd5602be2a41eb9d0ae56a7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2601338Reviewed-by: default avatarJulian Pastarmov <pastarmovj@chromium.org>
Commit-Queue: Nicolas Ouellet-Payeur <nicolaso@chromium.org>
Cr-Commit-Position: refs/heads/master@{#839106}
parent e7ea1421
......@@ -39,6 +39,7 @@ const char kChromeExecutableName[] = "Google Chrome";
const char kFirefoxExecutableName[] = "Firefox";
const char kOperaExecutableName[] = "Opera";
const char kSafariExecutableName[] = "Safari";
const char kEdgeExecutableName[] = "Microsoft Edge";
#else
const char kChromeExecutableName[] = "google-chrome";
const char kFirefoxExecutableName[] = "firefox";
......@@ -50,6 +51,7 @@ const char kFirefoxVarName[] = "${firefox}";
const char kOperaVarName[] = "${opera}";
#if defined(OS_MAC)
const char kSafariVarName[] = "${safari}";
const char kEdgeVarName[] = "${edge}";
#endif
struct BrowserVarMapping {
......@@ -66,6 +68,7 @@ const BrowserVarMapping kBrowserVarMappings[] = {
{kOperaVarName, kOperaExecutableName, "Opera", BrowserType::kOpera},
#if defined(OS_MAC)
{kSafariVarName, kSafariExecutableName, "Safari", BrowserType::kSafari},
{kEdgeVarName, kEdgeExecutableName, "Microsoft Edge", BrowserType::kEdge},
#endif
};
......@@ -216,6 +219,12 @@ void TryLaunchBlocking(GURL url,
const bool success = base::LaunchProcess(cmd_line, options).IsValid();
if (!success)
LOG(ERROR) << "Could not start the alternative browser!";
content::GetUIThreadTaskRunner({})->PostTask(
FROM_HERE,
base::BindOnce(
[](bool success, LaunchCallback cb) { std::move(cb).Run(success); },
success, std::move(cb)));
}
} // namespace
......
......@@ -120,15 +120,16 @@ TEST_F(AlternativeBrowserDriverTest, GetBrowserName) {
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)
SetBrowserPath("${safari}");
actual = driver()->GetBrowserName();
EXPECT_EQ("Safari", actual);
SetBrowserPath("${edge}");
actual = driver()->GetBrowserName();
EXPECT_EQ("Microsoft Edge", actual);
#endif
SetBrowserPath("${firefox}");
......@@ -177,16 +178,16 @@ 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)
SetBrowserPath("${safari}");
actual = driver()->GetBrowserType();
EXPECT_EQ(BrowserType::kSafari, actual);
SetBrowserPath("${edge}");
actual = driver()->GetBrowserType();
EXPECT_EQ(BrowserType::kEdge, actual);
#endif
SetBrowserPath("${firefox}");
......
......@@ -19622,7 +19622,7 @@
'supported_on': ['chrome.*:71-'],
'caption': '''Alternative browser to launch for configured websites.''',
'tags': [],
'desc': '''Setting the policy controls which command to use to open URLs in an alternative browser. The policy can be set to one of <ph name="INTERNET_EXPLORER_VALUE_PLACEHOLDER">${ie}</ph>, <ph name="FIREFOX_VALUE_PLACEHOLDER">${firefox}</ph>, <ph name="SAFARI_VALUE_PLACEHOLDER">${safari}</ph>, <ph name="OPERA_VALUE_PLACEHOLDER">${opera}</ph>, <ph name="EDGE_VALUE_PLACEHOLDER">${edge}</ph> or a file path. When this policy is set to a file path, that file is used as an executable file. <ph name="INTERNET_EXPLORER_VALUE_PLACEHOLDER">${ie}</ph> and <ph name="EDGE_VALUE_PLACEHOLDER">${edge}</ph> are only available on <ph name="MS_WIN_NAME">Microsoft® Windows®</ph>, and <ph name="SAFARI_VALUE_PLACEHOLDER">${safari}</ph> is only available on <ph name="MS_WIN_NAME">Microsoft® Windows®</ph> and <ph name="MAC_OS_NAME">macOS</ph>.
'desc': '''Setting the policy controls which command to use to open URLs in an alternative browser. The policy can be set to one of <ph name="INTERNET_EXPLORER_VALUE_PLACEHOLDER">${ie}</ph>, <ph name="FIREFOX_VALUE_PLACEHOLDER">${firefox}</ph>, <ph name="SAFARI_VALUE_PLACEHOLDER">${safari}</ph>, <ph name="OPERA_VALUE_PLACEHOLDER">${opera}</ph>, <ph name="EDGE_VALUE_PLACEHOLDER">${edge}</ph> or a file path. When this policy is set to a file path, that file is used as an executable file. <ph name="INTERNET_EXPLORER_VALUE_PLACEHOLDER">${ie}</ph> is only available on <ph name="MS_WIN_NAME">Microsoft® Windows®</ph>. <ph name="SAFARI_VALUE_PLACEHOLDER">${safari}</ph> and <ph name="EDGE_VALUE_PLACEHOLDER">${edge}</ph> are only available on <ph name="MS_WIN_NAME">Microsoft® Windows®</ph> and <ph name="MAC_OS_NAME">macOS</ph>.
Leaving the policy unset puts a platform-specific default in use: <ph name="IE_PRODUCT_NAME">Internet Explorer®</ph> for <ph name="MS_WIN_NAME">Microsoft® Windows®</ph>, or <ph name="SAFARI_PRODUCT_NAME">Safari®</ph> for <ph name="MAC_OS_NAME">macOS</ph>. On <ph name="LINUX_OS_NAME">Linux®</ph>, launching an alternative browser will fail.''',
},
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