| 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 #include <stdint.h> |
| 9 | 10 |
| 10 #include "base/base_export.h" | 11 #include "base/base_export.h" |
| 11 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
| 12 #include "base/logging.h" | 13 #include "base/logging.h" |
| 13 #include "base/strings/string16.h" | 14 #include "base/strings/string16.h" |
| 14 | 15 |
| 15 namespace base { | 16 namespace base { |
| 16 namespace win { | 17 namespace win { |
| 17 | 18 |
| 18 enum ShortcutOperation { | 19 enum ShortcutOperation { |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 // The path to the icon (can be a dll or exe, in which case |icon_index| is | 107 // The path to the icon (can be a dll or exe, in which case |icon_index| is |
| 107 // the resource id). | 108 // the resource id). |
| 108 FilePath icon; | 109 FilePath icon; |
| 109 int icon_index; | 110 int icon_index; |
| 110 // The app model id for the shortcut (Win7+). | 111 // The app model id for the shortcut (Win7+). |
| 111 string16 app_id; | 112 string16 app_id; |
| 112 // Whether this is a dual mode shortcut (Win8+). | 113 // Whether this is a dual mode shortcut (Win8+). |
| 113 bool dual_mode; | 114 bool dual_mode; |
| 114 // Bitfield made of IndividualProperties. Properties set in |options| will be | 115 // Bitfield made of IndividualProperties. Properties set in |options| will be |
| 115 // set on the shortcut, others will be ignored. | 116 // set on the shortcut, others will be ignored. |
| 116 uint32 options; | 117 uint32_t options; |
| 117 }; | 118 }; |
| 118 | 119 |
| 119 // This method creates (or updates) a shortcut link at |shortcut_path| using the | 120 // This method creates (or updates) a shortcut link at |shortcut_path| using the |
| 120 // information given through |properties|. | 121 // information given through |properties|. |
| 121 // Ensure you have initialized COM before calling into this function. | 122 // Ensure you have initialized COM before calling into this function. |
| 122 // |operation|: a choice from the ShortcutOperation enum. | 123 // |operation|: a choice from the ShortcutOperation enum. |
| 123 // If |operation| is SHORTCUT_REPLACE_EXISTING or SHORTCUT_UPDATE_EXISTING and | 124 // If |operation| is SHORTCUT_REPLACE_EXISTING or SHORTCUT_UPDATE_EXISTING and |
| 124 // |shortcut_path| does not exist, this method is a no-op and returns false. | 125 // |shortcut_path| does not exist, this method is a no-op and returns false. |
| 125 BASE_EXPORT bool CreateOrUpdateShortcutLink( | 126 BASE_EXPORT bool CreateOrUpdateShortcutLink( |
| 126 const FilePath& shortcut_path, | 127 const FilePath& shortcut_path, |
| 127 const ShortcutProperties& properties, | 128 const ShortcutProperties& properties, |
| 128 ShortcutOperation operation); | 129 ShortcutOperation operation); |
| 129 | 130 |
| 130 // Resolves Windows shortcut (.LNK file). | 131 // Resolves Windows shortcut (.LNK file). |
| 131 // This methods tries to resolve selected properties of a shortcut .LNK file. | 132 // This methods tries to resolve selected properties of a shortcut .LNK file. |
| 132 // The path of the shortcut to resolve is in |shortcut_path|. |options| is a bit | 133 // The path of the shortcut to resolve is in |shortcut_path|. |options| is a bit |
| 133 // field composed of ShortcutProperties::IndividualProperties, to specify which | 134 // field composed of ShortcutProperties::IndividualProperties, to specify which |
| 134 // properties to read. It should be non-0. The resulting data are read into | 135 // properties to read. It should be non-0. The resulting data are read into |
| 135 // |properties|, which must not be NULL. Note: PROPERTIES_TARGET will retrieve | 136 // |properties|, which must not be NULL. Note: PROPERTIES_TARGET will retrieve |
| 136 // the target path as stored in the shortcut but won't attempt to resolve that | 137 // the target path as stored in the shortcut but won't attempt to resolve that |
| 137 // path so it may not be valid. The function returns true if all requested | 138 // path so it may not be valid. The function returns true if all requested |
| 138 // properties are successfully read. Otherwise some reads have failed and | 139 // properties are successfully read. Otherwise some reads have failed and |
| 139 // intermediate values written to |properties| should be ignored. | 140 // intermediate values written to |properties| should be ignored. |
| 140 BASE_EXPORT bool ResolveShortcutProperties(const FilePath& shortcut_path, | 141 BASE_EXPORT bool ResolveShortcutProperties(const FilePath& shortcut_path, |
| 141 uint32 options, | 142 uint32_t options, |
| 142 ShortcutProperties* properties); | 143 ShortcutProperties* properties); |
| 143 | 144 |
| 144 // Resolves Windows shortcut (.LNK file). | 145 // Resolves Windows shortcut (.LNK file). |
| 145 // This is a wrapper to ResolveShortcutProperties() to handle the common use | 146 // This is a wrapper to ResolveShortcutProperties() to handle the common use |
| 146 // case of resolving target and arguments. |target_path| and |args| are | 147 // case of resolving target and arguments. |target_path| and |args| are |
| 147 // optional output variables that are ignored if NULL (but at least one must be | 148 // optional output variables that are ignored if NULL (but at least one must be |
| 148 // non-NULL). The function returns true if all requested fields are found | 149 // non-NULL). The function returns true if all requested fields are found |
| 149 // successfully. Callers can safely use the same variable for both | 150 // successfully. Callers can safely use the same variable for both |
| 150 // |shortcut_path| and |target_path|. | 151 // |shortcut_path| and |target_path|. |
| 151 BASE_EXPORT bool ResolveShortcut(const FilePath& shortcut_path, | 152 BASE_EXPORT bool ResolveShortcut(const FilePath& shortcut_path, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 163 | 164 |
| 164 // Unpins a shortcut from the Windows 7+ taskbar. The |shortcut| must exist and | 165 // Unpins a shortcut from the Windows 7+ taskbar. The |shortcut| must exist and |
| 165 // already be pinned to the taskbar. The app id of the shortcut is used as the | 166 // already be pinned to the taskbar. The app id of the shortcut is used as the |
| 166 // identifier for the taskbar item to remove and must be set correctly. | 167 // identifier for the taskbar item to remove and must be set correctly. |
| 167 BASE_EXPORT bool UnpinShortcutFromTaskbar(const FilePath& shortcut); | 168 BASE_EXPORT bool UnpinShortcutFromTaskbar(const FilePath& shortcut); |
| 168 | 169 |
| 169 } // namespace win | 170 } // namespace win |
| 170 } // namespace base | 171 } // namespace base |
| 171 | 172 |
| 172 #endif // BASE_WIN_SHORTCUT_H_ | 173 #endif // BASE_WIN_SHORTCUT_H_ |
| OLD | NEW |