OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "extensions/browser/process_map.h" | 5 #include "extensions/browser/process_map.h" |
6 | 6 |
7 #include "content/public/browser/child_process_security_policy.h" | |
8 #include "extensions/browser/extension_registry.h" | |
7 #include "extensions/browser/process_map_factory.h" | 9 #include "extensions/browser/process_map_factory.h" |
10 #include "extensions/common/extension.h" | |
11 #include "extensions/common/features/feature.h" | |
8 | 12 |
9 namespace extensions { | 13 namespace extensions { |
10 | 14 |
11 // Item | 15 // Item |
12 struct ProcessMap::Item { | 16 struct ProcessMap::Item { |
13 Item() : process_id(0), site_instance_id(0) { | 17 Item() : process_id(0), site_instance_id(0) { |
14 } | 18 } |
15 | 19 |
16 // Purposely implicit constructor needed on older gcc's. See: | 20 // Purposely implicit constructor needed on older gcc's. See: |
17 // http://codereview.chromium.org/8769022/ | 21 // http://codereview.chromium.org/8769022/ |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
112 std::set<std::string> ProcessMap::GetExtensionsInProcess(int process_id) const { | 116 std::set<std::string> ProcessMap::GetExtensionsInProcess(int process_id) const { |
113 std::set<std::string> result; | 117 std::set<std::string> result; |
114 for (ItemSet::const_iterator iter = items_.begin(); iter != items_.end(); | 118 for (ItemSet::const_iterator iter = items_.begin(); iter != items_.end(); |
115 ++iter) { | 119 ++iter) { |
116 if (iter->process_id == process_id) | 120 if (iter->process_id == process_id) |
117 result.insert(iter->extension_id); | 121 result.insert(iter->extension_id); |
118 } | 122 } |
119 return result; | 123 return result; |
120 } | 124 } |
121 | 125 |
126 Feature::Context ProcessMap::GuessContextType(const Extension* extension, | |
127 int process_id) const { | |
128 // WARNING: This logic must match Dispatcher::ClassifyJavaScriptContext, as | |
129 // much as possible. | |
130 | |
131 if (content::ChildProcessSecurityPolicy::GetInstance()->HasWebUIBindings( | |
132 process_id)) { | |
133 return Feature::WEBUI_CONTEXT; | |
134 } | |
135 | |
136 if (!extension) { | |
137 return Feature::WEB_PAGE_CONTEXT; | |
138 } | |
139 | |
140 if (!Contains(extension->id(), process_id)) { | |
141 // This could equally be UNBLESSED_EXTENSION_CONTEXT, but we don't record | |
142 // which processes have extension frames in them. | |
143 // TODO(kalman): Investigate this. | |
144 return Feature::CONTENT_SCRIPT_CONTEXT; | |
145 } | |
146 | |
147 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.
| |
148 extension->location() != Manifest::COMPONENT) | |
149 ? Feature::BLESSED_WEB_PAGE_CONTEXT | |
150 : Feature::BLESSED_EXTENSION_CONTEXT; | |
151 } | |
152 | |
122 } // namespace extensions | 153 } // namespace extensions |
OLD | NEW |