the current light is connected to the white wires coming out of the box now.The two black wires are hooked together. can I hook the fan to the white wires like the light is now? Is it safe to do this? There is not ground in the box. When I looked in the breaker box, the white wires were hooked to the ground bar.
You're likely seeing what's called a "switch loop". So the white wire of the cable running between the switch and the light, is used as the switched hot. The wire should be reidentified as such, but it's often not.
If you're connecting the new light exactly as the old light was, you're probably okay. Use a voltmeter or multimeter to confirm, or have a look in the switch box.
I would guess that one is actually hot one neutral and not marked properly... The black to black connection is most likely going to a switch, and out of the switch for what ever reason they ran a white and did not label it... BUT it is always concerning when you do not see proper colors :) I would check the switch...