SAN FRANCISCO (Reuters) - Silicon Valley has tried to distance itself from the controversial U.S. surveillance programs exposed by Edward Snowden, but there is a long history of close cooperation between technology companies and the intelligence community.