| 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 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 // DelegateExecute ProgId. Needed for Chrome Metro in Windows 8. | 233 // DelegateExecute ProgId. Needed for Chrome Metro in Windows 8. |
| 234 if (set_delegate_execute) { | 234 if (set_delegate_execute) { |
| 235 string16 model_id_shell(ShellUtil::kRegClasses); | 235 string16 model_id_shell(ShellUtil::kRegClasses); |
| 236 model_id_shell.push_back(FilePath::kSeparators[0]); | 236 model_id_shell.push_back(FilePath::kSeparators[0]); |
| 237 model_id_shell.append(app_id); | 237 model_id_shell.append(app_id); |
| 238 model_id_shell.append(ShellUtil::kRegExePath); | 238 model_id_shell.append(ShellUtil::kRegExePath); |
| 239 model_id_shell.append(ShellUtil::kRegShellPath); | 239 model_id_shell.append(ShellUtil::kRegShellPath); |
| 240 | 240 |
| 241 // <root hkey>\Software\Classes\<app_id>\.exe\shell @=open | 241 // <root hkey>\Software\Classes\<app_id>\.exe\shell @=open |
| 242 entries->push_back(new RegistryEntry(model_id_shell, | 242 entries->push_back(new RegistryEntry(model_id_shell, |
| 243 ShellUtil::kRegVerbOpen)); | 243 ShellUtil::kRegVerbOpen)); |
| 244 | 244 |
| 245 const wchar_t* const verbs[] = { ShellUtil::kRegVerbOpen, | 245 const wchar_t* const verbs[] = { ShellUtil::kRegVerbOpen, |
| 246 ShellUtil::kRegVerbOpenNewWindow, | 246 ShellUtil::kRegVerbOpenNewWindow }; |
| 247 ShellUtil::kRegVerbRun }; | |
| 248 for (size_t i = 0; i < arraysize(verbs); ++i) { | 247 for (size_t i = 0; i < arraysize(verbs); ++i) { |
| 249 string16 sub_path(model_id_shell); | 248 string16 sub_path(model_id_shell); |
| 250 sub_path.push_back(FilePath::kSeparators[0]); | 249 sub_path.push_back(FilePath::kSeparators[0]); |
| 251 sub_path.append(verbs[i]); | 250 sub_path.append(verbs[i]); |
| 252 | 251 |
| 253 // <root hkey>\Software\Classes\<app_id>\.exe\shell\<verb> | 252 // <root hkey>\Software\Classes\<app_id>\.exe\shell\<verb> |
| 254 entries->push_back(new RegistryEntry( | 253 entries->push_back(new RegistryEntry( |
| 255 sub_path, L"CommandId", L"Browser.Launch")); | 254 sub_path, L"CommandId", L"Browser.Launch")); |
| 256 | 255 |
| 257 sub_path.push_back(FilePath::kSeparators[0]); | 256 sub_path.push_back(FilePath::kSeparators[0]); |
| (...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1009 shortcut_properties.set_app_id( | 1008 shortcut_properties.set_app_id( |
| 1010 ShellUtil::GetBrowserModelId(dist, is_per_user_install)); | 1009 ShellUtil::GetBrowserModelId(dist, is_per_user_install)); |
| 1011 } | 1010 } |
| 1012 | 1011 |
| 1013 if (properties.has_dual_mode()) | 1012 if (properties.has_dual_mode()) |
| 1014 shortcut_properties.set_dual_mode(properties.dual_mode); | 1013 shortcut_properties.set_dual_mode(properties.dual_mode); |
| 1015 | 1014 |
| 1016 return shortcut_properties; | 1015 return shortcut_properties; |
| 1017 } | 1016 } |
| 1018 | 1017 |
| 1018 // Cleans up an old verb (run) we used to register in |
| 1019 // <root>\Software\Classes\Chrome<.suffix>\.exe\shell\run on Windows 8. |
| 1020 // TODO (gab): This was fixed before the general availability of Windows 8 and |
| 1021 // thus can safely be removed in February 2013. |
| 1022 void RemoveRunVerbOnWindows8( |
| 1023 BrowserDistribution* dist, |
| 1024 const string16& chrome_exe) { |
| 1025 if (IsChromeMetroSupported()) { |
| 1026 bool is_per_user_install =InstallUtil::IsPerUserInstall(chrome_exe.c_str()); |
| 1027 HKEY root_key = DetermineShellIntegrationRoot(is_per_user_install); |
| 1028 // There's no need to rollback, so forgo the usual work item lists and just |
| 1029 // remove the key from the registry. |
| 1030 string16 run_verb_key(ShellUtil::kRegClasses); |
| 1031 run_verb_key.push_back(FilePath::kSeparators[0]); |
| 1032 run_verb_key.append(ShellUtil::GetBrowserModelId( |
| 1033 dist, is_per_user_install)); |
| 1034 run_verb_key.append(ShellUtil::kRegExePath); |
| 1035 run_verb_key.append(ShellUtil::kRegShellPath); |
| 1036 run_verb_key.push_back(FilePath::kSeparators[0]); |
| 1037 run_verb_key.append(ShellUtil::kRegVerbRun); |
| 1038 InstallUtil::DeleteRegistryKey(root_key, run_verb_key); |
| 1039 } |
| 1040 } |
| 1041 |
| 1019 // Gets the short (8.3) form of |path|, putting the result in |short_path| and | 1042 // Gets the short (8.3) form of |path|, putting the result in |short_path| and |
| 1020 // returning true on success. |short_path| is not modified on failure. | 1043 // returning true on success. |short_path| is not modified on failure. |
| 1021 bool ShortNameFromPath(const FilePath& path, string16* short_path) { | 1044 bool ShortNameFromPath(const FilePath& path, string16* short_path) { |
| 1022 DCHECK(short_path); | 1045 DCHECK(short_path); |
| 1023 string16 result(MAX_PATH, L'\0'); | 1046 string16 result(MAX_PATH, L'\0'); |
| 1024 DWORD short_length = GetShortPathName(path.value().c_str(), &result[0], | 1047 DWORD short_length = GetShortPathName(path.value().c_str(), &result[0], |
| 1025 result.size()); | 1048 result.size()); |
| 1026 if (short_length == 0 || short_length > result.size()) { | 1049 if (short_length == 0 || short_length > result.size()) { |
| 1027 PLOG(ERROR) << "Error getting short (8.3) path"; | 1050 PLOG(ERROR) << "Error getting short (8.3) path"; |
| 1028 return false; | 1051 return false; |
| (...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1687 string16 suffix; | 1710 string16 suffix; |
| 1688 if (!unique_suffix.empty()) { | 1711 if (!unique_suffix.empty()) { |
| 1689 suffix = unique_suffix; | 1712 suffix = unique_suffix; |
| 1690 } else if (!GetInstallationSpecificSuffix(dist, chrome_exe, &suffix)) { | 1713 } else if (!GetInstallationSpecificSuffix(dist, chrome_exe, &suffix)) { |
| 1691 return false; | 1714 return false; |
| 1692 } | 1715 } |
| 1693 | 1716 |
| 1694 // TODO(grt): remove this on or after 2012-08-01; see impl for details. | 1717 // TODO(grt): remove this on or after 2012-08-01; see impl for details. |
| 1695 RemoveBadWindows8RegistrationIfNeeded(dist, chrome_exe); | 1718 RemoveBadWindows8RegistrationIfNeeded(dist, chrome_exe); |
| 1696 | 1719 |
| 1720 // TODO(gab): remove this on or after 2013-02-01; see impl for details. |
| 1721 RemoveRunVerbOnWindows8(dist, chrome_exe); |
| 1722 |
| 1697 // Check if Chromium is already registered with this suffix. | 1723 // Check if Chromium is already registered with this suffix. |
| 1698 if (IsChromeRegistered(dist, chrome_exe, suffix)) | 1724 if (IsChromeRegistered(dist, chrome_exe, suffix)) |
| 1699 return true; | 1725 return true; |
| 1700 | 1726 |
| 1701 bool user_level = InstallUtil::IsPerUserInstall(chrome_exe.c_str()); | 1727 bool user_level = InstallUtil::IsPerUserInstall(chrome_exe.c_str()); |
| 1702 HKEY root = DetermineShellIntegrationRoot(user_level); | 1728 HKEY root = DetermineShellIntegrationRoot(user_level); |
| 1703 | 1729 |
| 1704 // Do the full registration if we can do it at user-level or if the user is an | 1730 // Do the full registration if we can do it at user-level or if the user is an |
| 1705 // admin. | 1731 // admin. |
| 1706 if (root == HKEY_CURRENT_USER || IsUserAnAdmin()) { | 1732 if (root == HKEY_CURRENT_USER || IsUserAnAdmin()) { |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1913 // are any left...). | 1939 // are any left...). |
| 1914 if (free_bits >= 8 && next_byte_index < size) { | 1940 if (free_bits >= 8 && next_byte_index < size) { |
| 1915 free_bits -= 8; | 1941 free_bits -= 8; |
| 1916 bit_stream += bytes[next_byte_index++] << free_bits; | 1942 bit_stream += bytes[next_byte_index++] << free_bits; |
| 1917 } | 1943 } |
| 1918 } | 1944 } |
| 1919 | 1945 |
| 1920 DCHECK_EQ(ret.length(), encoded_length); | 1946 DCHECK_EQ(ret.length(), encoded_length); |
| 1921 return ret; | 1947 return ret; |
| 1922 } | 1948 } |
| OLD | NEW |