Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4305)

Unified Diff: chrome/installer/util/shell_util.cc

Issue 10826188: Sharing shell_util_unittest code to verify shortcuts (Closed) Base URL: https://src.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/installer/util/shell_util.cc
===================================================================
--- chrome/installer/util/shell_util.cc (revision 150342)
+++ chrome/installer/util/shell_util.cc (working copy)
@@ -1657,6 +1657,46 @@
ConvertShellUtilShortcutOptionsToFileUtil(options));
}
+ShellUtil::VerifyShortcuts ShellUtil::VerifyChromeShortcut(
+ const string16& exe_path, const string16& shortcut,
+ const string16& description, int icon_index) {
+ base::win::ScopedComPtr<IShellLink> i_shell_link;
+ base::win::ScopedComPtr<IPersistFile> i_persist_file;
+ wchar_t long_path[MAX_PATH] = {0};
+ wchar_t short_path[MAX_PATH] = {0};
+ wchar_t file_path[MAX_PATH] = {0};
+ wchar_t icon_path[MAX_PATH] = {0};
+ wchar_t desc[MAX_PATH] = {0};
+ int index = 0;
+
+ // Get the shortcut's properties.
+ if (FAILED(i_shell_link.CreateInstance(CLSID_ShellLink, NULL,
+ CLSCTX_INPROC_SERVER)) ||
+ FAILED(i_persist_file.QueryFrom(i_shell_link)) ||
+ FAILED(i_persist_file->Load(shortcut.c_str(), 0)) ||
+ ::GetLongPathName(exe_path.c_str(), long_path, MAX_PATH) == 0 ||
+ ::GetShortPathName(exe_path.c_str(), short_path, MAX_PATH) == 0 ||
+ FAILED(i_shell_link->GetPath(file_path, MAX_PATH, NULL,
+ SLGP_UNCPRIORITY)) ||
+ FAILED(i_shell_link->GetIconLocation(icon_path, MAX_PATH, &index)) ||
+ FAILED(i_shell_link->GetDescription(desc, MAX_PATH)) ||
+ FAILED(i_shell_link->GetDescription(desc, MAX_PATH)))
+ return VERIFY_SHORTCUT_FAILURE_UNEXPECTED;
+
+ FilePath path(file_path);
+
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.
+ if (path != FilePath(long_path) && path != FilePath(short_path))
+ return VERIFY_SHORTCUT_FAILURE_PATH;
+
+ if (string16(desc) != string16(description))
+ return VERIFY_SHORTCUT_FAILURE_DESCRIPTION;
+
+ if (index != icon_index)
+ return VERIFY_SHORTCUT_FAILURE_ICON_INDEX;
+
+ return VERIFY_SHORTCUT_SUCCESS;
+}
+
bool ShellUtil::GetUserSpecificRegistrySuffix(string16* suffix) {
// Use a thread-safe cache for the user's suffix.
static base::LazyInstance<UserSpecificRegistrySuffix>::Leaky suffix_instance =

Powered by Google App Engine
This is Rietveld 408576698