What do Facebook and Google have in common with the National Security Agency?

They're adept at spying.

NSA officials say they're hunting terrorists. Internet and social media companies are hunting profits.

Both the spy agency and the webmasters rely on information that ordinary citizens may consider private, and neither welcomes scrutiny of its data-mining practices.

Privacy debates have focused almost exclusively on the government in the six months since leaked documents revealed the extent of the NSA's snooping on ordinary Americans as well as citizens, and even the elected leaders, of other countries, including close U.S. allies.

It's easy to see why.

We now know that the NSA gathers records of phone calls, including who talks to whom, when and for how long, and copies email and other online communications on a real-time basis. We also know that the agency has, at times, ignored boundaries set by federal law and by a special court that handles national security matters.

This past week, a federal judge ruled that the NSA's systematic collection of telephone records probably violates Fourth Amendment protections against unreasonable searches. Judge Richard J. DeLeon described the practice as "almost Orwellian" and, undercutting the program's rationale, he noted that the government hadn't cited "a single instance" where it prevented an imminent attack.

Two days later, the White House released an advisory committee's report on U.S. surveillance programs. Among the panel's 46 recommendations is ending the practice of collecting and storing Americans' phone records. The NSA and other intelligence agencies would instead need a court order to obtain the records from phone companies.

Before the NSA revelations, concerns about privacy and telecommunications often involved data mining by online companies such as Google, Yahoo and Facebook.

Some of these companies are the harshest critics of government snooping, warning that it will drive their users away.

The irony is that many of them rely on users voluntarily — and perhaps not so voluntarily — sharing information more detailed and more personal than the telephone meta-data gathered by the government.

It didn't take a leak of classified documents to figure that out. Only the most naive Internet users aren't aware that their activities are cataloged and used to place ads matching their interests on the screen.

Only the savviest users probably understand that information they didn't share can be systematically collected and analyzed, too.

In 2010, we learned that Google's Street View cars collected data from unsecured home wireless networks. Facebook recently tracked the activity of 5 million users for 17 days to see when they typed something but didn't post it. Is nothing secret?

The privacy issue isn't going away. Many of the boundaries will be set in Congress and the courts. But a summary offered to the New York Times by Richard A. Clarke, a member of the White House's advisory panel, may be a good guideline for public agencies and commercial interests alike:

"What we're saying is just because we can doesn't mean we should."