Chromium Code Reviews| Index: extensions/renderer/user_script_set.cc |
| diff --git a/extensions/renderer/user_script_set.cc b/extensions/renderer/user_script_set.cc |
| index 8582184bbb68a0a703b40c5934e7da5065b076fb..0326e100e140ecce2f554d218841e2266e46bdd1 100644 |
| --- a/extensions/renderer/user_script_set.cc |
| +++ b/extensions/renderer/user_script_set.cc |
| @@ -72,7 +72,13 @@ void UserScriptSet::GetInjections( |
| if (!extension) |
| continue; |
| scoped_ptr<ScriptInjection> injection = GetInjectionForScript( |
| - *iter, web_frame, tab_id, run_location, document_url, extension); |
| + *iter, |
| + web_frame, |
| + tab_id, |
| + run_location, |
| + document_url, |
| + extension, |
| + false /* is_declarative */); |
| if (injection.get()) |
| injections->push_back(injection.release()); |
| } |
| @@ -143,13 +149,37 @@ bool UserScriptSet::UpdateUserScripts( |
| return true; |
| } |
| +scoped_ptr<ScriptInjection> UserScriptSet::GetInjectionByScriptID( |
| + int script_id, |
| + blink::WebFrame* web_frame, |
| + int tab_id, |
| + UserScript::RunLocation run_location, |
| + const GURL& document_url, |
| + const Extension* extension) { |
| + for (ScopedVector<UserScript>::const_iterator it = scripts_.begin(); |
| + it != scripts_.end(); |
| + ++it) { |
| + if ((*it)->id() == script_id) { |
| + return GetInjectionForScript(*it, |
| + web_frame, |
| + tab_id, |
| + run_location, |
| + document_url, |
| + extension, |
| + true /* is_declarative */); |
|
Devlin
2014/08/25 22:31:06
We should either pass this in as a param or rename
Mark Dittmer
2014/08/27 21:21:48
Done.
|
| + } |
| + } |
| + return scoped_ptr<ScriptInjection>(); |
| +} |
| + |
| scoped_ptr<ScriptInjection> UserScriptSet::GetInjectionForScript( |
| UserScript* script, |
| blink::WebFrame* web_frame, |
| int tab_id, |
| UserScript::RunLocation run_location, |
| const GURL& document_url, |
| - const Extension* extension) { |
| + const Extension* extension, |
| + bool is_declarative) { |
| scoped_ptr<ScriptInjection> injection; |
| if (web_frame->parent() && !script->match_all_frames()) |
| return injection.Pass(); // Only match subframes if the script declared it. |
| @@ -160,13 +190,15 @@ scoped_ptr<ScriptInjection> UserScriptSet::GetInjectionForScript( |
| if (!script->MatchesURL(effective_document_url)) |
| return injection.Pass(); |
| - if (extension->permissions_data()->GetContentScriptAccess( |
| + scoped_ptr<ScriptInjector> injector(new UserScriptInjector(script, |
| + this, |
| + is_declarative)); |
| + if (injector->CanExecuteOnFrame( |
| extension, |
| - effective_document_url, |
| - web_frame->top()->document().url(), |
| + web_frame, |
| -1, // Content scripts are not tab-specific. |
| - -1, // We don't have a process id in this context. |
| - NULL /* ignore error */) == PermissionsData::ACCESS_DENIED) { |
| + web_frame->top()->document().url()) == |
| + PermissionsData::ACCESS_DENIED) { |
| return injection.Pass(); |
| } |
| @@ -176,7 +208,7 @@ scoped_ptr<ScriptInjection> UserScriptSet::GetInjectionForScript( |
| !script->js_scripts().empty() && script->run_location() == run_location; |
| if (inject_css || inject_js) { |
| injection.reset(new ScriptInjection( |
| - scoped_ptr<ScriptInjector>(new UserScriptInjector(script, this)), |
| + injector.Pass(), |
| web_frame, |
| extension->id(), |
| run_location, |