Enable MSVC warning for unused locals.
[chromium-blink-merge.git] / chrome / installer / util / shell_util.h
blob313972a92de2819204690301c888789455290449
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.
9 #ifndef CHROME_INSTALLER_UTIL_SHELL_UTIL_H_
10 #define CHROME_INSTALLER_UTIL_SHELL_UTIL_H_
12 #include <windows.h>
14 #include <map>
15 #include <set>
16 #include <utility>
17 #include <vector>
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;
28 namespace base {
29 class CancellationFlag;
30 class CommandLine;
33 // This is a utility class that provides common shell integration methods
34 // that can be used by installer as well as Chrome.
35 class ShellUtil {
36 public:
37 // Input to any methods that make changes to OS shell.
38 enum ShellChange {
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.
44 enum DefaultState {
45 UNKNOWN_DEFAULT,
46 NOT_DEFAULT,
47 IS_DEFAULT,
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 : level(level_in), icon_index(0), dual_mode(false),
97 pin_to_taskbar(false), options(0U) {}
99 // Sets the target executable to launch from this shortcut.
100 // This is mandatory when creating a shortcut.
101 void set_target(const base::FilePath& target_in) {
102 target = target_in;
103 options |= PROPERTIES_TARGET;
106 // Sets the arguments to be passed to |target| when launching from this
107 // shortcut.
108 // The length of this string must be less than MAX_PATH.
109 void set_arguments(const base::string16& arguments_in) {
110 // Size restriction as per MSDN at
111 // http://msdn.microsoft.com/library/windows/desktop/bb774954.aspx.
112 DCHECK(arguments_in.length() < MAX_PATH);
113 arguments = arguments_in;
114 options |= PROPERTIES_ARGUMENTS;
117 // Sets the localized description of the shortcut.
118 // The length of this string must be less than MAX_PATH.
119 void set_description(const base::string16& description_in) {
120 // Size restriction as per MSDN at
121 // http://msdn.microsoft.com/library/windows/desktop/bb774955.aspx.
122 DCHECK(description_in.length() < MAX_PATH);
123 description = description_in;
124 options |= PROPERTIES_DESCRIPTION;
127 // Sets the path to the icon (icon_index set to 0).
128 // icon index unless otherwise specified in master_preferences).
129 void set_icon(const base::FilePath& icon_in, int icon_index_in) {
130 icon = icon_in;
131 icon_index = icon_index_in;
132 options |= PROPERTIES_ICON;
135 // Sets the app model id for the shortcut (Win7+).
136 void set_app_id(const base::string16& app_id_in) {
137 app_id = app_id_in;
138 options |= PROPERTIES_APP_ID;
141 // Forces the shortcut's name to |shortcut_name_in|.
142 // Default: the current distribution's GetShortcutName(SHORTCUT_CHROME).
143 // The ".lnk" extension will automatically be added to this name.
144 void set_shortcut_name(const base::string16& shortcut_name_in) {
145 shortcut_name = shortcut_name_in;
146 options |= PROPERTIES_SHORTCUT_NAME;
149 // Sets whether this is a dual mode shortcut (Win8+).
150 // NOTE: Only the default (no arguments and default browser appid) browser
151 // shortcut in the Start menu (Start screen on Win8+) should be made dual
152 // mode.
153 void set_dual_mode(bool dual_mode_in) {
154 dual_mode = dual_mode_in;
155 options |= PROPERTIES_DUAL_MODE;
158 // Sets whether to pin this shortcut to the taskbar after creating it
159 // (ignored if the shortcut is only being updated).
160 // Note: This property doesn't have a mask in |options|.
161 void set_pin_to_taskbar(bool pin_to_taskbar_in) {
162 pin_to_taskbar = pin_to_taskbar_in;
165 bool has_target() const {
166 return (options & PROPERTIES_TARGET) != 0;
169 bool has_arguments() const {
170 return (options & PROPERTIES_ARGUMENTS) != 0;
173 bool has_description() const {
174 return (options & PROPERTIES_DESCRIPTION) != 0;
177 bool has_icon() const {
178 return (options & PROPERTIES_ICON) != 0;
181 bool has_app_id() const {
182 return (options & PROPERTIES_APP_ID) != 0;
185 bool has_shortcut_name() const {
186 return (options & PROPERTIES_SHORTCUT_NAME) != 0;
189 bool has_dual_mode() const {
190 return (options & PROPERTIES_DUAL_MODE) != 0;
193 // The level to install this shortcut at (CURRENT_USER for a per-user
194 // shortcut and SYSTEM_LEVEL for an all-users shortcut).
195 ShellChange level;
197 base::FilePath target;
198 base::string16 arguments;
199 base::string16 description;
200 base::FilePath icon;
201 int icon_index;
202 base::string16 app_id;
203 base::string16 shortcut_name;
204 bool dual_mode;
205 bool pin_to_taskbar;
206 // Bitfield made of IndividualProperties. Properties set in |options| will
207 // be used to create/update the shortcut, others will be ignored on update
208 // and possibly replaced by default values on create (see individual
209 // property setters above for details on default values).
210 uint32 options;
213 // Relative path of the URL Protocol registry entry (prefixed with '\').
214 static const wchar_t* kRegURLProtocol;
216 // Relative path of DefaultIcon registry entry (prefixed with '\').
217 static const wchar_t* kRegDefaultIcon;
219 // Relative path of "shell" registry key.
220 static const wchar_t* kRegShellPath;
222 // Relative path of shell open command in Windows registry
223 // (i.e. \\shell\\open\\command).
224 static const wchar_t* kRegShellOpen;
226 // Relative path of registry key under which applications need to register
227 // to control Windows Start menu links.
228 static const wchar_t* kRegStartMenuInternet;
230 // Relative path of Classes registry entry under which file associations
231 // are added on Windows.
232 static const wchar_t* kRegClasses;
234 // Relative path of RegisteredApplications registry entry under which
235 // we add Chrome as a Windows application
236 static const wchar_t* kRegRegisteredApplications;
238 // The key path and key name required to register Chrome on Windows such
239 // that it can be launched from Start->Run just by name (chrome.exe).
240 static const wchar_t* kAppPathsRegistryKey;
241 static const wchar_t* kAppPathsRegistryPathName;
243 // Registry path that stores url associations on Vista.
244 static const wchar_t* kRegVistaUrlPrefs;
246 // File extensions that Chrome registers itself as the default handler
247 // for when the user makes Chrome the default browser.
248 static const wchar_t* kDefaultFileAssociations[];
250 // File extensions that Chrome registers itself as being capable of
251 // handling.
252 static const wchar_t* kPotentialFileAssociations[];
254 // Protocols that Chrome registers itself as the default handler for
255 // when the user makes Chrome the default browser.
256 static const wchar_t* kBrowserProtocolAssociations[];
258 // Protocols that Chrome registers itself as being capable of handling.
259 static const wchar_t* kPotentialProtocolAssociations[];
261 // Registry value name that is needed for ChromeHTML ProgId
262 static const wchar_t* kRegUrlProtocol;
264 // Relative registry path from \Software\Classes\ChromeHTML to the ProgId
265 // Application definitions.
266 static const wchar_t* kRegApplication;
268 // Registry value name for the AppUserModelId of an application.
269 static const wchar_t* kRegAppUserModelId;
271 // Registry value name for the description of an application.
272 static const wchar_t* kRegApplicationDescription;
274 // Registry value name for an application's name.
275 static const wchar_t* kRegApplicationName;
277 // Registry value name for the path to an application's icon.
278 static const wchar_t* kRegApplicationIcon;
280 // Registry value name for an application's company.
281 static const wchar_t* kRegApplicationCompany;
283 // Relative path of ".exe" registry key.
284 static const wchar_t* kRegExePath;
286 // Registry value name of the open verb.
287 static const wchar_t* kRegVerbOpen;
289 // Registry value name of the opennewwindow verb.
290 static const wchar_t* kRegVerbOpenNewWindow;
292 // Registry value name of the run verb.
293 static const wchar_t* kRegVerbRun;
295 // Registry value name for command entries.
296 static const wchar_t* kRegCommand;
298 // Registry value name for the DelegateExecute verb handler.
299 static const wchar_t* kRegDelegateExecute;
301 // Registry value name for the OpenWithProgids entry for file associations.
302 static const wchar_t* kRegOpenWithProgids;
304 // Returns true if |chrome_exe| is registered in HKLM with |suffix|.
305 // Note: This only checks one deterministic key in HKLM for |chrome_exe| and
306 // doesn't otherwise validate a full Chrome install in HKLM.
307 static bool QuickIsChromeRegisteredInHKLM(BrowserDistribution* dist,
308 const base::string16& chrome_exe,
309 const base::string16& suffix);
311 // Returns true if the current Windows version supports the presence of
312 // shortcuts at |location|.
313 static bool ShortcutLocationIsSupported(ShellUtil::ShortcutLocation location);
315 // Sets |path| to the path for a shortcut at the |location| desired for the
316 // given |level| (CURRENT_USER for per-user path and SYSTEM_LEVEL for
317 // all-users path).
318 // Returns false on failure.
319 static bool GetShortcutPath(ShellUtil::ShortcutLocation location,
320 BrowserDistribution* dist,
321 ShellChange level,
322 base::FilePath* path);
324 // Updates shortcut in |location| (or creates it if |options| specify
325 // SHELL_SHORTCUT_CREATE_ALWAYS).
326 // |dist| gives the type of browser distribution currently in use.
327 // |properties| and |operation| affect this method as described on their
328 // invidividual definitions above.
329 // |location| may be one of SHORTCUT_LOCATION_DESKTOP,
330 // SHORTCUT_LOCATION_QUICK_LAUNCH, SHORTCUT_LOCATION_START_MENU_ROOT,
331 // SHORTCUT_LOCATION_START_MENU_CHROME_DIR, or
332 // SHORTCUT_LOCATION_START_MENU_CHROME_APPS_DIR.
333 static bool CreateOrUpdateShortcut(
334 ShellUtil::ShortcutLocation location,
335 BrowserDistribution* dist,
336 const ShellUtil::ShortcutProperties& properties,
337 ShellUtil::ShortcutOperation operation);
339 // Returns the string "|icon_path|,|icon_index|" (see, for example,
340 // http://msdn.microsoft.com/library/windows/desktop/dd391573.aspx).
341 static base::string16 FormatIconLocation(const base::string16& icon_path,
342 int icon_index);
344 // This method returns the command to open URLs/files using chrome. Typically
345 // this command is written to the registry under shell\open\command key.
346 // |chrome_exe|: the full path to chrome.exe
347 static base::string16 GetChromeShellOpenCmd(const base::string16& chrome_exe);
349 // This method returns the command to be called by the DelegateExecute verb
350 // handler to launch chrome on Windows 8. Typically this command is written to
351 // the registry under the HKCR\Chrome\.exe\shell\(open|run)\command key.
352 // |chrome_exe|: the full path to chrome.exe
353 static base::string16 GetChromeDelegateCommand(
354 const base::string16& chrome_exe);
356 // Gets a mapping of all registered browser names (excluding browsers in the
357 // |dist| distribution) and their reinstall command (which usually sets
358 // browser as default).
359 // Given browsers can be registered in HKCU (as of Win7) and/or in HKLM, this
360 // method looks in both and gives precedence to values in HKCU as per the msdn
361 // standard: http://goo.gl/xjczJ.
362 static void GetRegisteredBrowsers(
363 BrowserDistribution* dist,
364 std::map<base::string16, base::string16>* browsers);
366 // Returns the suffix this user's Chrome install is registered with.
367 // Always returns the empty string on system-level installs.
369 // This method is meant for external methods which need to know the suffix of
370 // the current install at run-time, not for install-time decisions.
371 // There are no guarantees that this suffix will not change later:
372 // (e.g. if two user-level installs were previously installed in parallel on
373 // the same machine, both without admin rights and with no user-level install
374 // having claimed the non-suffixed HKLM registrations, they both have no
375 // suffix in their progId entries (as per the old suffix rules). If they were
376 // to both fully register (i.e. click "Make Chrome Default" and go through
377 // UAC; or upgrade to Win8 and get the automatic no UAC full registration)
378 // they would then both get a suffixed registration as per the new suffix
379 // rules).
381 // |chrome_exe| The path to the currently installed (or running) chrome.exe.
382 static base::string16 GetCurrentInstallationSuffix(
383 BrowserDistribution* dist,
384 const base::string16& chrome_exe);
386 // Returns the application name of the program under |dist|.
387 // This application name will be suffixed as is appropriate for the current
388 // install.
389 // This is the name that is registered with Default Programs on Windows and
390 // that should thus be used to "make chrome default" and such.
391 static base::string16 GetApplicationName(BrowserDistribution* dist,
392 const base::string16& chrome_exe);
394 // Returns the AppUserModelId for |dist|. This identifier is unconditionally
395 // suffixed with a unique id for this user on user-level installs (in contrast
396 // to other registration entries which are suffixed as described in
397 // GetCurrentInstallationSuffix() above).
398 static base::string16 GetBrowserModelId(BrowserDistribution* dist,
399 bool is_per_user_install);
401 // Returns an AppUserModelId composed of each member of |components| separated
402 // by dots.
403 // The returned appid is guaranteed to be no longer than
404 // chrome::kMaxAppModelIdLength (some of the components might have been
405 // shortened to enforce this).
406 static base::string16 BuildAppModelId(
407 const std::vector<base::string16>& components);
409 // Returns true if Chrome can make itself the default browser without relying
410 // on the Windows shell to prompt the user. This is the case for versions of
411 // Windows prior to Windows 8.
412 static bool CanMakeChromeDefaultUnattended();
414 // Returns the DefaultState of Chrome for HTTP and HTTPS.
415 static DefaultState GetChromeDefaultState();
417 // Returns the DefaultState of the Chrome instance with the specified path
418 // for HTTP and HTTPs.
419 static DefaultState GetChromeDefaultStateFromPath(
420 const base::FilePath& chrome_exe);
422 // Returns the DefaultState of Chrome for |protocol|.
423 static DefaultState GetChromeDefaultProtocolClientState(
424 const base::string16& protocol);
426 // Make Chrome the default browser. This function works by going through
427 // the url protocols and file associations that are related to general
428 // browsing, e.g. http, https, .html etc., and requesting to become the
429 // default handler for each. If any of these fails the operation will return
430 // false to indicate failure, which is consistent with the return value of
431 // ShellIntegration::GetDefaultBrowser.
433 // In the case of failure any successful changes will be left, however no
434 // more changes will be attempted.
435 // TODO(benwells): Attempt to undo any changes that were successfully made.
436 // http://crbug.com/83970
438 // shell_change: Defined whether to register as default browser at system
439 // level or user level. If value has ShellChange::SYSTEM_LEVEL
440 // we should be running as admin user.
441 // chrome_exe: The chrome.exe path to register as default browser.
442 // elevate_if_not_admin: On Vista if user is not admin, try to elevate for
443 // Chrome registration.
444 static bool MakeChromeDefault(BrowserDistribution* dist,
445 int shell_change,
446 const base::string16& chrome_exe,
447 bool elevate_if_not_admin);
449 // Shows and waits for the Windows 8 "How do you want to open webpages?"
450 // dialog if Chrome is not already the default HTTP/HTTPS handler. Also does
451 // XP-era registrations if Chrome is chosen or was already the default. Do
452 // not use on pre-Win8 OSes.
454 // |dist| gives the type of browser distribution currently in use.
455 // |chrome_exe| The chrome.exe path to register as default browser.
456 static bool ShowMakeChromeDefaultSystemUI(BrowserDistribution* dist,
457 const base::string16& chrome_exe);
459 // Make Chrome the default application for a protocol.
460 // chrome_exe: The chrome.exe path to register as default browser.
461 // protocol: The protocol to register as the default handler for.
462 static bool MakeChromeDefaultProtocolClient(BrowserDistribution* dist,
463 const base::string16& chrome_exe,
464 const base::string16& protocol);
466 // Shows and waits for the Windows 8 "How do you want to open links of this
467 // type?" dialog if Chrome is not already the default |protocol|
468 // handler. Also does XP-era registrations if Chrome is chosen or was already
469 // the default for |protocol|. Do not use on pre-Win8 OSes.
471 // |dist| gives the type of browser distribution currently in use.
472 // |chrome_exe| The chrome.exe path to register as default browser.
473 // |protocol| is the protocol being registered.
474 static bool ShowMakeChromeDefaultProtocolClientSystemUI(
475 BrowserDistribution* dist,
476 const base::string16& chrome_exe,
477 const base::string16& protocol);
479 // Registers Chrome as a potential default browser and handler for filetypes
480 // and protocols.
481 // If Chrome is already registered, this method is a no-op.
482 // This method requires write access to HKLM (prior to Win8) so is just a
483 // best effort deal.
484 // If write to HKLM is required, but fails, and:
485 // - |elevate_if_not_admin| is true (and OS is Vista or above):
486 // tries to launch setup.exe with admin priviledges (by prompting the user
487 // with a UAC) to do these tasks.
488 // - |elevate_if_not_admin| is false (or OS is XP):
489 // adds the ProgId entries to HKCU. These entries will not make Chrome show
490 // in Default Programs but they are still useful because Chrome can be
491 // registered to run when the user clicks on an http link or an html file.
493 // |chrome_exe| full path to chrome.exe.
494 // |unique_suffix| Optional input. If given, this function appends the value
495 // to default browser entries names that it creates in the registry.
496 // Currently, this is only used to continue an install with the same suffix
497 // when elevating and calling setup.exe with admin privileges as described
498 // above.
499 // |elevate_if_not_admin| if true will make this method try alternate methods
500 // as described above. This should only be true when following a user action
501 // (e.g. "Make Chrome Default") as it allows this method to UAC.
503 // Returns true if Chrome is successfully registered (or already registered).
504 static bool RegisterChromeBrowser(BrowserDistribution* dist,
505 const base::string16& chrome_exe,
506 const base::string16& unique_suffix,
507 bool elevate_if_not_admin);
509 // This method declares to Windows that Chrome is capable of handling the
510 // given protocol. This function will call the RegisterChromeBrowser function
511 // to register with Windows as capable of handling the protocol, if it isn't
512 // currently registered as capable.
513 // Declaring the capability of handling a protocol is necessary to register
514 // as the default handler for the protocol in Vista and later versions of
515 // Windows.
517 // If called by the browser and elevation is required, it will elevate by
518 // calling setup.exe which will again call this function with elevate false.
520 // |chrome_exe| full path to chrome.exe.
521 // |unique_suffix| Optional input. If given, this function appends the value
522 // to default browser entries names that it creates in the registry.
523 // |protocol| The protocol to register as being capable of handling.s
524 // |elevate_if_not_admin| if true will make this method try alternate methods
525 // as described above.
526 static bool RegisterChromeForProtocol(BrowserDistribution* dist,
527 const base::string16& chrome_exe,
528 const base::string16& unique_suffix,
529 const base::string16& protocol,
530 bool elevate_if_not_admin);
532 // Removes installed shortcut(s) at |location|.
533 // |level|: CURRENT_USER to remove per-user shortcuts, or SYSTEM_LEVEL to
534 // remove all-users shortcuts.
535 // |target_exe|: Shortcut target exe; shortcuts will only be deleted when
536 // their target is |target_exe|.
537 // If |location| is a Chrome-specific folder, it will be deleted as well.
538 // Returns true if all shortcuts pointing to |target_exe| are successfully
539 // deleted, including the case where no such shortcuts are found.
540 static bool RemoveShortcuts(ShellUtil::ShortcutLocation location,
541 BrowserDistribution* dist,
542 ShellChange level,
543 const base::FilePath& target_exe);
545 // Updates the target of all shortcuts in |location| that satisfy the
546 // following:
547 // - the shortcut's original target is |old_target_exe|,
548 // - the original arguments are non-empty.
549 // If the shortcut's icon points to |old_target_exe|, then it also gets
550 // redirected to |new_target_exe|.
551 // Returns true if all updates to matching shortcuts are successful, including
552 // the vacuous case where no matching shortcuts are found.
553 static bool RetargetShortcutsWithArgs(
554 ShellUtil::ShortcutLocation location,
555 BrowserDistribution* dist,
556 ShellChange level,
557 const base::FilePath& old_target_exe,
558 const base::FilePath& new_target_exe);
560 typedef base::RefCountedData<base::CancellationFlag> SharedCancellationFlag;
562 // Appends Chrome shortcuts with non-whitelisted arguments to |shortcuts| if
563 // not NULL. If |do_removal|, also removes non-whitelisted arguments from
564 // those shortcuts. This method will abort and return false if |cancel| is
565 // non-NULL and gets set at any point during this call.
566 static bool ShortcutListMaybeRemoveUnknownArgs(
567 ShellUtil::ShortcutLocation location,
568 BrowserDistribution* dist,
569 ShellChange level,
570 const base::FilePath& chrome_exe,
571 bool do_removal,
572 const scoped_refptr<SharedCancellationFlag>& cancel,
573 std::vector<std::pair<base::FilePath, base::string16> >* shortcuts);
575 // Sets |suffix| to the base 32 encoding of the md5 hash of this user's sid
576 // preceded by a dot.
577 // This is guaranteed to be unique on the machine and 27 characters long
578 // (including the '.').
579 // This suffix is then meant to be added to all registration that may conflict
580 // with another user-level Chrome install.
581 // Note that prior to Chrome 21, the suffix registered used to be the user's
582 // username (see GetOldUserSpecificRegistrySuffix() below). We still honor old
583 // installs registered that way, but it was wrong because some of the
584 // characters allowed in a username are not allowed in a ProgId.
585 // Returns true unless the OS call to retrieve the username fails.
586 // NOTE: Only the installer should use this suffix directly. Other callers
587 // should call GetCurrentInstallationSuffix().
588 static bool GetUserSpecificRegistrySuffix(base::string16* suffix);
590 // Sets |suffix| to this user's username preceded by a dot. This suffix should
591 // only be used to support legacy installs that used this suffixing
592 // style.
593 // Returns true unless the OS call to retrieve the username fails.
594 // NOTE: Only the installer should use this suffix directly. Other callers
595 // should call GetCurrentInstallationSuffix().
596 static bool GetOldUserSpecificRegistrySuffix(base::string16* suffix);
598 // Returns the base32 encoding (using the [A-Z2-7] alphabet) of |bytes|.
599 // |size| is the length of |bytes|.
600 // Note: This method does not suffix the output with '=' signs as technically
601 // required by the base32 standard for inputs that aren't a multiple of 5
602 // bytes.
603 static base::string16 ByteArrayToBase32(const uint8* bytes, size_t size);
605 // Associates a set of file extensions with a particular application in the
606 // Windows registry, for the current user only. If an extension has no
607 // existing default association, the given application becomes the default.
608 // Otherwise, the application is added to the Open With menu for this type,
609 // but does not become the default.
611 // |prog_id| is the ProgId used by Windows for file associations with this
612 // application. Must not be empty or start with a '.'.
613 // |command_line| is the command to execute when opening a file via this
614 // association. It should contain "%1" (to tell Windows to pass the filename
615 // as an argument).
616 // |file_type_name| and |icon_path| are the friendly name, and the path of the
617 // icon, respectively, that will be used for files of these types when
618 // associated with this application by default. (They are NOT the name/icon
619 // that will represent the application under the Open With menu.)
620 // |file_extensions| is the set of extensions to associate. They must not be
621 // empty or start with a '.'.
622 // Returns true on success, false on failure.
623 static bool AddFileAssociations(
624 const base::string16& prog_id,
625 const base::CommandLine& command_line,
626 const base::string16& file_type_name,
627 const base::FilePath& icon_path,
628 const std::set<base::string16>& file_extensions);
630 // Deletes all associations with a particular application in the Windows
631 // registry, for the current user only.
632 // |prog_id| is the ProgId used by Windows for file associations with this
633 // application, as given to AddFileAssociations. All information associated
634 // with this name will be deleted.
635 static bool DeleteFileAssociations(const base::string16& prog_id);
637 private:
638 DISALLOW_COPY_AND_ASSIGN(ShellUtil);
642 #endif // CHROME_INSTALLER_UTIL_SHELL_UTIL_H_