Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4306)

Unified Diff: chrome/installer/util/shell_util.cc

Issue 1140293002: Improve the default browser settings dialog for Win10 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix comment Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/installer/util/shell_util.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/installer/util/shell_util.cc
diff --git a/chrome/installer/util/shell_util.cc b/chrome/installer/util/shell_util.cc
index acff489d78441011d3fe5ea115e82576981d484c..5dd804af45f6ec92cd4f4de26b147c97e3a21a11 100644
--- a/chrome/installer/util/shell_util.cc
+++ b/chrome/installer/util/shell_util.cc
@@ -11,6 +11,7 @@
#include <windows.h>
#include <shlobj.h>
+#include <shobjidl.h>
#include <limits>
#include <string>
@@ -876,6 +877,25 @@ bool ElevateAndRegisterChrome(BrowserDistribution* dist,
return false;
}
+// Launches the Windows 'settings' modern app with the 'default apps' view
+// focused. This only works for Windows 8 and Windows 10. The appModelId
+// looks arbitrary but it is the same in Win8 and Win10 previews. There
+// is no easy way to retrieve the appModelId from the registry.
+bool LaunchDefaultAppsSettingsModernDialog() {
+ base::win::ScopedComPtr<IApplicationActivationManager> activator;
+ HRESULT hr = activator.CreateInstance(CLSID_ApplicationActivationManager);
+ if (SUCCEEDED(hr)) {
+ DWORD pid = 0;
+ CoAllowSetForegroundWindow(activator.get(), nullptr);
+ hr = activator->ActivateApplication(
+ L"windows.immersivecontrolpanel_cw5n1h2txyewy"
+ L"!microsoft.windows.immersivecontrolpanel",
+ L"page=SettingsPageAppsDefaults", AO_NONE, &pid);
+ return SUCCEEDED(hr);
+ }
+ return false;
+}
+
// Launches the Windows 7 and Windows 8 dialog for picking the application to
// handle the given protocol. Most importantly, this is used to set the default
// handler for http (and, implicitly with it, https). In that case it is also
@@ -2061,13 +2081,22 @@ bool ShellUtil::ShowMakeChromeDefaultSystemUI(
bool succeeded = true;
bool is_default = (GetChromeDefaultState() == IS_DEFAULT);
if (!is_default) {
- // On Windows 8, you can't set yourself as the default handler
- // programatically. In other words IApplicationAssociationRegistration
- // has been rendered useless. What you can do is to launch
- // "Set Program Associations" section of the "Default Programs"
- // control panel, which is a mess, or pop the concise "How you want to open
- // webpages?" dialog. We choose the latter.
- succeeded = LaunchSelectDefaultProtocolHandlerDialog(L"http");
+ if (base::win::GetVersion() < base::win::VERSION_WIN10) {
+ // On Windows 8, you can't set yourself as the default handler
+ // programatically. In other words IApplicationAssociationRegistration
+ // has been rendered useless. What you can do is to launch
+ // "Set Program Associations" section of the "Default Programs"
+ // control panel, which is a mess, or pop the concise "How you want to
+ // open webpages?" dialog. We choose the latter.
+ succeeded = LaunchSelectDefaultProtocolHandlerDialog(L"http");
+ } else {
+ // On Windows 10, you can't even launch the associations dialog.
+ // So we launch the settings dialog. Quoting from MSDN: "The Open With
+ // dialog box can no longer be used to change the default program used to
+ // open a file extension. You can only use SHOpenWithDialog to open
+ // a single file."
+ succeeded = LaunchDefaultAppsSettingsModernDialog();
+ }
is_default = (succeeded && GetChromeDefaultState() == IS_DEFAULT);
}
if (succeeded && is_default)
« no previous file with comments | « chrome/installer/util/shell_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698