HardMac claims that there is a water sensor in both the iPod Touch and iPhone which allows Apple to determine if your iPhone was damaged due to being submerged in water.
At the bottom of the jack plug you can see a white disc that will irreversibly change color when entering in contact with water. So one would not need to open an iPhone or an iPod Touch to ensure it stopped working due to an unexpected bath.