This mechanism has been around for a long time, so it is safe to say there is not a miniature camera inside the nozzle hooked to a microprocessor. It's purely mechanical -- and ingenious.
Near the tip of the nozzle is a small hole, and a small pipe leads back from the hole into the handle. Suction is applied to this pipe using a venturi. When the tank is not full, air is being drawn through the hole by the vacuum, and the air flows easily. When gasoline in the tank rises high enough to block the hole, a mechanical linkage in the handle senses the change in suction and flips the nozzle off.
Here's a way to think about it -- you've got a small pipe with suction being applied at one end and air flowing through the pipe easily. If you stick the free end of the pipe in a glass of water, much more suction is needed, so a vacuum develops in the middle of the pipe. That vacuum can be used to flip a lever that cuts off the nozzle.
The next time you fill up your tank, look for this hole either on the inside or the outside of the tip.
Here are some interesting links: