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

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

Issue 10963004: Fix registerProtocolHandler OS registration on Windows 8 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removed blank line Created 8 years, 3 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 f6e696c1f885aaaf39f0f2236de47cb32ebbbaff..70632fe672a936e26a001937779a0f4faf30eda2 100644
--- a/chrome/installer/util/shell_util.cc
+++ b/chrome/installer/util/shell_util.cc
@@ -911,6 +911,27 @@ bool RegisterChromeAsDefaultForXP(BrowserDistribution* dist,
return ret;
}
+// Associates Chrome with |protocol| in the registry. This should not be
+// required on Vista+ but since some applications still read these registry
+// keys directly, we have to do this on Vista+ as well.
+// See http://msdn.microsoft.com/library/aa767914.aspx for more details.
+bool RegisterChromeAsDefaultProtocolClientForXP(BrowserDistribution* dist,
+ const string16& chrome_exe,
+ const string16& protocol) {
+ ScopedVector<RegistryEntry> entries;
+ const string16 chrome_open(ShellUtil::GetChromeShellOpenCmd(chrome_exe));
+ const string16 chrome_icon(ShellUtil::GetChromeIcon(dist, chrome_exe));
+ RegistryEntry::GetUserProtocolEntries(protocol, chrome_icon, chrome_open,
+ &entries);
+ // Change the default protocol handler for current user.
+ if (!AddRegistryEntries(HKEY_CURRENT_USER, entries)) {
+ LOG(ERROR) << "Could not make Chrome default protocol client (XP).";
+ return false;
+ }
+
+ return true;
+}
+
} // namespace
const wchar_t* ShellUtil::kRegDefaultIcon = L"\\DefaultIcon";
@@ -1375,7 +1396,14 @@ bool ShellUtil::MakeChromeDefaultProtocolClient(BrowserDistribution* dist,
if (!dist->CanSetAsDefault())
return false;
- ShellUtil::RegisterChromeForProtocol(dist, chrome_exe, L"", protocol, true);
+ if (!RegisterChromeForProtocol(dist, chrome_exe, string16(), protocol, true))
+ 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
+ // ShowMakeChromeDefaultProocolClientSystemUI instead (below).
+ if (!CanMakeChromeDefaultUnattended())
+ return false;
bool ret = true;
// First use the new "recommended" way on Vista to make Chrome default
@@ -1401,18 +1429,34 @@ bool ShellUtil::MakeChromeDefaultProtocolClient(BrowserDistribution* dist,
// Now use the old way to associate Chrome with the desired protocol. This
// should not be required on Vista but since some applications still read
// Software\Classes\http key directly, we have to do this on Vista also.
+ if (!RegisterChromeAsDefaultProtocolClientForXP(dist, chrome_exe, protocol))
+ ret = false;
- ScopedVector<RegistryEntry> entries;
- const string16 suffix(GetCurrentInstallationSuffix(dist, chrome_exe));
- const string16 chrome_open(ShellUtil::GetChromeShellOpenCmd(chrome_exe));
- const string16 chrome_icon(ShellUtil::GetChromeIcon(dist, chrome_exe));
- RegistryEntry::GetUserProtocolEntries(protocol, chrome_icon, chrome_open,
- &entries);
- // Change the default protocol handler for current user.
- if (!AddRegistryEntries(HKEY_CURRENT_USER, entries)) {
- ret = false;
- LOG(ERROR) << "Could not make Chrome default protocol client (XP).";
- }
+ return ret;
+}
+
+bool ShellUtil::ShowMakeChromeDefaultProtocolClientSystemUI(
gab 2012/10/03 19:32:42 I just saw this in the code, does this work from C
+ BrowserDistribution* dist,
+ const string16& chrome_exe,
+ const string16& protocol) {
+ DCHECK_GE(base::win::GetVersion(), base::win::VERSION_WIN8);
+ if (!dist->CanSetAsDefault())
+ return false;
+
+ if (!RegisterChromeForProtocol(dist, chrome_exe, string16(), protocol, 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
+ // links of this type (protocol)?" dialog. We choose the latter.
+ // Return true only when the user took an action and there was no error.
+ const bool ret = LaunchSelectDefaultProtocolHandlerDialog(protocol.c_str());
+
+ if (ret)
+ RegisterChromeAsDefaultProtocolClientForXP(dist, chrome_exe, protocol);
return ret;
}
« 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