She had known Blair for more than a decade, she said, with many social and political meetings in the time he was prime minister. They also spoke on the phone and had dinners together.
Brooks and her husband, Charlie Brooks, live near Cameron's constituency home and have socialized together. She attended a private birthday party for Cameron in late 2010.
Questioned about her working relationship with Rupert Murdoch, Brooks said she was close to him and believed he trusted her implicitly.
But she rejected the suggestion that politicians thought they had to go through her to get close to Murdoch.
Brooks acknowledged she had made friendships during her years as a journalist, editor and chief executive but said she was always aware that she was a journalist and they were politicians, and assumed they also were.
Asked whether The Sun engendered fear in politicians, Brooks said she did not see them as people who were easily scared.
Jay, the inquiry lawyer, pressed Brooks over her newspaper's role in putting pressure on the Cameron government, particularly Home Secretary Theresa May, to review the case of Madeleine McCann, a child abducted in Portugal.
Brooks said The Sun had tried to persuade the government to open a review but said "threat" was too strong a word to describe its efforts.
Brooks' appearance at the Leveson Inquiry came a day after fellow ex-News of the World editor Andy Coulson, who became director of communications for Cameron after he quit the paper, took to the stand.
Critics have questioned Cameron's judgment in hiring Coulson in 2007 and asked why he was not subjected to more rigorous security vetting.
Coulson resigned as Cameron's spokesman in January 2011 when police opened a new investigation into the scandal. He insisted he was innocent but said he had become a distraction for the government.
Questioned Thursday, Coulson said the jailing of two News of the World employees over phone hacking in 2007 did come up in discussions with senior party members before his job offer.
He told the inquiry he had told them and Cameron what he has said repeatedly -- that he knew nothing about the practice of hacking under his leadership of the paper.
Coulson said he never witnessed a conversation that was "inappropriate" between members of the government and News International.
He dismissed as a conspiracy theory the suggestion that Conservatives had struck some kind of deal on News Corp.'s takeover of BSkyB in return for Murdoch's support.