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 |
gab
2014/01/03 18:25:52
Remove extra empty line.
huangs
2014/01/03 20:19:35
Done.
| |
51 | |
43 ShortcutProperties() : icon_index(-1), dual_mode(false), options(0U) {} | 52 ShortcutProperties() : icon_index(-1), dual_mode(false), options(0U) {} |
44 | 53 |
45 void set_target(const FilePath& target_in) { | 54 void set_target(const FilePath& target_in) { |
46 target = target_in; | 55 target = target_in; |
47 options |= PROPERTIES_TARGET; | 56 options |= PROPERTIES_TARGET; |
48 } | 57 } |
49 | 58 |
50 void set_working_dir(const FilePath& working_dir_in) { | 59 void set_working_dir(const FilePath& working_dir_in) { |
51 working_dir = working_dir_in; | 60 working_dir = working_dir_in; |
52 options |= PROPERTIES_WORKING_DIR; | 61 options |= PROPERTIES_WORKING_DIR; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
110 // information given through |properties|. | 119 // information given through |properties|. |
111 // Ensure you have initialized COM before calling into this function. | 120 // Ensure you have initialized COM before calling into this function. |
112 // |operation|: a choice from the ShortcutOperation enum. | 121 // |operation|: a choice from the ShortcutOperation enum. |
113 // If |operation| is SHORTCUT_REPLACE_EXISTING or SHORTCUT_UPDATE_EXISTING and | 122 // 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. | 123 // |shortcut_path| does not exist, this method is a no-op and returns false. |
115 BASE_EXPORT bool CreateOrUpdateShortcutLink( | 124 BASE_EXPORT bool CreateOrUpdateShortcutLink( |
116 const FilePath& shortcut_path, | 125 const FilePath& shortcut_path, |
117 const ShortcutProperties& properties, | 126 const ShortcutProperties& properties, |
118 ShortcutOperation operation); | 127 ShortcutOperation operation); |
119 | 128 |
120 // Resolve Windows shortcut (.LNK file) | 129 // Resolves Windows shortcut (.LNK file) |
121 // This methods tries to resolve a shortcut .LNK file. The path of the shortcut | 130 // 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 | 131 // 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 | 132 // field composed of ShortcutProperties::IndividualProperties, to specify which |
124 // arguments will be retrieved and placed in |args|. The function returns true | 133 // properties to read. It should be non-0. The resulting data are read into |
125 // if all requested fields are found successfully. | 134 // |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 | 135 // requested properties are successfully read. Otherwise some reads have failed |
127 // |target_path|. | 136 // and intermediate values written to |properties| should be ignored. |
137 BASE_EXPORT bool ResolveShortcutProperties(const FilePath& shortcut_path, | |
138 uint32 options, | |
139 ShortcutProperties* properties); | |
140 | |
141 // Resolves Windows shortcut (.LNK file). | |
142 // This is a wrapper to ResolveShortcutProperties() to handle the common use | |
143 // case of resolving target and arguments. |target_path| and |args| are | |
144 // optional output variables that are ignored if NULL (but at least one must be | |
145 // non-NULL). The function returns true if all requested fields are found | |
146 // successfully. Callers can safely use the same variable for both | |
147 // |shortcut_path| and |target_path|. | |
128 BASE_EXPORT bool ResolveShortcut(const FilePath& shortcut_path, | 148 BASE_EXPORT bool ResolveShortcut(const FilePath& shortcut_path, |
129 FilePath* target_path, | 149 FilePath* target_path, |
130 string16* args); | 150 string16* args); |
131 | 151 |
132 // Pins a shortcut to the Windows 7 taskbar. The shortcut file must already | 152 // 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 | 153 // 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. | 154 // shortcut is used to group windows and must be set correctly. |
135 BASE_EXPORT bool TaskbarPinShortcutLink(const wchar_t* shortcut); | 155 BASE_EXPORT bool TaskbarPinShortcutLink(const wchar_t* shortcut); |
136 | 156 |
137 // Unpins a shortcut from the Windows 7 taskbar. The shortcut must exist and | 157 // 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 | 158 // 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. | 159 // identifier for the taskbar item to remove and must be set correctly. |
140 BASE_EXPORT bool TaskbarUnpinShortcutLink(const wchar_t* shortcut); | 160 BASE_EXPORT bool TaskbarUnpinShortcutLink(const wchar_t* shortcut); |
141 | 161 |
142 } // namespace win | 162 } // namespace win |
143 } // namespace base | 163 } // namespace base |
144 | 164 |
145 #endif // BASE_WIN_SHORTCUT_H_ | 165 #endif // BASE_WIN_SHORTCUT_H_ |
OLD | NEW |