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

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

Issue 14287008: Refactoring installer shortcut deletion; adding dedicated shortcut update feature. (Closed) Base URL: http://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed redundant routines; cleaning up interfaces, including fixing callers. Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 26 matching lines...) Expand all
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 enum ShortcutLocation { 43 enum ShortcutLocation {
44 SHORTCUT_LOCATION_DESKTOP, 44 SHORTCUT_LOCATION_DESKTOP,
45 SHORTCUT_LOCATION_QUICK_LAUNCH, 45 SHORTCUT_LOCATION_QUICK_LAUNCH,
46 SHORTCUT_LOCATION_START_MENU, 46 SHORTCUT_LOCATION_START_MENU,
47 SHORTCUT_LOCATION_TASKBAR_PINS, // base::win::VERSION_WIN7 +
48 SHORTCUT_LOCATION_APP_SHORTCUTS, // base::win::VERSION_WIN8 +
47 }; 49 };
48 50
49 enum ShortcutOperation { 51 enum ShortcutOperation {
50 // Create a new shortcut (overwriting if necessary). 52 // Create a new shortcut (overwriting if necessary).
51 SHELL_SHORTCUT_CREATE_ALWAYS, 53 SHELL_SHORTCUT_CREATE_ALWAYS,
52 // Create the per-user shortcut only if its system-level equivalent (with 54 // Create the per-user shortcut only if its system-level equivalent (with
53 // the same name) is not present. 55 // the same name) is not present.
54 SHELL_SHORTCUT_CREATE_IF_NO_SYSTEM_LEVEL, 56 SHELL_SHORTCUT_CREATE_IF_NO_SYSTEM_LEVEL,
55 // Overwrite an existing shortcut (fail if the shortcut doesn't exist). 57 // 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 58 // If the arguments are not specified on the new shortcut, keep the old
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 // |protocol| The protocol to register as being capable of handling.s 493 // |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 494 // |elevate_if_not_admin| if true will make this method try alternate methods
493 // as described above. 495 // as described above.
494 static bool RegisterChromeForProtocol(BrowserDistribution* dist, 496 static bool RegisterChromeForProtocol(BrowserDistribution* dist,
495 const string16& chrome_exe, 497 const string16& chrome_exe,
496 const string16& unique_suffix, 498 const string16& unique_suffix,
497 const string16& protocol, 499 const string16& protocol,
498 bool elevate_if_not_admin); 500 bool elevate_if_not_admin);
499 501
500 // Removes installed shortcut(s) at |location|. 502 // Removes installed shortcut(s) at |location|.
503 // |level|: CURRENT_USER to remove the per-user shortcut and SYSTEM_LEVEL to
grt (UTC plus 2) 2013/04/30 14:38:07 and -> or
huangs 2013/04/30 15:58:38 Done.
504 // remove the all-users shortcut.
501 // |target_exe|: Shortcut target exe; shortcuts will only be deleted when 505 // |target_exe|: Shortcut target exe; shortcuts will only be deleted when
502 // their target is |target_exe|. 506 // 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 507 // If |location| is SHORTCUT_LOCATION_START_MENU, the shortcut folder specific
508 // to |dist| is deleted. 508 // to |dist| is deleted.
509 // Also attempts to unpin the removed shortcut(s) from the taskbar. 509 // Also attempts to unpin the removed shortcut(s) from the taskbar.
510 // Returns true if the shortcut(s) were successfully deleted (or there were 510 // Returns true if the shortcut(s) were successfully deleted (or there were
511 // none at |location| pointing to |target_exe|). 511 // none at |location| pointing to |target_exe|).
512 static bool RemoveShortcut(ShellUtil::ShortcutLocation location, 512 static bool RemoveShortcut(ShellUtil::ShortcutLocation location,
grt (UTC plus 2) 2013/04/30 14:38:07 RemoveShortcut -> RemoveShortcuts
huangs 2013/04/30 15:58:38 Done.
513 BrowserDistribution* dist, 513 BrowserDistribution* dist,
514 const base::FilePath& target_exe,
515 ShellChange level, 514 ShellChange level,
516 const string16* shortcut_name); 515 const base::FilePath& target_exe);
517 516
518 // Enumerates all shortcuts pinned to the taskbar and deletes those pointing 517 // Remove all secondary tiles with target set to |target_exe| from the
519 // to |target_exe|. 518 // start screen for |dist|.
520 // base::win::TaskbarUnpinShortcutLink() should be prefered, but this is 519 static void RemoveStartScreenShortcuts(BrowserDistribution* dist,
521 // useful on uninstall as the parent shortcut of a pin might no longer exist 520 const base::FilePath& target_exe);
522 // (thus making it impossible to unpin it via that API).
523 static void RemoveTaskbarShortcuts(const string16& target_exe);
524 521
525 // This will remove all secondary tiles from the start screen for |dist|. 522 // Traverses through installed shortcut(s) in a similar manner as
526 static void RemoveStartScreenShortcuts(BrowserDistribution* dist, 523 // RemoveShortcut(). For each matched shortcut to |old_target_exe|,
527 const string16& target_exe); 524 // update the shortcut so that it points to |new_target_exe|.
525 static bool MigrateShortcut(ShellUtil::ShortcutLocation location,
grt (UTC plus 2) 2013/04/30 14:38:07 "Migrate" is very generic. Since this updates the
huangs 2013/04/30 15:58:38 Using "Retarget". :)
526 BrowserDistribution* dist,
527 ShellChange level,
528 const base::FilePath& old_target_exe,
529 const base::FilePath& new_target_exe);
530
531 // Similar to RemoveStartScreenShortcuts(), but performs migration.
grt (UTC plus 2) 2013/04/30 14:38:07 Same comment about "migrate" here in comment and m
huangs 2013/04/30 15:58:38 Done.
532 static void MigrateStartScreenShortcuts(BrowserDistribution* dist,
grt (UTC plus 2) 2013/04/30 14:38:07 this doesn't appear to ever be called. why is it i
huangs 2013/04/30 15:58:38 This CL is intended for immediate use by: https://
grt (UTC plus 2) 2013/04/30 19:59:53 I don't see MigrateStartScreenShortcuts being used
533 const base::FilePath& old_target_exe,
534 const base::FilePath& new_target_exe);
528 535
529 // Sets |suffix| to the base 32 encoding of the md5 hash of this user's sid 536 // Sets |suffix| to the base 32 encoding of the md5 hash of this user's sid
530 // preceded by a dot. 537 // preceded by a dot.
531 // This is guaranteed to be unique on the machine and 27 characters long 538 // This is guaranteed to be unique on the machine and 27 characters long
532 // (including the '.'). 539 // (including the '.').
533 // This suffix is then meant to be added to all registration that may conflict 540 // This suffix is then meant to be added to all registration that may conflict
534 // with another user-level Chrome install. 541 // with another user-level Chrome install.
535 // Note that prior to Chrome 21, the suffix registered used to be the user's 542 // Note that prior to Chrome 21, the suffix registered used to be the user's
536 // username (see GetOldUserSpecificRegistrySuffix() below). We still honor old 543 // username (see GetOldUserSpecificRegistrySuffix() below). We still honor old
537 // installs registered that way, but it was wrong because some of the 544 // installs registered that way, but it was wrong because some of the
(...skipping 17 matching lines...) Expand all
555 // required by the base32 standard for inputs that aren't a multiple of 5 562 // required by the base32 standard for inputs that aren't a multiple of 5
556 // bytes. 563 // bytes.
557 static string16 ByteArrayToBase32(const uint8* bytes, size_t size); 564 static string16 ByteArrayToBase32(const uint8* bytes, size_t size);
558 565
559 private: 566 private:
560 DISALLOW_COPY_AND_ASSIGN(ShellUtil); 567 DISALLOW_COPY_AND_ASSIGN(ShellUtil);
561 }; 568 };
562 569
563 570
564 #endif // CHROME_INSTALLER_UTIL_SHELL_UTIL_H_ 571 #endif // CHROME_INSTALLER_UTIL_SHELL_UTIL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698