Index: chrome/installer/util/shell_util.cc |
diff --git a/chrome/installer/util/shell_util.cc b/chrome/installer/util/shell_util.cc |
index ef7177ec96fb95b042d23b8defb0c757c4323347..7fb620cde1122a10dcf0b2b976531c642f225c73 100644 |
--- a/chrome/installer/util/shell_util.cc |
+++ b/chrome/installer/util/shell_util.cc |
@@ -611,6 +611,21 @@ bool AnotherUserHasDefaultBrowser(BrowserDistribution* dist, |
return true; |
} |
+// Launches the Windows 7 and Windows 8 dialog for picking the application to |
+// handle the http (and https) protocol. Also known as 'how do you want to open |
+// webpages' dialog. |
+bool LaunchSelectDefaultHttpHandlerDialog() { |
grt (UTC plus 2)
2012/06/01 14:36:39
since this exact same thing will be needed for the
motek.
2012/06/01 20:50:17
Done.
|
+ static const wchar_t* protocol = L"http"; |
+ OPENASINFO open_as_info = {}; |
+ open_as_info.pcszFile = protocol; |
+ open_as_info.oaifInFlags = |
+ OAIF_URL_PROTOCOL | OAIF_FORCE_REGISTRATION | OAIF_REGISTER_EXT; |
+ HRESULT hr = SHOpenWithDialog(NULL, &open_as_info); |
+ DLOG_IF(WARNING, FAILED(hr)) << "Failed to set as default http handler; hr=0x" |
+ << std::hex << hr; |
+ return SUCCEEDED(hr); |
+} |
+ |
// Launches the Windows 7 and Windows 8 application association dialog, which |
// is the only documented way to make a browser the default browser on |
// Windows 8. |
@@ -945,6 +960,14 @@ bool ShellUtil::MakeChromeDefault(BrowserDistribution* dist, |
if (!dist->CanSetAsDefault()) |
return false; |
+ // Windows 8 does not permit making a browser default just like that. |
+ // This process needs to be routed through the system's UI. Use |
+ // ShowMakeChromeDefaultSystemUI instead (below). |
+ if (base::win::GetVersion() >= base::win::VERSION_WIN8) { |
+ NOTREACHED(); |
+ return false; |
+ } |
+ |
ShellUtil::RegisterChromeBrowser(dist, chrome_exe, L"", elevate_if_not_admin); |
bool ret = true; |
@@ -955,17 +978,7 @@ bool ShellUtil::MakeChromeDefault(BrowserDistribution* dist, |
if (ShellUtil::GetUserSpecificDefaultBrowserSuffix(dist, &app_suffix)) |
app_name += app_suffix; |
- if (base::win::GetVersion() >= base::win::VERSION_WIN8) { |
- // 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. This action does not require elevation and we |
- // don't get to control window activation. More info at: |
- // http://msdn.microsoft.com/en-us/library/cc144154(VS.85).aspx |
- return LaunchApplicationAssociationDialog(app_name.c_str()); |
- |
- } else if (base::win::GetVersion() >= base::win::VERSION_VISTA) { |
+ if (base::win::GetVersion() >= base::win::VERSION_VISTA) { |
// On Windows Vista and Win7 we still can set ourselves via the |
// the IApplicationAssociationRegistration interface. |
VLOG(1) << "Registering Chrome as default browser on Vista."; |
@@ -1027,6 +1040,27 @@ bool ShellUtil::MakeChromeDefault(BrowserDistribution* dist, |
return ret; |
} |
+bool ShellUtil::ShowMakeChromeDefaultSystemUI(BrowserDistribution* dist, |
+ int shell_change, |
grt (UTC plus 2)
2012/06/01 14:36:39
indeed, looks like this is never used. please rem
motek.
2012/06/01 20:50:17
Done.
|
+ const string16& chrome_exe, |
+ bool elevate_if_not_admin) { |
gab
2012/06/01 15:27:08
|elevate_if_not_admin| is only false when we regis
motek.
2012/06/01 20:50:17
Done.
|
+ DCHECK(base::win::GetVersion() >= base::win::VERSION_WIN8) |
+ << "This routine is intended for Windows 8 and newer only"; |
grt (UTC plus 2)
2012/06/01 14:36:39
remove the text here since it's obvious.
motek.
2012/06/01 20:50:17
Done.
|
+ if (!dist->CanSetAsDefault()) |
+ return false; |
+ |
+ ShellUtil::RegisterChromeBrowser(dist, chrome_exe, L"", elevate_if_not_admin); |
gab
2012/06/01 15:27:08
This call should be preceeded by !IsChromeRegister
motek.
2012/06/01 20:50:17
Man, none of that existed when I wrote this first
grt (UTC plus 2)
2012/06/04 02:41:14
gab: are you sure this is needed? It looks to me
gab
2012/06/05 01:48:48
Arg, my bad, yes indeed RegisterChromeBrowser does
|
+ |
+ // 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. |
+ // http://msdn.microsoft.com/en-us/library/cc144154(VS.85).aspx |
grt (UTC plus 2)
2012/06/01 14:36:39
i don't think this link is relevant.
motek.
2012/06/01 20:50:17
Done.
|
+ return LaunchSelectDefaultHttpHandlerDialog(); |
+} |
+ |
bool ShellUtil::MakeChromeDefaultProtocolClient(BrowserDistribution* dist, |
const string16& chrome_exe, |
const string16& protocol) { |