Remove packaged app Windows shortcuts when app is uninstalled.
BUG=130456
TEST=Check app shortcuts are removed when the app is uninstalled. Test extension uninstallation in general.
Review URL: https://chromiumcodereview.appspot.com/10837034
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@151021 0039d316-1c4b-4281-b951-d872f2087c98
CrOS-Libchrome-Original-Commit: c002e757a3ce8027631cd2f22e5ec0f9b1322b14
diff --git a/base/file_util.h b/base/file_util.h
index fb6f624..a868112 100644
--- a/base/file_util.h
+++ b/base/file_util.h
@@ -235,10 +235,16 @@
};
// Resolve Windows shortcut (.LNK file)
-// This methods tries to resolve a shortcut .LNK file. If the |path| is valid
-// returns true and puts the target into the |path|, otherwise returns
-// false leaving the path as it is.
-BASE_EXPORT bool ResolveShortcut(FilePath* path);
+// This methods tries to resolve a shortcut .LNK file. The path of the shortcut
+// to resolve is in |shortcut_path|. If |target_path| is not NULL, the target
+// will be resolved and placed in |target_path|. If |args| is not NULL, the
+// arguments will be retrieved and placed in |args|. The function returns true
+// if all requested fields are are found successfully.
+// Callers can safely use the same variable for both |shortcut_path| and
+// |target_path|.
+BASE_EXPORT bool ResolveShortcut(const FilePath& shortcut_path,
+ FilePath* target_path,
+ string16* args);
// Creates (or updates) a Windows shortcut (.LNK file)
// This method creates (or updates) a shortcut link using the information given.
diff --git a/base/file_util_unittest.cc b/base/file_util_unittest.cc
index 25e2f40..b471f88 100644
--- a/base/file_util_unittest.cc
+++ b/base/file_util_unittest.cc
@@ -1617,6 +1617,8 @@
EXPECT_TRUE(SUCCEEDED(result));
result = shell->SetDescription(L"ResolveShortcutTest");
EXPECT_TRUE(SUCCEEDED(result));
+ result = shell->SetArguments(L"--args");
+ EXPECT_TRUE(SUCCEEDED(result));
result = persist->Save(link_file.value().c_str(), TRUE);
EXPECT_TRUE(SUCCEEDED(result));
if (persist)
@@ -1625,8 +1627,10 @@
shell->Release();
bool is_solved;
- is_solved = file_util::ResolveShortcut(&link_file);
+ std::wstring args;
+ is_solved = file_util::ResolveShortcut(link_file, &link_file, &args);
EXPECT_TRUE(is_solved);
+ EXPECT_EQ(L"--args", args);
std::wstring contents;
contents = ReadTextFile(link_file);
EXPECT_EQ(L"This is the target.", contents);
@@ -1649,8 +1653,8 @@
target_file.value().c_str(), link_file.value().c_str(), NULL,
NULL, NULL, NULL, 0, NULL,
file_util::SHORTCUT_CREATE_ALWAYS));
- FilePath resolved_name = link_file;
- EXPECT_TRUE(file_util::ResolveShortcut(&resolved_name));
+ FilePath resolved_name;
+ EXPECT_TRUE(file_util::ResolveShortcut(link_file, &resolved_name, NULL));
std::wstring read_contents = ReadTextFile(resolved_name);
EXPECT_EQ(file_contents, read_contents);