Fix crash in ExtensionProcessBindings

Fixes a crash in ExtensionProcessBindings, and updates a couple notification sources in ExtensionService to be profile aware.

BUG=87457, 91582
TEST=none


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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@97279 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc
index 4f393d0..c2f6431 100644
--- a/chrome/browser/extensions/extension_service.cc
+++ b/chrome/browser/extensions/extension_service.cc
@@ -2445,6 +2445,11 @@
     }
     case content::NOTIFICATION_RENDERER_PROCESS_CREATED: {
       RenderProcessHost* process = Source<RenderProcessHost>(source).ptr();
+      Profile* host_profile =
+          Profile::FromBrowserContext(process->browser_context());
+      if (!profile_->IsSameProfile(host_profile->GetOriginalProfile()))
+          break;
+
       // Valid extension function names, used to setup bindings in renderer.
       std::vector<std::string> function_names;
       ExtensionFunctionDispatcher::GetAllFunctionNames(&function_names);
@@ -2464,6 +2469,11 @@
     }
     case content::NOTIFICATION_RENDERER_PROCESS_TERMINATED: {
       RenderProcessHost* process = Source<RenderProcessHost>(source).ptr();
+      Profile* host_profile =
+          Profile::FromBrowserContext(process->browser_context());
+      if (!profile_->IsSameProfile(host_profile->GetOriginalProfile()))
+          break;
+
       installed_app_hosts_.erase(process->id());
       break;
     }