Fixes an old crash in GetCurrentPageActions().

This was caused by a race between navigation to an extension URL and updating
renderers about loaded extensions.

BUG=91582

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@117398 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc
index d26afbb..cadf4ff 100644
--- a/chrome/browser/extensions/extension_service.cc
+++ b/chrome/browser/extensions/extension_service.cc
@@ -943,13 +943,6 @@
   // extension.
   profile_->RegisterExtensionWithRequestContexts(extension);
 
-  // Tell subsystems that use the EXTENSION_LOADED notification about the new
-  // extension.
-  content::NotificationService::current()->Notify(
-      chrome::NOTIFICATION_EXTENSION_LOADED,
-      content::Source<Profile>(profile_),
-      content::Details<const Extension>(extension));
-
   // Tell renderers about the new extension, unless it's a theme (renderers
   // don't need to know about themes).
   if (!extension->is_theme()) {
@@ -969,6 +962,17 @@
     }
   }
 
+  // Tell subsystems that use the EXTENSION_LOADED notification about the new
+  // extension.
+  //
+  // NOTE: It is important that this happen after notifying the renderers about
+  // the new extensions so that if we navigate to an extension URL in
+  // NOTIFICATION_EXTENSION_LOADED, the renderer is guaranteed to know about it.
+  content::NotificationService::current()->Notify(
+      chrome::NOTIFICATION_EXTENSION_LOADED,
+      content::Source<Profile>(profile_),
+      content::Details<const Extension>(extension));
+
   // Tell a random-ass collection of other subsystems about the new extension.
   // TODO(aa): What should we do with all this goop? Can it move into the
   // relevant objects via EXTENSION_LOADED?