President Obama is positioning himself as a champion of the news media in the face of his successor President-elect Trump, a stance that's at odds with his mixed record on the press after eight years in office.

At his final press conference Wednesday, Obama sent a signal to Trump, thanking journalists in the room for their work in covering his administration and by defending them as vital to democracy.

"That does not, of course, mean that I've enjoyed every story that you have filed," he said. But that's the point of this relationship. You're not supposed to be sycophants, you're supposed to be skeptics. You're supposed to ask me tough questions… I spent a lot of time in my farewell address talking about the state of our democracy. It goes without saying that essential to that is a free press."

It was an obvious dagger meant for Trump, who has tried to discredit specific news outlets and journalists. Trump recently called CNN "fake news" for publishing critical reports about him, and Trump's team has hinted at big changes in how the new White House will work with the media.

But Obama's two terms are rife with attempts to crack down on leaks to the press, freeze out news outlets and limit media access.

Perhaps most memorably, Obama's Justice Department in early 2015 dropped a seven-year legal attempt to compel New York Times reporter James Risen to reveal a source he cited in a book that exposed a government plan to thwart Iran's nuclear program.

And there were other press freedom scandals throughout Obama's presidency.

In 2013, the Justice Department quietly seized phone records of several Associated Press journalists as part of an investigation into government leaks. The Washington Post called it a "sweeping and unusual move."

After a press conference last week, wherein Trump singled out CNN as "fake news," journalists pushed back and accused the incoming president of inappropriate and anti-press behavior. But Obama and his White House have a history of singling out Fox News as an outlet that it couldn't trust.

In 2011, Obama's communications team attempted to exclude Fox from an interview opportunity it had granted to virtually every other major TV news outlet.

"We've demonstrated our willingness and ability to exclude Fox News from significant interviews…" then-deputy press secretary Josh Earnest said at the time in an internal White House email that surfaced in news reports.

Journalists have noticed the hostilities from Obama's White House along the way. At an awards ceremony last March, Obama talked about the importance of the press in America's democracy, but also critiqued the way some reports offer what he viewed as false equivalence of competing ideas.

In response, Politico media columnist Jack Shafer said Obama was "the last person in the world who should be lecturing journalists on how to do journalism."

In 2015, James Risen, the Times reporter who was pressed by the Justice Department to reveal a source, called the Obama administration "the greatest enemy of press freedom in a generation."

Jill Abramson, former executive editor of the Times, has also called Obama's White House "the most secretive White House that I have ever been involved in covering…"

Trump, throughout the campaign and during the transition, has maintained an aggressive posture when it comes to the press that he frequently accuses him of being "unfair" and "dishonest."

But Reuters reporter Jeff Mason, who heads the White House Correspondents' Association, has said he's hopeful that the new administration will be cooperative with the news media.

"The WHCA looks forward to having a constructive relationship with the president-elect's press team and to standing up for the rights of a free press to report vigorously on the new administration," he said in a statement last week.