chrome/browser/ui/views/app_list/app_list_controller_win.cc
// Check that a taskbar shortcut exists if it should, or does not exist if
// it should not. A taskbar shortcut should exist if the switch
// kShowAppListShortcut is set. The shortcut will be created or deleted in
// |user_data_dir| and will use a Windows Application Model Id of
// |app_model_id|.
// This runs on the FILE thread and not in the blocking IO thread pool as there
// are other tasks running (also on the FILE thread) which fiddle with shortcut
// icons (ShellIntegration::MigrateWin7ShortcutsOnPath). Having different
// threads fiddle with the same shortcuts could cause race issues.
Check that a taskbar shortcut exists if it should, or does not exist if
it should not. A taskbar shortcut should exist if the switch
kShowAppListShortcut is set. The shortcut will be created or deleted in
|user_data_dir| and will use a Windows Application Model Id of
|app_model_id|.
This runs on the FILE thread and not in the blocking IO thread pool as there
are other tasks running (also on the FILE thread) which fiddle with shortcut
icons (ShellIntegration::MigrateWin7ShortcutsOnPath). Having different
threads fiddle with the same shortcuts could cause race issues.
Check that a taskbar shortcut exists if it should or does not exist if it should not . A taskbar shortcut should exist if the switch kShowAppListShortcut is set . The shortcut will be created or deleted in |user_data_dir| and will use a Windows Application Model Id of |app_model_id| . This runs on the FILE thread and not in the blocking IO thread pool as there are other tasks running ( also on the FILE thread ) which fiddle with shortcut icons ( ShellIntegration :: MigrateWin7ShortcutsOnPath ) . Having different threads fiddle with the same shortcuts could cause race issues .
void CheckAppListTaskbarShortcutOnFileThread(const FilePath& user_data_dir,
                                             const string16& app_model_id) {
  DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE));
  const string16 shortcut_name = l10n_util::GetStringUTF16(
      IDS_APP_LIST_SHORTCUT_NAME);
  const FilePath shortcut_path(user_data_dir.Append(shortcut_name)
      .AddExtension(installer::kLnkExt));
  const bool should_show =
      CommandLine::ForCurrentProcess()->HasSwitch(
          switches::kShowAppListShortcut) ||
      chrome_launcher_support::IsAppLauncherPresent();
  if (should_show && !file_util::PathExists(shortcut_path)) {
    FilePath chrome_exe;
    if (!PathService::Get(base::FILE_EXE, &chrome_exe)) {
      NOTREACHED();
      return;
    }
    base::win::ShortcutProperties shortcut_properties;
    shortcut_properties.set_target(chrome_exe);
    shortcut_properties.set_working_dir(chrome_exe.DirName());
    string16 wide_switches(GetAppListCommandLine().GetArgumentsString());
    shortcut_properties.set_arguments(wide_switches);
    shortcut_properties.set_description(shortcut_name);
    shortcut_properties.set_icon(chrome_exe, kAppListIconIndex);
    shortcut_properties.set_app_id(app_model_id);
    base::win::CreateOrUpdateShortcutLink(shortcut_path, shortcut_properties,
                                          base::win::SHORTCUT_CREATE_ALWAYS);
    base::win::TaskbarPinShortcutLink(shortcut_path.value().c_str());
    return;
  }
  if (!should_show && file_util::PathExists(shortcut_path)) {
    base::win::TaskbarUnpinShortcutLink(shortcut_path.value().c_str());
    file_util::Delete(shortcut_path, false);
  }
}
void CheckAppListTaskbarShortcutOnFileThread ( const FilePath & user_data_dir , const string16 & app_model_id ) { DCHECK ( content :: BrowserThread :: CurrentlyOn ( content :: BrowserThread :: FILE ) ) ; const string16 shortcut_name = l10n_util :: GetStringUTF16 ( IDS_APP_LIST_SHORTCUT_NAME ) ; const FilePath shortcut_path ( user_data_dir . Append ( shortcut_name ) . AddExtension ( installer :: kLnkExt ) ) ; const bool should_show = CommandLine :: ForCurrentProcess ( ) -> HasSwitch ( switches :: kShowAppListShortcut ) || chrome_launcher_support :: IsAppLauncherPresent ( ) ; if ( should_show && ! file_util :: PathExists ( shortcut_path ) ) { FilePath chrome_exe ; if ( ! PathService :: Get ( base :: FILE_EXE , & chrome_exe ) ) { NOTREACHED ( ) ; return ; } base :: win :: ShortcutProperties shortcut_properties ; shortcut_properties . set_target ( chrome_exe ) ; shortcut_properties . set_working_dir ( chrome_exe . DirName ( ) ) ; string16 wide_switches ( GetAppListCommandLine ( ) . GetArgumentsString ( ) ) ; shortcut_properties . set_arguments ( wide_switches ) ; shortcut_properties . set_description ( shortcut_name ) ; shortcut_properties . set_icon ( chrome_exe , kAppListIconIndex ) ; shortcut_properties . set_app_id ( app_model_id ) ; base :: win :: CreateOrUpdateShortcutLink ( shortcut_path , shortcut_properties , base :: win :: SHORTCUT_CREATE_ALWAYS ) ; base :: win :: TaskbarPinShortcutLink ( shortcut_path . value ( ) . c_str ( ) ) ; return ; } if ( ! should_show && file_util :: PathExists ( shortcut_path ) ) { base :: win :: TaskbarUnpinShortcutLink ( shortcut_path . value ( ) . c_str ( ) ) ; file_util :: Delete ( shortcut_path , false ) ; } }
Check that a taskbar shortcut exists if it should, or does not exist if
it should not.
Check that a taskbar shortcut exists if it should or does not exist if it should not .
// This will not reshow a shortcut if it has been unpinned manually by the // user, as that will not delete the shortcut file.