Chromium Code Reviews| 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 1706 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1717 // are any left...). | 1717 // are any left...). |
| 1718 if (free_bits >= 8 && next_byte_index < size) { | 1718 if (free_bits >= 8 && next_byte_index < size) { |
| 1719 free_bits -= 8; | 1719 free_bits -= 8; |
| 1720 bit_stream += bytes[next_byte_index++] << free_bits; | 1720 bit_stream += bytes[next_byte_index++] << free_bits; |
| 1721 } | 1721 } |
| 1722 } | 1722 } |
| 1723 | 1723 |
| 1724 DCHECK_EQ(ret.length(), encoded_length); | 1724 DCHECK_EQ(ret.length(), encoded_length); |
| 1725 return ret; | 1725 return ret; |
| 1726 } | 1726 } |
| 1727 | |
| 1728 bool ShellUtil::VerifyChromeShortcut(const string16& exe_path, | |
| 1729 const string16& shortcut, | |
| 1730 const string16& description, | |
| 1731 int icon_index) { | |
| 1732 base::win::ScopedComPtr<IShellLink> i_shell_link; | |
| 1733 base::win::ScopedComPtr<IPersistFile> i_persist_file; | |
| 1734 | |
| 1735 // Get pointer to the IShellLink interface | |
| 1736 if (FAILED(i_shell_link.CreateInstance(CLSID_ShellLink, NULL, | |
| 1737 CLSCTX_INPROC_SERVER))) | |
| 1738 return false; | |
| 1739 | |
| 1740 // Query IShellLink for the IPersistFile interface | |
| 1741 if (FAILED(i_persist_file.QueryFrom(i_shell_link))) | |
| 1742 return false; | |
| 1743 | |
| 1744 if (FAILED(i_persist_file->Load(shortcut.c_str(), 0))) | |
| 1745 return false; | |
| 1746 | |
| 1747 wchar_t long_path[MAX_PATH] = {0}; | |
| 1748 wchar_t short_path[MAX_PATH] = {0}; | |
| 1749 | |
| 1750 if (::GetLongPathName(exe_path.c_str(), long_path, MAX_PATH) == 0 || | |
| 1751 ::GetShortPathName(exe_path.c_str(), short_path, MAX_PATH) == 0) | |
| 1752 return false; | |
| 1753 | |
| 1754 wchar_t file_path[MAX_PATH] = {0}; | |
| 1755 | |
| 1756 // File path did not match exe path | |
|
gab
2012/08/08 19:17:08
nit: remove this comment as well
| |
| 1757 if (FAILED(i_shell_link->GetPath(file_path, MAX_PATH, NULL, | |
| 1758 SLGP_UNCPRIORITY)) || FilePath(file_path) != FilePath(long_path) && | |
|
gab
2012/08/08 19:17:08
align SLGP_UNCPRIORITY with file_path above and pu
| |
| 1759 FilePath(file_path) != FilePath(short_path)) | |
| 1760 return false; | |
| 1761 | |
| 1762 wchar_t desc[MAX_PATH] = {0}; | |
| 1763 | |
| 1764 if (FAILED(i_shell_link->GetDescription(desc, MAX_PATH)) || | |
| 1765 string16(desc) != string16(description)) | |
| 1766 return false; | |
| 1767 | |
| 1768 wchar_t icon_path[MAX_PATH] = {0}; | |
| 1769 int index = 0; | |
| 1770 | |
| 1771 if (FAILED(i_shell_link->GetIconLocation(icon_path, MAX_PATH, &index)) || | |
| 1772 FilePath(file_path) != FilePath(long_path) && | |
| 1773 FilePath(file_path) != FilePath(short_path) || index != icon_index) | |
| 1774 return false; | |
| 1775 | |
| 1776 return true; | |
| 1777 } | |
| OLD | NEW |