OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/extensions/user_script_slave.h" | 5 #include "chrome/renderer/extensions/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 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 if (frame->parent() && !script->match_all_frames()) | 272 if (frame->parent() && !script->match_all_frames()) |
273 continue; // Only match subframes if the script declared it wanted to. | 273 continue; // Only match subframes if the script declared it wanted to. |
274 | 274 |
275 const Extension* extension = extensions_->GetByID(script->extension_id()); | 275 const Extension* extension = extensions_->GetByID(script->extension_id()); |
276 | 276 |
277 // Since extension info is sent separately from user script info, they can | 277 // Since extension info is sent separately from user script info, they can |
278 // be out of sync. We just ignore this situation. | 278 // be out of sync. We just ignore this situation. |
279 if (!extension) | 279 if (!extension) |
280 continue; | 280 continue; |
281 | 281 |
282 if (!extension->CanExecuteScriptOnPage(data_source_url, script, NULL)) | 282 // Content scripts are not tab-specific. |
| 283 int kNoTabId = -1; |
| 284 if (!extension->CanExecuteScriptOnPage(data_source_url, |
| 285 kNoTabId, |
| 286 script, |
| 287 NULL)) { |
283 continue; | 288 continue; |
| 289 } |
284 | 290 |
285 // We rely on WebCore for CSS injection, but it's still useful to know how | 291 // We rely on WebCore for CSS injection, but it's still useful to know how |
286 // many css files there are. | 292 // many css files there are. |
287 if (location == UserScript::DOCUMENT_START) | 293 if (location == UserScript::DOCUMENT_START) |
288 num_css += script->css_scripts().size(); | 294 num_css += script->css_scripts().size(); |
289 | 295 |
290 if (script->run_location() == location) { | 296 if (script->run_location() == location) { |
291 num_scripts += script->js_scripts().size(); | 297 num_scripts += script->js_scripts().size(); |
292 for (size_t j = 0; j < script->js_scripts().size(); ++j) { | 298 for (size_t j = 0; j < script->js_scripts().size(); ++j) { |
293 UserScript::File &file = script->js_scripts()[j]; | 299 UserScript::File &file = script->js_scripts()[j]; |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 if (num_scripts) | 361 if (num_scripts) |
356 UMA_HISTOGRAM_TIMES("Extensions.InjectEnd_Time", timer.Elapsed()); | 362 UMA_HISTOGRAM_TIMES("Extensions.InjectEnd_Time", timer.Elapsed()); |
357 } else if (location == UserScript::DOCUMENT_IDLE) { | 363 } else if (location == UserScript::DOCUMENT_IDLE) { |
358 UMA_HISTOGRAM_COUNTS_100("Extensions.InjectIdle_ScriptCount", num_scripts); | 364 UMA_HISTOGRAM_COUNTS_100("Extensions.InjectIdle_ScriptCount", num_scripts); |
359 if (num_scripts) | 365 if (num_scripts) |
360 UMA_HISTOGRAM_TIMES("Extensions.InjectIdle_Time", timer.Elapsed()); | 366 UMA_HISTOGRAM_TIMES("Extensions.InjectIdle_Time", timer.Elapsed()); |
361 } else { | 367 } else { |
362 NOTREACHED(); | 368 NOTREACHED(); |
363 } | 369 } |
364 } | 370 } |
OLD | NEW |