Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(315)

Unified Diff: chrome/renderer/extensions/user_script_slave.cc

Issue 10863002: Added check to prevent extensions from injecting scrips into other extensions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: added test cases for self injection... and failed injection attempt Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/renderer/extensions/user_script_slave.cc
diff --git a/chrome/renderer/extensions/user_script_slave.cc b/chrome/renderer/extensions/user_script_slave.cc
index f9166632d1a2e6dd75584d013f5ae184aa94ab01..1ac0697cfacd1539e66a5e0aee3ad6aed3f23e9d 100644
--- a/chrome/renderer/extensions/user_script_slave.cc
+++ b/chrome/renderer/extensions/user_script_slave.cc
@@ -271,6 +271,10 @@ void UserScriptSlave::InjectScripts(WebFrame* frame,
if (frame->parent() && !script->match_all_frames())
continue; // Only match subframes if the script declared it wanted to.
+ WebFrame* parent_frame = frame;
+ while (parent_frame->parent())
+ parent_frame = parent_frame->parent();
abarth-chromium 2012/08/22 00:54:19 Does WebFrame really not have a top() accessor?
zel 2012/08/22 01:39:20 Done.
+
const Extension* extension = extensions_->GetByID(script->extension_id());
// Since extension info is sent separately from user script info, they can
@@ -281,6 +285,7 @@ void UserScriptSlave::InjectScripts(WebFrame* frame,
// Content scripts are not tab-specific.
int kNoTabId = -1;
if (!extension->CanExecuteScriptOnPage(data_source_url,
+ parent_frame->document().url(),
abarth-chromium 2012/08/22 00:54:19 parent_frame is really the top_frame or what we ca
zel 2012/08/22 01:39:20 used frame->top() accessor instead. done.
kNoTabId,
script,
NULL)) {

Powered by Google App Engine
This is Rietveld 408576698