OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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_ |
(...skipping 22 matching lines...) Expand all Loading... |
33 }; | 33 }; |
34 | 34 |
35 // Chrome's default handler state for a given protocol. | 35 // Chrome's default handler state for a given protocol. |
36 enum DefaultState { | 36 enum DefaultState { |
37 UNKNOWN_DEFAULT, | 37 UNKNOWN_DEFAULT, |
38 NOT_DEFAULT, | 38 NOT_DEFAULT, |
39 IS_DEFAULT, | 39 IS_DEFAULT, |
40 }; | 40 }; |
41 | 41 |
42 // Typical shortcut directories. Resolved in GetShortcutPath(). | 42 // Typical shortcut directories. Resolved in GetShortcutPath(). |
| 43 // Also used in ShortcutLocationIsExpected(). |
43 enum ShortcutLocation { | 44 enum ShortcutLocation { |
44 SHORTCUT_LOCATION_DESKTOP, | 45 SHORTCUT_LOCATION_DESKTOP, |
45 SHORTCUT_LOCATION_QUICK_LAUNCH, | 46 SHORTCUT_LOCATION_QUICK_LAUNCH, |
46 SHORTCUT_LOCATION_START_MENU, | 47 SHORTCUT_LOCATION_START_MENU, |
| 48 SHORTCUT_LOCATION_TASKBAR_PINS, // base::win::VERSION_WIN7 + |
| 49 SHORTCUT_LOCATION_APP_SHORTCUTS, // base::win::VERSION_WIN8 + |
47 }; | 50 }; |
48 | 51 |
49 enum ShortcutOperation { | 52 enum ShortcutOperation { |
50 // Create a new shortcut (overwriting if necessary). | 53 // Create a new shortcut (overwriting if necessary). |
51 SHELL_SHORTCUT_CREATE_ALWAYS, | 54 SHELL_SHORTCUT_CREATE_ALWAYS, |
52 // Create the per-user shortcut only if its system-level equivalent (with | 55 // Create the per-user shortcut only if its system-level equivalent (with |
53 // the same name) is not present. | 56 // the same name) is not present. |
54 SHELL_SHORTCUT_CREATE_IF_NO_SYSTEM_LEVEL, | 57 SHELL_SHORTCUT_CREATE_IF_NO_SYSTEM_LEVEL, |
55 // Overwrite an existing shortcut (fail if the shortcut doesn't exist). | 58 // Overwrite an existing shortcut (fail if the shortcut doesn't exist). |
56 // If the arguments are not specified on the new shortcut, keep the old | 59 // If the arguments are not specified on the new shortcut, keep the old |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 // Registry value name for the OpenWithProgids entry for file associations. | 290 // Registry value name for the OpenWithProgids entry for file associations. |
288 static const wchar_t* kRegOpenWithProgids; | 291 static const wchar_t* kRegOpenWithProgids; |
289 | 292 |
290 // Returns true if |chrome_exe| is registered in HKLM with |suffix|. | 293 // Returns true if |chrome_exe| is registered in HKLM with |suffix|. |
291 // Note: This only checks one deterministic key in HKLM for |chrome_exe| and | 294 // Note: This only checks one deterministic key in HKLM for |chrome_exe| and |
292 // doesn't otherwise validate a full Chrome install in HKLM. | 295 // doesn't otherwise validate a full Chrome install in HKLM. |
293 static bool QuickIsChromeRegisteredInHKLM(BrowserDistribution* dist, | 296 static bool QuickIsChromeRegisteredInHKLM(BrowserDistribution* dist, |
294 const string16& chrome_exe, | 297 const string16& chrome_exe, |
295 const string16& suffix); | 298 const string16& suffix); |
296 | 299 |
| 300 // Returns true if the current Windows version supports the presence of |
| 301 // shortcuts at |location|. |
| 302 static bool ShortcutLocationIsExpected(ShellUtil::ShortcutLocation location); |
| 303 |
297 // Sets |path| to the path for a shortcut at the |location| desired for the | 304 // Sets |path| to the path for a shortcut at the |location| desired for the |
298 // given |level| (CURRENT_USER for per-user path and SYSTEM_LEVEL for | 305 // given |level| (CURRENT_USER for per-user path and SYSTEM_LEVEL for |
299 // all-users path). | 306 // all-users path). |
300 // Returns false on failure. | 307 // Returns false on failure. |
301 static bool GetShortcutPath(ShellUtil::ShortcutLocation location, | 308 static bool GetShortcutPath(ShellUtil::ShortcutLocation location, |
302 BrowserDistribution* dist, | 309 BrowserDistribution* dist, |
303 ShellChange level, | 310 ShellChange level, |
304 base::FilePath* path); | 311 base::FilePath* path); |
305 | 312 |
306 // Updates shortcut in |location| (or creates it if |options| specify | 313 // Updates shortcut in |location| (or creates it if |options| specify |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
491 // |protocol| The protocol to register as being capable of handling.s | 498 // |protocol| The protocol to register as being capable of handling.s |
492 // |elevate_if_not_admin| if true will make this method try alternate methods | 499 // |elevate_if_not_admin| if true will make this method try alternate methods |
493 // as described above. | 500 // as described above. |
494 static bool RegisterChromeForProtocol(BrowserDistribution* dist, | 501 static bool RegisterChromeForProtocol(BrowserDistribution* dist, |
495 const string16& chrome_exe, | 502 const string16& chrome_exe, |
496 const string16& unique_suffix, | 503 const string16& unique_suffix, |
497 const string16& protocol, | 504 const string16& protocol, |
498 bool elevate_if_not_admin); | 505 bool elevate_if_not_admin); |
499 | 506 |
500 // Removes installed shortcut(s) at |location|. | 507 // Removes installed shortcut(s) at |location|. |
| 508 // |level|: CURRENT_USER to remove per-user shortcuts, or SYSTEM_LEVEL to |
| 509 // remove all-users shortcuts. |
501 // |target_exe|: Shortcut target exe; shortcuts will only be deleted when | 510 // |target_exe|: Shortcut target exe; shortcuts will only be deleted when |
502 // their target is |target_exe|. | 511 // their target is |target_exe|. |
503 // |level|: CURRENT_USER to remove the per-user shortcut and SYSTEM_LEVEL to | |
504 // remove the all-users shortcut. | |
505 // |shortcut_name|: If non-null, remove the shortcut named |shortcut_name| at | |
506 // location; otherwise remove all shortcuts to |target_exe| at |location|. | |
507 // If |location| is SHORTCUT_LOCATION_START_MENU, the shortcut folder specific | 512 // If |location| is SHORTCUT_LOCATION_START_MENU, the shortcut folder specific |
508 // to |dist| is deleted. | 513 // to |dist| is deleted. |
509 // Also attempts to unpin the removed shortcut(s) from the taskbar. | 514 // Also attempts to unpin the removed shortcut(s) from the taskbar. |
510 // Returns true if the shortcut(s) were successfully deleted (or there were | 515 // Returns true if the shortcut(s) were successfully deleted (or there were |
511 // none at |location| pointing to |target_exe|). | 516 // none at |location| pointing to |target_exe|). |
512 static bool RemoveShortcut(ShellUtil::ShortcutLocation location, | 517 static bool RemoveShortcuts(ShellUtil::ShortcutLocation location, |
513 BrowserDistribution* dist, | 518 BrowserDistribution* dist, |
514 const base::FilePath& target_exe, | 519 ShellChange level, |
515 ShellChange level, | 520 const base::FilePath& target_exe); |
516 const string16* shortcut_name); | |
517 | 521 |
518 // Enumerates all shortcuts pinned to the taskbar and deletes those pointing | 522 // Iterates over all shortcuts at |location| that targets |old_target_exe|, |
519 // to |target_exe|. | 523 // and makes them target |new_target_exe| instead. |
520 // base::win::TaskbarUnpinShortcutLink() should be prefered, but this is | 524 static bool RetargetShortcuts(ShellUtil::ShortcutLocation location, |
521 // useful on uninstall as the parent shortcut of a pin might no longer exist | 525 BrowserDistribution* dist, |
522 // (thus making it impossible to unpin it via that API). | 526 ShellChange level, |
523 static void RemoveTaskbarShortcuts(const string16& target_exe); | 527 const base::FilePath& old_target_exe, |
524 | 528 const base::FilePath& new_target_exe); |
525 // This will remove all secondary tiles from the start screen for |dist|. | |
526 static void RemoveStartScreenShortcuts(BrowserDistribution* dist, | |
527 const string16& target_exe); | |
528 | 529 |
529 // Sets |suffix| to the base 32 encoding of the md5 hash of this user's sid | 530 // Sets |suffix| to the base 32 encoding of the md5 hash of this user's sid |
530 // preceded by a dot. | 531 // preceded by a dot. |
531 // This is guaranteed to be unique on the machine and 27 characters long | 532 // This is guaranteed to be unique on the machine and 27 characters long |
532 // (including the '.'). | 533 // (including the '.'). |
533 // This suffix is then meant to be added to all registration that may conflict | 534 // This suffix is then meant to be added to all registration that may conflict |
534 // with another user-level Chrome install. | 535 // with another user-level Chrome install. |
535 // Note that prior to Chrome 21, the suffix registered used to be the user's | 536 // Note that prior to Chrome 21, the suffix registered used to be the user's |
536 // username (see GetOldUserSpecificRegistrySuffix() below). We still honor old | 537 // username (see GetOldUserSpecificRegistrySuffix() below). We still honor old |
537 // installs registered that way, but it was wrong because some of the | 538 // installs registered that way, but it was wrong because some of the |
(...skipping 17 matching lines...) Expand all Loading... |
555 // required by the base32 standard for inputs that aren't a multiple of 5 | 556 // required by the base32 standard for inputs that aren't a multiple of 5 |
556 // bytes. | 557 // bytes. |
557 static string16 ByteArrayToBase32(const uint8* bytes, size_t size); | 558 static string16 ByteArrayToBase32(const uint8* bytes, size_t size); |
558 | 559 |
559 private: | 560 private: |
560 DISALLOW_COPY_AND_ASSIGN(ShellUtil); | 561 DISALLOW_COPY_AND_ASSIGN(ShellUtil); |
561 }; | 562 }; |
562 | 563 |
563 | 564 |
564 #endif // CHROME_INSTALLER_UTIL_SHELL_UTIL_H_ | 565 #endif // CHROME_INSTALLER_UTIL_SHELL_UTIL_H_ |
OLD | NEW |