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

Side by Side Diff: extensions/renderer/user_script_set.cc

Issue 1018163002: [Extensions] Skip injecting scripts into remote frames with site isolation turned on. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/memory/ref_counted.h"
8 #include "content/public/common/url_constants.h" 8 #include "content/public/common/url_constants.h"
9 #include "content/public/renderer/render_thread.h" 9 #include "content/public/renderer/render_thread.h"
10 #include "extensions/common/extension.h" 10 #include "extensions/common/extension.h"
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 197
198 GURL effective_document_url = ScriptContext::GetEffectiveDocumentURL( 198 GURL effective_document_url = ScriptContext::GetEffectiveDocumentURL(
199 web_frame, document_url, script->match_about_blank()); 199 web_frame, document_url, script->match_about_blank());
200 200
201 if (!script->MatchesURL(effective_document_url)) 201 if (!script->MatchesURL(effective_document_url))
202 return injection.Pass(); 202 return injection.Pass();
203 203
204 scoped_ptr<ScriptInjector> injector(new UserScriptInjector(script, 204 scoped_ptr<ScriptInjector> injector(new UserScriptInjector(script,
205 this, 205 this,
206 is_declarative)); 206 is_declarative));
207 if (injector->CanExecuteOnFrame( 207
208 injection_host.get(), 208 blink::WebDocument top_document = web_frame->top()->document();
Devlin 2015/03/18 22:49:31 nit: This seems like it should be one of the first
Devlin 2015/03/18 22:50:47 (I'll defer to nasko that this is a suitable diffe
not at google - send to devlin 2015/03/18 22:54:54 Another check would be to see if the top frame is
not at google - send to devlin 2015/03/18 22:54:54 It's a hack, and the least interesting check here
nasko 2015/03/19 17:33:48 Remote frames cannot host any documents or content
209 web_frame, 209 // This can be null if site isolation is turned on. The best we can do is to
210 -1, // Content scripts are not tab-specific. 210 // just give up - generally the wrong behavior, but better than crashing.
211 web_frame->top()->document().url()) == 211 // TODO(kalman): Fix this properly by moving all security checks into the
212 // browser. See http://crbug.com/466373 for ongoing work here.
213 if (top_document.isNull())
214 return injection.Pass();
215
216 if (injector->CanExecuteOnFrame(injection_host.get(), web_frame,
217 -1, // Content scripts are not tab-specific.
218 top_document.url()) ==
212 PermissionsData::ACCESS_DENIED) { 219 PermissionsData::ACCESS_DENIED) {
213 return injection.Pass(); 220 return injection.Pass();
214 } 221 }
215 222
216 bool inject_css = !script->css_scripts().empty() && 223 bool inject_css = !script->css_scripts().empty() &&
217 run_location == UserScript::DOCUMENT_START; 224 run_location == UserScript::DOCUMENT_START;
218 bool inject_js = 225 bool inject_js =
219 !script->js_scripts().empty() && script->run_location() == run_location; 226 !script->js_scripts().empty() && script->run_location() == run_location;
220 if (inject_css || inject_js) { 227 if (inject_css || inject_js) {
221 injection.reset(new ScriptInjection( 228 injection.reset(new ScriptInjection(
222 injector.Pass(), 229 injector.Pass(),
223 web_frame->toWebLocalFrame(), 230 web_frame->toWebLocalFrame(),
224 injection_host.Pass(), 231 injection_host.Pass(),
225 run_location, 232 run_location,
226 tab_id)); 233 tab_id));
227 } 234 }
228 return injection.Pass(); 235 return injection.Pass();
229 } 236 }
230 237
231 } // namespace extensions 238 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698