Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/renderer/user_script_slave.h" | 5 #include "chrome/renderer/user_script_slave.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 196 int num_css = 0; | 196 int num_css = 0; |
| 197 int num_scripts = 0; | 197 int num_scripts = 0; |
| 198 | 198 |
| 199 for (size_t i = 0; i < scripts_.size(); ++i) { | 199 for (size_t i = 0; i < scripts_.size(); ++i) { |
| 200 std::vector<WebScriptSource> sources; | 200 std::vector<WebScriptSource> sources; |
| 201 UserScript* script = scripts_[i]; | 201 UserScript* script = scripts_[i]; |
| 202 | 202 |
| 203 if (frame->parent() && !script->match_all_frames()) | 203 if (frame->parent() && !script->match_all_frames()) |
| 204 continue; // Only match subframes if the script declared it wanted to. | 204 continue; // Only match subframes if the script declared it wanted to. |
| 205 | 205 |
| 206 ExtensionRendererInfo* extension = | 206 scoped_refptr<const Extension> extension = |
|
Matt Perry
2011/01/24 20:08:34
raw ptr
Aaron Boodman
2011/01/25 00:27:33
Done.
| |
| 207 ExtensionRendererInfo::GetByID(script->extension_id()); | 207 RenderThread::current()->extensions()->GetByID(script->extension_id()); |
| 208 | 208 |
| 209 // Since extension info is sent separately from user script info, they can | 209 // Since extension info is sent separately from user script info, they can |
| 210 // be out of sync. We just ignore this situation. | 210 // be out of sync. We just ignore this situation. |
| 211 if (!extension) | 211 if (!extension) |
| 212 continue; | 212 continue; |
| 213 | 213 |
| 214 if (!Extension::CanExecuteScriptOnPage( | 214 if (!extension->CanExecuteScriptOnPage(frame_url, script, NULL)) |
| 215 frame_url, | |
| 216 extension->allowed_to_execute_script_everywhere(), | |
| 217 NULL, | |
| 218 script, | |
| 219 NULL)) { | |
| 220 continue; | 215 continue; |
| 221 } | |
| 222 | 216 |
| 223 if (frame_url.SchemeIsFile() && !script->allow_file_access()) | 217 if (frame_url.SchemeIsFile() && !script->allow_file_access()) |
| 224 continue; // This script isn't allowed to run on file URLs. | 218 continue; // This script isn't allowed to run on file URLs. |
| 225 | 219 |
| 226 // We rely on WebCore for CSS injection, but it's still useful to know how | 220 // We rely on WebCore for CSS injection, but it's still useful to know how |
| 227 // many css files there are. | 221 // many css files there are. |
| 228 if (location == UserScript::DOCUMENT_START) | 222 if (location == UserScript::DOCUMENT_START) |
| 229 num_css += script->css_scripts().size(); | 223 num_css += script->css_scripts().size(); |
| 230 | 224 |
| 231 if (script->run_location() == location) { | 225 if (script->run_location() == location) { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 281 if (num_scripts) | 275 if (num_scripts) |
| 282 UMA_HISTOGRAM_TIMES("Extensions.InjectEnd_Time", timer.Elapsed()); | 276 UMA_HISTOGRAM_TIMES("Extensions.InjectEnd_Time", timer.Elapsed()); |
| 283 } else if (location == UserScript::DOCUMENT_IDLE) { | 277 } else if (location == UserScript::DOCUMENT_IDLE) { |
| 284 UMA_HISTOGRAM_COUNTS_100("Extensions.InjectIdle_ScriptCount", num_scripts); | 278 UMA_HISTOGRAM_COUNTS_100("Extensions.InjectIdle_ScriptCount", num_scripts); |
| 285 if (num_scripts) | 279 if (num_scripts) |
| 286 UMA_HISTOGRAM_TIMES("Extensions.InjectIdle_Time", timer.Elapsed()); | 280 UMA_HISTOGRAM_TIMES("Extensions.InjectIdle_Time", timer.Elapsed()); |
| 287 } else { | 281 } else { |
| 288 NOTREACHED(); | 282 NOTREACHED(); |
| 289 } | 283 } |
| 290 } | 284 } |
| OLD | NEW |