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 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 | |
|
gab
2012/08/09 02:52:32
nit: Remove this line to have all declarations gro
Halli
2012/08/09 16:07:57
Done.
| |
| 1666 wchar_t long_path[MAX_PATH] = {0}; | |
| 1667 wchar_t short_path[MAX_PATH] = {0}; | |
| 1668 wchar_t file_path[MAX_PATH] = {0}; | |
| 1669 wchar_t icon_path[MAX_PATH] = {0}; | |
| 1670 wchar_t desc[MAX_PATH] = {0}; | |
| 1671 int index = 0; | |
| 1672 | |
| 1673 // Get pointer to the IShellLink interface | |
|
gab
2012/08/09 02:52:32
Change this comment to something like "Get the sho
Halli
2012/08/09 16:07:57
Done.
| |
| 1674 if (FAILED(i_shell_link.CreateInstance(CLSID_ShellLink, NULL, | |
| 1675 CLSCTX_INPROC_SERVER)) || | |
| 1676 FAILED(i_persist_file.QueryFrom(i_shell_link)) || | |
| 1677 FAILED(i_persist_file->Load(shortcut.c_str(), 0)) || | |
| 1678 ::GetLongPathName(exe_path.c_str(), long_path, MAX_PATH) == 0 || | |
| 1679 ::GetShortPathName(exe_path.c_str(), short_path, MAX_PATH) == 0 || | |
| 1680 FAILED(i_shell_link->GetPath(file_path, MAX_PATH, NULL, | |
| 1681 SLGP_UNCPRIORITY)) || | |
|
gab
2012/08/09 02:52:32
nit: align with |file_path|
Halli
2012/08/09 16:07:57
Done.
| |
| 1682 FAILED(i_shell_link->GetIconLocation(icon_path, MAX_PATH, &index)) || | |
| 1683 FAILED(i_shell_link->GetDescription(desc, MAX_PATH)) || | |
| 1684 FAILED(i_shell_link->GetDescription(desc, MAX_PATH))) | |
| 1685 return VERIFY_SHORTCUT_FAILURE_UNEXPECTED; | |
| 1686 | |
| 1687 if (FilePath(file_path) != FilePath(long_path) && | |
|
gab
2012/08/09 02:52:32
Change && to ||
Halli
2012/08/09 16:07:57
Original code uses &&
Isn't && correct? I think th
| |
| 1688 FilePath(file_path) != FilePath(short_path)) | |
|
gab
2012/08/09 02:52:32
nit: indent one more space
gab
2012/08/09 02:52:32
nit: as-per chromium style, since this conditional
gab
2012/08/09 02:52:32
You are creating a FilePath(file_path) twice, extr
Halli
2012/08/09 16:07:57
Done.
Halli
2012/08/09 16:07:57
Done.
Halli
2012/08/09 16:07:57
Line is less than 80 chars with the constant from
| |
| 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 |