Chromium Code Reviews| Index: base/win/shortcut.cc |
| diff --git a/base/win/shortcut.cc b/base/win/shortcut.cc |
| index 57a93dc6524e1540cad465eb639482ed6f6e90c2..abfaec61ea611b78e2f15fbe9920118ab1142e47 100644 |
| --- a/base/win/shortcut.cc |
| +++ b/base/win/shortcut.cc |
| @@ -172,9 +172,10 @@ bool CreateOrUpdateShortcutLink(const FilePath& shortcut_path, |
| return succeeded; |
| } |
| -bool ResolveShortcut(const FilePath& shortcut_path, |
| - FilePath* target_path, |
| - string16* args) { |
| +bool ResolveShortcutProperties(const FilePath& shortcut_path, |
| + uint32 options, |
| + ShortcutProperties* p) { |
|
gab
2013/12/23 14:25:01
s/p/properties
Chromium doesn't encourage abbrevi
huangs
2013/12/30 20:15:10
Done (also .h and comments).
|
| + DCHECK(p != NULL); |
|
gab
2013/12/23 14:25:01
DCHECK(properties);
(i.e. no need for "!= NULL")
huangs
2013/12/30 20:15:10
Done.
|
| base::ThreadRestrictions::AssertIOAllowed(); |
| HRESULT result; |
| @@ -197,8 +198,9 @@ bool ResolveShortcut(const FilePath& shortcut_path, |
| if (FAILED(result)) |
| return false; |
| + p->options = 0; |
| WCHAR temp[MAX_PATH]; |
| - if (target_path) { |
| + if (options & ShortcutProperties::PROPERTIES_TARGET) { |
| // Try to find the target of a shortcut. |
| result = i_shell_link->Resolve(0, SLR_NO_UI | SLR_NOSEARCH); |
| if (FAILED(result)) |
| @@ -208,16 +210,44 @@ bool ResolveShortcut(const FilePath& shortcut_path, |
| if (FAILED(result)) |
| return false; |
| - *target_path = FilePath(temp); |
| + p->set_target(FilePath(temp)); |
| } |
| - if (args) { |
| + if (options & ShortcutProperties::PROPERTIES_ARGUMENTS) { |
| result = i_shell_link->GetArguments(temp, MAX_PATH); |
|
gab
2013/12/23 14:25:01
Looks like |result| is a write-only variable here
huangs
2013/12/30 20:15:10
Done.
|
| if (FAILED(result)) |
| return false; |
| - *args = string16(temp); |
| + p->set_arguments(string16(temp)); |
| } |
| + |
| + if (options & ShortcutProperties::PROPERTIES_ICON) { |
| + int temp_index; |
| + if (FAILED(i_shell_link->GetIconLocation(temp, MAX_PATH, &temp_index))) |
| + return false; |
| + |
| + p->set_icon(FilePath(temp), temp_index); |
| + } |
| + |
| + // Implement other options if the need arise. |
| + |
| + return true; |
| +} |
| + |
| +bool ResolveShortcut(const FilePath& shortcut_path, |
| + FilePath* target_path, |
| + string16* args) { |
| + uint32 options = 0; |
| + options |= target_path ? ShortcutProperties::PROPERTIES_TARGET : 0; |
| + options |= args ? ShortcutProperties::PROPERTIES_ARGUMENTS : 0; |
|
gab
2013/12/23 14:25:01
Change these two lines to:
if (target_path)
opt
huangs
2013/12/30 20:15:10
Done. Also, being defensive: return true if option
|
| + ShortcutProperties p; |
| + if (!ResolveShortcutProperties(shortcut_path, options, &p)) |
| + return false; |
| + |
| + if (target_path) |
| + *target_path = p.target; |
| + if (args) |
| + *args = p.arguments; |
| return true; |
| } |