Asked if she and Cameron had discussed the phone hacking allegations against News of the World, she said they had done so in very general terms.
In late 2010, they had a more detailed discussion, she said, because civil cases were in court and the issue was in the news.
Brooks was editor of News of the World in 2002 when the newspaper hacked the voice mail of a missing schoolgirl, Milly Dowler, who was later found dead. The hacking scandal led to the paper's closure in 2011. Brooks then edited The Sun, Britain's biggest-selling daily tabloid, from 2003 to 2009.
Cameron has said the relationship between the media and politicians has become "too cozy." He is expected to appear before the inquiry in the coming weeks.
Testifying Friday, Brooks told the inquiry she had received "indirect messages" of sympathy on her resignation in July, from 10 Downing Street, 11 Downing Street, the Home Office and the Foreign Office.
A "very few" Labour politicians sent messages of commiseration, Brooks said.
Former Prime Minister Tony Blair sent her a message, but his successor, Gordon Brown, did not, she said.
Blair's Labour Party benefited from the support of The Sun in three elections, but the paper switched allegiance to the Conservatives before the 2010 election in which Brown lost power.
In 2009, "we were running out of ways to support Mr. Brown's government," Brooks said, explaining what lay behind the paper's shift to Cameron in September that year.
She also said Brown had been "incredibly aggressive and very angry" in a phone call to her after The Sun published stories critical of his handling of a condolence letter to the family of a soldier killed in Afghanistan.
Brooks defended The Sun's handling of an article it published in 2006 about Brown's infant son, Fraser, having cystic fibrosis, which the former prime minister criticized in 2011.
Brooks denied the paper had illegally accessed Fraser's medical records. She did not reveal The Sun's source for the article but said the Browns had given permission for the paper to run it.
She said Brown had not raised concerns in the intervening years, when they continued to meet socially, and that "Mr. Brown's recollections of that time were not the same as my own."
Asked Friday if there was a danger that her newspaper got too close to those in power and their "spin doctors," Brooks said the job of journalists was to question what they were told and serve their readers.
Brooks acknowledged becoming friendly with Blair by the end of his decade in power but said she was less friendly with Brown. She was more friends with Brown's wife, Sarah, Brooks said.
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.