chrome/browser/profiles/profile_shortcut_manager_win.cc
// Updates all desktop shortcuts for the given profile to have the specified
// parameters. If |create_mode| is CREATE_WHEN_NONE_FOUND, a new shortcut is
// created if no existing ones were found. Whether non-profile shortcuts should
// be updated is specified by |action|. Must be called on the FILE thread.
Updates all desktop shortcuts for the given profile to have the specified
parameters. If |create_mode| is CREATE_WHEN_NONE_FOUND, a new shortcut is
created if no existing ones were found. Whether non-profile shortcuts should
be updated is specified by |action|. Must be called on the FILE thread.
Updates all desktop shortcuts for the given profile to have the specified parameters . If |create_mode| is CREATE_WHEN_NONE_FOUND a new shortcut is created if no existing ones were found . Whether non - profile shortcuts should be updated is specified by |action| . Must be called on the FILE thread .
void CreateOrUpdateDesktopShortcutsForProfile(
    const FilePath& profile_path,
    const string16& profile_name,
    const SkBitmap& avatar_image,
    ProfileShortcutManagerWin::CreateOrUpdateMode create_mode,
    ProfileShortcutManagerWin::NonProfileShortcutAction action) {
  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
  FilePath chrome_exe;
  if (!PathService::Get(base::FILE_EXE, &chrome_exe)) {
    NOTREACHED();
    return;
  }
  BrowserDistribution* distribution = BrowserDistribution::GetDistribution();
  installer::Product product(distribution);
  ShellUtil::ShortcutProperties properties(ShellUtil::CURRENT_USER);
  product.AddDefaultShortcutProperties(chrome_exe, &properties);
  const FilePath shortcut_icon =
      CreateChromeDesktopShortcutIconForProfile(profile_path, avatar_image);
  if (!shortcut_icon.empty())
    properties.set_icon(shortcut_icon, 0);
  const string16 command_line =
      profiles::internal::CreateProfileShortcutFlags(profile_path);
  properties.set_arguments(command_line);
  ShellUtil::ShortcutOperation operation =
      ShellUtil::SHELL_SHORTCUT_REPLACE_EXISTING;
  std::vector<FilePath> shortcuts;
  ListDesktopShortcutsWithCommandLine(chrome_exe, command_line,
      action == ProfileShortcutManagerWin::UPDATE_NON_PROFILE_SHORTCUTS,
      &shortcuts);
  if (create_mode == ProfileShortcutManagerWin::CREATE_WHEN_NONE_FOUND &&
      shortcuts.empty()) {
    const string16 shortcut_name =
        profiles::internal::GetShortcutFilenameForProfile(profile_name,
                                                          distribution);
    shortcuts.push_back(FilePath(shortcut_name));
    operation = ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS;
  }
  for (size_t i = 0; i < shortcuts.size(); ++i) {
    const FilePath shortcut_name = shortcuts[i].BaseName().RemoveExtension();
    properties.set_shortcut_name(shortcut_name.value());
    ShellUtil::CreateOrUpdateShortcut(ShellUtil::SHORTCUT_LOCATION_DESKTOP,
        distribution, properties, operation);
  }
}
void CreateOrUpdateDesktopShortcutsForProfile ( const FilePath & profile_path , const string16 & profile_name , const SkBitmap & avatar_image , ProfileShortcutManagerWin :: CreateOrUpdateMode create_mode , ProfileShortcutManagerWin :: NonProfileShortcutAction action ) { DCHECK ( BrowserThread :: CurrentlyOn ( BrowserThread :: FILE ) ) ; FilePath chrome_exe ; if ( ! PathService :: Get ( base :: FILE_EXE , & chrome_exe ) ) { NOTREACHED ( ) ; return ; } BrowserDistribution * distribution = BrowserDistribution :: GetDistribution ( ) ; installer :: Product product ( distribution ) ; ShellUtil :: ShortcutProperties properties ( ShellUtil :: CURRENT_USER ) ; product . AddDefaultShortcutProperties ( chrome_exe , & properties ) ; const FilePath shortcut_icon = CreateChromeDesktopShortcutIconForProfile ( profile_path , avatar_image ) ; if ( ! shortcut_icon . empty ( ) ) properties . set_icon ( shortcut_icon , 0 ) ; const string16 command_line = profiles :: internal :: CreateProfileShortcutFlags ( profile_path ) ; properties . set_arguments ( command_line ) ; ShellUtil :: ShortcutOperation operation = ShellUtil :: SHELL_SHORTCUT_REPLACE_EXISTING ; std :: vector < FilePath > shortcuts ; ListDesktopShortcutsWithCommandLine ( chrome_exe , command_line , action == ProfileShortcutManagerWin :: UPDATE_NON_PROFILE_SHORTCUTS , & shortcuts ) ; if ( create_mode == ProfileShortcutManagerWin :: CREATE_WHEN_NONE_FOUND && shortcuts . empty ( ) ) { const string16 shortcut_name = profiles :: internal :: GetShortcutFilenameForProfile ( profile_name , distribution ) ; shortcuts . push_back ( FilePath ( shortcut_name ) ) ; operation = ShellUtil :: SHELL_SHORTCUT_CREATE_ALWAYS ; } for ( size_t i = 0 ; i < shortcuts . size ( ) ; ++ i ) { const FilePath shortcut_name = shortcuts [ i ] . BaseName ( ) . RemoveExtension ( ) ; properties . set_shortcut_name ( shortcut_name . value ( ) ) ; ShellUtil :: CreateOrUpdateShortcut ( ShellUtil :: SHORTCUT_LOCATION_DESKTOP , distribution , properties , operation ) ; } }
Updates all desktop shortcuts for the given profile to have the specified
parameters.
Updates all desktop shortcuts for the given profile to have the specified parameters .