[Mac] During shutdown, do not post NSApplicationWillTerminateNotification twice.

In the quit path where zero browser windows are open,
-[BrowserCrApplication terminate:] was posting
NSApplicationWillTerminateNotification twice, via the stacks pasted on the bug.
Some system code assumes that after posting this notification, _exit() will be
called and so it does not bother removing itself as an observer, which leads
to a shutdown crash.

This change makes it so that browser::HandleAppExitingForPlatform() is
responsible for posting the notification. That function is called via
browser::OnAppExiting(), which is the final step in the cross-platform shutdown
code. At that time, all browsers have been closed and shutdown cannot be aborted,
so this should only ever be called once.

BUG=153283
TEST=Prayer and a sacrificial goat.

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@160443 0039d316-1c4b-4281-b951-d872f2087c98
2 files changed