OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // This file declares methods that are useful for integrating Chrome in | 5 // This file declares methods that are useful for integrating Chrome in |
6 // Windows shell. These methods are all static and currently part of | 6 // Windows shell. These methods are all static and currently part of |
7 // ShellUtil class. | 7 // ShellUtil class. |
8 | 8 |
9 #ifndef CHROME_INSTALLER_UTIL_SHELL_UTIL_H_ | 9 #ifndef CHROME_INSTALLER_UTIL_SHELL_UTIL_H_ |
10 #define CHROME_INSTALLER_UTIL_SHELL_UTIL_H_ | 10 #define CHROME_INSTALLER_UTIL_SHELL_UTIL_H_ |
11 #pragma once | 11 #pragma once |
12 | 12 |
13 #include <windows.h> | 13 #include <windows.h> |
14 #include <map> | 14 #include <map> |
15 #include <string> | 15 #include <string> |
16 | 16 |
17 #include "base/basictypes.h" | 17 #include "base/basictypes.h" |
18 #include "chrome/installer/util/work_item_list.h" | 18 #include "chrome/installer/util/work_item_list.h" |
19 | 19 |
20 class BrowserDistribution; | 20 class BrowserDistribution; |
21 class FilePath; | 21 class FilePath; |
22 | 22 |
| 23 namespace base { |
| 24 class DictionaryValue; |
| 25 } |
| 26 |
23 // This is a utility class that provides common shell integration methods | 27 // This is a utility class that provides common shell integration methods |
24 // that can be used by installer as well as Chrome. | 28 // that can be used by installer as well as Chrome. |
25 class ShellUtil { | 29 class ShellUtil { |
26 public: | 30 public: |
27 // Input to any methods that make changes to OS shell. | 31 // Input to any methods that make changes to OS shell. |
28 enum ShellChange { | 32 enum ShellChange { |
29 CURRENT_USER = 0x1, // Make any shell changes only at the user level | 33 CURRENT_USER = 0x1, // Make any shell changes only at the user level |
30 SYSTEM_LEVEL = 0x2 // Make any shell changes only at the system level | 34 SYSTEM_LEVEL = 0x2 // Make any shell changes only at the system level |
31 }; | 35 }; |
32 | 36 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 static const wchar_t* kPotentialProtocolAssociations[]; | 84 static const wchar_t* kPotentialProtocolAssociations[]; |
81 | 85 |
82 // Registry value name that is needed for ChromeHTML ProgId | 86 // Registry value name that is needed for ChromeHTML ProgId |
83 static const wchar_t* kRegUrlProtocol; | 87 static const wchar_t* kRegUrlProtocol; |
84 | 88 |
85 // Checks if we need Admin rights for registry cleanup by checking if any | 89 // Checks if we need Admin rights for registry cleanup by checking if any |
86 // entry exists in HKLM. | 90 // entry exists in HKLM. |
87 static bool AdminNeededForRegistryCleanup(BrowserDistribution* dist, | 91 static bool AdminNeededForRegistryCleanup(BrowserDistribution* dist, |
88 const std::wstring& suffix); | 92 const std::wstring& suffix); |
89 | 93 |
90 // Create Chrome shortcut on Desktop | 94 // Creates Chrome shortcut on the Desktop. |
91 // If shell_change is CURRENT_USER, the shortcut is created in the | 95 // |dist| gives the type of browser distribution currently in use. |
92 // Desktop folder of current user's profile. | 96 // |chrome_exe| provides the target path information. |
93 // If shell_change is SYSTEM_LEVEL, the shortcut is created in the | 97 // |description| provides the shortcut's "comment" property. |
94 // Desktop folder of "All Users" profile. | 98 // |appended_name| provides a string to be appended to the distribution name, |
95 // If alternate is true, an alternate text for the shortcut is used. | 99 // and can be the empty string. |
96 // create_new: If false, will only update the shortcut. If true, the function | 100 // |arguments| gives a set of arguments to be passed to the executable. |
97 // will create a new shortcut if it doesn't exist already. | 101 // If |shell_change| is CURRENT_USER, the shortcut is created in the |
| 102 // Desktop folder of current user's profile. |
| 103 // If |shell_change| is SYSTEM_LEVEL, the shortcut is created in the |
| 104 // Desktop folder of the "All Users" profile. |
| 105 // If |alternate| is true, an alternate text for the shortcut is used. |
| 106 // If |create_new| is false, an existing shortcut will be updated, but if |
| 107 // no shortcut exists, it will not be created. |
98 // Returns true iff the method causes a shortcut to be created / updated. | 108 // Returns true iff the method causes a shortcut to be created / updated. |
99 static bool CreateChromeDesktopShortcut(BrowserDistribution* dist, | 109 static bool CreateChromeDesktopShortcut(BrowserDistribution* dist, |
100 const std::wstring& chrome_exe, | 110 const std::wstring& chrome_exe, |
101 const std::wstring& description, | 111 const std::wstring& description, |
| 112 const std::wstring& appended_name, |
| 113 const std::wstring& arguments, |
102 ShellChange shell_change, | 114 ShellChange shell_change, |
103 bool alternate, | 115 bool alternate, |
104 bool create_new); | 116 bool create_new); |
105 | 117 |
106 // Create Chrome shortcut on Quick Launch Bar. | 118 // Create Chrome shortcut on Quick Launch Bar. |
107 // If shell_change is CURRENT_USER, the shortcut is created in the | 119 // If shell_change is CURRENT_USER, the shortcut is created in the |
108 // Quick Launch folder of current user's profile. | 120 // Quick Launch folder of current user's profile. |
109 // If shell_change is SYSTEM_LEVEL, the shortcut is created in the | 121 // If shell_change is SYSTEM_LEVEL, the shortcut is created in the |
110 // Quick Launch folder of "Default User" profile. This will make sure | 122 // Quick Launch folder of "Default User" profile. This will make sure |
111 // that this shortcut will be seen by all the new users logging into the | 123 // that this shortcut will be seen by all the new users logging into the |
(...skipping 10 matching lines...) Expand all Loading... |
122 // Chrome icon that can be used as value for Windows registry keys. | 134 // Chrome icon that can be used as value for Windows registry keys. |
123 // |chrome_exe| full path to chrome.exe. | 135 // |chrome_exe| full path to chrome.exe. |
124 static std::wstring GetChromeIcon(BrowserDistribution* dist, | 136 static std::wstring GetChromeIcon(BrowserDistribution* dist, |
125 const std::wstring& chrome_exe); | 137 const std::wstring& chrome_exe); |
126 | 138 |
127 // This method returns the command to open URLs/files using chrome. Typically | 139 // This method returns the command to open URLs/files using chrome. Typically |
128 // this command is written to the registry under shell\open\command key. | 140 // this command is written to the registry under shell\open\command key. |
129 // chrome_exe: the full path to chrome.exe | 141 // chrome_exe: the full path to chrome.exe |
130 static std::wstring GetChromeShellOpenCmd(const std::wstring& chrome_exe); | 142 static std::wstring GetChromeShellOpenCmd(const std::wstring& chrome_exe); |
131 | 143 |
132 // Returns the localized name of Chrome shortcut. If |alternate| is true | 144 // Returns the localized name of Chrome shortcut in |shortcut|. If |
133 // it returns a second localized text that is better suited for certain | 145 // |appended_name| is not empty, it is included in the shortcut name. If |
134 // scenarios. | 146 // |alternate| is true, a second localized text that is better suited for |
| 147 // certain scenarios is used. |
135 static bool GetChromeShortcutName(BrowserDistribution* dist, | 148 static bool GetChromeShortcutName(BrowserDistribution* dist, |
136 std::wstring* shortcut, bool alternate); | 149 bool alternate, |
| 150 const std::wstring& appended_name, |
| 151 std::wstring* shortcut); |
137 | 152 |
138 // Gets the desktop path for the current user or all users (if system_level | 153 // Gets the desktop path for the current user or all users (if system_level |
139 // is true) and returns it in 'path' argument. Return true if successful, | 154 // is true) and returns it in 'path' argument. Return true if successful, |
140 // otherwise returns false. | 155 // otherwise returns false. |
141 static bool GetDesktopPath(bool system_level, FilePath* path); | 156 static bool GetDesktopPath(bool system_level, FilePath* path); |
142 | 157 |
143 // Gets the Quick Launch shortcuts path for the current user and | 158 // Gets the Quick Launch shortcuts path for the current user and |
144 // returns it in 'path' argument. Return true if successful, otherwise | 159 // returns it in 'path' argument. Return true if successful, otherwise |
145 // returns false. If system_level is true this function returns the path | 160 // returns false. If system_level is true this function returns the path |
146 // to Default Users Quick Launch shortcuts path. Adding a shortcut to Default | 161 // to Default Users Quick Launch shortcuts path. Adding a shortcut to Default |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 bool elevate_if_not_admin); | 258 bool elevate_if_not_admin); |
244 | 259 |
245 // Remove Chrome shortcut from Desktop. | 260 // Remove Chrome shortcut from Desktop. |
246 // If shell_change is CURRENT_USER, the shortcut is removed from the | 261 // If shell_change is CURRENT_USER, the shortcut is removed from the |
247 // Desktop folder of current user's profile. | 262 // Desktop folder of current user's profile. |
248 // If shell_change is SYSTEM_LEVEL, the shortcut is removed from the | 263 // If shell_change is SYSTEM_LEVEL, the shortcut is removed from the |
249 // Desktop folder of "All Users" profile. | 264 // Desktop folder of "All Users" profile. |
250 // If alternate is true, the shortcut with the alternate name is removed. See | 265 // If alternate is true, the shortcut with the alternate name is removed. See |
251 // CreateChromeDesktopShortcut() for more information. | 266 // CreateChromeDesktopShortcut() for more information. |
252 static bool RemoveChromeDesktopShortcut(BrowserDistribution* dist, | 267 static bool RemoveChromeDesktopShortcut(BrowserDistribution* dist, |
253 int shell_change, bool alternate); | 268 int shell_change, |
| 269 bool alternate); |
| 270 |
| 271 // Removes a set of existing Chrome desktop shortcuts. |appended_names| is a |
| 272 // list of shortcut file names as obtained from |
| 273 // ShellUtil::GetChromeShortcutName. |
| 274 static bool RemoveChromeDesktopShortcutsWithAppendedNames( |
| 275 const std::vector<std::wstring>& appended_names); |
254 | 276 |
255 // Remove Chrome shortcut from Quick Launch Bar. | 277 // Remove Chrome shortcut from Quick Launch Bar. |
256 // If shell_change is CURRENT_USER, the shortcut is removed from | 278 // If shell_change is CURRENT_USER, the shortcut is removed from |
257 // the Quick Launch folder of current user's profile. | 279 // the Quick Launch folder of current user's profile. |
258 // If shell_change is SYSTEM_LEVEL, the shortcut is removed from | 280 // If shell_change is SYSTEM_LEVEL, the shortcut is removed from |
259 // the Quick Launch folder of "Default User" profile. | 281 // the Quick Launch folder of "Default User" profile. |
260 static bool RemoveChromeQuickLaunchShortcut(BrowserDistribution* dist, | 282 static bool RemoveChromeQuickLaunchShortcut(BrowserDistribution* dist, |
261 int shell_change); | 283 int shell_change); |
262 | 284 |
263 // Updates shortcut (or creates a new shortcut) at destination given by | 285 // Updates shortcut (or creates a new shortcut) at destination given by |
264 // shortcut to a target given by chrome_exe. The arguments is left NULL | 286 // shortcut to a target given by chrome_exe. The arguments are given by |
265 // for the target and icon is set as icon at index 0 from exe. | 287 // |arguments| for the target and icon is set as icon at index 0 from exe. |
266 // If create_new is set to true, the function will create a new shortcut if | 288 // If create_new is set to true, the function will create a new shortcut if |
267 // if doesn't exist. | 289 // if doesn't exist. |
268 static bool UpdateChromeShortcut(BrowserDistribution* dist, | 290 static bool UpdateChromeShortcut(BrowserDistribution* dist, |
269 const std::wstring& chrome_exe, | 291 const std::wstring& chrome_exe, |
270 const std::wstring& shortcut, | 292 const std::wstring& shortcut, |
| 293 const std::wstring& arguments, |
271 const std::wstring& description, | 294 const std::wstring& description, |
272 bool create_new); | 295 bool create_new); |
273 | 296 |
274 private: | 297 private: |
275 DISALLOW_COPY_AND_ASSIGN(ShellUtil); | 298 DISALLOW_COPY_AND_ASSIGN(ShellUtil); |
276 }; | 299 }; |
277 | 300 |
278 | 301 |
279 #endif // CHROME_INSTALLER_UTIL_SHELL_UTIL_H_ | 302 #endif // CHROME_INSTALLER_UTIL_SHELL_UTIL_H_ |
OLD | NEW |