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..3a0ac189e37ec99df9344f7c848375e4f08e5f4c 100644 |
--- a/chrome/installer/util/shell_util.cc |
+++ b/chrome/installer/util/shell_util.cc |
@@ -611,6 +611,22 @@ bool AnotherUserHasDefaultBrowser(BrowserDistribution* dist, |
return true; |
} |
+// 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 |
+// known as the 'how do you want to open webpages' dialog. |
+bool LaunchSelectDefaultProtocolHandlerDialog(const wchar_t* protocol) { |
gab
2012/06/06 22:47:21
This method should either:
- RegisterChromeForProt
grt (UTC plus 2)
2012/06/07 02:50:36
Don't do this. This is a small, private, easy to
gab
2012/06/07 14:01:51
Ok, but do add it to the contract then, right?
motek.
2012/06/07 14:58:50
Ack.
motek.
2012/06/07 14:58:50
Ack. But see below.
motek.
2012/06/07 14:58:50
Well, perhaps to comments. Enforcement through DCH
gab
2012/06/07 15:18:54
Arg, indeed, for now, because you need to know the
|
+ DCHECK(protocol); |
+ 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" |
gab
2012/06/06 22:47:21
"http" --> << protocol <<
motek.
2012/06/07 14:58:50
Done.
|
+ << std::hex << hr; |
gab
2012/06/06 22:47:21
I'm not exactly sure which osstream is used for DL
grt (UTC plus 2)
2012/06/07 02:50:36
The stream's lifetime is bound to the log message
gab
2012/06/07 15:18:54
Awesome, good to know :).
|
+ 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 +961,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 +979,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 +1041,24 @@ bool ShellUtil::MakeChromeDefault(BrowserDistribution* dist, |
return ret; |
} |
+bool ShellUtil::ShowMakeChromeDefaultSystemUI(BrowserDistribution* dist, |
+ const string16& chrome_exe) { |
+ DCHECK_GE(base::win::GetVersion(), base::win::VERSION_WIN8); |
+ if (!dist->CanSetAsDefault()) |
+ return false; |
+ |
+ if (!RegisterChromeBrowser(dist, chrome_exe, string16(), true)) |
+ 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. |
gab
2012/06/06 22:47:21
The '?' goes inside the quotes right?
gab
2012/06/06 22:47:21
choose --> chose (i.e. chose is the past tense of
grt (UTC plus 2)
2012/06/07 02:50:36
Dunno. It sounds fine to me as-is.
motek.
2012/06/07 14:58:50
Done.
motek.
2012/06/07 14:58:50
This is as intended. I find the present tense to b
motek.
2012/06/07 14:58:50
Ack.
|
+ return LaunchSelectDefaultProtocolHandlerDialog(L"http"); |
+} |
+ |
bool ShellUtil::MakeChromeDefaultProtocolClient(BrowserDistribution* dist, |
const string16& chrome_exe, |
const string16& protocol) { |