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 20 matching lines...) Expand all Loading... |
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 = 1 << 0, |
35 PROPERTIES_WORKING_DIR = 1 << 1, | 35 PROPERTIES_WORKING_DIR = 1 << 1, |
36 PROPERTIES_ARGUMENTS = 1 << 2, | 36 PROPERTIES_ARGUMENTS = 1 << 2, |
37 PROPERTIES_DESCRIPTION = 1 << 3, | 37 PROPERTIES_DESCRIPTION = 1 << 3, |
38 PROPERTIES_ICON = 1 << 4, | 38 PROPERTIES_ICON = 1 << 4, |
39 PROPERTIES_APP_ID = 1 << 5, | 39 PROPERTIES_APP_ID = 1 << 5, |
40 PROPERTIES_DUAL_MODE = 1 << 6, | 40 PROPERTIES_DUAL_MODE = 1 << 6, |
| 41 PROPERTIES_HOTKEY = 1 << 7, |
41 }; | 42 }; |
42 | 43 |
43 ShortcutProperties() : icon_index(-1), dual_mode(false), options(0U) {} | 44 ShortcutProperties() |
| 45 : icon_index(-1), dual_mode(false), hotkey(0), options(0U) {} |
44 | 46 |
45 void set_target(const FilePath& target_in) { | 47 void set_target(const FilePath& target_in) { |
46 target = target_in; | 48 target = target_in; |
47 options |= PROPERTIES_TARGET; | 49 options |= PROPERTIES_TARGET; |
48 } | 50 } |
49 | 51 |
50 void set_working_dir(const FilePath& working_dir_in) { | 52 void set_working_dir(const FilePath& working_dir_in) { |
51 working_dir = working_dir_in; | 53 working_dir = working_dir_in; |
52 options |= PROPERTIES_WORKING_DIR; | 54 options |= PROPERTIES_WORKING_DIR; |
53 } | 55 } |
(...skipping 21 matching lines...) Expand all Loading... |
75 void set_app_id(const string16& app_id_in) { | 77 void set_app_id(const string16& app_id_in) { |
76 app_id = app_id_in; | 78 app_id = app_id_in; |
77 options |= PROPERTIES_APP_ID; | 79 options |= PROPERTIES_APP_ID; |
78 } | 80 } |
79 | 81 |
80 void set_dual_mode(bool dual_mode_in) { | 82 void set_dual_mode(bool dual_mode_in) { |
81 dual_mode = dual_mode_in; | 83 dual_mode = dual_mode_in; |
82 options |= PROPERTIES_DUAL_MODE; | 84 options |= PROPERTIES_DUAL_MODE; |
83 } | 85 } |
84 | 86 |
| 87 void set_hotkey(int hotkey_in) { |
| 88 hotkey = hotkey_in; |
| 89 options |= PROPERTIES_HOTKEY; |
| 90 } |
| 91 |
85 // The target to launch from this shortcut. This is mandatory when creating | 92 // The target to launch from this shortcut. This is mandatory when creating |
86 // a shortcut. | 93 // a shortcut. |
87 FilePath target; | 94 FilePath target; |
88 // The name of the working directory when launching the shortcut. | 95 // The name of the working directory when launching the shortcut. |
89 FilePath working_dir; | 96 FilePath working_dir; |
90 // The arguments to be applied to |target| when launching from this shortcut. | 97 // The arguments to be applied to |target| when launching from this shortcut. |
91 // The length of this string must be less than MAX_PATH. | 98 // The length of this string must be less than MAX_PATH. |
92 string16 arguments; | 99 string16 arguments; |
93 // The localized description of the shortcut. | 100 // The localized description of the shortcut. |
94 // The length of this string must be less than MAX_PATH. | 101 // The length of this string must be less than MAX_PATH. |
95 string16 description; | 102 string16 description; |
96 // The path to the icon (can be a dll or exe, in which case |icon_index| is | 103 // The path to the icon (can be a dll or exe, in which case |icon_index| is |
97 // the resource id). | 104 // the resource id). |
98 FilePath icon; | 105 FilePath icon; |
99 int icon_index; | 106 int icon_index; |
100 // The app model id for the shortcut (Win7+). | 107 // The app model id for the shortcut (Win7+). |
101 string16 app_id; | 108 string16 app_id; |
102 // Whether this is a dual mode shortcut (Win8+). | 109 // Whether this is a dual mode shortcut (Win8+). |
103 bool dual_mode; | 110 bool dual_mode; |
| 111 // The shell launch hotkey. |
| 112 int hotkey; |
104 // Bitfield made of IndividualProperties. Properties set in |options| will be | 113 // Bitfield made of IndividualProperties. Properties set in |options| will be |
105 // set on the shortcut, others will be ignored. | 114 // set on the shortcut, others will be ignored. |
106 uint32 options; | 115 uint32 options; |
107 }; | 116 }; |
108 | 117 |
109 // This method creates (or updates) a shortcut link at |shortcut_path| using the | 118 // This method creates (or updates) a shortcut link at |shortcut_path| using the |
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 |
(...skipping 22 matching lines...) Expand all Loading... |
136 | 145 |
137 // Unpins a shortcut from the Windows 7 taskbar. The shortcut must exist and | 146 // 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 | 147 // 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. | 148 // identifier for the taskbar item to remove and must be set correctly. |
140 BASE_EXPORT bool TaskbarUnpinShortcutLink(const wchar_t* shortcut); | 149 BASE_EXPORT bool TaskbarUnpinShortcutLink(const wchar_t* shortcut); |
141 | 150 |
142 } // namespace win | 151 } // namespace win |
143 } // namespace base | 152 } // namespace base |
144 | 153 |
145 #endif // BASE_WIN_SHORTCUT_H_ | 154 #endif // BASE_WIN_SHORTCUT_H_ |
OLD | NEW |