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

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

Issue 1405993006: Revert of Change shortcut install location to non-subdir. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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
« no previous file with comments | « chrome/installer/setup/setup_main.cc ('k') | chrome/installer/util/shell_util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_DEPRECATED, // now placed in root 57 SHORTCUT_LOCATION_START_MENU_CHROME_DIR,
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(ShortcutLocation location); 314 static bool ShortcutLocationIsSupported(ShellUtil::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(ShortcutLocation location, 320 static bool GetShortcutPath(ShellUtil::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
333 // Updates shortcut in |location| (or creates it if |options| specify 325 // Updates shortcut in |location| (or creates it if |options| specify
334 // SHELL_SHORTCUT_CREATE_ALWAYS). 326 // SHELL_SHORTCUT_CREATE_ALWAYS).
335 // |dist| gives the type of browser distribution currently in use. 327 // |dist| gives the type of browser distribution currently in use.
336 // |properties| and |operation| affect this method as described on their 328 // |properties| and |operation| affect this method as described on their
337 // invidividual definitions above. 329 // invidividual definitions above.
338 // |location| may be one of SHORTCUT_LOCATION_DESKTOP, 330 // |location| may be one of SHORTCUT_LOCATION_DESKTOP,
339 // SHORTCUT_LOCATION_QUICK_LAUNCH, SHORTCUT_LOCATION_START_MENU_ROOT, 331 // SHORTCUT_LOCATION_QUICK_LAUNCH, SHORTCUT_LOCATION_START_MENU_ROOT,
340 // SHORTCUT_LOCATION_START_MENU_CHROME_DIR, or 332 // SHORTCUT_LOCATION_START_MENU_CHROME_DIR, or
341 // SHORTCUT_LOCATION_START_MENU_CHROME_APPS_DIR. 333 // SHORTCUT_LOCATION_START_MENU_CHROME_APPS_DIR.
342 static bool CreateOrUpdateShortcut( 334 static bool CreateOrUpdateShortcut(
343 ShortcutLocation location, 335 ShellUtil::ShortcutLocation location,
344 BrowserDistribution* dist, 336 BrowserDistribution* dist,
345 const ShortcutProperties& properties, 337 const ShellUtil::ShortcutProperties& properties,
346 ShortcutOperation operation); 338 ShellUtil::ShortcutOperation operation);
347 339
348 // Returns the string "|icon_path|,|icon_index|" (see, for example, 340 // Returns the string "|icon_path|,|icon_index|" (see, for example,
349 // http://msdn.microsoft.com/library/windows/desktop/dd391573.aspx). 341 // http://msdn.microsoft.com/library/windows/desktop/dd391573.aspx).
350 static base::string16 FormatIconLocation(const base::FilePath& icon_path, 342 static base::string16 FormatIconLocation(const base::FilePath& icon_path,
351 int icon_index); 343 int icon_index);
352 344
353 // This method returns the command to open URLs/files using chrome. Typically 345 // This method returns the command to open URLs/files using chrome. Typically
354 // this command is written to the registry under shell\open\command key. 346 // this command is written to the registry under shell\open\command key.
355 // |chrome_exe|: the full path to chrome.exe 347 // |chrome_exe|: the full path to chrome.exe
356 static base::string16 GetChromeShellOpenCmd(const base::FilePath& chrome_exe); 348 static base::string16 GetChromeShellOpenCmd(const base::FilePath& chrome_exe);
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 bool elevate_if_not_admin); 536 bool elevate_if_not_admin);
545 537
546 // Removes installed shortcut(s) at |location|. 538 // Removes installed shortcut(s) at |location|.
547 // |level|: CURRENT_USER to remove per-user shortcuts, or SYSTEM_LEVEL to 539 // |level|: CURRENT_USER to remove per-user shortcuts, or SYSTEM_LEVEL to
548 // remove all-users shortcuts. 540 // remove all-users shortcuts.
549 // |target_exe|: Shortcut target exe; shortcuts will only be deleted when 541 // |target_exe|: Shortcut target exe; shortcuts will only be deleted when
550 // their target is |target_exe|. 542 // their target is |target_exe|.
551 // If |location| is a Chrome-specific folder, it will be deleted as well. 543 // If |location| is a Chrome-specific folder, it will be deleted as well.
552 // Returns true if all shortcuts pointing to |target_exe| are successfully 544 // Returns true if all shortcuts pointing to |target_exe| are successfully
553 // deleted, including the case where no such shortcuts are found. 545 // deleted, including the case where no such shortcuts are found.
554 static bool RemoveShortcuts(ShortcutLocation location, 546 static bool RemoveShortcuts(ShellUtil::ShortcutLocation location,
555 BrowserDistribution* dist, 547 BrowserDistribution* dist,
556 ShellChange level, 548 ShellChange level,
557 const base::FilePath& target_exe); 549 const base::FilePath& target_exe);
558 550
559 // Updates the target of all shortcuts in |location| that satisfy the 551 // Updates the target of all shortcuts in |location| that satisfy the
560 // following: 552 // following:
561 // - the shortcut's original target is |old_target_exe|, 553 // - the shortcut's original target is |old_target_exe|,
562 // - the original arguments are non-empty. 554 // - the original arguments are non-empty.
563 // If the shortcut's icon points to |old_target_exe|, then it also gets 555 // If the shortcut's icon points to |old_target_exe|, then it also gets
564 // redirected to |new_target_exe|. 556 // redirected to |new_target_exe|.
565 // Returns true if all updates to matching shortcuts are successful, including 557 // Returns true if all updates to matching shortcuts are successful, including
566 // the vacuous case where no matching shortcuts are found. 558 // the vacuous case where no matching shortcuts are found.
567 static bool RetargetShortcutsWithArgs( 559 static bool RetargetShortcutsWithArgs(
568 ShortcutLocation location, 560 ShellUtil::ShortcutLocation location,
569 BrowserDistribution* dist, 561 BrowserDistribution* dist,
570 ShellChange level, 562 ShellChange level,
571 const base::FilePath& old_target_exe, 563 const base::FilePath& old_target_exe,
572 const base::FilePath& new_target_exe); 564 const base::FilePath& new_target_exe);
573 565
574 typedef base::RefCountedData<base::CancellationFlag> SharedCancellationFlag; 566 typedef base::RefCountedData<base::CancellationFlag> SharedCancellationFlag;
575 567
576 // Appends Chrome shortcuts with non-whitelisted arguments to |shortcuts| if 568 // Appends Chrome shortcuts with non-whitelisted arguments to |shortcuts| if
577 // not NULL. If |do_removal|, also removes non-whitelisted arguments from 569 // not NULL. If |do_removal|, also removes non-whitelisted arguments from
578 // those shortcuts. This method will abort and return false if |cancel| is 570 // those shortcuts. This method will abort and return false if |cancel| is
579 // non-NULL and gets set at any point during this call. 571 // non-NULL and gets set at any point during this call.
580 static bool ShortcutListMaybeRemoveUnknownArgs( 572 static bool ShortcutListMaybeRemoveUnknownArgs(
581 ShortcutLocation location, 573 ShellUtil::ShortcutLocation location,
582 BrowserDistribution* dist, 574 BrowserDistribution* dist,
583 ShellChange level, 575 ShellChange level,
584 const base::FilePath& chrome_exe, 576 const base::FilePath& chrome_exe,
585 bool do_removal, 577 bool do_removal,
586 const scoped_refptr<SharedCancellationFlag>& cancel, 578 const scoped_refptr<SharedCancellationFlag>& cancel,
587 std::vector<std::pair<base::FilePath, base::string16> >* shortcuts); 579 std::vector<std::pair<base::FilePath, base::string16> >* shortcuts);
588 580
589 // Sets |suffix| to the base 32 encoding of the md5 hash of this user's sid 581 // Sets |suffix| to the base 32 encoding of the md5 hash of this user's sid
590 // preceded by a dot. 582 // preceded by a dot.
591 // This is guaranteed to be unique on the machine and 27 characters long 583 // This is guaranteed to be unique on the machine and 27 characters long
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
647 // application, as given to AddFileAssociations. All information associated 639 // application, as given to AddFileAssociations. All information associated
648 // with this name will be deleted. 640 // with this name will be deleted.
649 static bool DeleteFileAssociations(const base::string16& prog_id); 641 static bool DeleteFileAssociations(const base::string16& prog_id);
650 642
651 private: 643 private:
652 DISALLOW_COPY_AND_ASSIGN(ShellUtil); 644 DISALLOW_COPY_AND_ASSIGN(ShellUtil);
653 }; 645 };
654 646
655 647
656 #endif // CHROME_INSTALLER_UTIL_SHELL_UTIL_H_ 648 #endif // CHROME_INSTALLER_UTIL_SHELL_UTIL_H_
OLDNEW
« no previous file with comments | « chrome/installer/setup/setup_main.cc ('k') | chrome/installer/util/shell_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698