| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef BASE_WIN_SHORTCUT_H_ | 5 #ifndef BASE_WIN_SHORTCUT_H_ |
| 6 #define BASE_WIN_SHORTCUT_H_ | 6 #define BASE_WIN_SHORTCUT_H_ |
| 7 | 7 |
| 8 #include <windows.h> | 8 #include <windows.h> |
| 9 | 9 |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 // Update specified properties only on an existing shortcut. | 24 // Update specified properties only on an existing shortcut. |
| 25 SHORTCUT_UPDATE_EXISTING, | 25 SHORTCUT_UPDATE_EXISTING, |
| 26 }; | 26 }; |
| 27 | 27 |
| 28 // Properties for shortcuts. Properties set will be applied to the shortcut on | 28 // Properties for shortcuts. Properties set will be applied to the shortcut on |
| 29 // creation/update, others will be ignored. | 29 // creation/update, others will be ignored. |
| 30 // Callers are encouraged to use the setters provided which take care of | 30 // Callers are encouraged to use the setters provided which take care of |
| 31 // setting |options| as desired. | 31 // setting |options| as desired. |
| 32 struct ShortcutProperties { | 32 struct ShortcutProperties { |
| 33 enum IndividualProperties { | 33 enum IndividualProperties { |
| 34 PROPERTIES_TARGET = 1 << 0, | 34 PROPERTIES_TARGET = 1U << 0, |
| 35 PROPERTIES_WORKING_DIR = 1 << 1, | 35 PROPERTIES_WORKING_DIR = 1U << 1, |
| 36 PROPERTIES_ARGUMENTS = 1 << 2, | 36 PROPERTIES_ARGUMENTS = 1U << 2, |
| 37 PROPERTIES_DESCRIPTION = 1 << 3, | 37 PROPERTIES_DESCRIPTION = 1U << 3, |
| 38 PROPERTIES_ICON = 1 << 4, | 38 PROPERTIES_ICON = 1U << 4, |
| 39 PROPERTIES_APP_ID = 1 << 5, | 39 PROPERTIES_APP_ID = 1U << 5, |
| 40 PROPERTIES_DUAL_MODE = 1 << 6, | 40 PROPERTIES_DUAL_MODE = 1U << 6, |
| 41 // Be sure to update the values below when adding a new property. |
| 42 PROPERTIES_BASIC = PROPERTIES_TARGET | |
| 43 PROPERTIES_WORKING_DIR | |
| 44 PROPERTIES_ARGUMENTS | |
| 45 PROPERTIES_DESCRIPTION | |
| 46 PROPERTIES_ICON, |
| 47 PROPERTIES_WIN7 = PROPERTIES_APP_ID | PROPERTIES_DUAL_MODE, |
| 48 PROPERTIES_ALL = PROPERTIES_BASIC | PROPERTIES_WIN7 |
| 41 }; | 49 }; |
| 42 | 50 |
| 43 ShortcutProperties() : icon_index(-1), dual_mode(false), options(0U) {} | 51 ShortcutProperties() : icon_index(-1), dual_mode(false), options(0U) {} |
| 44 | 52 |
| 45 void set_target(const FilePath& target_in) { | 53 void set_target(const FilePath& target_in) { |
| 46 target = target_in; | 54 target = target_in; |
| 47 options |= PROPERTIES_TARGET; | 55 options |= PROPERTIES_TARGET; |
| 48 } | 56 } |
| 49 | 57 |
| 50 void set_working_dir(const FilePath& working_dir_in) { | 58 void set_working_dir(const FilePath& working_dir_in) { |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 // information given through |properties|. | 118 // information given through |properties|. |
| 111 // Ensure you have initialized COM before calling into this function. | 119 // Ensure you have initialized COM before calling into this function. |
| 112 // |operation|: a choice from the ShortcutOperation enum. | 120 // |operation|: a choice from the ShortcutOperation enum. |
| 113 // If |operation| is SHORTCUT_REPLACE_EXISTING or SHORTCUT_UPDATE_EXISTING and | 121 // If |operation| is SHORTCUT_REPLACE_EXISTING or SHORTCUT_UPDATE_EXISTING and |
| 114 // |shortcut_path| does not exist, this method is a no-op and returns false. | 122 // |shortcut_path| does not exist, this method is a no-op and returns false. |
| 115 BASE_EXPORT bool CreateOrUpdateShortcutLink( | 123 BASE_EXPORT bool CreateOrUpdateShortcutLink( |
| 116 const FilePath& shortcut_path, | 124 const FilePath& shortcut_path, |
| 117 const ShortcutProperties& properties, | 125 const ShortcutProperties& properties, |
| 118 ShortcutOperation operation); | 126 ShortcutOperation operation); |
| 119 | 127 |
| 120 // Resolve Windows shortcut (.LNK file) | 128 // Resolves Windows shortcut (.LNK file) |
| 121 // This methods tries to resolve a shortcut .LNK file. The path of the shortcut | 129 // This methods tries to resolve selected properties of a shortcut .LNK file. |
| 122 // to resolve is in |shortcut_path|. If |target_path| is not NULL, the target | 130 // The path of the shortcut to resolve is in |shortcut_path|. |options| is a bit |
| 123 // will be resolved and placed in |target_path|. If |args| is not NULL, the | 131 // field composed of ShortcutProperties::IndividualProperties, to specify which |
| 124 // arguments will be retrieved and placed in |args|. The function returns true | 132 // properties to read. It should be non-0. The resulting data are read into |
| 125 // if all requested fields are found successfully. | 133 // |properties|, which must not be NULL. The function returns true if all |
| 126 // Callers can safely use the same variable for both |shortcut_path| and | 134 // requested properties are successfully read. Otherwise some reads have failed |
| 127 // |target_path|. | 135 // and intermediate values written to |properties| should be ignored. |
| 136 BASE_EXPORT bool ResolveShortcutProperties(const FilePath& shortcut_path, |
| 137 uint32 options, |
| 138 ShortcutProperties* properties); |
| 139 |
| 140 // Resolves Windows shortcut (.LNK file). |
| 141 // This is a wrapper to ResolveShortcutProperties() to handle the common use |
| 142 // case of resolving target and arguments. |target_path| and |args| are |
| 143 // optional output variables that are ignored if NULL (but at least one must be |
| 144 // non-NULL). The function returns true if all requested fields are found |
| 145 // successfully. Callers can safely use the same variable for both |
| 146 // |shortcut_path| and |target_path|. |
| 128 BASE_EXPORT bool ResolveShortcut(const FilePath& shortcut_path, | 147 BASE_EXPORT bool ResolveShortcut(const FilePath& shortcut_path, |
| 129 FilePath* target_path, | 148 FilePath* target_path, |
| 130 string16* args); | 149 string16* args); |
| 131 | 150 |
| 132 // Pins a shortcut to the Windows 7 taskbar. The shortcut file must already | 151 // Pins a shortcut to the Windows 7 taskbar. The shortcut file must already |
| 133 // exist and be a shortcut that points to an executable. The app id of the | 152 // exist and be a shortcut that points to an executable. The app id of the |
| 134 // shortcut is used to group windows and must be set correctly. | 153 // shortcut is used to group windows and must be set correctly. |
| 135 BASE_EXPORT bool TaskbarPinShortcutLink(const wchar_t* shortcut); | 154 BASE_EXPORT bool TaskbarPinShortcutLink(const wchar_t* shortcut); |
| 136 | 155 |
| 137 // Unpins a shortcut from the Windows 7 taskbar. The shortcut must exist and | 156 // Unpins a shortcut from the Windows 7 taskbar. The shortcut must exist and |
| 138 // already be pinned to the taskbar. The app id of the shortcut is used as the | 157 // already be pinned to the taskbar. The app id of the shortcut is used as the |
| 139 // identifier for the taskbar item to remove and must be set correctly. | 158 // identifier for the taskbar item to remove and must be set correctly. |
| 140 BASE_EXPORT bool TaskbarUnpinShortcutLink(const wchar_t* shortcut); | 159 BASE_EXPORT bool TaskbarUnpinShortcutLink(const wchar_t* shortcut); |
| 141 | 160 |
| 142 } // namespace win | 161 } // namespace win |
| 143 } // namespace base | 162 } // namespace base |
| 144 | 163 |
| 145 #endif // BASE_WIN_SHORTCUT_H_ | 164 #endif // BASE_WIN_SHORTCUT_H_ |
| OLD | NEW |