Financially failing care homes will be taken into public ownership under a Labour government in order to protect social care provision, Jeremy Corbyn has said.