I don't believe this is a correct explanation for why photons travel
more slowly through matter than through empty space. It has nothing to
do with gravity, which would be inconceivably small at this scale.
Rather, the photons interact with the electrons around the atom.
In effect, the photons are constantly being absorbed and almost instantly
re-emitted. Phase and other state information is preserved, but the
photons end up being slowed down. Once the photon re-enters vacuum it
is able to proceed unimpeded at c.
It is possible to travel faster than photons within matter. If a charged
particle does so will it will be slowed down by the electrons and will
emit Cherenkov radiation, something like a "sonic boom" but of light.
Hal