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

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

Issue 321533003: Separate PermissionsData::CanExecuteScriptOnPage into two functions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 | Annotate | Revision Log
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/script_injection.h" 5 #include "extensions/renderer/script_injection.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 return false; 247 return false;
248 248
249 // Content scripts are not tab-specific. 249 // Content scripts are not tab-specific.
250 static const int kNoTabId = -1; 250 static const int kNoTabId = -1;
251 // We don't have a process id in this context. 251 // We don't have a process id in this context.
252 static const int kNoProcessId = -1; 252 static const int kNoProcessId = -1;
253 253
254 GURL effective_document_url = ScriptContext::GetEffectiveDocumentURL( 254 GURL effective_document_url = ScriptContext::GetEffectiveDocumentURL(
255 frame, document_url, script_->match_about_blank()); 255 frame, document_url, script_->match_about_blank());
256 256
257 if (!extension->permissions_data()->CanExecuteScriptOnPage( 257 if (!script_->MatchesURL(effective_document_url))
258 return false;
259
260 if (!extension->permissions_data()->CanContentScriptPage(
258 extension, 261 extension,
259 effective_document_url, 262 effective_document_url,
260 frame->top()->document().url(), 263 frame->top()->document().url(),
261 kNoTabId, 264 kNoTabId,
262 script_.get(),
263 kNoProcessId, 265 kNoProcessId,
264 NULL /* ignore error */)) { 266 NULL /* ignore error */)) {
265 return false; 267 return false;
266 } 268 }
267 269
268 return ShouldInjectCSS(run_location) || ShouldInjectJS(run_location); 270 return ShouldInjectCSS(run_location) || ShouldInjectJS(run_location);
269 } 271 }
270 272
271 void ScriptInjection::Inject(blink::WebFrame* frame, 273 void ScriptInjection::Inject(blink::WebFrame* frame,
272 UserScript::RunLocation run_location, 274 UserScript::RunLocation run_location,
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 scripts_run_info->num_css += css_scripts.size(); 349 scripts_run_info->num_css += css_scripts.size();
348 for (UserScript::FileList::const_iterator iter = css_scripts.begin(); 350 for (UserScript::FileList::const_iterator iter = css_scripts.begin();
349 iter != css_scripts.end(); 351 iter != css_scripts.end();
350 ++iter) { 352 ++iter) {
351 frame->document().insertStyleSheet( 353 frame->document().insertStyleSheet(
352 blink::WebString::fromUTF8(iter->GetContent().as_string())); 354 blink::WebString::fromUTF8(iter->GetContent().as_string()));
353 } 355 }
354 } 356 }
355 357
356 } // namespace extensions 358 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698