OLD | NEW |
---|---|
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
Mark Mentovai
2011/05/23 00:23:52
I didn’t review this file or anything else in chro
| |
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 |
(...skipping 11 matching lines...) Expand all Loading... | |
23 // This is a utility class that provides common shell integration methods | 23 // This is a utility class that provides common shell integration methods |
24 // that can be used by installer as well as Chrome. | 24 // that can be used by installer as well as Chrome. |
25 class ShellUtil { | 25 class ShellUtil { |
26 public: | 26 public: |
27 // Input to any methods that make changes to OS shell. | 27 // Input to any methods that make changes to OS shell. |
28 enum ShellChange { | 28 enum ShellChange { |
29 CURRENT_USER = 0x1, // Make any shell changes only at the user level | 29 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 | 30 SYSTEM_LEVEL = 0x2 // Make any shell changes only at the system level |
31 }; | 31 }; |
32 | 32 |
33 // Relative path of the URL Protocol registry entry (prefixed with '\'). | |
34 static const wchar_t* kRegURLProtocol; | |
35 | |
33 // Relative path of DefaultIcon registry entry (prefixed with '\'). | 36 // Relative path of DefaultIcon registry entry (prefixed with '\'). |
34 static const wchar_t* kRegDefaultIcon; | 37 static const wchar_t* kRegDefaultIcon; |
35 | 38 |
36 // Relative path of "shell" registry key. | 39 // Relative path of "shell" registry key. |
37 static const wchar_t* kRegShellPath; | 40 static const wchar_t* kRegShellPath; |
38 | 41 |
39 // Relative path of shell open command in Windows registry | 42 // Relative path of shell open command in Windows registry |
40 // (i.e. \\shell\\open\\command). | 43 // (i.e. \\shell\\open\\command). |
41 static const wchar_t* kRegShellOpen; | 44 static const wchar_t* kRegShellOpen; |
42 | 45 |
(...skipping 19 matching lines...) Expand all Loading... | |
62 | 65 |
63 // Description of Chrome file association handler ProgId. | 66 // Description of Chrome file association handler ProgId. |
64 static const wchar_t* kChromeHTMLProgIdDesc; | 67 static const wchar_t* kChromeHTMLProgIdDesc; |
65 | 68 |
66 // Registry path that stores url associations on Vista. | 69 // Registry path that stores url associations on Vista. |
67 static const wchar_t* kRegVistaUrlPrefs; | 70 static const wchar_t* kRegVistaUrlPrefs; |
68 | 71 |
69 // File extensions that Chrome registers itself for. | 72 // File extensions that Chrome registers itself for. |
70 static const wchar_t* kFileAssociations[]; | 73 static const wchar_t* kFileAssociations[]; |
71 | 74 |
72 // Protocols that Chrome registers itself for. | 75 // Protocols that Chrome registers itself as the default handler for |
73 static const wchar_t* kProtocolAssociations[]; | 76 // when the user makes Chrome the default browser. |
77 static const wchar_t* kBrowserProtocolAssociations[]; | |
78 | |
79 // Protocols that Chrome registers itself as being capable of handling. | |
80 static const wchar_t* kPotentialProtocolAssociations[]; | |
74 | 81 |
75 // Registry value name that is needed for ChromeHTML ProgId | 82 // Registry value name that is needed for ChromeHTML ProgId |
76 static const wchar_t* kRegUrlProtocol; | 83 static const wchar_t* kRegUrlProtocol; |
77 | 84 |
78 // Checks if we need Admin rights for registry cleanup by checking if any | 85 // Checks if we need Admin rights for registry cleanup by checking if any |
79 // entry exists in HKLM. | 86 // entry exists in HKLM. |
80 static bool AdminNeededForRegistryCleanup(BrowserDistribution* dist, | 87 static bool AdminNeededForRegistryCleanup(BrowserDistribution* dist, |
81 const std::wstring& suffix); | 88 const std::wstring& suffix); |
82 | 89 |
83 // Create Chrome shortcut on Desktop | 90 // Create Chrome shortcut on Desktop |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
161 // level or user level. If value has ShellChange::SYSTEM_LEVEL | 168 // level or user level. If value has ShellChange::SYSTEM_LEVEL |
162 // we should be running as admin user. | 169 // we should be running as admin user. |
163 // chrome_exe: The chrome.exe path to register as default browser. | 170 // chrome_exe: The chrome.exe path to register as default browser. |
164 // elevate_if_not_admin: On Vista if user is not admin, try to elevate for | 171 // elevate_if_not_admin: On Vista if user is not admin, try to elevate for |
165 // Chrome registration. | 172 // Chrome registration. |
166 static bool MakeChromeDefault(BrowserDistribution* dist, | 173 static bool MakeChromeDefault(BrowserDistribution* dist, |
167 int shell_change, | 174 int shell_change, |
168 const std::wstring& chrome_exe, | 175 const std::wstring& chrome_exe, |
169 bool elevate_if_not_admin); | 176 bool elevate_if_not_admin); |
170 | 177 |
178 // Make Chrome default application for a protocol. | |
179 // chrome_exe: The chrome.exe path to register as default browser. | |
180 // elevate_if_not_admin: On Vista if user is not admin, try to elevate for | |
181 // Chrome registration. | |
182 static bool MakeChromeDefaultProtocolClient(BrowserDistribution* dist, | |
183 const std::wstring& chrome_exe, | |
184 const std::wstring& protocol); | |
185 | |
171 // This method adds Chrome to the list that shows up in Add/Remove Programs-> | 186 // This method adds Chrome to the list that shows up in Add/Remove Programs-> |
172 // Set Program Access and Defaults and also creates Chrome ProgIds under | 187 // Set Program Access and Defaults and also creates Chrome ProgIds under |
173 // Software\Classes. This method requires write access to HKLM so is just | 188 // Software\Classes. This method requires write access to HKLM so is just |
174 // best effort deal. If write to HKLM fails and elevate_if_not_admin is true, | 189 // best effort deal. If write to HKLM fails and elevate_if_not_admin is true, |
175 // this method will: | 190 // this method will: |
176 // - add the ProgId entries to HKCU on XP. HKCU entries will not make | 191 // - add the ProgId entries to HKCU on XP. HKCU entries will not make |
177 // Chrome show in Set Program Access and Defaults but they are still useful | 192 // Chrome show in Set Program Access and Defaults but they are still useful |
178 // because we can make Chrome run when user clicks on http link or html | 193 // because we can make Chrome run when user clicks on http link or html |
179 // file. | 194 // file. |
180 // - will try to launch setup.exe with admin priviledges on Vista to do | 195 // - will try to launch setup.exe with admin priviledges on Vista to do |
181 // these tasks. Users will see standard Vista elevation prompt and if they | 196 // these tasks. Users will see standard Vista elevation prompt and if they |
182 // enter the right credentials, the write operation will work. | 197 // enter the right credentials, the write operation will work. |
183 // Currently elevate_if_not_admin is true only when user tries to make Chrome | 198 // Currently elevate_if_not_admin is true only when user tries to make Chrome |
184 // default browser (through the UI or through installer options) and Chrome | 199 // default browser (through the UI or through installer options) and Chrome |
185 // is not registered on the machine. | 200 // is not registered on the machine. |
186 // | 201 // |
187 // |chrome_exe| full path to chrome.exe. | 202 // |chrome_exe| full path to chrome.exe. |
188 // |unique_suffix| Optional input. If given, this function appends the value | 203 // |unique_suffix| Optional input. If given, this function appends the value |
189 // to default browser entries names that it creates in the registry. | 204 // to default browser entries names that it creates in the registry. |
190 // |elevate_if_not_admin| if true will make this method try alternate methods | 205 // |elevate_if_not_admin| if true will make this method try alternate methods |
191 // as described above. | 206 // as described above. |
192 static bool RegisterChromeBrowser(BrowserDistribution* dist, | 207 static bool RegisterChromeBrowser(BrowserDistribution* dist, |
193 const std::wstring& chrome_exe, | 208 const std::wstring& chrome_exe, |
194 const std::wstring& unique_suffix, | 209 const std::wstring& unique_suffix, |
195 bool elevate_if_not_admin); | 210 bool elevate_if_not_admin); |
196 | 211 |
212 // This method declares to Windows that Chrome is capable of handling the | |
213 // given protocol. If necessary it will also call RegisterChromeBrowser above. | |
214 // Declaring the capability of handling a protocol is necessary to register | |
215 // as the default handler for the protocol is Vista and later versions of | |
216 // Windows. | |
217 // | |
218 // If called by the browser and elevation is required, it will elevate by | |
219 // calling setup.exe which will again call this function with elevate false. | |
220 // | |
221 // |chrome_exe| full path to chrome.exe. | |
222 // |unique_suffix| Optional input. If given, this function appends the value | |
223 // to default browser entries names that it creates in the registry. | |
224 // |protocol| The protocol to register as being capable of handling.s | |
225 // |elevate_if_not_admin| if true will make this method try alternate methods | |
226 // as described above. | |
227 static bool RegisterChromeForProtocol(BrowserDistribution* dist, | |
228 const std::wstring& chrome_exe, | |
229 const std::wstring& unique_suffix, | |
230 const std::wstring& protocol, | |
231 bool elevate_if_not_admin); | |
232 | |
197 // Remove Chrome shortcut from Desktop. | 233 // Remove Chrome shortcut from Desktop. |
198 // If shell_change is CURRENT_USER, the shortcut is removed from the | 234 // If shell_change is CURRENT_USER, the shortcut is removed from the |
199 // Desktop folder of current user's profile. | 235 // Desktop folder of current user's profile. |
200 // If shell_change is SYSTEM_LEVEL, the shortcut is removed from the | 236 // If shell_change is SYSTEM_LEVEL, the shortcut is removed from the |
201 // Desktop folder of "All Users" profile. | 237 // Desktop folder of "All Users" profile. |
202 // If alternate is true, the shortcut with the alternate name is removed. See | 238 // If alternate is true, the shortcut with the alternate name is removed. See |
203 // CreateChromeDesktopShortcut() for more information. | 239 // CreateChromeDesktopShortcut() for more information. |
204 static bool RemoveChromeDesktopShortcut(BrowserDistribution* dist, | 240 static bool RemoveChromeDesktopShortcut(BrowserDistribution* dist, |
205 int shell_change, bool alternate); | 241 int shell_change, bool alternate); |
206 | 242 |
(...skipping 15 matching lines...) Expand all Loading... | |
222 const std::wstring& shortcut, | 258 const std::wstring& shortcut, |
223 const std::wstring& description, | 259 const std::wstring& description, |
224 bool create_new); | 260 bool create_new); |
225 | 261 |
226 private: | 262 private: |
227 DISALLOW_COPY_AND_ASSIGN(ShellUtil); | 263 DISALLOW_COPY_AND_ASSIGN(ShellUtil); |
228 }; | 264 }; |
229 | 265 |
230 | 266 |
231 #endif // CHROME_INSTALLER_UTIL_SHELL_UTIL_H_ | 267 #endif // CHROME_INSTALLER_UTIL_SHELL_UTIL_H_ |
OLD | NEW |