Judge Chin ruled that Google’s scanning of more than 20 million books for an electronic database, and making materials available for online searches constituted fair use. Also the use of Google Books for linguistic research on ngrams played a role in the decision.
See a documentary on NRK: http://tv.nrk.no/program/koid28009211/google-ein-kunnskapsbank
For the UK, see also the Hargreaves report