OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 // | 4 // |
5 // This file defines functions that integrate Chrome in Windows shell. These | 5 // This file defines functions that integrate Chrome in Windows shell. These |
6 // functions can be used by Chrome as well as Chrome installer. All of the | 6 // functions can be used by Chrome as well as Chrome installer. All of the |
7 // work is done by the local functions defined in anonymous namespace in | 7 // work is done by the local functions defined in anonymous namespace in |
8 // this class. | 8 // this class. |
9 | 9 |
10 #include "chrome/installer/util/shell_util.h" | 10 #include "chrome/installer/util/shell_util.h" |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 const string16& chrome_exe, | 82 const string16& chrome_exe, |
83 const string16& suffix, | 83 const string16& suffix, |
84 std::list<RegistryEntry*>* entries) { | 84 std::list<RegistryEntry*>* entries) { |
85 string16 icon_path(ShellUtil::GetChromeIcon(dist, chrome_exe)); | 85 string16 icon_path(ShellUtil::GetChromeIcon(dist, chrome_exe)); |
86 string16 open_cmd(ShellUtil::GetChromeShellOpenCmd(chrome_exe)); | 86 string16 open_cmd(ShellUtil::GetChromeShellOpenCmd(chrome_exe)); |
87 string16 delegate_command(ShellUtil::GetChromeDelegateCommand(chrome_exe)); | 87 string16 delegate_command(ShellUtil::GetChromeDelegateCommand(chrome_exe)); |
88 // For user-level installs: entries for the app id and DelegateExecute verb | 88 // For user-level installs: entries for the app id and DelegateExecute verb |
89 // handler will be in HKCU; thus we do not need a suffix on those entries. | 89 // handler will be in HKCU; thus we do not need a suffix on those entries. |
90 string16 app_id(dist->GetBrowserAppId()); | 90 string16 app_id(dist->GetBrowserAppId()); |
91 string16 delegate_guid; | 91 string16 delegate_guid; |
| 92 // TODO(grt): remove HasDelegateExecuteHandler when the exe is ever-present; |
| 93 // see also install_worker.cc's AddDelegateExecuteWorkItems. |
92 bool set_delegate_execute = | 94 bool set_delegate_execute = |
93 base::win::GetVersion() >= base::win::VERSION_WIN8 && | 95 dist->GetDelegateExecuteHandlerData(&delegate_guid, NULL, NULL, NULL) && |
94 dist->GetDelegateExecuteHandlerData(&delegate_guid, NULL, NULL, NULL); | 96 InstallUtil::HasDelegateExecuteHandler(dist, chrome_exe); |
95 | 97 |
96 // DelegateExecute ProgId. Needed for Chrome Metro in Windows 8. | 98 // DelegateExecute ProgId. Needed for Chrome Metro in Windows 8. |
97 if (set_delegate_execute) { | 99 if (set_delegate_execute) { |
98 string16 model_id_shell(ShellUtil::kRegClasses); | 100 string16 model_id_shell(ShellUtil::kRegClasses); |
99 model_id_shell.push_back(FilePath::kSeparators[0]); | 101 model_id_shell.push_back(FilePath::kSeparators[0]); |
100 model_id_shell.append(app_id); | 102 model_id_shell.append(app_id); |
101 model_id_shell.append(ShellUtil::kRegExePath); | 103 model_id_shell.append(ShellUtil::kRegExePath); |
102 model_id_shell.append(ShellUtil::kRegShellPath); | 104 model_id_shell.append(ShellUtil::kRegShellPath); |
103 | 105 |
104 // <root hkey>\Software\Classes\<app_id>\.exe\shell @=open | 106 // <root hkey>\Software\Classes\<app_id>\.exe\shell @=open |
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
597 | 599 |
598 uint32 ConvertShellUtilShortcutOptionsToFileUtil(uint32 options) { | 600 uint32 ConvertShellUtilShortcutOptionsToFileUtil(uint32 options) { |
599 uint32 converted_options = 0; | 601 uint32 converted_options = 0; |
600 if (options & ShellUtil::SHORTCUT_DUAL_MODE) | 602 if (options & ShellUtil::SHORTCUT_DUAL_MODE) |
601 converted_options |= file_util::SHORTCUT_DUAL_MODE; | 603 converted_options |= file_util::SHORTCUT_DUAL_MODE; |
602 if (options & ShellUtil::SHORTCUT_CREATE_ALWAYS) | 604 if (options & ShellUtil::SHORTCUT_CREATE_ALWAYS) |
603 converted_options |= file_util::SHORTCUT_CREATE_ALWAYS; | 605 converted_options |= file_util::SHORTCUT_CREATE_ALWAYS; |
604 return converted_options; | 606 return converted_options; |
605 } | 607 } |
606 | 608 |
| 609 // As of r133333, the DelegateExecute verb handler was being registered for |
| 610 // Google Chrome installs on Windows 8 even though the binary itself wasn't |
| 611 // present. This affected Chrome 20.0.1115.1 on the dev channel (and anyone who |
| 612 // pulled a Canary >= 20.0.1112.0 and installed it manually as Google Chrome). |
| 613 // This egregious hack is here to remove the bad values for those installs, and |
| 614 // should be removed after a reasonable time, say 2012-08-01. Anyone on Win8 |
| 615 // dev channel who hasn't been autoupdated or manually updated by then will have |
| 616 // to uninstall and reinstall Chrome to repair. See http://crbug.com/124666 and |
| 617 // http://crbug.com/123994 for gory details. |
| 618 void RemoveBadWindows8RegistrationIfNeeded( |
| 619 BrowserDistribution* dist, |
| 620 const string16& chrome_exe, |
| 621 const string16& suffix) { |
| 622 string16 handler_guid; |
| 623 |
| 624 if (dist->GetDelegateExecuteHandlerData(&handler_guid, NULL, NULL, NULL) && |
| 625 !InstallUtil::HasDelegateExecuteHandler(dist, chrome_exe)) { |
| 626 // There's no need to rollback, so forgo the usual work item lists and just |
| 627 // remove the values from the registry. |
| 628 const HKEY root_key = InstallUtil::IsPerUserInstall(chrome_exe.c_str()) ? |
| 629 HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE; |
| 630 const string16 app_id(dist->GetBrowserAppId()); |
| 631 |
| 632 // <root hkey>\Software\Classes\<app_id> |
| 633 string16 key(ShellUtil::kRegClasses); |
| 634 key.push_back(FilePath::kSeparators[0]); |
| 635 key.append(app_id); |
| 636 InstallUtil::DeleteRegistryKey(root_key, key); |
| 637 |
| 638 // <root hkey>\Software\Classes\ChromiumHTML[.user]\shell\open\command |
| 639 key = ShellUtil::kRegClasses; |
| 640 key.push_back(FilePath::kSeparators[0]); |
| 641 key.append(ShellUtil::kChromeHTMLProgId); |
| 642 key.append(suffix); |
| 643 key.append(ShellUtil::kRegShellOpen); |
| 644 InstallUtil::DeleteRegistryValue(root_key, key, |
| 645 ShellUtil::kRegDelegateExecute); |
| 646 } |
| 647 } |
| 648 |
607 } // namespace | 649 } // namespace |
608 | 650 |
609 const wchar_t* ShellUtil::kRegDefaultIcon = L"\\DefaultIcon"; | 651 const wchar_t* ShellUtil::kRegDefaultIcon = L"\\DefaultIcon"; |
610 const wchar_t* ShellUtil::kRegShellPath = L"\\shell"; | 652 const wchar_t* ShellUtil::kRegShellPath = L"\\shell"; |
611 const wchar_t* ShellUtil::kRegShellOpen = L"\\shell\\open\\command"; | 653 const wchar_t* ShellUtil::kRegShellOpen = L"\\shell\\open\\command"; |
612 const wchar_t* ShellUtil::kRegStartMenuInternet = | 654 const wchar_t* ShellUtil::kRegStartMenuInternet = |
613 L"Software\\Clients\\StartMenuInternet"; | 655 L"Software\\Clients\\StartMenuInternet"; |
614 const wchar_t* ShellUtil::kRegClasses = L"Software\\Classes"; | 656 const wchar_t* ShellUtil::kRegClasses = L"Software\\Classes"; |
615 const wchar_t* ShellUtil::kRegRegisteredApplications = | 657 const wchar_t* ShellUtil::kRegRegisteredApplications = |
616 L"Software\\RegisteredApplications"; | 658 L"Software\\RegisteredApplications"; |
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1020 // make them unique. | 1062 // make them unique. |
1021 string16 suffix; | 1063 string16 suffix; |
1022 if (!unique_suffix.empty()) { | 1064 if (!unique_suffix.empty()) { |
1023 suffix = unique_suffix; | 1065 suffix = unique_suffix; |
1024 } else if (InstallUtil::IsPerUserInstall(chrome_exe.c_str()) && | 1066 } else if (InstallUtil::IsPerUserInstall(chrome_exe.c_str()) && |
1025 !GetUserSpecificDefaultBrowserSuffix(dist, &suffix) && | 1067 !GetUserSpecificDefaultBrowserSuffix(dist, &suffix) && |
1026 !AnotherUserHasDefaultBrowser(dist, chrome_exe)) { | 1068 !AnotherUserHasDefaultBrowser(dist, chrome_exe)) { |
1027 suffix = L""; | 1069 suffix = L""; |
1028 } | 1070 } |
1029 | 1071 |
| 1072 // TODO(grt): remove this on or after 2012-08-01; see impl for details. |
| 1073 RemoveBadWindows8RegistrationIfNeeded(dist, chrome_exe, suffix); |
| 1074 |
1030 // Check if Chromium is already registered with this suffix. | 1075 // Check if Chromium is already registered with this suffix. |
1031 if (IsChromeRegistered(dist, chrome_exe, suffix)) | 1076 if (IsChromeRegistered(dist, chrome_exe, suffix)) |
1032 return true; | 1077 return true; |
1033 | 1078 |
1034 // If user is an admin try to register and return the status. | 1079 // If user is an admin try to register and return the status. |
1035 if (IsUserAnAdmin()) { | 1080 if (IsUserAnAdmin()) { |
1036 std::list<RegistryEntry*> progids; | 1081 std::list<RegistryEntry*> progids; |
1037 STLElementDeleter<std::list<RegistryEntry*> > progids_deleter(&progids); | 1082 STLElementDeleter<std::list<RegistryEntry*> > progids_deleter(&progids); |
1038 std::list<RegistryEntry*> sys_entries; | 1083 std::list<RegistryEntry*> sys_entries; |
1039 STLElementDeleter<std::list<RegistryEntry*> > sys_deleter(&sys_entries); | 1084 STLElementDeleter<std::list<RegistryEntry*> > sys_deleter(&sys_entries); |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1215 chrome_exe.c_str(), | 1260 chrome_exe.c_str(), |
1216 shortcut.c_str(), | 1261 shortcut.c_str(), |
1217 chrome_path.c_str(), | 1262 chrome_path.c_str(), |
1218 arguments.c_str(), | 1263 arguments.c_str(), |
1219 description.c_str(), | 1264 description.c_str(), |
1220 icon_path.c_str(), | 1265 icon_path.c_str(), |
1221 icon_index, | 1266 icon_index, |
1222 dist->GetBrowserAppId().c_str(), | 1267 dist->GetBrowserAppId().c_str(), |
1223 ConvertShellUtilShortcutOptionsToFileUtil(options)); | 1268 ConvertShellUtilShortcutOptionsToFileUtil(options)); |
1224 } | 1269 } |
OLD | NEW |