Index: chrome/installer/util/shell_util.cc |
=================================================================== |
--- chrome/installer/util/shell_util.cc (revision 149222) |
+++ chrome/installer/util/shell_util.cc (working copy) |
@@ -1679,3 +1679,69 @@ |
DCHECK_EQ(ret.length(), encoded_length); |
return ret; |
} |
+ |
+bool ShellUtil::VerifyChromeShortcut(const std::wstring& exe_path, |
+ const std::wstring& shortcut, |
+ const std::wstring& description, |
+ int icon_index) { |
+ base::win::ScopedComPtr<IShellLink> i_shell_link; |
gab
2012/08/07 19:18:25
#include "base/win/scoped_comptr.h"
Halli
2012/08/07 20:52:16
This is included already.
gab
2012/08/08 16:24:26
No, scoped_ptr.h is not scoped_comptr.h, it might
Halli
2012/08/08 18:59:13
Line 34 (:
On 2012/08/08 16:24:26, gab wrote:
|
+ base::win::ScopedComPtr<IPersistFile> i_persist_file; |
gab
2012/08/07 19:18:25
IPersistFile is said to come from ObjIdl.h by MSDN
gab
2012/08/08 17:01:24
Discussed with robert offline, although we like in
|
+ |
+ // Get pointer to the IShellLink interface |
+ bool failed = FAILED(i_shell_link.CreateInstance(CLSID_ShellLink, NULL, |
gab
2012/08/07 19:18:25
The value of this variable is never used except in
Halli
2012/08/07 20:52:16
Done.
|
+ CLSCTX_INPROC_SERVER)); |
+ LOG_IF(ERROR, failed) << "Failed to get IShellLink"; |
+ if (failed) |
+ return false; |
+ |
+ // Query IShellLink for the IPersistFile interface |
+ failed = FAILED(i_persist_file.QueryFrom(i_shell_link)); |
+ LOG_IF(ERROR, failed) << "Failed to get IPersistFile"; |
+ if (failed) |
+ return false; |
+ |
+ failed = FAILED(i_persist_file->Load(shortcut.c_str(), 0)); |
+ LOG_IF(ERROR, failed) << "Failed to load shortcut " << shortcut.c_str(); |
+ if (failed) |
+ return false; |
+ |
+ wchar_t long_path[MAX_PATH] = {0}; |
+ wchar_t short_path[MAX_PATH] = {0}; |
+ failed = ((::GetLongPathName(exe_path.c_str(), long_path, MAX_PATH) == 0) || |
+ (::GetShortPathName(exe_path.c_str(), short_path, MAX_PATH) == 0)); |
+ LOG_IF(ERROR, failed) << "Failed to get long and short path names for " |
+ << exe_path; |
+ if (failed) |
+ return false; |
+ |
+ wchar_t file_path[MAX_PATH] = {0}; |
+ failed = ((FAILED(i_shell_link->GetPath(file_path, MAX_PATH, NULL, |
+ SLGP_UNCPRIORITY))) || |
+ ((FilePath(file_path) != FilePath(long_path)) && |
+ (FilePath(file_path) != FilePath(short_path)))); |
+ LOG_IF(ERROR, failed) << "File path " << file_path << " did not match with " |
+ << exe_path; |
+ if (failed) |
+ return false; |
+ |
+ wchar_t desc[MAX_PATH] = {0}; |
+ failed = ((FAILED(i_shell_link->GetDescription(desc, MAX_PATH))) || |
+ (std::wstring(desc) != std::wstring(description))); |
+ LOG_IF(ERROR, failed) << "Description " << desc << " did not match with " |
+ << description; |
+ if (failed) |
+ return false; |
+ |
+ wchar_t icon_path[MAX_PATH] = {0}; |
+ int index = 0; |
+ failed = ((FAILED(i_shell_link->GetIconLocation(icon_path, MAX_PATH, |
+ &index))) || |
+ ((FilePath(file_path) != FilePath(long_path)) && |
+ (FilePath(file_path) != FilePath(short_path))) || |
+ (index != icon_index)); |
+ LOG_IF(ERROR, failed); |
+ if (failed) |
+ return false; |
+ |
+ return true; |
+} |