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 // Failed to get IShellLink | |
|
gab
2012/08/08 16:24:27
Remove these "Failed *" comments (here and below),
Halli
2012/08/08 18:59:13
Done.
| |
| 1737 if (FAILED(i_shell_link.CreateInstance(CLSID_ShellLink, NULL, | |
| 1738 CLSCTX_INPROC_SERVER))) | |
|
gab
2012/08/08 16:24:27
nit: indentation
Halli
2012/08/08 18:59:13
Done.
| |
| 1739 return false; | |
| 1740 | |
| 1741 // Query IShellLink for the IPersistFile interface | |
| 1742 // Failed to get IPersistFile | |
| 1743 if (FAILED(i_persist_file.QueryFrom(i_shell_link))) | |
| 1744 return false; | |
| 1745 | |
| 1746 // Failed to load shortcut | |
| 1747 if (FAILED(i_persist_file->Load(shortcut.c_str(), 0))) | |
| 1748 return false; | |
| 1749 | |
| 1750 wchar_t long_path[MAX_PATH] = {0}; | |
| 1751 wchar_t short_path[MAX_PATH] = {0}; | |
| 1752 | |
| 1753 // Failed to get long and short path names | |
| 1754 if (((::GetLongPathName(exe_path.c_str(), long_path, MAX_PATH) == 0) || | |
|
gab
2012/08/08 16:24:27
In the conditionals all the way from here to the b
Halli
2012/08/08 18:59:13
Done.
| |
| 1755 (::GetShortPathName(exe_path.c_str(), short_path, MAX_PATH) == 0))) | |
|
gab
2012/08/08 16:24:27
nit: indentation
Halli
2012/08/08 18:59:13
Done.
| |
| 1756 return false; | |
| 1757 | |
| 1758 wchar_t file_path[MAX_PATH] = {0}; | |
| 1759 | |
| 1760 // File path did not match exe path | |
| 1761 if (((FAILED(i_shell_link->GetPath(file_path, MAX_PATH, NULL, | |
| 1762 SLGP_UNCPRIORITY))) || | |
|
gab
2012/08/08 16:24:27
nit: indentation
Halli
2012/08/08 18:59:13
Done.
| |
| 1763 ((FilePath(file_path) != FilePath(long_path)) && | |
|
gab
2012/08/08 16:24:27
nit: indentation
Halli
2012/08/08 18:59:13
Done.
| |
| 1764 (FilePath(file_path) != FilePath(short_path))))) | |
| 1765 return false; | |
| 1766 | |
| 1767 wchar_t desc[MAX_PATH] = {0}; | |
| 1768 | |
| 1769 // Description did not match shortcut's description | |
| 1770 if (((FAILED(i_shell_link->GetDescription(desc, MAX_PATH))) || | |
| 1771 (string16(desc) != string16(description)))) | |
| 1772 return false; | |
| 1773 | |
| 1774 wchar_t icon_path[MAX_PATH] = {0}; | |
| 1775 int index = 0; | |
| 1776 | |
| 1777 if (((FAILED(i_shell_link->GetIconLocation(icon_path, MAX_PATH, | |
|
gab
2012/08/08 16:24:27
Thinking more about it (and chatting with robert)
Halli
2012/08/08 18:59:13
How is this different from returning true or false
gab
2012/08/08 19:17:08
I don't want a different one for the getters (i.e.
Halli
2012/08/08 20:28:09
Hopefully this is what you meant (:
On 2012/08/08
| |
| 1778 &index))) || | |
| 1779 ((FilePath(file_path) != FilePath(long_path)) && | |
| 1780 (FilePath(file_path) != FilePath(short_path))) || | |
| 1781 (index != icon_index))) | |
| 1782 return false; | |
| 1783 | |
| 1784 return true; | |
| 1785 } | |
| OLD | NEW |