Measurement of the prompt J/ψ and ψ(2S) polarizations in pp collisions at sqrt(s)=7 TeV