Rework prerender browsertests to use base::RunLoop.

Remove most of the places where we content::RunMessageLoop() and then elsewhere
base::MessageLoop::current()->Quit(). Too many parts of the tests involve
spinning the message loop and waiting for one of three or four events to
happen, some complex conditions on some of the events when we want AND instead
of OR.

The primary change is a TestPrerender object vended out by the
TestPrerenderFactory. This object is a PrerenderObserver and holds a non-owning
reference to the TestPrerenderContents. Its lifetime is not tied to the
TestPrerenderContents and is managed by the caller. TestPrerender exposes
methods to wait for various events which replaces the content::RunMessageLoop
calls.

The hope is that this will make it easier to write tests which create multiple
prerenders and allow us to unbreak and reenable tests disabled because the old
wait conditions clobbered each other.

BUG=307592, 249179
TEST=Prerender*.*

Review URL: https://codereview.chromium.org/137263002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@245100 0039d316-1c4b-4281-b951-d872f2087c98
Media Galleries API Extension functions: Refactor Preference initialization block.

This refactors some repeated code, as we're about to add a few more extension calls.

BUG=161119

Review URL: https://codereview.chromium.org/137313003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@245101 0039d316-1c4b-4281-b951-d872f2087c98
SVN changes up to revision 245101
Fixing endless loop when getting the active profile

BUG=334098
TEST=none

Review URL: https://codereview.chromium.org/137323005

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@245102 0039d316-1c4b-4281-b951-d872f2087c98
SVN changes up to revision 245102