LONDON (CNN) -

Rebekah Brooks, a former newspaper editor and News Corp. executive, was grilled Friday about her close relationship with Prime Minister David Cameron and other top politicians at a UK inquiry into media ethics.

Brooks detailed frequent contacts with Cameron in the run-up to the 2010 election and said she had received commiserations from the prime minister when she resigned from News International last summer.

She said the message, along the lines of "keep your head up," was among a number of "indirect messages" of sympathy that top politicians sent to her.

Brooks resigned as chief executive of News International, the British arm of Rupert Murdoch's News Corp., in July amid public outrage over claims of widespread hacking by staff at its News of the World newspaper.

The government-appointed Leveson Inquiry, set up in response to the accusations of phone hacking by the News of the World, is examining the links between Britain's media and politics.

Brooks' testimony about the contacts she had with Britain's current and former prime ministers could prove embarrassing to them if it reveals too close a relationship.

And her evidence surrounding News Corp.'s bid to take over full ownership of British satellite broadcaster BSkyB may prompt further questions.

Brooks, who said she had an "informal role" in lobbying for the bid, told the inquiry she had discussed it with both Cameron and Chancellor of the Exchequer George Osborne.

An e-mail from a News Corp. employee to Brooks also suggested Culture Secretary Jeremy Hunt had asked him to advise privately on how News International was dealing with the phone hacking allegations, the inquiry heard.

The employee is known to have referred to contact with Hunt -- the Cabinet minister who oversees British broadcasting and who was charged with making an impartial decision on the bid -- when he in fact dealt with Hunt's aide.

The aide was forced to resign last month over revelations of apparent back-channel communications between his office and News Corp. over the bid.

The controversial bid was eventually abandoned last summer amid the furor over the phone hacking scandal.

Brooks said her discussion of the takeover with Cameron was not in depth, and that he made it clear it was not his decision to make.

She also argued in favor of the bid to Osborne over dinner, but he was not explicitly supportive of it, Brooks said. It was an appropriate conversation to have, she told inquiry lawyer Robert Jay, as she was entitled to reflect the opposite view to what Osborne had heard from many other news outlets.

In the closing minutes of her five hours of testimony -- during which she appeared largely composed but grew more testy as time wore on -- Brooks defended her position as an editor and chief executive.

She said "much has been made of cozy relationships and informal contacts" between journalists and politicians, but that it came down to individuals to ensure their conduct was professional.

The system is not perfect, she told the judge overseeing the inquiry, Lord Justice Leveson, but the current government has taken steps to improve transparency about meetings between the press and politicians.

Brooks said the phone hacking scandal increasingly occupied her time in her final months at News International.

But she denied being a "go-between" in an increasingly fraught relationship between Rupert Murdoch and his son James, and she dismissed the suggestion the younger Murdoch had sought to shift the blame to subordinates.

Brooks also said she never witnessed any inappropriate dealings with the police.