Around 2% of all A stars have photospheres depleted in refractory elements. This is hypothesised to arise from gas being accreted more efficiently than dust, but the specific processes and the origin of the material -circum-or interstellar -are not known. The same depletion is seen in 30% of young, disk-hosting Herbig Ae/Be stars. We investigate whether the chemical peculiarity originates in a circumstellar disk. Using a sample of systems for which both the stellar abundances and the protoplanetary disk structure are known, we find that stars hosting warm, flaring group I disks typically have Fe, Mg and Si depletions of 0.5 dex compared to the solar-like abundances of stars hosting cold, flat group II disks. The volatile, C and O, abundances in both sets are identical. Group I disks are generally transitional, having radial cavities depleted in millimetre-sized dust grains, while those of group II are usually not. Thus we propose that the depletion of heavy elements emerges as Jupiter-like planets block the accretion of part of the dust, while gas continues to flow towards the central star. We calculate gas to dust ratios for the accreted material and find values consistent with models of disk clearing by planets. Our results suggest that giant planets of ∼0.1 to 10 M Jup are hiding in at least 30% of Herbig Ae/Be disks.