| 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 "content/public/common/url_constants.h" | 7 #include "content/public/common/url_constants.h" |
| 8 #include "content/public/renderer/render_thread.h" | 8 #include "content/public/renderer/render_thread.h" |
| 9 #include "extensions/common/extension.h" | 9 #include "extensions/common/extension.h" |
| 10 #include "extensions/common/extension_messages.h" | 10 #include "extensions/common/extension_messages.h" |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 scoped_ptr<ScriptInjection> injection; | 184 scoped_ptr<ScriptInjection> injection; |
| 185 if (web_frame->parent() && !script->match_all_frames()) | 185 if (web_frame->parent() && !script->match_all_frames()) |
| 186 return injection.Pass(); // Only match subframes if the script declared it. | 186 return injection.Pass(); // Only match subframes if the script declared it. |
| 187 | 187 |
| 188 GURL effective_document_url = ScriptContext::GetEffectiveDocumentURL( | 188 GURL effective_document_url = ScriptContext::GetEffectiveDocumentURL( |
| 189 web_frame, document_url, script->match_about_blank()); | 189 web_frame, document_url, script->match_about_blank()); |
| 190 | 190 |
| 191 if (!script->MatchesURL(effective_document_url)) | 191 if (!script->MatchesURL(effective_document_url)) |
| 192 return injection.Pass(); | 192 return injection.Pass(); |
| 193 | 193 |
| 194 if (!extension->permissions_data()->CanRunContentScriptOnPage( | 194 if (extension->permissions_data()->CanRunContentScriptOnPageWithUserConsent( |
| 195 extension, | 195 extension, |
| 196 effective_document_url, | 196 effective_document_url, |
| 197 web_frame->top()->document().url(), | 197 web_frame->top()->document().url(), |
| 198 -1, // Content scripts are not tab-specific. | 198 -1, // Content scripts are not tab-specific. |
| 199 -1, // We don't have a process id in this context. | 199 -1, // We don't have a process id in this context. |
| 200 NULL /* ignore error */)) { | 200 NULL /* ignore error */) == PermissionsData::DENY_ACCESS) { |
| 201 return injection.Pass(); | 201 return injection.Pass(); |
| 202 } | 202 } |
| 203 | 203 |
| 204 bool inject_css = !script->css_scripts().empty() && | 204 bool inject_css = !script->css_scripts().empty() && |
| 205 run_location == UserScript::DOCUMENT_START; | 205 run_location == UserScript::DOCUMENT_START; |
| 206 bool inject_js = | 206 bool inject_js = |
| 207 !script->js_scripts().empty() && script->run_location() == run_location; | 207 !script->js_scripts().empty() && script->run_location() == run_location; |
| 208 if (inject_css || inject_js) { | 208 if (inject_css || inject_js) { |
| 209 injection.reset(new ScriptInjection( | 209 injection.reset(new ScriptInjection( |
| 210 scoped_ptr<ScriptInjector>(new UserScriptInjector(script, this)), | 210 scoped_ptr<ScriptInjector>(new UserScriptInjector(script, this)), |
| 211 web_frame, | 211 web_frame, |
| 212 extension->id(), | 212 extension->id(), |
| 213 run_location, | 213 run_location, |
| 214 tab_id)); | 214 tab_id)); |
| 215 } | 215 } |
| 216 return injection.Pass(); | 216 return injection.Pass(); |
| 217 } | 217 } |
| 218 | 218 |
| 219 } // namespace extensions | 219 } // namespace extensions |
| OLD | NEW |