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..b072c4e0c8ca6274ed5b5d8e1ca6dbd0ae35c88e 100644 |
--- a/chrome/installer/util/shell_util.cc |
+++ b/chrome/installer/util/shell_util.cc |
@@ -611,6 +611,20 @@ 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(const wchar_t* protocol) { |
grt (UTC plus 2)
2012/06/04 02:41:14
Replace "Http" with "Protocol" in the function nam
motek.
2012/06/06 18:30:41
Done.
|
+ OPENASINFO open_as_info = {}; |
grt (UTC plus 2)
2012/06/04 02:41:14
DCHECK(protocol); just before this
motek.
2012/06/06 18:30:41
Done.
|
+ 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 +959,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 +977,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 +1039,27 @@ bool ShellUtil::MakeChromeDefault(BrowserDistribution* dist, |
return ret; |
} |
+bool ShellUtil::ShowMakeChromeDefaultSystemUI(BrowserDistribution* dist, |
+ const string16& chrome_exe) { |
+ static const wchar_t* protocol = L"http"; |
gab
2012/06/05 01:48:48
nit: static strings in the Chrome codebase should
gab
2012/06/05 01:48:48
nit: How about "protocol" -->"http_protocol" or ha
motek.
2012/06/06 18:30:41
In-lined as discussed.
motek.
2012/06/06 18:30:41
Ack.
|
+ DCHECK(base::win::GetVersion() >= base::win::VERSION_WIN8); |
grt (UTC plus 2)
2012/06/04 02:41:14
nit: DCHECK_GE(base::win::GetVersion(), base::win:
motek.
2012/06/06 18:30:41
Done.
|
+ if (!dist->CanSetAsDefault()) |
+ return false; |
+ |
+ if (!IsChromeRegistered(dist, chrome_exe, L"") && |
+ !RegisterChromeBrowser(dist, chrome_exe, L"", true)) { |
grt (UTC plus 2)
2012/06/04 02:41:14
ubernit: L"" -> string()
motek.
2012/06/06 18:30:41
string16() ;-)?
Done.
|
+ return false; |
+ } |
+ |
+ // 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. |
+ return LaunchSelectDefaultHttpHandlerDialog(protocol); |
+} |
+ |
bool ShellUtil::MakeChromeDefaultProtocolClient(BrowserDistribution* dist, |
const string16& chrome_exe, |
const string16& protocol) { |