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 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 | |
gab
2012/08/09 19:25:57
nit: no empty line between variable and if (i.e. s
Halli
2012/08/09 20:49:59
Done.
| |
1688 if (path != FilePath(long_path) && path != FilePath(short_path)) | |
1689 return VERIFY_SHORTCUT_FAILURE_PATH; | |
1690 | |
1691 if (string16(desc) != string16(description)) | |
1692 return VERIFY_SHORTCUT_FAILURE_DESCRIPTION; | |
1693 | |
1694 if (index != icon_index) | |
1695 return VERIFY_SHORTCUT_FAILURE_ICON_INDEX; | |
1696 | |
1697 return VERIFY_SHORTCUT_SUCCESS; | |
1698 } | |
1699 | |
1660 bool ShellUtil::GetUserSpecificRegistrySuffix(string16* suffix) { | 1700 bool ShellUtil::GetUserSpecificRegistrySuffix(string16* suffix) { |
1661 // Use a thread-safe cache for the user's suffix. | 1701 // Use a thread-safe cache for the user's suffix. |
1662 static base::LazyInstance<UserSpecificRegistrySuffix>::Leaky suffix_instance = | 1702 static base::LazyInstance<UserSpecificRegistrySuffix>::Leaky suffix_instance = |
1663 LAZY_INSTANCE_INITIALIZER; | 1703 LAZY_INSTANCE_INITIALIZER; |
1664 return suffix_instance.Get().GetSuffix(suffix); | 1704 return suffix_instance.Get().GetSuffix(suffix); |
1665 } | 1705 } |
1666 | 1706 |
1667 bool ShellUtil::GetOldUserSpecificRegistrySuffix(string16* suffix) { | 1707 bool ShellUtil::GetOldUserSpecificRegistrySuffix(string16* suffix) { |
1668 wchar_t user_name[256]; | 1708 wchar_t user_name[256]; |
1669 DWORD size = arraysize(user_name); | 1709 DWORD size = arraysize(user_name); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1717 // are any left...). | 1757 // are any left...). |
1718 if (free_bits >= 8 && next_byte_index < size) { | 1758 if (free_bits >= 8 && next_byte_index < size) { |
1719 free_bits -= 8; | 1759 free_bits -= 8; |
1720 bit_stream += bytes[next_byte_index++] << free_bits; | 1760 bit_stream += bytes[next_byte_index++] << free_bits; |
1721 } | 1761 } |
1722 } | 1762 } |
1723 | 1763 |
1724 DCHECK_EQ(ret.length(), encoded_length); | 1764 DCHECK_EQ(ret.length(), encoded_length); |
1725 return ret; | 1765 return ret; |
1726 } | 1766 } |
OLD | NEW |