Fix extension shutdown notification, take 2.

The first patch was broken because a lot of stuff relied on the EXTENSION_PROCESS_CRASHED notification being sent when the extension hadn't actually "crashed". New fix: rename the notification to EXTENSION_PROCESS_TERMINATED, and don't send unload notifications during browser shutdown.

BUG=30057

Review URL: http://codereview.chromium.org/489009

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@34489 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/extensions/extension_host.cc b/chrome/browser/extensions/extension_host.cc
index 767da27..525b2671 100644
--- a/chrome/browser/extensions/extension_host.cc
+++ b/chrome/browser/extensions/extension_host.cc
@@ -14,6 +14,7 @@
 #include "base/string_util.h"
 #include "chrome/browser/browser.h"
 #include "chrome/browser/browser_list.h"
+#include "chrome/browser/browser_shutdown.h"
 #include "chrome/browser/browser_theme_provider.h"
 #include "chrome/browser/browsing_instance.h"
 #include "chrome/browser/debugger/devtools_manager.h"
@@ -242,10 +243,16 @@
 }
 
 void ExtensionHost::RenderViewGone(RenderViewHost* render_view_host) {
-  LOG(INFO) << "Sending EXTENSION_PROCESS_CRASHED for " + extension_->name();
+  // During browser shutdown, we may use sudden termination on an extension
+  // process, so it is expected to lose our connection to the render view.
+  // Do nothing.
+  if (browser_shutdown::GetShutdownType() != browser_shutdown::NOT_VALID)
+    return;
+
+  LOG(INFO) << "Sending EXTENSION_PROCESS_TERMINATED for " + extension_->name();
   DCHECK_EQ(render_view_host_, render_view_host);
   NotificationService::current()->Notify(
-      NotificationType::EXTENSION_PROCESS_CRASHED,
+      NotificationType::EXTENSION_PROCESS_TERMINATED,
       Source<Profile>(profile_),
       Details<ExtensionHost>(this));
 }