• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
3 // found in the LICENSE file.
4 //
5 // This file declares methods that are useful for integrating Chrome in
6 // Windows shell. These methods are all static and currently part of
7 // ShellUtil class.
8 
9 #ifndef CHROME_INSTALLER_UTIL_SHELL_UTIL_H_
10 #define CHROME_INSTALLER_UTIL_SHELL_UTIL_H_
11 
12 #include <windows.h>
13 
14 #include <map>
15 #include <vector>
16 
17 #include "base/basictypes.h"
18 #include "base/files/file_path.h"
19 #include "base/logging.h"
20 #include "base/strings/string16.h"
21 #include "chrome/installer/util/work_item_list.h"
22 
23 class BrowserDistribution;
24 
25 // This is a utility class that provides common shell integration methods
26 // that can be used by installer as well as Chrome.
27 class ShellUtil {
28  public:
29   // Input to any methods that make changes to OS shell.
30   enum ShellChange {
31     CURRENT_USER = 0x1,  // Make any shell changes only at the user level
32     SYSTEM_LEVEL = 0x2   // Make any shell changes only at the system level
33   };
34 
35   // Chrome's default handler state for a given protocol.
36   enum DefaultState {
37     UNKNOWN_DEFAULT,
38     NOT_DEFAULT,
39     IS_DEFAULT,
40   };
41 
42   // Typical shortcut directories. Resolved in GetShortcutPath().
43   // Also used in ShortcutLocationIsSupported().
44   enum ShortcutLocation {
45     SHORTCUT_LOCATION_FIRST = 0,
46     SHORTCUT_LOCATION_DESKTOP = SHORTCUT_LOCATION_FIRST,
47     SHORTCUT_LOCATION_QUICK_LAUNCH,
48     SHORTCUT_LOCATION_START_MENU_ROOT,
49     SHORTCUT_LOCATION_START_MENU_CHROME_DIR,
50     SHORTCUT_LOCATION_START_MENU_CHROME_APPS_DIR,
51     SHORTCUT_LOCATION_TASKBAR_PINS,  // base::win::VERSION_WIN7 +
52     SHORTCUT_LOCATION_APP_SHORTCUTS,  // base::win::VERSION_WIN8 +
53     NUM_SHORTCUT_LOCATIONS
54   };
55 
56   enum ShortcutOperation {
57     // Create a new shortcut (overwriting if necessary).
58     SHELL_SHORTCUT_CREATE_ALWAYS,
59     // Create the per-user shortcut only if its system-level equivalent (with
60     // the same name) is not present.
61     SHELL_SHORTCUT_CREATE_IF_NO_SYSTEM_LEVEL,
62     // Overwrite an existing shortcut (fail if the shortcut doesn't exist).
63     // If the arguments are not specified on the new shortcut, keep the old
64     // shortcut's arguments.
65     SHELL_SHORTCUT_REPLACE_EXISTING,
66     // Update specified properties only on an existing shortcut.
67     SHELL_SHORTCUT_UPDATE_EXISTING,
68   };
69 
70   // Properties for shortcuts. Properties set will be applied to
71   // the shortcut on creation/update. On update, unset properties are ignored;
72   // on create (and replaced) unset properties might have a default value (see
73   // individual property setters below for details).
74   // Callers are encouraged to use the setters provided which take care of
75   // setting |options| as desired.
76   struct ShortcutProperties {
77     enum IndividualProperties {
78       PROPERTIES_TARGET = 1 << 0,
79       PROPERTIES_ARGUMENTS = 1 << 1,
80       PROPERTIES_DESCRIPTION = 1 << 2,
81       PROPERTIES_ICON = 1 << 3,
82       PROPERTIES_APP_ID = 1 << 4,
83       PROPERTIES_SHORTCUT_NAME = 1 << 5,
84       PROPERTIES_DUAL_MODE = 1 << 6,
85     };
86 
ShortcutPropertiesShortcutProperties87     explicit ShortcutProperties(ShellChange level_in)
88         : level(level_in), icon_index(0), dual_mode(false),
89           pin_to_taskbar(false), options(0U) {}
90 
91     // Sets the target executable to launch from this shortcut.
92     // This is mandatory when creating a shortcut.
set_targetShortcutProperties93     void set_target(const base::FilePath& target_in) {
94       target = target_in;
95       options |= PROPERTIES_TARGET;
96     }
97 
98     // Sets the arguments to be passed to |target| when launching from this
99     // shortcut.
100     // The length of this string must be less than MAX_PATH.
set_argumentsShortcutProperties101     void set_arguments(const string16& arguments_in) {
102       // Size restriction as per MSDN at
103       // http://msdn.microsoft.com/library/windows/desktop/bb774954.aspx.
104       DCHECK(arguments_in.length() < MAX_PATH);
105       arguments = arguments_in;
106       options |= PROPERTIES_ARGUMENTS;
107     }
108 
109     // Sets the localized description of the shortcut.
110     // The length of this string must be less than MAX_PATH.
set_descriptionShortcutProperties111     void set_description(const string16& description_in) {
112       // Size restriction as per MSDN at
113       // http://msdn.microsoft.com/library/windows/desktop/bb774955.aspx.
114       DCHECK(description_in.length() < MAX_PATH);
115       description = description_in;
116       options |= PROPERTIES_DESCRIPTION;
117     }
118 
119     // Sets the path to the icon (icon_index set to 0).
120     // icon index unless otherwise specified in master_preferences).
set_iconShortcutProperties121     void set_icon(const base::FilePath& icon_in, int icon_index_in) {
122       icon = icon_in;
123       icon_index = icon_index_in;
124       options |= PROPERTIES_ICON;
125     }
126 
127     // Sets the app model id for the shortcut (Win7+).
set_app_idShortcutProperties128     void set_app_id(const string16& app_id_in) {
129       app_id = app_id_in;
130       options |= PROPERTIES_APP_ID;
131     }
132 
133     // Forces the shortcut's name to |shortcut_name_in|.
134     // Default: the current distribution's GetShortcutName(SHORTCUT_CHROME).
135     // The ".lnk" extension will automatically be added to this name.
set_shortcut_nameShortcutProperties136     void set_shortcut_name(const string16& shortcut_name_in) {
137       shortcut_name = shortcut_name_in;
138       options |= PROPERTIES_SHORTCUT_NAME;
139     }
140 
141     // Sets whether this is a dual mode shortcut (Win8+).
142     // NOTE: Only the default (no arguments and default browser appid) browser
143     // shortcut in the Start menu (Start screen on Win8+) should be made dual
144     // mode.
set_dual_modeShortcutProperties145     void set_dual_mode(bool dual_mode_in) {
146       dual_mode = dual_mode_in;
147       options |= PROPERTIES_DUAL_MODE;
148     }
149 
150     // Sets whether to pin this shortcut to the taskbar after creating it
151     // (ignored if the shortcut is only being updated).
152     // Note: This property doesn't have a mask in |options|.
set_pin_to_taskbarShortcutProperties153     void set_pin_to_taskbar(bool pin_to_taskbar_in) {
154       pin_to_taskbar = pin_to_taskbar_in;
155     }
156 
has_targetShortcutProperties157     bool has_target() const {
158       return (options & PROPERTIES_TARGET) != 0;
159     }
160 
has_argumentsShortcutProperties161     bool has_arguments() const {
162       return (options & PROPERTIES_ARGUMENTS) != 0;
163     }
164 
has_descriptionShortcutProperties165     bool has_description() const {
166       return (options & PROPERTIES_DESCRIPTION) != 0;
167     }
168 
has_iconShortcutProperties169     bool has_icon() const {
170       return (options & PROPERTIES_ICON) != 0;
171     }
172 
has_app_idShortcutProperties173     bool has_app_id() const {
174       return (options & PROPERTIES_APP_ID) != 0;
175     }
176 
has_shortcut_nameShortcutProperties177     bool has_shortcut_name() const {
178       return (options & PROPERTIES_SHORTCUT_NAME) != 0;
179     }
180 
has_dual_modeShortcutProperties181     bool has_dual_mode() const {
182       return (options & PROPERTIES_DUAL_MODE) != 0;
183     }
184 
185     // The level to install this shortcut at (CURRENT_USER for a per-user
186     // shortcut and SYSTEM_LEVEL for an all-users shortcut).
187     ShellChange level;
188 
189     base::FilePath target;
190     string16 arguments;
191     string16 description;
192     base::FilePath icon;
193     int icon_index;
194     string16 app_id;
195     string16 shortcut_name;
196     bool dual_mode;
197     bool pin_to_taskbar;
198     // Bitfield made of IndividualProperties. Properties set in |options| will
199     // be used to create/update the shortcut, others will be ignored on update
200     // and possibly replaced by default values on create (see individual
201     // property setters above for details on default values).
202     uint32 options;
203   };
204 
205   // Relative path of the URL Protocol registry entry (prefixed with '\').
206   static const wchar_t* kRegURLProtocol;
207 
208   // Relative path of DefaultIcon registry entry (prefixed with '\').
209   static const wchar_t* kRegDefaultIcon;
210 
211   // Relative path of "shell" registry key.
212   static const wchar_t* kRegShellPath;
213 
214   // Relative path of shell open command in Windows registry
215   // (i.e. \\shell\\open\\command).
216   static const wchar_t* kRegShellOpen;
217 
218   // Relative path of registry key under which applications need to register
219   // to control Windows Start menu links.
220   static const wchar_t* kRegStartMenuInternet;
221 
222   // Relative path of Classes registry entry under which file associations
223   // are added on Windows.
224   static const wchar_t* kRegClasses;
225 
226   // Relative path of RegisteredApplications registry entry under which
227   // we add Chrome as a Windows application
228   static const wchar_t* kRegRegisteredApplications;
229 
230   // The key path and key name required to register Chrome on Windows such
231   // that it can be launched from Start->Run just by name (chrome.exe).
232   static const wchar_t* kAppPathsRegistryKey;
233   static const wchar_t* kAppPathsRegistryPathName;
234 
235   // Registry path that stores url associations on Vista.
236   static const wchar_t* kRegVistaUrlPrefs;
237 
238   // File extensions that Chrome registers itself as the default handler
239   // for when the user makes Chrome the default browser.
240   static const wchar_t* kDefaultFileAssociations[];
241 
242   // File extensions that Chrome registers itself as being capable of
243   // handling.
244   static const wchar_t* kPotentialFileAssociations[];
245 
246   // Protocols that Chrome registers itself as the default handler for
247   // when the user makes Chrome the default browser.
248   static const wchar_t* kBrowserProtocolAssociations[];
249 
250   // Protocols that Chrome registers itself as being capable of handling.
251   static const wchar_t* kPotentialProtocolAssociations[];
252 
253   // Registry value name that is needed for ChromeHTML ProgId
254   static const wchar_t* kRegUrlProtocol;
255 
256   // Relative registry path from \Software\Classes\ChromeHTML to the ProgId
257   // Application definitions.
258   static const wchar_t* kRegApplication;
259 
260   // Registry value name for the AppUserModelId of an application.
261   static const wchar_t* kRegAppUserModelId;
262 
263   // Registry value name for the description of an application.
264   static const wchar_t* kRegApplicationDescription;
265 
266   // Registry value name for an application's name.
267   static const wchar_t* kRegApplicationName;
268 
269   // Registry value name for the path to an application's icon.
270   static const wchar_t* kRegApplicationIcon;
271 
272   // Registry value name for an application's company.
273   static const wchar_t* kRegApplicationCompany;
274 
275   // Relative path of ".exe" registry key.
276   static const wchar_t* kRegExePath;
277 
278   // Registry value name of the open verb.
279   static const wchar_t* kRegVerbOpen;
280 
281   // Registry value name of the opennewwindow verb.
282   static const wchar_t* kRegVerbOpenNewWindow;
283 
284   // Registry value name of the run verb.
285   static const wchar_t* kRegVerbRun;
286 
287   // Registry value name for command entries.
288   static const wchar_t* kRegCommand;
289 
290   // Registry value name for the DelegateExecute verb handler.
291   static const wchar_t* kRegDelegateExecute;
292 
293   // Registry value name for the OpenWithProgids entry for file associations.
294   static const wchar_t* kRegOpenWithProgids;
295 
296   // Returns true if |chrome_exe| is registered in HKLM with |suffix|.
297   // Note: This only checks one deterministic key in HKLM for |chrome_exe| and
298   // doesn't otherwise validate a full Chrome install in HKLM.
299   static bool QuickIsChromeRegisteredInHKLM(BrowserDistribution* dist,
300                                             const string16& chrome_exe,
301                                             const string16& suffix);
302 
303   // Returns true if the current Windows version supports the presence of
304   // shortcuts at |location|.
305   static bool ShortcutLocationIsSupported(ShellUtil::ShortcutLocation location);
306 
307   // Sets |path| to the path for a shortcut at the |location| desired for the
308   // given |level| (CURRENT_USER for per-user path and SYSTEM_LEVEL for
309   // all-users path).
310   // Returns false on failure.
311   static bool GetShortcutPath(ShellUtil::ShortcutLocation location,
312                               BrowserDistribution* dist,
313                               ShellChange level,
314                               base::FilePath* path);
315 
316   // Updates shortcut in |location| (or creates it if |options| specify
317   // SHELL_SHORTCUT_CREATE_ALWAYS).
318   // |dist| gives the type of browser distribution currently in use.
319   // |properties| and |operation| affect this method as described on their
320   // invidividual definitions above.
321   // |location| may be one of SHORTCUT_LOCATION_DESKTOP,
322   // SHORTCUT_LOCATION_QUICK_LAUNCH, SHORTCUT_LOCATION_START_MENU_ROOT,
323   // SHORTCUT_LOCATION_START_MENU_CHROME_DIR, or
324   // SHORTCUT_LOCATION_START_MENU_CHROME_APPS_DIR.
325   static bool CreateOrUpdateShortcut(
326       ShellUtil::ShortcutLocation location,
327       BrowserDistribution* dist,
328       const ShellUtil::ShortcutProperties& properties,
329       ShellUtil::ShortcutOperation operation);
330 
331   // Returns the string "|icon_path|,|icon_index|" (see, for example,
332   // http://msdn.microsoft.com/library/windows/desktop/dd391573.aspx).
333   static string16 FormatIconLocation(const string16& icon_path, int icon_index);
334 
335   // This method returns the command to open URLs/files using chrome. Typically
336   // this command is written to the registry under shell\open\command key.
337   // |chrome_exe|: the full path to chrome.exe
338   static string16 GetChromeShellOpenCmd(const string16& chrome_exe);
339 
340   // This method returns the command to be called by the DelegateExecute verb
341   // handler to launch chrome on Windows 8. Typically this command is written to
342   // the registry under the HKCR\Chrome\.exe\shell\(open|run)\command key.
343   // |chrome_exe|: the full path to chrome.exe
344   static string16 GetChromeDelegateCommand(const string16& chrome_exe);
345 
346   // Gets a mapping of all registered browser names (excluding browsers in the
347   // |dist| distribution) and their reinstall command (which usually sets
348   // browser as default).
349   // Given browsers can be registered in HKCU (as of Win7) and/or in HKLM, this
350   // method looks in both and gives precedence to values in HKCU as per the msdn
351   // standard: http://goo.gl/xjczJ.
352   static void GetRegisteredBrowsers(BrowserDistribution* dist,
353                                     std::map<string16, string16>* browsers);
354 
355   // Returns the suffix this user's Chrome install is registered with.
356   // Always returns the empty string on system-level installs.
357   //
358   // This method is meant for external methods which need to know the suffix of
359   // the current install at run-time, not for install-time decisions.
360   // There are no guarantees that this suffix will not change later:
361   // (e.g. if two user-level installs were previously installed in parallel on
362   // the same machine, both without admin rights and with no user-level install
363   // having claimed the non-suffixed HKLM registrations, they both have no
364   // suffix in their progId entries (as per the old suffix rules). If they were
365   // to both fully register (i.e. click "Make Chrome Default" and go through
366   // UAC; or upgrade to Win8 and get the automatic no UAC full registration)
367   // they would then both get a suffixed registration as per the new suffix
368   // rules).
369   //
370   // |chrome_exe| The path to the currently installed (or running) chrome.exe.
371   static string16 GetCurrentInstallationSuffix(BrowserDistribution* dist,
372                                                const string16& chrome_exe);
373 
374   // Returns the application name of the program under |dist|.
375   // This application name will be suffixed as is appropriate for the current
376   // install.
377   // This is the name that is registered with Default Programs on Windows and
378   // that should thus be used to "make chrome default" and such.
379   static string16 GetApplicationName(BrowserDistribution* dist,
380                                      const string16& chrome_exe);
381 
382   // Returns the AppUserModelId for |dist|. This identifier is unconditionally
383   // suffixed with a unique id for this user on user-level installs (in contrast
384   // to other registration entries which are suffixed as described in
385   // GetCurrentInstallationSuffix() above).
386   static string16 GetBrowserModelId(BrowserDistribution* dist,
387                                     bool is_per_user_install);
388 
389   // Returns an AppUserModelId composed of each member of |components| separated
390   // by dots.
391   // The returned appid is guaranteed to be no longer than
392   // chrome::kMaxAppModelIdLength (some of the components might have been
393   // shortened to enforce this).
394   static string16 BuildAppModelId(const std::vector<string16>& components);
395 
396   // Returns true if Chrome can make itself the default browser without relying
397   // on the Windows shell to prompt the user. This is the case for versions of
398   // Windows prior to Windows 8.
399   static bool CanMakeChromeDefaultUnattended();
400 
401   // Returns the DefaultState of Chrome for HTTP and HTTPS.
402   static DefaultState GetChromeDefaultState();
403 
404   // Returns the DefaultState of Chrome for |protocol|.
405   static DefaultState GetChromeDefaultProtocolClientState(
406       const string16& protocol);
407 
408   // Make Chrome the default browser. This function works by going through
409   // the url protocols and file associations that are related to general
410   // browsing, e.g. http, https, .html etc., and requesting to become the
411   // default handler for each. If any of these fails the operation will return
412   // false to indicate failure, which is consistent with the return value of
413   // ShellIntegration::GetDefaultBrowser.
414   //
415   // In the case of failure any successful changes will be left, however no
416   // more changes will be attempted.
417   // TODO(benwells): Attempt to undo any changes that were successfully made.
418   // http://crbug.com/83970
419   //
420   // shell_change: Defined whether to register as default browser at system
421   //               level or user level. If value has ShellChange::SYSTEM_LEVEL
422   //               we should be running as admin user.
423   // chrome_exe: The chrome.exe path to register as default browser.
424   // elevate_if_not_admin: On Vista if user is not admin, try to elevate for
425   //                       Chrome registration.
426   static bool MakeChromeDefault(BrowserDistribution* dist,
427                                 int shell_change,
428                                 const string16& chrome_exe,
429                                 bool elevate_if_not_admin);
430 
431   // Shows and waits for the Windows 8 "How do you want to open webpages?"
432   // dialog if Chrome is not already the default HTTP/HTTPS handler. Also does
433   // XP-era registrations if Chrome is chosen or was already the default. Do
434   // not use on pre-Win8 OSes.
435   //
436   // |dist| gives the type of browser distribution currently in use.
437   // |chrome_exe| The chrome.exe path to register as default browser.
438   static bool ShowMakeChromeDefaultSystemUI(BrowserDistribution* dist,
439                                             const string16& chrome_exe);
440 
441   // Make Chrome the default application for a protocol.
442   // chrome_exe: The chrome.exe path to register as default browser.
443   // protocol: The protocol to register as the default handler for.
444   static bool MakeChromeDefaultProtocolClient(BrowserDistribution* dist,
445                                               const string16& chrome_exe,
446                                               const string16& protocol);
447 
448   // Shows and waits for the Windows 8 "How do you want to open links of this
449   // type?" dialog if Chrome is not already the default |protocol|
450   // handler. Also does XP-era registrations if Chrome is chosen or was already
451   // the default for |protocol|. Do not use on pre-Win8 OSes.
452   //
453   // |dist| gives the type of browser distribution currently in use.
454   // |chrome_exe| The chrome.exe path to register as default browser.
455   // |protocol| is the protocol being registered.
456   static bool ShowMakeChromeDefaultProtocolClientSystemUI(
457       BrowserDistribution* dist,
458       const string16& chrome_exe,
459       const string16& protocol);
460 
461   // Registers Chrome as a potential default browser and handler for filetypes
462   // and protocols.
463   // If Chrome is already registered, this method is a no-op.
464   // This method requires write access to HKLM (prior to Win8) so is just a
465   // best effort deal.
466   // If write to HKLM is required, but fails, and:
467   // - |elevate_if_not_admin| is true (and OS is Vista or above):
468   //   tries to launch setup.exe with admin priviledges (by prompting the user
469   //   with a UAC) to do these tasks.
470   // - |elevate_if_not_admin| is false (or OS is XP):
471   //   adds the ProgId entries to HKCU. These entries will not make Chrome show
472   //   in Default Programs but they are still useful because Chrome can be
473   //   registered to run when the user clicks on an http link or an html file.
474   //
475   // |chrome_exe| full path to chrome.exe.
476   // |unique_suffix| Optional input. If given, this function appends the value
477   // to default browser entries names that it creates in the registry.
478   // Currently, this is only used to continue an install with the same suffix
479   // when elevating and calling setup.exe with admin privileges as described
480   // above.
481   // |elevate_if_not_admin| if true will make this method try alternate methods
482   // as described above. This should only be true when following a user action
483   // (e.g. "Make Chrome Default") as it allows this method to UAC.
484   //
485   // Returns true if Chrome is successfully registered (or already registered).
486   static bool RegisterChromeBrowser(BrowserDistribution* dist,
487                                     const string16& chrome_exe,
488                                     const string16& unique_suffix,
489                                     bool elevate_if_not_admin);
490 
491   // This method declares to Windows that Chrome is capable of handling the
492   // given protocol. This function will call the RegisterChromeBrowser function
493   // to register with Windows as capable of handling the protocol, if it isn't
494   // currently registered as capable.
495   // Declaring the capability of handling a protocol is necessary to register
496   // as the default handler for the protocol in Vista and later versions of
497   // Windows.
498   //
499   // If called by the browser and elevation is required, it will elevate by
500   // calling setup.exe which will again call this function with elevate false.
501   //
502   // |chrome_exe| full path to chrome.exe.
503   // |unique_suffix| Optional input. If given, this function appends the value
504   // to default browser entries names that it creates in the registry.
505   // |protocol| The protocol to register as being capable of handling.s
506   // |elevate_if_not_admin| if true will make this method try alternate methods
507   // as described above.
508   static bool RegisterChromeForProtocol(BrowserDistribution* dist,
509                                         const string16& chrome_exe,
510                                         const string16& unique_suffix,
511                                         const string16& protocol,
512                                         bool elevate_if_not_admin);
513 
514   // Removes installed shortcut(s) at |location|.
515   // |level|: CURRENT_USER to remove per-user shortcuts, or SYSTEM_LEVEL to
516   // remove all-users shortcuts.
517   // |target_exe|: Shortcut target exe; shortcuts will only be deleted when
518   // their target is |target_exe|.
519   // If |location| is a Chrome-specific folder, it will be deleted as well.
520   // Returns true if all shortcuts pointing to |target_exe| are successfully
521   // deleted, including the case where no such shortcuts are found.
522   static bool RemoveShortcuts(ShellUtil::ShortcutLocation location,
523                               BrowserDistribution* dist,
524                               ShellChange level,
525                               const base::FilePath& target_exe);
526 
527   // Applies the updates in |properties| to all matching shortcuts in
528   // |location|, i.e.:
529   // - the shortcut's original target is |target_exe|,
530   // - the original arguments are non-empty.
531   // Returns true if all updates to matching shortcuts are successful, including
532   // the vacuous case where no matching shortcuts are found.
533   static bool UpdateShortcutsWithArgs(
534       ShellUtil::ShortcutLocation location,
535       BrowserDistribution* dist,
536       ShellChange level,
537       const base::FilePath& target_exe,
538       const ShellUtil::ShortcutProperties& properties);
539 
540   // Sets |suffix| to the base 32 encoding of the md5 hash of this user's sid
541   // preceded by a dot.
542   // This is guaranteed to be unique on the machine and 27 characters long
543   // (including the '.').
544   // This suffix is then meant to be added to all registration that may conflict
545   // with another user-level Chrome install.
546   // Note that prior to Chrome 21, the suffix registered used to be the user's
547   // username (see GetOldUserSpecificRegistrySuffix() below). We still honor old
548   // installs registered that way, but it was wrong because some of the
549   // characters allowed in a username are not allowed in a ProgId.
550   // Returns true unless the OS call to retrieve the username fails.
551   // NOTE: Only the installer should use this suffix directly. Other callers
552   // should call GetCurrentInstallationSuffix().
553   static bool GetUserSpecificRegistrySuffix(string16* suffix);
554 
555   // Sets |suffix| to this user's username preceded by a dot. This suffix should
556   // only be used to support legacy installs that used this suffixing
557   // style.
558   // Returns true unless the OS call to retrieve the username fails.
559   // NOTE: Only the installer should use this suffix directly. Other callers
560   // should call GetCurrentInstallationSuffix().
561   static bool GetOldUserSpecificRegistrySuffix(string16* suffix);
562 
563   // Returns the base32 encoding (using the [A-Z2-7] alphabet) of |bytes|.
564   // |size| is the length of |bytes|.
565   // Note: This method does not suffix the output with '=' signs as technically
566   // required by the base32 standard for inputs that aren't a multiple of 5
567   // bytes.
568   static string16 ByteArrayToBase32(const uint8* bytes, size_t size);
569 
570  private:
571   DISALLOW_COPY_AND_ASSIGN(ShellUtil);
572 };
573 
574 
575 #endif  // CHROME_INSTALLER_UTIL_SHELL_UTIL_H_
576