OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/renderer/user_script_set.h" | 5 #include "extensions/renderer/user_script_set.h" |
6 | 6 |
| 7 #include "base/memory/ref_counted.h" |
7 #include "content/public/common/url_constants.h" | 8 #include "content/public/common/url_constants.h" |
8 #include "content/public/renderer/render_thread.h" | 9 #include "content/public/renderer/render_thread.h" |
9 #include "extensions/common/extension.h" | 10 #include "extensions/common/extension.h" |
10 #include "extensions/common/extension_set.h" | 11 #include "extensions/common/extension_set.h" |
11 #include "extensions/common/permissions/permissions_data.h" | 12 #include "extensions/common/permissions/permissions_data.h" |
| 13 #include "extensions/renderer/extension_injection_host.h" |
12 #include "extensions/renderer/extensions_renderer_client.h" | 14 #include "extensions/renderer/extensions_renderer_client.h" |
13 #include "extensions/renderer/script_context.h" | 15 #include "extensions/renderer/script_context.h" |
14 #include "extensions/renderer/script_injection.h" | 16 #include "extensions/renderer/script_injection.h" |
15 #include "extensions/renderer/user_script_injector.h" | 17 #include "extensions/renderer/user_script_injector.h" |
16 #include "third_party/WebKit/public/web/WebDocument.h" | 18 #include "third_party/WebKit/public/web/WebDocument.h" |
17 #include "third_party/WebKit/public/web/WebFrame.h" | 19 #include "third_party/WebKit/public/web/WebFrame.h" |
18 #include "url/gurl.h" | 20 #include "url/gurl.h" |
19 | 21 |
20 namespace extensions { | 22 namespace extensions { |
21 | 23 |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 | 189 |
188 GURL effective_document_url = ScriptContext::GetEffectiveDocumentURL( | 190 GURL effective_document_url = ScriptContext::GetEffectiveDocumentURL( |
189 web_frame, document_url, script->match_about_blank()); | 191 web_frame, document_url, script->match_about_blank()); |
190 | 192 |
191 if (!script->MatchesURL(effective_document_url)) | 193 if (!script->MatchesURL(effective_document_url)) |
192 return injection.Pass(); | 194 return injection.Pass(); |
193 | 195 |
194 scoped_ptr<ScriptInjector> injector(new UserScriptInjector(script, | 196 scoped_ptr<ScriptInjector> injector(new UserScriptInjector(script, |
195 this, | 197 this, |
196 is_declarative)); | 198 is_declarative)); |
| 199 HostID host_id(HostID::EXTENSIONS, extension->id()); |
| 200 ExtensionInjectionHost extension_injection_host( |
| 201 make_scoped_refptr<const Extension>(extension)); |
197 if (injector->CanExecuteOnFrame( | 202 if (injector->CanExecuteOnFrame( |
198 extension, | 203 &extension_injection_host, |
199 web_frame, | 204 web_frame, |
200 -1, // Content scripts are not tab-specific. | 205 -1, // Content scripts are not tab-specific. |
201 web_frame->top()->document().url()) == | 206 web_frame->top()->document().url()) == |
202 PermissionsData::ACCESS_DENIED) { | 207 PermissionsData::ACCESS_DENIED) { |
203 return injection.Pass(); | 208 return injection.Pass(); |
204 } | 209 } |
205 | 210 |
206 bool inject_css = !script->css_scripts().empty() && | 211 bool inject_css = !script->css_scripts().empty() && |
207 run_location == UserScript::DOCUMENT_START; | 212 run_location == UserScript::DOCUMENT_START; |
208 bool inject_js = | 213 bool inject_js = |
209 !script->js_scripts().empty() && script->run_location() == run_location; | 214 !script->js_scripts().empty() && script->run_location() == run_location; |
210 if (inject_css || inject_js) { | 215 if (inject_css || inject_js) { |
211 injection.reset(new ScriptInjection( | 216 injection.reset(new ScriptInjection( |
212 injector.Pass(), | 217 injector.Pass(), |
213 web_frame->toWebLocalFrame(), | 218 web_frame->toWebLocalFrame(), |
214 extension->id(), | 219 host_id, |
215 run_location, | 220 run_location, |
216 tab_id)); | 221 tab_id)); |
217 } | 222 } |
218 return injection.Pass(); | 223 return injection.Pass(); |
219 } | 224 } |
220 | 225 |
221 } // namespace extensions | 226 } // namespace extensions |
OLD | NEW |