Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(323)

Side by Side Diff: chrome/installer/util/shell_util.h

Issue 6961013: Allow chrome to become the os default handler for arbitrary protocols on mac/win. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More changes in response to comments. Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 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
(...skipping 11 matching lines...) Expand all
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
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
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 // protocol: The protocol to register as the default handler for.
181 static bool MakeChromeDefaultProtocolClient(BrowserDistribution* dist,
182 const std::wstring& chrome_exe,
183 const std::wstring& protocol);
184
171 // This method adds Chrome to the list that shows up in Add/Remove Programs-> 185 // 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 186 // Set Program Access and Defaults and also creates Chrome ProgIds under
173 // Software\Classes. This method requires write access to HKLM so is just 187 // 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, 188 // best effort deal. If write to HKLM fails and elevate_if_not_admin is true,
175 // this method will: 189 // this method will:
176 // - add the ProgId entries to HKCU on XP. HKCU entries will not make 190 // - 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 191 // 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 192 // because we can make Chrome run when user clicks on http link or html
179 // file. 193 // file.
180 // - will try to launch setup.exe with admin priviledges on Vista to do 194 // - 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 195 // these tasks. Users will see standard Vista elevation prompt and if they
182 // enter the right credentials, the write operation will work. 196 // enter the right credentials, the write operation will work.
183 // Currently elevate_if_not_admin is true only when user tries to make Chrome 197 // 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 198 // default browser (through the UI or through installer options) and Chrome
185 // is not registered on the machine. 199 // is not registered on the machine.
186 // 200 //
187 // |chrome_exe| full path to chrome.exe. 201 // |chrome_exe| full path to chrome.exe.
188 // |unique_suffix| Optional input. If given, this function appends the value 202 // |unique_suffix| Optional input. If given, this function appends the value
189 // to default browser entries names that it creates in the registry. 203 // 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 204 // |elevate_if_not_admin| if true will make this method try alternate methods
191 // as described above. 205 // as described above.
192 static bool RegisterChromeBrowser(BrowserDistribution* dist, 206 static bool RegisterChromeBrowser(BrowserDistribution* dist,
193 const std::wstring& chrome_exe, 207 const std::wstring& chrome_exe,
194 const std::wstring& unique_suffix, 208 const std::wstring& unique_suffix,
195 bool elevate_if_not_admin); 209 bool elevate_if_not_admin);
196 210
211 // This method declares to Windows that Chrome is capable of handling the
212 // given protocol. This function will call the RegisterChromeBrowser function
213 // to register with Windows as capable of handling the protocol, if it isn't
214 // currently registered as capable.
215 // Declaring the capability of handling a protocol is necessary to register
216 // as the default handler for the protocol in Vista and later versions of
217 // Windows.
218 //
219 // If called by the browser and elevation is required, it will elevate by
220 // calling setup.exe which will again call this function with elevate false.
221 //
222 // |chrome_exe| full path to chrome.exe.
223 // |unique_suffix| Optional input. If given, this function appends the value
224 // to default browser entries names that it creates in the registry.
225 // |protocol| The protocol to register as being capable of handling.s
226 // |elevate_if_not_admin| if true will make this method try alternate methods
227 // as described above.
228 static bool RegisterChromeForProtocol(BrowserDistribution* dist,
229 const std::wstring& chrome_exe,
230 const std::wstring& unique_suffix,
231 const std::wstring& protocol,
232 bool elevate_if_not_admin);
233
197 // Remove Chrome shortcut from Desktop. 234 // Remove Chrome shortcut from Desktop.
198 // If shell_change is CURRENT_USER, the shortcut is removed from the 235 // If shell_change is CURRENT_USER, the shortcut is removed from the
199 // Desktop folder of current user's profile. 236 // Desktop folder of current user's profile.
200 // If shell_change is SYSTEM_LEVEL, the shortcut is removed from the 237 // If shell_change is SYSTEM_LEVEL, the shortcut is removed from the
201 // Desktop folder of "All Users" profile. 238 // Desktop folder of "All Users" profile.
202 // If alternate is true, the shortcut with the alternate name is removed. See 239 // If alternate is true, the shortcut with the alternate name is removed. See
203 // CreateChromeDesktopShortcut() for more information. 240 // CreateChromeDesktopShortcut() for more information.
204 static bool RemoveChromeDesktopShortcut(BrowserDistribution* dist, 241 static bool RemoveChromeDesktopShortcut(BrowserDistribution* dist,
205 int shell_change, bool alternate); 242 int shell_change, bool alternate);
206 243
(...skipping 15 matching lines...) Expand all
222 const std::wstring& shortcut, 259 const std::wstring& shortcut,
223 const std::wstring& description, 260 const std::wstring& description,
224 bool create_new); 261 bool create_new);
225 262
226 private: 263 private:
227 DISALLOW_COPY_AND_ASSIGN(ShellUtil); 264 DISALLOW_COPY_AND_ASSIGN(ShellUtil);
228 }; 265 };
229 266
230 267
231 #endif // CHROME_INSTALLER_UTIL_SHELL_UTIL_H_ 268 #endif // CHROME_INSTALLER_UTIL_SHELL_UTIL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698