| 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 1639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1650 shortcut.c_str(), | 1650 shortcut.c_str(), |
| 1651 chrome_path.value().c_str(), | 1651 chrome_path.value().c_str(), |
| 1652 arguments.c_str(), | 1652 arguments.c_str(), |
| 1653 description.c_str(), | 1653 description.c_str(), |
| 1654 icon_path.c_str(), | 1654 icon_path.c_str(), |
| 1655 icon_index, | 1655 icon_index, |
| 1656 app_id.c_str(), | 1656 app_id.c_str(), |
| 1657 ConvertShellUtilShortcutOptionsToFileUtil(options)); | 1657 ConvertShellUtilShortcutOptionsToFileUtil(options)); |
| 1658 } | 1658 } |
| 1659 | 1659 |
| 1660 ShellUtil::VerifyShortcutStatus ShellUtil::VerifyChromeShortcut( |
| 1661 const string16& exe_path, const string16& shortcut, |
| 1662 const string16& description, int icon_index) { |
| 1663 base::win::ScopedComPtr<IShellLink> i_shell_link; |
| 1664 base::win::ScopedComPtr<IPersistFile> i_persist_file; |
| 1665 wchar_t long_path[MAX_PATH] = {0}; |
| 1666 wchar_t short_path[MAX_PATH] = {0}; |
| 1667 wchar_t file_path[MAX_PATH] = {0}; |
| 1668 wchar_t icon_path[MAX_PATH] = {0}; |
| 1669 wchar_t desc[MAX_PATH] = {0}; |
| 1670 int index = 0; |
| 1671 |
| 1672 // Get the shortcut's properties. |
| 1673 if (FAILED(i_shell_link.CreateInstance(CLSID_ShellLink, NULL, |
| 1674 CLSCTX_INPROC_SERVER)) || |
| 1675 FAILED(i_persist_file.QueryFrom(i_shell_link)) || |
| 1676 FAILED(i_persist_file->Load(shortcut.c_str(), 0)) || |
| 1677 ::GetLongPathName(exe_path.c_str(), long_path, MAX_PATH) == 0 || |
| 1678 ::GetShortPathName(exe_path.c_str(), short_path, MAX_PATH) == 0 || |
| 1679 FAILED(i_shell_link->GetPath(file_path, MAX_PATH, NULL, |
| 1680 SLGP_UNCPRIORITY)) || |
| 1681 FAILED(i_shell_link->GetIconLocation(icon_path, MAX_PATH, &index)) || |
| 1682 FAILED(i_shell_link->GetDescription(desc, MAX_PATH)) || |
| 1683 FAILED(i_shell_link->GetDescription(desc, MAX_PATH))) |
| 1684 return VERIFY_SHORTCUT_FAILURE_UNEXPECTED; |
| 1685 |
| 1686 FilePath path(file_path); |
| 1687 if (path != FilePath(long_path) && path != FilePath(short_path)) |
| 1688 return VERIFY_SHORTCUT_FAILURE_PATH; |
| 1689 |
| 1690 if (string16(desc) != string16(description)) |
| 1691 return VERIFY_SHORTCUT_FAILURE_DESCRIPTION; |
| 1692 |
| 1693 if (index != icon_index) |
| 1694 return VERIFY_SHORTCUT_FAILURE_ICON_INDEX; |
| 1695 |
| 1696 return VERIFY_SHORTCUT_SUCCESS; |
| 1697 } |
| 1698 |
| 1660 bool ShellUtil::GetUserSpecificRegistrySuffix(string16* suffix) { | 1699 bool ShellUtil::GetUserSpecificRegistrySuffix(string16* suffix) { |
| 1661 // Use a thread-safe cache for the user's suffix. | 1700 // Use a thread-safe cache for the user's suffix. |
| 1662 static base::LazyInstance<UserSpecificRegistrySuffix>::Leaky suffix_instance = | 1701 static base::LazyInstance<UserSpecificRegistrySuffix>::Leaky suffix_instance = |
| 1663 LAZY_INSTANCE_INITIALIZER; | 1702 LAZY_INSTANCE_INITIALIZER; |
| 1664 return suffix_instance.Get().GetSuffix(suffix); | 1703 return suffix_instance.Get().GetSuffix(suffix); |
| 1665 } | 1704 } |
| 1666 | 1705 |
| 1667 bool ShellUtil::GetOldUserSpecificRegistrySuffix(string16* suffix) { | 1706 bool ShellUtil::GetOldUserSpecificRegistrySuffix(string16* suffix) { |
| 1668 wchar_t user_name[256]; | 1707 wchar_t user_name[256]; |
| 1669 DWORD size = arraysize(user_name); | 1708 DWORD size = arraysize(user_name); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1717 // are any left...). | 1756 // are any left...). |
| 1718 if (free_bits >= 8 && next_byte_index < size) { | 1757 if (free_bits >= 8 && next_byte_index < size) { |
| 1719 free_bits -= 8; | 1758 free_bits -= 8; |
| 1720 bit_stream += bytes[next_byte_index++] << free_bits; | 1759 bit_stream += bytes[next_byte_index++] << free_bits; |
| 1721 } | 1760 } |
| 1722 } | 1761 } |
| 1723 | 1762 |
| 1724 DCHECK_EQ(ret.length(), encoded_length); | 1763 DCHECK_EQ(ret.length(), encoded_length); |
| 1725 return ret; | 1764 return ret; |
| 1726 } | 1765 } |
| OLD | NEW |