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

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: Sync; fixing .git/config to allow CQ to commit. 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 22 matching lines...) Expand all
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 ShortcutLocationIsSupported().
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 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 // Registry value name for the OpenWithProgids entry for file associations. 295 // Registry value name for the OpenWithProgids entry for file associations.
293 static const wchar_t* kRegOpenWithProgids; 296 static const wchar_t* kRegOpenWithProgids;
294 297
295 // Returns true if |chrome_exe| is registered in HKLM with |suffix|. 298 // Returns true if |chrome_exe| is registered in HKLM with |suffix|.
296 // Note: This only checks one deterministic key in HKLM for |chrome_exe| and 299 // Note: This only checks one deterministic key in HKLM for |chrome_exe| and
297 // doesn't otherwise validate a full Chrome install in HKLM. 300 // doesn't otherwise validate a full Chrome install in HKLM.
298 static bool QuickIsChromeRegisteredInHKLM(BrowserDistribution* dist, 301 static bool QuickIsChromeRegisteredInHKLM(BrowserDistribution* dist,
299 const string16& chrome_exe, 302 const string16& chrome_exe,
300 const string16& suffix); 303 const string16& suffix);
301 304
305 // Returns true if the current Windows version supports the presence of
306 // shortcuts at |location|.
307 static bool ShortcutLocationIsSupported(ShellUtil::ShortcutLocation location);
308
302 // Sets |path| to the path for a shortcut at the |location| desired for the 309 // Sets |path| to the path for a shortcut at the |location| desired for the
303 // given |level| (CURRENT_USER for per-user path and SYSTEM_LEVEL for 310 // given |level| (CURRENT_USER for per-user path and SYSTEM_LEVEL for
304 // all-users path). 311 // all-users path).
305 // Returns false on failure. 312 // Returns false on failure.
306 static bool GetShortcutPath(ShellUtil::ShortcutLocation location, 313 static bool GetShortcutPath(ShellUtil::ShortcutLocation location,
307 BrowserDistribution* dist, 314 BrowserDistribution* dist,
308 ShellChange level, 315 ShellChange level,
309 base::FilePath* path); 316 base::FilePath* path);
310 317
311 // Updates shortcut in |location| (or creates it if |options| specify 318 // Updates shortcut in |location| (or creates it if |options| specify
312 // SHELL_SHORTCUT_CREATE_ALWAYS). 319 // SHELL_SHORTCUT_CREATE_ALWAYS).
313 // |dist| gives the type of browser distribution currently in use. 320 // |dist| gives the type of browser distribution currently in use.
314 // |properties| and |operation| affect this method as described on their 321 // |properties| and |operation| affect this method as described on their
315 // invidividual definitions above. 322 // invidividual definitions above.
323 // |location| may be one of SHORTCUT_LOCATION_DESKTOP,
324 // SHORTCUT_LOCATION_QUICK_LAUNCH, or SHORTCUT_LOCATION_START_MENU.
316 static bool CreateOrUpdateShortcut( 325 static bool CreateOrUpdateShortcut(
317 ShellUtil::ShortcutLocation location, 326 ShellUtil::ShortcutLocation location,
318 BrowserDistribution* dist, 327 BrowserDistribution* dist,
319 const ShellUtil::ShortcutProperties& properties, 328 const ShellUtil::ShortcutProperties& properties,
320 ShellUtil::ShortcutOperation operation); 329 ShellUtil::ShortcutOperation operation);
321 330
322 // Returns the string "|icon_path|,|icon_index|" (see, for example, 331 // Returns the string "|icon_path|,|icon_index|" (see, for example,
323 // http://msdn.microsoft.com/library/windows/desktop/dd391573.aspx). 332 // http://msdn.microsoft.com/library/windows/desktop/dd391573.aspx).
324 static string16 FormatIconLocation(const string16& icon_path, int icon_index); 333 static string16 FormatIconLocation(const string16& icon_path, int icon_index);
325 334
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 // |protocol| The protocol to register as being capable of handling.s 505 // |protocol| The protocol to register as being capable of handling.s
497 // |elevate_if_not_admin| if true will make this method try alternate methods 506 // |elevate_if_not_admin| if true will make this method try alternate methods
498 // as described above. 507 // as described above.
499 static bool RegisterChromeForProtocol(BrowserDistribution* dist, 508 static bool RegisterChromeForProtocol(BrowserDistribution* dist,
500 const string16& chrome_exe, 509 const string16& chrome_exe,
501 const string16& unique_suffix, 510 const string16& unique_suffix,
502 const string16& protocol, 511 const string16& protocol,
503 bool elevate_if_not_admin); 512 bool elevate_if_not_admin);
504 513
505 // Removes installed shortcut(s) at |location|. 514 // Removes installed shortcut(s) at |location|.
515 // |level|: CURRENT_USER to remove per-user shortcuts, or SYSTEM_LEVEL to
516 // remove all-users shortcuts.
506 // |target_exe|: Shortcut target exe; shortcuts will only be deleted when 517 // |target_exe|: Shortcut target exe; shortcuts will only be deleted when
507 // their target is |target_exe|. 518 // their target is |target_exe|.
508 // |level|: CURRENT_USER to remove the per-user shortcut and SYSTEM_LEVEL to
509 // remove the all-users shortcut.
510 // |shortcut_name|: If non-null, remove the shortcut named |shortcut_name| at
511 // location; otherwise remove all shortcuts to |target_exe| at |location|.
512 // If |location| is SHORTCUT_LOCATION_START_MENU, the shortcut folder specific 519 // If |location| is SHORTCUT_LOCATION_START_MENU, the shortcut folder specific
513 // to |dist| is deleted. 520 // to |dist| is deleted.
514 // Also attempts to unpin the removed shortcut(s) from the taskbar. 521 // Returns true if all shortcuts pointing to |target_exe| are successfully
515 // Returns true if the shortcut(s) were successfully deleted (or there were 522 // deleted, including the case where no such shortcuts are found.
516 // none at |location| pointing to |target_exe|). 523 static bool RemoveShortcuts(ShellUtil::ShortcutLocation location,
517 static bool RemoveShortcut(ShellUtil::ShortcutLocation location, 524 BrowserDistribution* dist,
518 BrowserDistribution* dist, 525 ShellChange level,
519 const base::FilePath& target_exe, 526 const base::FilePath& target_exe);
520 ShellChange level,
521 const string16* shortcut_name);
522 527
523 // Enumerates all shortcuts pinned to the taskbar and deletes those pointing 528 // Applies the updates in |shortcut_properties| to all shortcuts in |location|
524 // to |target_exe|. 529 // that target |target_exe|.
525 // base::win::TaskbarUnpinShortcutLink() should be prefered, but this is 530 // Returns true if all shortcuts pointing to |target_exe| are successfully
526 // useful on uninstall as the parent shortcut of a pin might no longer exist 531 // updated, including the case where no such shortcuts are found.
527 // (thus making it impossible to unpin it via that API). 532 static bool UpdateShortcuts(
528 static void RemoveTaskbarShortcuts(const string16& target_exe); 533 ShellUtil::ShortcutLocation location,
529 534 BrowserDistribution* dist,
530 // This will remove all secondary tiles from the start screen for |dist|. 535 ShellChange level,
531 static void RemoveStartScreenShortcuts(BrowserDistribution* dist, 536 const base::FilePath& target_exe,
532 const string16& target_exe); 537 const ShellUtil::ShortcutProperties& properties);
533 538
534 // Sets |suffix| to the base 32 encoding of the md5 hash of this user's sid 539 // Sets |suffix| to the base 32 encoding of the md5 hash of this user's sid
535 // preceded by a dot. 540 // preceded by a dot.
536 // This is guaranteed to be unique on the machine and 27 characters long 541 // This is guaranteed to be unique on the machine and 27 characters long
537 // (including the '.'). 542 // (including the '.').
538 // This suffix is then meant to be added to all registration that may conflict 543 // This suffix is then meant to be added to all registration that may conflict
539 // with another user-level Chrome install. 544 // with another user-level Chrome install.
540 // Note that prior to Chrome 21, the suffix registered used to be the user's 545 // Note that prior to Chrome 21, the suffix registered used to be the user's
541 // username (see GetOldUserSpecificRegistrySuffix() below). We still honor old 546 // username (see GetOldUserSpecificRegistrySuffix() below). We still honor old
542 // installs registered that way, but it was wrong because some of the 547 // installs registered that way, but it was wrong because some of the
(...skipping 17 matching lines...) Expand all
560 // required by the base32 standard for inputs that aren't a multiple of 5 565 // required by the base32 standard for inputs that aren't a multiple of 5
561 // bytes. 566 // bytes.
562 static string16 ByteArrayToBase32(const uint8* bytes, size_t size); 567 static string16 ByteArrayToBase32(const uint8* bytes, size_t size);
563 568
564 private: 569 private:
565 DISALLOW_COPY_AND_ASSIGN(ShellUtil); 570 DISALLOW_COPY_AND_ASSIGN(ShellUtil);
566 }; 571 };
567 572
568 573
569 #endif // CHROME_INSTALLER_UTIL_SHELL_UTIL_H_ 574 #endif // CHROME_INSTALLER_UTIL_SHELL_UTIL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698