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.
5 // This file declares methods that are useful for integrating Chrome in
6 // Windows shell. These methods are all static and currently part of
9 #ifndef CHROME_INSTALLER_UTIL_SHELL_UTIL_H_
10 #define CHROME_INSTALLER_UTIL_SHELL_UTIL_H_
19 #include "base/basictypes.h"
20 #include "base/files/file_path.h"
21 #include "base/logging.h"
22 #include "base/memory/ref_counted.h"
23 #include "base/strings/string16.h"
24 #include "chrome/installer/util/work_item_list.h"
26 class BrowserDistribution
;
29 class CancellationFlag
;
33 // This is a utility class that provides common shell integration methods
34 // that can be used by installer as well as Chrome.
37 // Input to any methods that make changes to OS shell.
39 CURRENT_USER
= 0x1, // Make any shell changes only at the user level
40 SYSTEM_LEVEL
= 0x2 // Make any shell changes only at the system level
43 // Chrome's default handler state for a given protocol.
50 // Typical shortcut directories. Resolved in GetShortcutPath().
51 // Also used in ShortcutLocationIsSupported().
52 enum ShortcutLocation
{
53 SHORTCUT_LOCATION_FIRST
= 0,
54 SHORTCUT_LOCATION_DESKTOP
= SHORTCUT_LOCATION_FIRST
,
55 SHORTCUT_LOCATION_QUICK_LAUNCH
,
56 SHORTCUT_LOCATION_START_MENU_ROOT
,
57 SHORTCUT_LOCATION_START_MENU_CHROME_DIR
,
58 SHORTCUT_LOCATION_START_MENU_CHROME_APPS_DIR
,
59 SHORTCUT_LOCATION_TASKBAR_PINS
, // base::win::VERSION_WIN7 +
60 SHORTCUT_LOCATION_APP_SHORTCUTS
, // base::win::VERSION_WIN8 +
61 NUM_SHORTCUT_LOCATIONS
64 enum ShortcutOperation
{
65 // Create a new shortcut (overwriting if necessary).
66 SHELL_SHORTCUT_CREATE_ALWAYS
,
67 // Create the per-user shortcut only if its system-level equivalent (with
68 // the same name) is not present.
69 SHELL_SHORTCUT_CREATE_IF_NO_SYSTEM_LEVEL
,
70 // Overwrite an existing shortcut (fail if the shortcut doesn't exist).
71 // If the arguments are not specified on the new shortcut, keep the old
72 // shortcut's arguments.
73 SHELL_SHORTCUT_REPLACE_EXISTING
,
74 // Update specified properties only on an existing shortcut.
75 SHELL_SHORTCUT_UPDATE_EXISTING
,
78 // Properties for shortcuts. Properties set will be applied to
79 // the shortcut on creation/update. On update, unset properties are ignored;
80 // on create (and replaced) unset properties might have a default value (see
81 // individual property setters below for details).
82 // Callers are encouraged to use the setters provided which take care of
83 // setting |options| as desired.
84 struct ShortcutProperties
{
85 enum IndividualProperties
{
86 PROPERTIES_TARGET
= 1 << 0,
87 PROPERTIES_ARGUMENTS
= 1 << 1,
88 PROPERTIES_DESCRIPTION
= 1 << 2,
89 PROPERTIES_ICON
= 1 << 3,
90 PROPERTIES_APP_ID
= 1 << 4,
91 PROPERTIES_SHORTCUT_NAME
= 1 << 5,
92 PROPERTIES_DUAL_MODE
= 1 << 6,
95 explicit ShortcutProperties(ShellChange level_in
);
96 ~ShortcutProperties();
98 // Sets the target executable to launch from this shortcut.
99 // This is mandatory when creating a shortcut.
100 void set_target(const base::FilePath
& target_in
) {
102 options
|= PROPERTIES_TARGET
;
105 // Sets the arguments to be passed to |target| when launching from this
107 // The length of this string must be less than MAX_PATH.
108 void set_arguments(const base::string16
& arguments_in
) {
109 // Size restriction as per MSDN at
110 // http://msdn.microsoft.com/library/windows/desktop/bb774954.aspx.
111 DCHECK(arguments_in
.length() < MAX_PATH
);
112 arguments
= arguments_in
;
113 options
|= PROPERTIES_ARGUMENTS
;
116 // Sets the localized description of the shortcut.
117 // The length of this string must be less than MAX_PATH.
118 void set_description(const base::string16
& description_in
) {
119 // Size restriction as per MSDN at
120 // http://msdn.microsoft.com/library/windows/desktop/bb774955.aspx.
121 DCHECK(description_in
.length() < MAX_PATH
);
122 description
= description_in
;
123 options
|= PROPERTIES_DESCRIPTION
;
126 // Sets the path to the icon (icon_index set to 0).
127 // icon index unless otherwise specified in master_preferences).
128 void set_icon(const base::FilePath
& icon_in
, int icon_index_in
) {
130 icon_index
= icon_index_in
;
131 options
|= PROPERTIES_ICON
;
134 // Sets the app model id for the shortcut (Win7+).
135 void set_app_id(const base::string16
& app_id_in
) {
137 options
|= PROPERTIES_APP_ID
;
140 // Forces the shortcut's name to |shortcut_name_in|.
141 // Default: the current distribution's GetShortcutName(SHORTCUT_CHROME).
142 // The ".lnk" extension will automatically be added to this name.
143 void set_shortcut_name(const base::string16
& shortcut_name_in
) {
144 shortcut_name
= shortcut_name_in
;
145 options
|= PROPERTIES_SHORTCUT_NAME
;
148 // Sets whether this is a dual mode shortcut (Win8+).
149 // Documentation on usage of the dual mode property on Win8:
150 // http://go.microsoft.com/fwlink/p/?linkid=243079
151 // NOTE: Only the default (no arguments and default browser appid) browser
152 // shortcut in the Start menu (Start screen on Win8+) should be made dual
154 void set_dual_mode(bool dual_mode_in
) {
155 dual_mode
= dual_mode_in
;
156 options
|= PROPERTIES_DUAL_MODE
;
159 // Sets whether to pin this shortcut to the taskbar after creating it
160 // (ignored if the shortcut is only being updated).
161 // Note: This property doesn't have a mask in |options|.
162 void set_pin_to_taskbar(bool pin_to_taskbar_in
) {
163 pin_to_taskbar
= pin_to_taskbar_in
;
166 // Sets whether to pin this shortcut to the Win10+ start menu after creating
167 // it (ignored if the shortcut is only being updated).
168 // Note: This property doesn't have a mask in |options|.
169 void set_pin_to_start(bool pin_to_start_in
) {
170 pin_to_start
= pin_to_start_in
;
173 bool has_target() const {
174 return (options
& PROPERTIES_TARGET
) != 0;
177 bool has_arguments() const {
178 return (options
& PROPERTIES_ARGUMENTS
) != 0;
181 bool has_description() const {
182 return (options
& PROPERTIES_DESCRIPTION
) != 0;
185 bool has_icon() const {
186 return (options
& PROPERTIES_ICON
) != 0;
189 bool has_app_id() const {
190 return (options
& PROPERTIES_APP_ID
) != 0;
193 bool has_shortcut_name() const {
194 return (options
& PROPERTIES_SHORTCUT_NAME
) != 0;
197 bool has_dual_mode() const {
198 return (options
& PROPERTIES_DUAL_MODE
) != 0;
201 // The level to install this shortcut at (CURRENT_USER for a per-user
202 // shortcut and SYSTEM_LEVEL for an all-users shortcut).
205 base::FilePath target
;
206 base::string16 arguments
;
207 base::string16 description
;
210 base::string16 app_id
;
211 base::string16 shortcut_name
;
215 // Bitfield made of IndividualProperties. Properties set in |options| will
216 // be used to create/update the shortcut, others will be ignored on update
217 // and possibly replaced by default values on create (see individual
218 // property setters above for details on default values).
222 // Relative path of the URL Protocol registry entry (prefixed with '\').
223 static const wchar_t* kRegURLProtocol
;
225 // Relative path of DefaultIcon registry entry (prefixed with '\').
226 static const wchar_t* kRegDefaultIcon
;
228 // Relative path of "shell" registry key.
229 static const wchar_t* kRegShellPath
;
231 // Relative path of shell open command in Windows registry
232 // (i.e. \\shell\\open\\command).
233 static const wchar_t* kRegShellOpen
;
235 // Relative path of registry key under which applications need to register
236 // to control Windows Start menu links.
237 static const wchar_t* kRegStartMenuInternet
;
239 // Relative path of Classes registry entry under which file associations
240 // are added on Windows.
241 static const wchar_t* kRegClasses
;
243 // Relative path of RegisteredApplications registry entry under which
244 // we add Chrome as a Windows application
245 static const wchar_t* kRegRegisteredApplications
;
247 // The key path and key name required to register Chrome on Windows such
248 // that it can be launched from Start->Run just by name (chrome.exe).
249 static const wchar_t* kAppPathsRegistryKey
;
250 static const wchar_t* kAppPathsRegistryPathName
;
252 // Registry path that stores url associations on Vista.
253 static const wchar_t* kRegVistaUrlPrefs
;
255 // File extensions that Chrome registers itself as the default handler
256 // for when the user makes Chrome the default browser.
257 static const wchar_t* kDefaultFileAssociations
[];
259 // File extensions that Chrome registers itself as being capable of
261 static const wchar_t* kPotentialFileAssociations
[];
263 // Protocols that Chrome registers itself as the default handler for
264 // when the user makes Chrome the default browser.
265 static const wchar_t* kBrowserProtocolAssociations
[];
267 // Protocols that Chrome registers itself as being capable of handling.
268 static const wchar_t* kPotentialProtocolAssociations
[];
270 // Registry value name that is needed for ChromeHTML ProgId
271 static const wchar_t* kRegUrlProtocol
;
273 // Relative registry path from \Software\Classes\ChromeHTML to the ProgId
274 // Application definitions.
275 static const wchar_t* kRegApplication
;
277 // Registry value name for the AppUserModelId of an application.
278 static const wchar_t* kRegAppUserModelId
;
280 // Registry value name for the description of an application.
281 static const wchar_t* kRegApplicationDescription
;
283 // Registry value name for an application's name.
284 static const wchar_t* kRegApplicationName
;
286 // Registry value name for the path to an application's icon.
287 static const wchar_t* kRegApplicationIcon
;
289 // Registry value name for an application's company.
290 static const wchar_t* kRegApplicationCompany
;
292 // Relative path of ".exe" registry key.
293 static const wchar_t* kRegExePath
;
295 // Registry value name of the open verb.
296 static const wchar_t* kRegVerbOpen
;
298 // Registry value name of the opennewwindow verb.
299 static const wchar_t* kRegVerbOpenNewWindow
;
301 // Registry value name of the run verb.
302 static const wchar_t* kRegVerbRun
;
304 // Registry value name for command entries.
305 static const wchar_t* kRegCommand
;
307 // Registry value name for the DelegateExecute verb handler.
308 static const wchar_t* kRegDelegateExecute
;
310 // Registry value name for the OpenWithProgids entry for file associations.
311 static const wchar_t* kRegOpenWithProgids
;
313 // Returns true if |chrome_exe| is registered in HKLM with |suffix|.
314 // Note: This only checks one deterministic key in HKLM for |chrome_exe| and
315 // doesn't otherwise validate a full Chrome install in HKLM.
316 static bool QuickIsChromeRegisteredInHKLM(BrowserDistribution
* dist
,
317 const base::FilePath
& chrome_exe
,
318 const base::string16
& suffix
);
320 // Returns true if the current Windows version supports the presence of
321 // shortcuts at |location|.
322 static bool ShortcutLocationIsSupported(ShellUtil::ShortcutLocation location
);
324 // Sets |path| to the path for a shortcut at the |location| desired for the
325 // given |level| (CURRENT_USER for per-user path and SYSTEM_LEVEL for
327 // Returns false on failure.
328 static bool GetShortcutPath(ShellUtil::ShortcutLocation location
,
329 BrowserDistribution
* dist
,
331 base::FilePath
* path
);
333 // Updates shortcut in |location| (or creates it if |options| specify
334 // SHELL_SHORTCUT_CREATE_ALWAYS).
335 // |dist| gives the type of browser distribution currently in use.
336 // |properties| and |operation| affect this method as described on their
337 // invidividual definitions above.
338 // |location| may be one of SHORTCUT_LOCATION_DESKTOP,
339 // SHORTCUT_LOCATION_QUICK_LAUNCH, SHORTCUT_LOCATION_START_MENU_ROOT,
340 // SHORTCUT_LOCATION_START_MENU_CHROME_DIR, or
341 // SHORTCUT_LOCATION_START_MENU_CHROME_APPS_DIR.
342 static bool CreateOrUpdateShortcut(
343 ShellUtil::ShortcutLocation location
,
344 BrowserDistribution
* dist
,
345 const ShellUtil::ShortcutProperties
& properties
,
346 ShellUtil::ShortcutOperation operation
);
348 // Returns the string "|icon_path|,|icon_index|" (see, for example,
349 // http://msdn.microsoft.com/library/windows/desktop/dd391573.aspx).
350 static base::string16
FormatIconLocation(const base::FilePath
& icon_path
,
353 // This method returns the command to open URLs/files using chrome. Typically
354 // this command is written to the registry under shell\open\command key.
355 // |chrome_exe|: the full path to chrome.exe
356 static base::string16
GetChromeShellOpenCmd(const base::FilePath
& chrome_exe
);
358 // This method returns the command to be called by the DelegateExecute verb
359 // handler to launch chrome on Windows 8. Typically this command is written to
360 // the registry under the HKCR\Chrome\.exe\shell\(open|run)\command key.
361 // |chrome_exe|: the full path to chrome.exe
362 static base::string16
GetChromeDelegateCommand(
363 const base::FilePath
& chrome_exe
);
365 // Gets a mapping of all registered browser names (excluding browsers in the
366 // |dist| distribution) and their reinstall command (which usually sets
367 // browser as default).
368 // Given browsers can be registered in HKCU (as of Win7) and/or in HKLM, this
369 // method looks in both and gives precedence to values in HKCU as per the msdn
370 // standard: http://goo.gl/xjczJ.
371 static void GetRegisteredBrowsers(
372 BrowserDistribution
* dist
,
373 std::map
<base::string16
, base::string16
>* browsers
);
375 // Returns the suffix this user's Chrome install is registered with.
376 // Always returns the empty string on system-level installs.
378 // This method is meant for external methods which need to know the suffix of
379 // the current install at run-time, not for install-time decisions.
380 // There are no guarantees that this suffix will not change later:
381 // (e.g. if two user-level installs were previously installed in parallel on
382 // the same machine, both without admin rights and with no user-level install
383 // having claimed the non-suffixed HKLM registrations, they both have no
384 // suffix in their progId entries (as per the old suffix rules). If they were
385 // to both fully register (i.e. click "Make Chrome Default" and go through
386 // UAC; or upgrade to Win8 and get the automatic no UAC full registration)
387 // they would then both get a suffixed registration as per the new suffix
390 // |chrome_exe| The path to the currently installed (or running) chrome.exe.
391 static base::string16
GetCurrentInstallationSuffix(
392 BrowserDistribution
* dist
,
393 const base::FilePath
& chrome_exe
);
395 // Returns the application name of the program under |dist|.
396 // This application name will be suffixed as is appropriate for the current
398 // This is the name that is registered with Default Programs on Windows and
399 // that should thus be used to "make chrome default" and such.
400 static base::string16
GetApplicationName(BrowserDistribution
* dist
,
401 const base::FilePath
& chrome_exe
);
403 // Returns the AppUserModelId for |dist|. This identifier is unconditionally
404 // suffixed with a unique id for this user on user-level installs (in contrast
405 // to other registration entries which are suffixed as described in
406 // GetCurrentInstallationSuffix() above).
407 static base::string16
GetBrowserModelId(BrowserDistribution
* dist
,
408 bool is_per_user_install
);
410 // Returns an AppUserModelId composed of each member of |components| separated
412 // The returned appid is guaranteed to be no longer than
413 // chrome::kMaxAppModelIdLength (some of the components might have been
414 // shortened to enforce this).
415 static base::string16
BuildAppModelId(
416 const std::vector
<base::string16
>& components
);
418 // Returns true if Chrome can make itself the default browser without relying
419 // on the Windows shell to prompt the user. This is the case for versions of
420 // Windows prior to Windows 8.
421 static bool CanMakeChromeDefaultUnattended();
423 // Returns the DefaultState of Chrome for HTTP and HTTPS and updates the
424 // default browser beacons as appropriate.
425 static DefaultState
GetChromeDefaultState();
427 // Returns the DefaultState of the Chrome instance with the specified path for
428 // HTTP and HTTPs and updates the default browser beacons as appropriate.
429 static DefaultState
GetChromeDefaultStateFromPath(
430 const base::FilePath
& chrome_exe
);
432 // Returns the DefaultState of Chrome for |protocol|.
433 static DefaultState
GetChromeDefaultProtocolClientState(
434 const base::string16
& protocol
);
436 // Make Chrome the default browser. This function works by going through
437 // the url protocols and file associations that are related to general
438 // browsing, e.g. http, https, .html etc., and requesting to become the
439 // default handler for each. If any of these fails the operation will return
440 // false to indicate failure, which is consistent with the return value of
441 // ShellIntegration::GetDefaultBrowser.
443 // In the case of failure any successful changes will be left, however no
444 // more changes will be attempted.
445 // TODO(benwells): Attempt to undo any changes that were successfully made.
446 // http://crbug.com/83970
448 // shell_change: Defined whether to register as default browser at system
449 // level or user level. If value has ShellChange::SYSTEM_LEVEL
450 // we should be running as admin user.
451 // chrome_exe: The chrome.exe path to register as default browser.
452 // elevate_if_not_admin: On Vista if user is not admin, try to elevate for
453 // Chrome registration.
454 static bool MakeChromeDefault(BrowserDistribution
* dist
,
456 const base::FilePath
& chrome_exe
,
457 bool elevate_if_not_admin
);
459 // Windows 8: Shows and waits for the "How do you want to open webpages?"
460 // dialog if Chrome is not already the default HTTP/HTTPS handler. Also does
461 // XP-era registrations if Chrome is chosen or was already the default. Do
462 // not use on pre-Win8 OSes.
464 // Windows 10: The associations dialog cannot be launched so the settings
465 // dialog focused on default apps is launched. The function does not wait
468 // |dist| gives the type of browser distribution currently in use.
469 // |chrome_exe| The chrome.exe path to register as default browser.
470 static bool ShowMakeChromeDefaultSystemUI(BrowserDistribution
* dist
,
471 const base::FilePath
& chrome_exe
);
473 // Make Chrome the default application for a protocol.
474 // chrome_exe: The chrome.exe path to register as default browser.
475 // protocol: The protocol to register as the default handler for.
476 static bool MakeChromeDefaultProtocolClient(BrowserDistribution
* dist
,
477 const base::FilePath
& chrome_exe
,
478 const base::string16
& protocol
);
480 // Shows and waits for the Windows 8 "How do you want to open links of this
481 // type?" dialog if Chrome is not already the default |protocol|
482 // handler. Also does XP-era registrations if Chrome is chosen or was already
483 // the default for |protocol|. Do not use on pre-Win8 OSes.
485 // |dist| gives the type of browser distribution currently in use.
486 // |chrome_exe| The chrome.exe path to register as default browser.
487 // |protocol| is the protocol being registered.
488 static bool ShowMakeChromeDefaultProtocolClientSystemUI(
489 BrowserDistribution
* dist
,
490 const base::FilePath
& chrome_exe
,
491 const base::string16
& protocol
);
493 // Registers Chrome as a potential default browser and handler for filetypes
495 // If Chrome is already registered, this method is a no-op.
496 // This method requires write access to HKLM (prior to Win8) so is just a
498 // If write to HKLM is required, but fails, and:
499 // - |elevate_if_not_admin| is true (and OS is Vista or above):
500 // tries to launch setup.exe with admin priviledges (by prompting the user
501 // with a UAC) to do these tasks.
502 // - |elevate_if_not_admin| is false (or OS is XP):
503 // adds the ProgId entries to HKCU. These entries will not make Chrome show
504 // in Default Programs but they are still useful because Chrome can be
505 // registered to run when the user clicks on an http link or an html file.
507 // |chrome_exe| full path to chrome.exe.
508 // |unique_suffix| Optional input. If given, this function appends the value
509 // to default browser entries names that it creates in the registry.
510 // Currently, this is only used to continue an install with the same suffix
511 // when elevating and calling setup.exe with admin privileges as described
513 // |elevate_if_not_admin| if true will make this method try alternate methods
514 // as described above. This should only be true when following a user action
515 // (e.g. "Make Chrome Default") as it allows this method to UAC.
517 // Returns true if Chrome is successfully registered (or already registered).
518 static bool RegisterChromeBrowser(BrowserDistribution
* dist
,
519 const base::FilePath
& chrome_exe
,
520 const base::string16
& unique_suffix
,
521 bool elevate_if_not_admin
);
523 // This method declares to Windows that Chrome is capable of handling the
524 // given protocol. This function will call the RegisterChromeBrowser function
525 // to register with Windows as capable of handling the protocol, if it isn't
526 // currently registered as capable.
527 // Declaring the capability of handling a protocol is necessary to register
528 // as the default handler for the protocol in Vista and later versions of
531 // If called by the browser and elevation is required, it will elevate by
532 // calling setup.exe which will again call this function with elevate false.
534 // |chrome_exe| full path to chrome.exe.
535 // |unique_suffix| Optional input. If given, this function appends the value
536 // to default browser entries names that it creates in the registry.
537 // |protocol| The protocol to register as being capable of handling.s
538 // |elevate_if_not_admin| if true will make this method try alternate methods
539 // as described above.
540 static bool RegisterChromeForProtocol(BrowserDistribution
* dist
,
541 const base::FilePath
& chrome_exe
,
542 const base::string16
& unique_suffix
,
543 const base::string16
& protocol
,
544 bool elevate_if_not_admin
);
546 // Removes installed shortcut(s) at |location|.
547 // |level|: CURRENT_USER to remove per-user shortcuts, or SYSTEM_LEVEL to
548 // remove all-users shortcuts.
549 // |target_exe|: Shortcut target exe; shortcuts will only be deleted when
550 // their target is |target_exe|.
551 // If |location| is a Chrome-specific folder, it will be deleted as well.
552 // Returns true if all shortcuts pointing to |target_exe| are successfully
553 // deleted, including the case where no such shortcuts are found.
554 static bool RemoveShortcuts(ShellUtil::ShortcutLocation location
,
555 BrowserDistribution
* dist
,
557 const base::FilePath
& target_exe
);
559 // Updates the target of all shortcuts in |location| that satisfy the
561 // - the shortcut's original target is |old_target_exe|,
562 // - the original arguments are non-empty.
563 // If the shortcut's icon points to |old_target_exe|, then it also gets
564 // redirected to |new_target_exe|.
565 // Returns true if all updates to matching shortcuts are successful, including
566 // the vacuous case where no matching shortcuts are found.
567 static bool RetargetShortcutsWithArgs(
568 ShellUtil::ShortcutLocation location
,
569 BrowserDistribution
* dist
,
571 const base::FilePath
& old_target_exe
,
572 const base::FilePath
& new_target_exe
);
574 typedef base::RefCountedData
<base::CancellationFlag
> SharedCancellationFlag
;
576 // Appends Chrome shortcuts with non-whitelisted arguments to |shortcuts| if
577 // not NULL. If |do_removal|, also removes non-whitelisted arguments from
578 // those shortcuts. This method will abort and return false if |cancel| is
579 // non-NULL and gets set at any point during this call.
580 static bool ShortcutListMaybeRemoveUnknownArgs(
581 ShellUtil::ShortcutLocation location
,
582 BrowserDistribution
* dist
,
584 const base::FilePath
& chrome_exe
,
586 const scoped_refptr
<SharedCancellationFlag
>& cancel
,
587 std::vector
<std::pair
<base::FilePath
, base::string16
> >* shortcuts
);
589 // Sets |suffix| to the base 32 encoding of the md5 hash of this user's sid
590 // preceded by a dot.
591 // This is guaranteed to be unique on the machine and 27 characters long
592 // (including the '.').
593 // This suffix is then meant to be added to all registration that may conflict
594 // with another user-level Chrome install.
595 // Note that prior to Chrome 21, the suffix registered used to be the user's
596 // username (see GetOldUserSpecificRegistrySuffix() below). We still honor old
597 // installs registered that way, but it was wrong because some of the
598 // characters allowed in a username are not allowed in a ProgId.
599 // Returns true unless the OS call to retrieve the username fails.
600 // NOTE: Only the installer should use this suffix directly. Other callers
601 // should call GetCurrentInstallationSuffix().
602 static bool GetUserSpecificRegistrySuffix(base::string16
* suffix
);
604 // Sets |suffix| to this user's username preceded by a dot. This suffix should
605 // only be used to support legacy installs that used this suffixing
607 // Returns true unless the OS call to retrieve the username fails.
608 // NOTE: Only the installer should use this suffix directly. Other callers
609 // should call GetCurrentInstallationSuffix().
610 static bool GetOldUserSpecificRegistrySuffix(base::string16
* suffix
);
612 // Returns the base32 encoding (using the [A-Z2-7] alphabet) of |bytes|.
613 // |size| is the length of |bytes|.
614 // Note: This method does not suffix the output with '=' signs as technically
615 // required by the base32 standard for inputs that aren't a multiple of 5
617 static base::string16
ByteArrayToBase32(const uint8
* bytes
, size_t size
);
619 // Associates a set of file extensions with a particular application in the
620 // Windows registry, for the current user only. If an extension has no
621 // existing default association, the given application becomes the default.
622 // Otherwise, the application is added to the Open With menu for this type,
623 // but does not become the default.
625 // |prog_id| is the ProgId used by Windows for file associations with this
626 // application. Must not be empty or start with a '.'.
627 // |command_line| is the command to execute when opening a file via this
628 // association. It should contain "%1" (to tell Windows to pass the filename
630 // |file_type_name| and |icon_path| are the friendly name, and the path of the
631 // icon, respectively, that will be used for files of these types when
632 // associated with this application by default. (They are NOT the name/icon
633 // that will represent the application under the Open With menu.)
634 // |file_extensions| is the set of extensions to associate. They must not be
635 // empty or start with a '.'.
636 // Returns true on success, false on failure.
637 static bool AddFileAssociations(
638 const base::string16
& prog_id
,
639 const base::CommandLine
& command_line
,
640 const base::string16
& file_type_name
,
641 const base::FilePath
& icon_path
,
642 const std::set
<base::string16
>& file_extensions
);
644 // Deletes all associations with a particular application in the Windows
645 // registry, for the current user only.
646 // |prog_id| is the ProgId used by Windows for file associations with this
647 // application, as given to AddFileAssociations. All information associated
648 // with this name will be deleted.
649 static bool DeleteFileAssociations(const base::string16
& prog_id
);
652 DISALLOW_COPY_AND_ASSIGN(ShellUtil
);
656 #endif // CHROME_INSTALLER_UTIL_SHELL_UTIL_H_