As you know Google scans the websites on the Internet regularly. So it only makes sense that they are able to detect when sites have been hacked. Recently they have notified the webmasters of 20,000 websites where code on the sites redirect visitors to a malicious site. The code they look for in this latest scan is an eval() function used to execute Javascript.
The email provides a link to a page with instructions on how to clean the website: Google's Webmaster Tools support page.
I applaud Google's efforts and would like to see them continue this. A part of me, though, wonders how long until spammers start sending out fakes notices with link to their malicious site. Maybe they should just tell people to visit their search site and search for removing eval function from website -- I'm pretty sure they have the ability to redirect users to their fix page. ;)
This article talks about this item in further detail. http://www.h-online.com/security/news/item/Google-warns-the-operators-of-thousands-of-hacked-web-sites-1542374.html