Chromium Code Reviews| Index: chrome/installer/util/shell_util.cc |
| diff --git a/chrome/installer/util/shell_util.cc b/chrome/installer/util/shell_util.cc |
| index 229abe52f79b9b56664f144c7750c697bdd8306b..ec918e7d5ed52e4ea4896a30b0d3b9ad3771b950 100644 |
| --- a/chrome/installer/util/shell_util.cc |
| +++ b/chrome/installer/util/shell_util.cc |
| @@ -127,6 +127,7 @@ class RegistryEntry { |
| // are needed to register Chromium ProgIds. |
| // These entries should be registered in HKCU for user-level installs and in |
| // HKLM for system-level installs. |
| + // TODO (gab): Extract the Windows 8 only registrations out of this function. |
|
grt (UTC plus 2)
2012/06/20 19:42:12
has it been a long time since you rebased?
motek.
2012/06/20 22:02:29
Not really. This is some git accident, gab@ says l
|
| static bool GetProgIdEntries(BrowserDistribution* dist, |
| const string16& chrome_exe, |
| const string16& suffix, |
| @@ -198,7 +199,7 @@ class RegistryEntry { |
| } |
| // The following entries are required as of Windows 8, but do not |
| - // depend on the DelegateExecute verb handler being set. |
| + // depend on the DelegateExecute. |
| if (base::win::GetVersion() >= base::win::VERSION_WIN8) { |
| entries->push_front(new RegistryEntry( |
| chrome_html_prog_id, ShellUtil::kRegAppUserModelId, app_id)); |
| @@ -552,10 +553,6 @@ bool ElevateAndRegisterChrome(BrowserDistribution* dist, |
| const string16& chrome_exe, |
| const string16& suffix, |
| const string16& protocol) { |
| - // Only user-level installs prior to Windows 8 should need to elevate to |
| - // register. |
| - DCHECK(InstallUtil::IsPerUserInstall(chrome_exe.c_str())); |
| - DCHECK_LT(base::win::GetVersion(), base::win::VERSION_WIN8); |
| FilePath exe_path = |
| FilePath::FromWStringHack(chrome_exe).DirName() |
| .Append(installer::kSetupExe); |
| @@ -610,10 +607,11 @@ bool LaunchSelectDefaultProtocolHandlerDialog(const wchar_t* protocol) { |
| HRESULT hr = SHOpenWithDialog(NULL, &open_as_info); |
| DLOG_IF(WARNING, FAILED(hr)) << "Failed to set as default " << protocol |
| << " handler; hr=0x" << std::hex << hr; |
| + |
| if (FAILED(hr)) |
| return false; |
| SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL); |
| - return true; |
| + return SUCCEEDED(hr); |
| } |
| // Launches the Windows 7 and Windows 8 application association dialog, which |
| @@ -1142,8 +1140,6 @@ bool ShellUtil::MakeChromeDefault(BrowserDistribution* dist, |
| int shell_change, |
| const string16& chrome_exe, |
| bool elevate_if_not_admin) { |
| - DCHECK(!(shell_change & ShellUtil::SYSTEM_LEVEL) || IsUserAnAdmin()); |
| - |
| if (!dist->CanSetAsDefault()) |
| return false; |
| @@ -1241,6 +1237,7 @@ bool ShellUtil::ShowMakeChromeDefaultSystemUI(BrowserDistribution* dist, |
| // "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 true only when the user took an action and there was no error. |
| return LaunchSelectDefaultProtocolHandlerDialog(L"http"); |
| } |
| @@ -1333,16 +1330,14 @@ bool ShellUtil::RegisterChromeBrowser(BrowserDistribution* dist, |
| AddRegistryEntries(root, shell_entries); |
| } |
| - // If the user is not an admin and OS is between Vista and Windows 7 |
| - // inclusively, try to elevate and register. This is only intended for |
| - // user-level installs as system-level installs should always be run with |
| - // admin rights. |
| + // If user is not an admin and OS is Vista, try to elevate and register. |
| if (elevate_if_not_admin && |
| base::win::GetVersion() >= base::win::VERSION_VISTA && |
| ElevateAndRegisterChrome(dist, chrome_exe, suffix, L"")) |
| return true; |
| - // If we got to this point then all we can do is create ProgIds under HKCU. |
| + // If we got to this point then all we can do is create ProgIds under HKCU |
| + // on XP as well as Vista. |
| std::list<RegistryEntry*> entries; |
| STLElementDeleter<std::list<RegistryEntry*> > entries_deleter(&entries); |
| RegistryEntry::GetProgIdEntries(dist, chrome_exe, L"", &entries); |
| @@ -1393,13 +1388,14 @@ bool ShellUtil::RegisterChromeForProtocol(BrowserDistribution* dist, |
| STLElementDeleter<std::list<RegistryEntry*> > entries_deleter(&entries); |
| RegistryEntry::GetProtocolCapabilityEntries(dist, suffix, protocol, |
| &entries); |
| - return AddRegistryEntries(root, entries); |
| + return AddRegistryEntries(HKEY_LOCAL_MACHINE, entries); |
| } else if (elevate_if_not_admin && |
| base::win::GetVersion() >= base::win::VERSION_VISTA) { |
| // Elevate to do the whole job |
| return ElevateAndRegisterChrome(dist, chrome_exe, suffix, protocol); |
| } else { |
| - // Admin rights are required to register capabilities before Windows 8. |
| + // we need admin rights to register our capability. If we don't |
| + // have them and can't elevate, give up. |
| return false; |
| } |
| } |