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::VerifyShortcuts 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 | |
1666 // Get pointer to the IShellLink interface | |
1667 if (FAILED(i_shell_link.CreateInstance(CLSID_ShellLink, NULL, | |
1668 CLSCTX_INPROC_SERVER))) | |
1669 return VERIFY_SHORTCUT_FAILURE_CREATE_SHELL_LINK_INSTANCE; | |
1670 | |
1671 // Query IShellLink for the IPersistFile interface | |
1672 if (FAILED(i_persist_file.QueryFrom(i_shell_link))) | |
1673 return VERIFY_SHORTCUT_FAILURE_QUERY_FROM_PERSIST; | |
1674 | |
1675 if (FAILED(i_persist_file->Load(shortcut.c_str(), 0))) | |
1676 return VERIFY_SHORTCUT_FAILURE_LOAD_FROM_PERSIST; | |
1677 | |
1678 wchar_t long_path[MAX_PATH] = {0}; | |
1679 wchar_t short_path[MAX_PATH] = {0}; | |
1680 | |
1681 if (::GetLongPathName(exe_path.c_str(), long_path, MAX_PATH) == 0 || | |
1682 ::GetShortPathName(exe_path.c_str(), short_path, MAX_PATH) == 0) | |
1683 return VERIFY_SHORTCUT_FAILURE_GET_PATH_NAMES; | |
1684 | |
1685 wchar_t file_path[MAX_PATH] = {0}; | |
1686 wchar_t desc[MAX_PATH] = {0}; | |
1687 wchar_t icon_path[MAX_PATH] = {0}; | |
1688 int index = 0; | |
1689 | |
1690 if (FAILED(i_shell_link->GetPath(file_path, MAX_PATH, NULL, | |
gab
2012/08/08 20:41:14
It's the opposite we want.
i.e. the things that s
Halli
2012/08/08 21:06:20
Done.
| |
1691 SLGP_UNCPRIORITY)) || FilePath(file_path) != FilePath(long_path) && | |
1692 FilePath(file_path) != FilePath(short_path) || | |
1693 FAILED(i_shell_link->GetDescription(desc, MAX_PATH)) || | |
1694 string16(desc) != string16(description) || | |
1695 FAILED(i_shell_link->GetIconLocation(icon_path, MAX_PATH, &index)) || | |
1696 index != icon_index) | |
1697 return VERIFY_SHORTCUT_FAILURE; | |
1698 | |
1699 return VERIFY_SHORTCUT_SUCCESS; | |
1700 } | |
1701 | |
1660 bool ShellUtil::GetUserSpecificRegistrySuffix(string16* suffix) { | 1702 bool ShellUtil::GetUserSpecificRegistrySuffix(string16* suffix) { |
1661 // Use a thread-safe cache for the user's suffix. | 1703 // Use a thread-safe cache for the user's suffix. |
1662 static base::LazyInstance<UserSpecificRegistrySuffix>::Leaky suffix_instance = | 1704 static base::LazyInstance<UserSpecificRegistrySuffix>::Leaky suffix_instance = |
1663 LAZY_INSTANCE_INITIALIZER; | 1705 LAZY_INSTANCE_INITIALIZER; |
1664 return suffix_instance.Get().GetSuffix(suffix); | 1706 return suffix_instance.Get().GetSuffix(suffix); |
1665 } | 1707 } |
1666 | 1708 |
1667 bool ShellUtil::GetOldUserSpecificRegistrySuffix(string16* suffix) { | 1709 bool ShellUtil::GetOldUserSpecificRegistrySuffix(string16* suffix) { |
1668 wchar_t user_name[256]; | 1710 wchar_t user_name[256]; |
1669 DWORD size = arraysize(user_name); | 1711 DWORD size = arraysize(user_name); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1717 // are any left...). | 1759 // are any left...). |
1718 if (free_bits >= 8 && next_byte_index < size) { | 1760 if (free_bits >= 8 && next_byte_index < size) { |
1719 free_bits -= 8; | 1761 free_bits -= 8; |
1720 bit_stream += bytes[next_byte_index++] << free_bits; | 1762 bit_stream += bytes[next_byte_index++] << free_bits; |
1721 } | 1763 } |
1722 } | 1764 } |
1723 | 1765 |
1724 DCHECK_EQ(ret.length(), encoded_length); | 1766 DCHECK_EQ(ret.length(), encoded_length); |
1725 return ret; | 1767 return ret; |
1726 } | 1768 } |
OLD | NEW |