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

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

Issue 309533007: Refactor PermissionsData pt1 (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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 return false; 94 return false;
95 95
96 // Content scripts are not tab-specific. 96 // Content scripts are not tab-specific.
97 static const int kNoTabId = -1; 97 static const int kNoTabId = -1;
98 // We don't have a process id in this context. 98 // We don't have a process id in this context.
99 static const int kNoProcessId = -1; 99 static const int kNoProcessId = -1;
100 100
101 GURL effective_document_url = ScriptContext::GetEffectiveDocumentURL( 101 GURL effective_document_url = ScriptContext::GetEffectiveDocumentURL(
102 frame, document_url, script_->match_about_blank()); 102 frame, document_url, script_->match_about_blank());
103 103
104 if (!PermissionsData::CanExecuteScriptOnPage(extension, 104 if (!PermissionsData::ForExtension(extension)
105 effective_document_url, 105 ->CanExecuteScriptOnPage(extension,
106 frame->top()->document().url(), 106 effective_document_url,
107 kNoTabId, 107 frame->top()->document().url(),
108 script_.get(), 108 kNoTabId,
109 kNoProcessId, 109 script_.get(),
110 NULL /* ignore error */)) { 110 kNoProcessId,
111 NULL /* ignore error */)) {
111 return false; 112 return false;
112 } 113 }
113 114
114 return ShouldInjectCSS(run_location) || ShouldInjectJS(run_location); 115 return ShouldInjectCSS(run_location) || ShouldInjectJS(run_location);
115 } 116 }
116 117
117 void ScriptInjection::Inject(blink::WebFrame* frame, 118 void ScriptInjection::Inject(blink::WebFrame* frame,
118 UserScript::RunLocation run_location, 119 UserScript::RunLocation run_location,
119 ScriptsRunInfo* scripts_run_info) const { 120 ScriptsRunInfo* scripts_run_info) const {
120 DCHECK(frame); 121 DCHECK(frame);
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 scripts_run_info->num_css += css_scripts.size(); 194 scripts_run_info->num_css += css_scripts.size();
194 for (UserScript::FileList::const_iterator iter = css_scripts.begin(); 195 for (UserScript::FileList::const_iterator iter = css_scripts.begin();
195 iter != css_scripts.end(); 196 iter != css_scripts.end();
196 ++iter) { 197 ++iter) {
197 frame->document().insertStyleSheet( 198 frame->document().insertStyleSheet(
198 blink::WebString::fromUTF8(iter->GetContent().as_string())); 199 blink::WebString::fromUTF8(iter->GetContent().as_string()));
199 } 200 }
200 } 201 }
201 202
202 } // namespace extensions 203 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698