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

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: Adding tests for cookie migration code; using SHORTCUT_REPLACE_EXISTING now. Created 7 years, 8 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|.
501 // |target_exe|: Shortcut target exe; shortcuts will only be deleted when
502 // their target is |target_exe|.
503 // |level|: CURRENT_USER to remove the per-user shortcut and SYSTEM_LEVEL to 503 // |level|: CURRENT_USER to remove the per-user shortcut and SYSTEM_LEVEL to
504 // remove the all-users shortcut. 504 // remove the all-users shortcut.
505 // |shortcut_name|: If non-null, remove the shortcut named |shortcut_name| at 505 // |target_path|: Shortcut target exe; shortcuts will only be deleted when
506 // location; otherwise remove all shortcuts to |target_exe| at |location|. 506 // their target is |target_path|.
507 // |name_filter|: Wildcard filter to specify specific shortcut file(s),
508 // with optional ".lnk" suffix.
507 // If |location| is SHORTCUT_LOCATION_START_MENU, the shortcut folder specific 509 // If |location| is SHORTCUT_LOCATION_START_MENU, the shortcut folder specific
508 // to |dist| is deleted. 510 // to |dist| is deleted.
509 // Also attempts to unpin the removed shortcut(s) from the taskbar. 511 // Also attempts to unpin the removed shortcut(s) from the taskbar.
510 // Returns true if the shortcut(s) were successfully deleted (or there were 512 // Returns true if the shortcut(s) were successfully deleted (or there were
511 // none at |location| pointing to |target_exe|). 513 // none at |location| pointing to |target_path|).
514 static bool RemoveShortcutWithName(ShellUtil::ShortcutLocation location,
gab 2013/04/29 19:06:36 I think that (once a comment above is adressed), t
huangs 2013/04/30 03:04:16 Done.
515 BrowserDistribution* dist,
516 ShellChange level,
517 const base::FilePath& target_path,
518 const string16& name_filter);
519
520 // Adaptor for RemoveShortcutWithName() with unconstrained |name_filter|.
512 static bool RemoveShortcut(ShellUtil::ShortcutLocation location, 521 static bool RemoveShortcut(ShellUtil::ShortcutLocation location,
513 BrowserDistribution* dist, 522 BrowserDistribution* dist,
514 const base::FilePath& target_exe,
515 ShellChange level, 523 ShellChange level,
516 const string16* shortcut_name); 524 const base::FilePath& target_path);
gab 2013/04/29 19:06:36 Please keep this named |target_exe|, variables end
huangs 2013/04/30 03:04:16 I wanted to distinguish string16 from FilePath (an
517 525
518 // Enumerates all shortcuts pinned to the taskbar and deletes those pointing 526 // Enumerates all shortcuts pinned to the taskbar and deletes those pointing
519 // to |target_exe|. 527 // to |target_exe|.
520 // base::win::TaskbarUnpinShortcutLink() should be prefered, but this is 528 // base::win::TaskbarUnpinShortcutLink() should be prefered, but this is
521 // useful on uninstall as the parent shortcut of a pin might no longer exist 529 // useful on uninstall as the parent shortcut of a pin might no longer exist
522 // (thus making it impossible to unpin it via that API). 530 // (thus making it impossible to unpin it via that API).
523 static void RemoveTaskbarShortcuts(const string16& target_exe); 531 static void RemoveTaskbarShortcuts(const string16& target_exe);
524 532
525 // This will remove all secondary tiles from the start screen for |dist|. 533 // This will remove all secondary tiles from the start screen for |dist|.
526 static void RemoveStartScreenShortcuts(BrowserDistribution* dist, 534 static void RemoveStartScreenShortcuts(BrowserDistribution* dist,
527 const string16& target_exe); 535 const string16& target_exe);
528 536
537 // Traverses through installed shortcut(s) in a similar manner as
538 // RemoveShortcut(). For each matched shortcut to |old_target_path|,
539 // update the shortcut so that it points to |new_target_path|.
540 static bool MigrateShortcut(ShellUtil::ShortcutLocation location,
541 BrowserDistribution* dist,
542 ShellChange level,
543 const base::FilePath& old_target_path,
544 const base::FilePath& new_target_path);
545
546 // Similar to RemoveTaskbarShortcuts(), but performs migration.
547 static void MigrateTaskbarShortcuts(const string16& old_target_exe,
548 const string16& new_target_exe);
549
550 // Similar to RemoveStartScreenShortcuts(), but performs migration.
551 static void MigrateStartScreenShortcuts(BrowserDistribution* dist,
552 const string16& old_target_exe,
553 const string16& new_target_exe);
554
529 // Sets |suffix| to the base 32 encoding of the md5 hash of this user's sid 555 // Sets |suffix| to the base 32 encoding of the md5 hash of this user's sid
530 // preceded by a dot. 556 // preceded by a dot.
531 // This is guaranteed to be unique on the machine and 27 characters long 557 // This is guaranteed to be unique on the machine and 27 characters long
532 // (including the '.'). 558 // (including the '.').
533 // This suffix is then meant to be added to all registration that may conflict 559 // This suffix is then meant to be added to all registration that may conflict
534 // with another user-level Chrome install. 560 // with another user-level Chrome install.
535 // Note that prior to Chrome 21, the suffix registered used to be the user's 561 // Note that prior to Chrome 21, the suffix registered used to be the user's
536 // username (see GetOldUserSpecificRegistrySuffix() below). We still honor old 562 // username (see GetOldUserSpecificRegistrySuffix() below). We still honor old
537 // installs registered that way, but it was wrong because some of the 563 // installs registered that way, but it was wrong because some of the
538 // characters allowed in a username are not allowed in a ProgId. 564 // characters allowed in a username are not allowed in a ProgId.
(...skipping 16 matching lines...) Expand all
555 // required by the base32 standard for inputs that aren't a multiple of 5 581 // required by the base32 standard for inputs that aren't a multiple of 5
556 // bytes. 582 // bytes.
557 static string16 ByteArrayToBase32(const uint8* bytes, size_t size); 583 static string16 ByteArrayToBase32(const uint8* bytes, size_t size);
558 584
559 private: 585 private:
560 DISALLOW_COPY_AND_ASSIGN(ShellUtil); 586 DISALLOW_COPY_AND_ASSIGN(ShellUtil);
561 }; 587 };
562 588
563 589
564 #endif // CHROME_INSTALLER_UTIL_SHELL_UTIL_H_ 590 #endif // CHROME_INSTALLER_UTIL_SHELL_UTIL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698