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 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
232 // DelegateExecute ProgId. Needed for Chrome Metro in Windows 8. | 232 // DelegateExecute ProgId. Needed for Chrome Metro in Windows 8. |
233 if (set_delegate_execute) { | 233 if (set_delegate_execute) { |
234 string16 model_id_shell(ShellUtil::kRegClasses); | 234 string16 model_id_shell(ShellUtil::kRegClasses); |
235 model_id_shell.push_back(FilePath::kSeparators[0]); | 235 model_id_shell.push_back(FilePath::kSeparators[0]); |
236 model_id_shell.append(app_id); | 236 model_id_shell.append(app_id); |
237 model_id_shell.append(ShellUtil::kRegExePath); | 237 model_id_shell.append(ShellUtil::kRegExePath); |
238 model_id_shell.append(ShellUtil::kRegShellPath); | 238 model_id_shell.append(ShellUtil::kRegShellPath); |
239 | 239 |
240 // <root hkey>\Software\Classes\<app_id>\.exe\shell @=open | 240 // <root hkey>\Software\Classes\<app_id>\.exe\shell @=open |
241 entries->push_back(new RegistryEntry(model_id_shell, | 241 entries->push_back(new RegistryEntry(model_id_shell, |
242 ShellUtil::kRegVerbOpen)); | 242 ShellUtil::kRegVerbOpen)); |
243 | 243 |
244 const wchar_t* const verbs[] = { ShellUtil::kRegVerbOpen, | 244 const wchar_t* const verbs[] = { ShellUtil::kRegVerbOpen, |
245 ShellUtil::kRegVerbOpenNewWindow, | 245 ShellUtil::kRegVerbOpenNewWindow }; |
246 ShellUtil::kRegVerbRun }; | |
247 for (size_t i = 0; i < arraysize(verbs); ++i) { | 246 for (size_t i = 0; i < arraysize(verbs); ++i) { |
248 string16 sub_path(model_id_shell); | 247 string16 sub_path(model_id_shell); |
249 sub_path.push_back(FilePath::kSeparators[0]); | 248 sub_path.push_back(FilePath::kSeparators[0]); |
250 sub_path.append(verbs[i]); | 249 sub_path.append(verbs[i]); |
251 | 250 |
252 // <root hkey>\Software\Classes\<app_id>\.exe\shell\<verb> | 251 // <root hkey>\Software\Classes\<app_id>\.exe\shell\<verb> |
253 entries->push_back(new RegistryEntry( | 252 entries->push_back(new RegistryEntry( |
254 sub_path, L"CommandId", L"Browser.Launch")); | 253 sub_path, L"CommandId", L"Browser.Launch")); |
255 | 254 |
256 sub_path.push_back(FilePath::kSeparators[0]); | 255 sub_path.push_back(FilePath::kSeparators[0]); |
(...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1008 shortcut_properties.set_app_id( | 1007 shortcut_properties.set_app_id( |
1009 ShellUtil::GetBrowserModelId(dist, is_per_user_install)); | 1008 ShellUtil::GetBrowserModelId(dist, is_per_user_install)); |
1010 } | 1009 } |
1011 | 1010 |
1012 if (properties.has_dual_mode()) | 1011 if (properties.has_dual_mode()) |
1013 shortcut_properties.set_dual_mode(properties.dual_mode); | 1012 shortcut_properties.set_dual_mode(properties.dual_mode); |
1014 | 1013 |
1015 return shortcut_properties; | 1014 return shortcut_properties; |
1016 } | 1015 } |
1017 | 1016 |
1017 // Cleans up an old verb (run) we used to register in | |
1018 // <root>\Software\Classes\Chrome<.suffix>\.exe\shell\run. | |
1019 // TODO (gab): This was fixed before the official release of Windows 8 and thus | |
grt (UTC plus 2)
2012/10/16 01:43:03
"official release" -> "general availability"
gab
2012/10/16 14:59:50
Done.
| |
1020 // can safely be removed in February 2013. | |
1021 void RemoveRunVerbOnWindows8( | |
1022 BrowserDistribution* dist, | |
1023 const string16& chrome_exe) { | |
1024 HKEY root_key = DetermineShellIntegrationRoot( | |
grt (UTC plus 2)
2012/10/16 01:43:03
wrap this function in:
if (IsChromeMetroSupported(
grt (UTC plus 2)
2012/10/16 01:43:03
is root_key always HKCU?
gab
2012/10/16 14:59:50
Done.
gab
2012/10/16 14:59:50
HKCU on user-level installs, HKLM on system-level
grt (UTC plus 2)
2012/10/16 15:31:13
Oh yeah. Good call.
| |
1025 InstallUtil::IsPerUserInstall(chrome_exe.c_str())); | |
grt (UTC plus 2)
2012/10/16 01:43:03
store the value of IsPerUserInstall() and re-use o
gab
2012/10/16 14:59:50
Indeed! Done.
| |
1026 // There's no need to rollback, so forgo the usual work item lists and just | |
1027 // remove the key from the registry. | |
1028 string16 run_verb_key(ShellUtil::kRegClasses); | |
1029 run_verb_key.push_back(FilePath::kSeparators[0]); | |
1030 run_verb_key.append(ShellUtil::GetBrowserModelId( | |
1031 dist, InstallUtil::IsPerUserInstall(chrome_exe.c_str()))); | |
1032 run_verb_key.append(ShellUtil::kRegExePath); | |
1033 run_verb_key.append(ShellUtil::kRegShellPath); | |
1034 run_verb_key.push_back(FilePath::kSeparators[0]); | |
1035 run_verb_key.append(ShellUtil::kRegVerbRun); | |
1036 InstallUtil::DeleteRegistryKey(root_key, run_verb_key); | |
1037 } | |
1038 | |
1018 } // namespace | 1039 } // namespace |
1019 | 1040 |
1020 const wchar_t* ShellUtil::kRegDefaultIcon = L"\\DefaultIcon"; | 1041 const wchar_t* ShellUtil::kRegDefaultIcon = L"\\DefaultIcon"; |
1021 const wchar_t* ShellUtil::kRegShellPath = L"\\shell"; | 1042 const wchar_t* ShellUtil::kRegShellPath = L"\\shell"; |
1022 const wchar_t* ShellUtil::kRegShellOpen = L"\\shell\\open\\command"; | 1043 const wchar_t* ShellUtil::kRegShellOpen = L"\\shell\\open\\command"; |
1023 const wchar_t* ShellUtil::kRegStartMenuInternet = | 1044 const wchar_t* ShellUtil::kRegStartMenuInternet = |
1024 L"Software\\Clients\\StartMenuInternet"; | 1045 L"Software\\Clients\\StartMenuInternet"; |
1025 const wchar_t* ShellUtil::kRegClasses = L"Software\\Classes"; | 1046 const wchar_t* ShellUtil::kRegClasses = L"Software\\Classes"; |
1026 const wchar_t* ShellUtil::kRegRegisteredApplications = | 1047 const wchar_t* ShellUtil::kRegRegisteredApplications = |
1027 L"Software\\RegisteredApplications"; | 1048 L"Software\\RegisteredApplications"; |
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1512 string16 suffix; | 1533 string16 suffix; |
1513 if (!unique_suffix.empty()) { | 1534 if (!unique_suffix.empty()) { |
1514 suffix = unique_suffix; | 1535 suffix = unique_suffix; |
1515 } else if (!GetInstallationSpecificSuffix(dist, chrome_exe, &suffix)) { | 1536 } else if (!GetInstallationSpecificSuffix(dist, chrome_exe, &suffix)) { |
1516 return false; | 1537 return false; |
1517 } | 1538 } |
1518 | 1539 |
1519 // TODO(grt): remove this on or after 2012-08-01; see impl for details. | 1540 // TODO(grt): remove this on or after 2012-08-01; see impl for details. |
1520 RemoveBadWindows8RegistrationIfNeeded(dist, chrome_exe); | 1541 RemoveBadWindows8RegistrationIfNeeded(dist, chrome_exe); |
1521 | 1542 |
1543 // TODO(gab): remove this on or after 2013-02-01; see impl for details. | |
1544 RemoveRunVerbOnWindows8(dist, chrome_exe); | |
1545 | |
1522 // Check if Chromium is already registered with this suffix. | 1546 // Check if Chromium is already registered with this suffix. |
1523 if (IsChromeRegistered(dist, chrome_exe, suffix)) | 1547 if (IsChromeRegistered(dist, chrome_exe, suffix)) |
1524 return true; | 1548 return true; |
1525 | 1549 |
1526 bool user_level = InstallUtil::IsPerUserInstall(chrome_exe.c_str()); | 1550 bool user_level = InstallUtil::IsPerUserInstall(chrome_exe.c_str()); |
1527 HKEY root = DetermineShellIntegrationRoot(user_level); | 1551 HKEY root = DetermineShellIntegrationRoot(user_level); |
1528 | 1552 |
1529 // Do the full registration if we can do it at user-level or if the user is an | 1553 // Do the full registration if we can do it at user-level or if the user is an |
1530 // admin. | 1554 // admin. |
1531 if (root == HKEY_CURRENT_USER || IsUserAnAdmin()) { | 1555 if (root == HKEY_CURRENT_USER || IsUserAnAdmin()) { |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1738 // are any left...). | 1762 // are any left...). |
1739 if (free_bits >= 8 && next_byte_index < size) { | 1763 if (free_bits >= 8 && next_byte_index < size) { |
1740 free_bits -= 8; | 1764 free_bits -= 8; |
1741 bit_stream += bytes[next_byte_index++] << free_bits; | 1765 bit_stream += bytes[next_byte_index++] << free_bits; |
1742 } | 1766 } |
1743 } | 1767 } |
1744 | 1768 |
1745 DCHECK_EQ(ret.length(), encoded_length); | 1769 DCHECK_EQ(ret.length(), encoded_length); |
1746 return ret; | 1770 return ret; |
1747 } | 1771 } |
OLD | NEW |