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

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

Issue 1289333005: Change shortcut install location to non-subdir. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: git cl format Created 5 years, 2 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 IS_DEFAULT, 47 IS_DEFAULT,
48 }; 48 };
49 49
50 // Typical shortcut directories. Resolved in GetShortcutPath(). 50 // Typical shortcut directories. Resolved in GetShortcutPath().
51 // Also used in ShortcutLocationIsSupported(). 51 // Also used in ShortcutLocationIsSupported().
52 enum ShortcutLocation { 52 enum ShortcutLocation {
53 SHORTCUT_LOCATION_FIRST = 0, 53 SHORTCUT_LOCATION_FIRST = 0,
54 SHORTCUT_LOCATION_DESKTOP = SHORTCUT_LOCATION_FIRST, 54 SHORTCUT_LOCATION_DESKTOP = SHORTCUT_LOCATION_FIRST,
55 SHORTCUT_LOCATION_QUICK_LAUNCH, 55 SHORTCUT_LOCATION_QUICK_LAUNCH,
56 SHORTCUT_LOCATION_START_MENU_ROOT, 56 SHORTCUT_LOCATION_START_MENU_ROOT,
57 SHORTCUT_LOCATION_START_MENU_CHROME_DIR, 57 SHORTCUT_LOCATION_START_MENU_CHROME_DIR_DEPRECATED, // now placed in root
58 SHORTCUT_LOCATION_START_MENU_CHROME_APPS_DIR, 58 SHORTCUT_LOCATION_START_MENU_CHROME_APPS_DIR,
59 SHORTCUT_LOCATION_TASKBAR_PINS, // base::win::VERSION_WIN7 + 59 SHORTCUT_LOCATION_TASKBAR_PINS, // base::win::VERSION_WIN7 +
60 SHORTCUT_LOCATION_APP_SHORTCUTS, // base::win::VERSION_WIN8 + 60 SHORTCUT_LOCATION_APP_SHORTCUTS, // base::win::VERSION_WIN8 +
61 NUM_SHORTCUT_LOCATIONS 61 NUM_SHORTCUT_LOCATIONS
62 }; 62 };
63 63
64 enum ShortcutOperation { 64 enum ShortcutOperation {
65 // Create a new shortcut (overwriting if necessary). 65 // Create a new shortcut (overwriting if necessary).
66 SHELL_SHORTCUT_CREATE_ALWAYS, 66 SHELL_SHORTCUT_CREATE_ALWAYS,
67 // Create the per-user shortcut only if its system-level equivalent (with 67 // Create the per-user shortcut only if its system-level equivalent (with
68 // the same name) is not present. 68 // the same name) is not present.
69 SHELL_SHORTCUT_CREATE_IF_NO_SYSTEM_LEVEL, 69 SHELL_SHORTCUT_CREATE_IF_NO_SYSTEM_LEVEL,
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 304
305 // Returns true if |chrome_exe| is registered in HKLM with |suffix|. 305 // Returns true if |chrome_exe| is registered in HKLM with |suffix|.
306 // Note: This only checks one deterministic key in HKLM for |chrome_exe| and 306 // Note: This only checks one deterministic key in HKLM for |chrome_exe| and
307 // doesn't otherwise validate a full Chrome install in HKLM. 307 // doesn't otherwise validate a full Chrome install in HKLM.
308 static bool QuickIsChromeRegisteredInHKLM(BrowserDistribution* dist, 308 static bool QuickIsChromeRegisteredInHKLM(BrowserDistribution* dist,
309 const base::FilePath& chrome_exe, 309 const base::FilePath& chrome_exe,
310 const base::string16& suffix); 310 const base::string16& suffix);
311 311
312 // Returns true if the current Windows version supports the presence of 312 // Returns true if the current Windows version supports the presence of
313 // shortcuts at |location|. 313 // shortcuts at |location|.
314 static bool ShortcutLocationIsSupported(ShellUtil::ShortcutLocation location); 314 static bool ShortcutLocationIsSupported(ShortcutLocation location);
315 315
316 // Sets |path| to the path for a shortcut at the |location| desired for the 316 // Sets |path| to the path for a shortcut at the |location| desired for the
317 // given |level| (CURRENT_USER for per-user path and SYSTEM_LEVEL for 317 // given |level| (CURRENT_USER for per-user path and SYSTEM_LEVEL for
318 // all-users path). 318 // all-users path).
319 // Returns false on failure. 319 // Returns false on failure.
320 static bool GetShortcutPath(ShellUtil::ShortcutLocation location, 320 static bool GetShortcutPath(ShortcutLocation location,
321 BrowserDistribution* dist, 321 BrowserDistribution* dist,
322 ShellChange level, 322 ShellChange level,
323 base::FilePath* path); 323 base::FilePath* path);
324 324
325 // Move an existing shortcut from |old_location| to |new_location| for the
326 // set |shortcut_level|. If the folder containing |old_location| is then
327 // empty, it will be removed.
328 static bool MoveExistingShortcut(ShortcutLocation old_location,
329 ShortcutLocation new_location,
330 BrowserDistribution* dist,
331 const ShortcutProperties& properties);
332
325 // Updates shortcut in |location| (or creates it if |options| specify 333 // Updates shortcut in |location| (or creates it if |options| specify
326 // SHELL_SHORTCUT_CREATE_ALWAYS). 334 // SHELL_SHORTCUT_CREATE_ALWAYS).
327 // |dist| gives the type of browser distribution currently in use. 335 // |dist| gives the type of browser distribution currently in use.
328 // |properties| and |operation| affect this method as described on their 336 // |properties| and |operation| affect this method as described on their
329 // invidividual definitions above. 337 // invidividual definitions above.
330 // |location| may be one of SHORTCUT_LOCATION_DESKTOP, 338 // |location| may be one of SHORTCUT_LOCATION_DESKTOP,
331 // SHORTCUT_LOCATION_QUICK_LAUNCH, SHORTCUT_LOCATION_START_MENU_ROOT, 339 // SHORTCUT_LOCATION_QUICK_LAUNCH, SHORTCUT_LOCATION_START_MENU_ROOT,
332 // SHORTCUT_LOCATION_START_MENU_CHROME_DIR, or 340 // SHORTCUT_LOCATION_START_MENU_CHROME_DIR, or
333 // SHORTCUT_LOCATION_START_MENU_CHROME_APPS_DIR. 341 // SHORTCUT_LOCATION_START_MENU_CHROME_APPS_DIR.
334 static bool CreateOrUpdateShortcut( 342 static bool CreateOrUpdateShortcut(ShortcutLocation location,
335 ShellUtil::ShortcutLocation location, 343 BrowserDistribution* dist,
336 BrowserDistribution* dist, 344 const ShortcutProperties& properties,
337 const ShellUtil::ShortcutProperties& properties, 345 ShortcutOperation operation);
338 ShellUtil::ShortcutOperation operation);
339 346
340 // Returns the string "|icon_path|,|icon_index|" (see, for example, 347 // Returns the string "|icon_path|,|icon_index|" (see, for example,
341 // http://msdn.microsoft.com/library/windows/desktop/dd391573.aspx). 348 // http://msdn.microsoft.com/library/windows/desktop/dd391573.aspx).
342 static base::string16 FormatIconLocation(const base::FilePath& icon_path, 349 static base::string16 FormatIconLocation(const base::FilePath& icon_path,
343 int icon_index); 350 int icon_index);
344 351
345 // This method returns the command to open URLs/files using chrome. Typically 352 // This method returns the command to open URLs/files using chrome. Typically
346 // this command is written to the registry under shell\open\command key. 353 // this command is written to the registry under shell\open\command key.
347 // |chrome_exe|: the full path to chrome.exe 354 // |chrome_exe|: the full path to chrome.exe
348 static base::string16 GetChromeShellOpenCmd(const base::FilePath& chrome_exe); 355 static base::string16 GetChromeShellOpenCmd(const base::FilePath& chrome_exe);
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 bool elevate_if_not_admin); 543 bool elevate_if_not_admin);
537 544
538 // Removes installed shortcut(s) at |location|. 545 // Removes installed shortcut(s) at |location|.
539 // |level|: CURRENT_USER to remove per-user shortcuts, or SYSTEM_LEVEL to 546 // |level|: CURRENT_USER to remove per-user shortcuts, or SYSTEM_LEVEL to
540 // remove all-users shortcuts. 547 // remove all-users shortcuts.
541 // |target_exe|: Shortcut target exe; shortcuts will only be deleted when 548 // |target_exe|: Shortcut target exe; shortcuts will only be deleted when
542 // their target is |target_exe|. 549 // their target is |target_exe|.
543 // If |location| is a Chrome-specific folder, it will be deleted as well. 550 // If |location| is a Chrome-specific folder, it will be deleted as well.
544 // Returns true if all shortcuts pointing to |target_exe| are successfully 551 // Returns true if all shortcuts pointing to |target_exe| are successfully
545 // deleted, including the case where no such shortcuts are found. 552 // deleted, including the case where no such shortcuts are found.
546 static bool RemoveShortcuts(ShellUtil::ShortcutLocation location, 553 static bool RemoveShortcuts(ShortcutLocation location,
547 BrowserDistribution* dist, 554 BrowserDistribution* dist,
548 ShellChange level, 555 ShellChange level,
549 const base::FilePath& target_exe); 556 const base::FilePath& target_exe);
550 557
551 // Updates the target of all shortcuts in |location| that satisfy the 558 // Updates the target of all shortcuts in |location| that satisfy the
552 // following: 559 // following:
553 // - the shortcut's original target is |old_target_exe|, 560 // - the shortcut's original target is |old_target_exe|,
554 // - the original arguments are non-empty. 561 // - the original arguments are non-empty.
555 // If the shortcut's icon points to |old_target_exe|, then it also gets 562 // If the shortcut's icon points to |old_target_exe|, then it also gets
556 // redirected to |new_target_exe|. 563 // redirected to |new_target_exe|.
557 // Returns true if all updates to matching shortcuts are successful, including 564 // Returns true if all updates to matching shortcuts are successful, including
558 // the vacuous case where no matching shortcuts are found. 565 // the vacuous case where no matching shortcuts are found.
559 static bool RetargetShortcutsWithArgs( 566 static bool RetargetShortcutsWithArgs(ShortcutLocation location,
560 ShellUtil::ShortcutLocation location, 567 BrowserDistribution* dist,
561 BrowserDistribution* dist, 568 ShellChange level,
562 ShellChange level, 569 const base::FilePath& old_target_exe,
563 const base::FilePath& old_target_exe, 570 const base::FilePath& new_target_exe);
564 const base::FilePath& new_target_exe);
565 571
566 typedef base::RefCountedData<base::CancellationFlag> SharedCancellationFlag; 572 typedef base::RefCountedData<base::CancellationFlag> SharedCancellationFlag;
567 573
568 // Appends Chrome shortcuts with non-whitelisted arguments to |shortcuts| if 574 // Appends Chrome shortcuts with non-whitelisted arguments to |shortcuts| if
569 // not NULL. If |do_removal|, also removes non-whitelisted arguments from 575 // not NULL. If |do_removal|, also removes non-whitelisted arguments from
570 // those shortcuts. This method will abort and return false if |cancel| is 576 // those shortcuts. This method will abort and return false if |cancel| is
571 // non-NULL and gets set at any point during this call. 577 // non-NULL and gets set at any point during this call.
572 static bool ShortcutListMaybeRemoveUnknownArgs( 578 static bool ShortcutListMaybeRemoveUnknownArgs(
573 ShellUtil::ShortcutLocation location, 579 ShortcutLocation location,
574 BrowserDistribution* dist, 580 BrowserDistribution* dist,
575 ShellChange level, 581 ShellChange level,
576 const base::FilePath& chrome_exe, 582 const base::FilePath& chrome_exe,
577 bool do_removal, 583 bool do_removal,
578 const scoped_refptr<SharedCancellationFlag>& cancel, 584 const scoped_refptr<SharedCancellationFlag>& cancel,
579 std::vector<std::pair<base::FilePath, base::string16> >* shortcuts); 585 std::vector<std::pair<base::FilePath, base::string16>>* shortcuts);
580 586
581 // Sets |suffix| to the base 32 encoding of the md5 hash of this user's sid 587 // Sets |suffix| to the base 32 encoding of the md5 hash of this user's sid
582 // preceded by a dot. 588 // preceded by a dot.
583 // This is guaranteed to be unique on the machine and 27 characters long 589 // This is guaranteed to be unique on the machine and 27 characters long
584 // (including the '.'). 590 // (including the '.').
585 // This suffix is then meant to be added to all registration that may conflict 591 // This suffix is then meant to be added to all registration that may conflict
586 // with another user-level Chrome install. 592 // with another user-level Chrome install.
587 // Note that prior to Chrome 21, the suffix registered used to be the user's 593 // Note that prior to Chrome 21, the suffix registered used to be the user's
588 // username (see GetOldUserSpecificRegistrySuffix() below). We still honor old 594 // username (see GetOldUserSpecificRegistrySuffix() below). We still honor old
589 // installs registered that way, but it was wrong because some of the 595 // installs registered that way, but it was wrong because some of the
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 // application, as given to AddFileAssociations. All information associated 645 // application, as given to AddFileAssociations. All information associated
640 // with this name will be deleted. 646 // with this name will be deleted.
641 static bool DeleteFileAssociations(const base::string16& prog_id); 647 static bool DeleteFileAssociations(const base::string16& prog_id);
642 648
643 private: 649 private:
644 DISALLOW_COPY_AND_ASSIGN(ShellUtil); 650 DISALLOW_COPY_AND_ASSIGN(ShellUtil);
645 }; 651 };
646 652
647 653
648 #endif // CHROME_INSTALLER_UTIL_SHELL_UTIL_H_ 654 #endif // CHROME_INSTALLER_UTIL_SHELL_UTIL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698