Commit d8605ed9 authored by Jayson Adams's avatar Jayson Adams Committed by Commit Bot

[Mac] Force macOS confirm window to front after default browser change.

When you use Chrome's infobar or Settings page to make Chrome your
default browser, macOS presents a confirmation dialog. Sometimes macOS
orders the dialog onscreen but behind the browser window, where it is
effectively invisible. Without confirmation via this dialog, macOS will
not change your default browser.

This cl forces the UI element responsible for the dialog to become
active after setting the default browser, bringing the confirmation
dialog to the foreground, in front of all windows.

Bug: 775281
Change-Id: I5376d57c088ea6b564d84cb3d35442a4330f954b
Reviewed-on: https://chromium-review.googlesource.com/722221Reviewed-by: default avatarMark Mentovai <mark@chromium.org>
Reviewed-by: default avatarRobert Sesek <rsesek@chromium.org>
Commit-Queue: Jayson Adams <shrike@chromium.org>
Cr-Commit-Position: refs/heads/master@{#509581}
parent e9624faf
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "base/mac/bundle_locations.h" #include "base/mac/bundle_locations.h"
#include "base/mac/foundation_util.h" #include "base/mac/foundation_util.h"
#include "base/mac/mac_util.h"
#include "base/strings/sys_string_conversions.h" #include "base/strings/sys_string_conversions.h"
#include "chrome/common/channel_info.h" #include "chrome/common/channel_info.h"
#include "components/version_info/version_info.h" #include "components/version_info/version_info.h"
...@@ -63,6 +64,26 @@ bool SetAsDefaultBrowser() { ...@@ -63,6 +64,26 @@ bool SetAsDefaultBrowser() {
return false; return false;
[[NSWorkspace sharedWorkspace] setDefaultBrowserWithIdentifier:identifier]; [[NSWorkspace sharedWorkspace] setDefaultBrowserWithIdentifier:identifier];
// The CoreServicesUIAgent presents a dialog asking the user to confirm their
// new default browser choice, but the agent sometimes orders the dialog
// behind the Chrome window. The user never sees the dialog, and therefore
// never confirms the change. Make the CoreServicesUIAgent active so the
// confirmation dialog comes to the front.
if (base::mac::IsAtLeastOS10_10()) {
NSString* const kCoreServicesUIAgentBundleID =
@"com.apple.coreservices.uiagent";
for (NSRunningApplication* application in
[[NSWorkspace sharedWorkspace] runningApplications]) {
if ([[application bundleIdentifier]
isEqualToString:kCoreServicesUIAgentBundleID]) {
[application activateWithOptions:NSApplicationActivateAllWindows];
break;
}
}
}
return true; return true;
} }
...@@ -152,4 +173,4 @@ DefaultWebClientState IsDefaultProtocolClient(const std::string& protocol) { ...@@ -152,4 +173,4 @@ DefaultWebClientState IsDefaultProtocolClient(const std::string& protocol) {
IS_DEFAULT : NOT_DEFAULT; IS_DEFAULT : NOT_DEFAULT;
} }
} // namespace shell_integration } // namespace shell_integration
\ No newline at end of file
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