Index: extensions/browser/process_map.cc |
diff --git a/extensions/browser/process_map.cc b/extensions/browser/process_map.cc |
index 3651f8af524fcc673756056ab1e3ce726addb210..b07d2da5553c01863bd1b203c3966bfa882e6c5a 100644 |
--- a/extensions/browser/process_map.cc |
+++ b/extensions/browser/process_map.cc |
@@ -4,7 +4,11 @@ |
#include "extensions/browser/process_map.h" |
+#include "content/public/browser/child_process_security_policy.h" |
+#include "extensions/browser/extension_registry.h" |
#include "extensions/browser/process_map_factory.h" |
+#include "extensions/common/extension.h" |
+#include "extensions/common/features/feature.h" |
namespace extensions { |
@@ -119,4 +123,31 @@ std::set<std::string> ProcessMap::GetExtensionsInProcess(int process_id) const { |
return result; |
} |
+Feature::Context ProcessMap::GuessContextType(const Extension* extension, |
+ int process_id) const { |
+ // WARNING: This logic must match Dispatcher::ClassifyJavaScriptContext, as |
+ // much as possible. |
+ |
+ if (content::ChildProcessSecurityPolicy::GetInstance()->HasWebUIBindings( |
+ process_id)) { |
+ return Feature::WEBUI_CONTEXT; |
+ } |
+ |
+ if (!extension) { |
+ return Feature::WEB_PAGE_CONTEXT; |
+ } |
+ |
+ if (!Contains(extension->id(), process_id)) { |
+ // This could equally be UNBLESSED_EXTENSION_CONTEXT, but we don't record |
+ // which processes have extension frames in them. |
+ // TODO(kalman): Investigate this. |
+ return Feature::CONTENT_SCRIPT_CONTEXT; |
+ } |
+ |
+ return (extension->is_hosted_app() && |
Ken Rockot(use gerrit already)
2014/08/06 21:44:45
I think it would be better to make more explicit t
not at google - send to devlin
2014/08/06 23:03:32
Done.
|
+ extension->location() != Manifest::COMPONENT) |
+ ? Feature::BLESSED_WEB_PAGE_CONTEXT |
+ : Feature::BLESSED_EXTENSION_CONTEXT; |
+} |
+ |
} // namespace extensions |