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

Unified Diff: base/file_util_win.cc

Issue 10837034: Remove packaged app Windows shortcuts when app is uninstalled. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merged to one function 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
« no previous file with comments | « base/file_util_unittest.cc ('k') | chrome/browser/extensions/app_shortcut_manager.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/file_util_win.cc
diff --git a/base/file_util_win.cc b/base/file_util_win.cc
index bf9dd9cb7046b2f58ce05b3215b2180afc394240..f40ad0acae912309d7d26a42c07441d78188ad5c 100644
--- a/base/file_util_win.cc
+++ b/base/file_util_win.cc
@@ -332,38 +332,53 @@ bool GetFileCreationLocalTime(const std::wstring& filename,
return GetFileCreationLocalTimeFromHandle(file_handle.Get(), creation_time);
}
-bool ResolveShortcut(FilePath* path) {
+bool ResolveShortcut(const FilePath& shortcut_path,
+ FilePath* target_path,
+ string16* args) {
base::ThreadRestrictions::AssertIOAllowed();
HRESULT result;
base::win::ScopedComPtr<IShellLink> i_shell_link;
- bool is_resolved = false;
// Get pointer to the IShellLink interface
result = i_shell_link.CreateInstance(CLSID_ShellLink, NULL,
CLSCTX_INPROC_SERVER);
- if (SUCCEEDED(result)) {
- base::win::ScopedComPtr<IPersistFile> persist;
- // Query IShellLink for the IPersistFile interface
- result = persist.QueryFrom(i_shell_link);
- if (SUCCEEDED(result)) {
- WCHAR temp_path[MAX_PATH];
- // Load the shell link
- result = persist->Load(path->value().c_str(), STGM_READ);
- if (SUCCEEDED(result)) {
- // Try to find the target of a shortcut
- result = i_shell_link->Resolve(0, SLR_NO_UI);
- if (SUCCEEDED(result)) {
- result = i_shell_link->GetPath(temp_path, MAX_PATH,
- NULL, SLGP_UNCPRIORITY);
- *path = FilePath(temp_path);
- is_resolved = true;
- }
- }
- }
+ if (FAILED(result))
+ return false;
+
+ base::win::ScopedComPtr<IPersistFile> persist;
+ // Query IShellLink for the IPersistFile interface
brettw 2012/08/07 17:51:27 While you're modifying these, can you make sure th
+ result = persist.QueryFrom(i_shell_link);
+ if (FAILED(result))
+ return false;
+
+ // Load the shell link
+ result = persist->Load(shortcut_path.value().c_str(), STGM_READ);
+ if (FAILED(result))
+ return false;
+
+ WCHAR temp[MAX_PATH];
+ if (target_path) {
+ // Try to find the target of a shortcut
+ result = i_shell_link->Resolve(0, SLR_NO_UI);
+ if (FAILED(result))
+ return false;
+
+ result = i_shell_link->GetPath(temp, MAX_PATH, NULL, SLGP_UNCPRIORITY);
+ if (FAILED(result))
+ return false;
+
+ *target_path = FilePath(temp);
}
- return is_resolved;
+ if (args) {
+ result = i_shell_link->GetArguments(temp, MAX_PATH);
+ if (FAILED(result))
+ return false;
+
+ *args = string16(temp);
+ }
+ return true;
}
bool CreateOrUpdateShortcutLink(const wchar_t *source,
« no previous file with comments | « base/file_util_unittest.cc ('k') | chrome/browser/extensions/app_shortcut_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698