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 no_tab_id = -1; | |
Aaron Boodman
2012/06/08 05:31:30
Nit: const int kNoTabId.
not at google - send to devlin
2012/06/12 20:40:51
Done.
| |
284 | |
Aaron Boodman
2012/06/08 05:31:30
Nit: you can delete this blank line.
not at google - send to devlin
2012/06/12 20:40:51
Done.
| |
285 if (!extension->CanExecuteScriptOnPage(data_source_url, | |
286 no_tab_id, | |
287 script, | |
288 NULL)) { | |
283 continue; | 289 continue; |
290 } | |
284 | 291 |
285 // We rely on WebCore for CSS injection, but it's still useful to know how | 292 // We rely on WebCore for CSS injection, but it's still useful to know how |
286 // many css files there are. | 293 // many css files there are. |
287 if (location == UserScript::DOCUMENT_START) | 294 if (location == UserScript::DOCUMENT_START) |
288 num_css += script->css_scripts().size(); | 295 num_css += script->css_scripts().size(); |
289 | 296 |
290 if (script->run_location() == location) { | 297 if (script->run_location() == location) { |
291 num_scripts += script->js_scripts().size(); | 298 num_scripts += script->js_scripts().size(); |
292 for (size_t j = 0; j < script->js_scripts().size(); ++j) { | 299 for (size_t j = 0; j < script->js_scripts().size(); ++j) { |
293 UserScript::File &file = script->js_scripts()[j]; | 300 UserScript::File &file = script->js_scripts()[j]; |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
355 if (num_scripts) | 362 if (num_scripts) |
356 UMA_HISTOGRAM_TIMES("Extensions.InjectEnd_Time", timer.Elapsed()); | 363 UMA_HISTOGRAM_TIMES("Extensions.InjectEnd_Time", timer.Elapsed()); |
357 } else if (location == UserScript::DOCUMENT_IDLE) { | 364 } else if (location == UserScript::DOCUMENT_IDLE) { |
358 UMA_HISTOGRAM_COUNTS_100("Extensions.InjectIdle_ScriptCount", num_scripts); | 365 UMA_HISTOGRAM_COUNTS_100("Extensions.InjectIdle_ScriptCount", num_scripts); |
359 if (num_scripts) | 366 if (num_scripts) |
360 UMA_HISTOGRAM_TIMES("Extensions.InjectIdle_Time", timer.Elapsed()); | 367 UMA_HISTOGRAM_TIMES("Extensions.InjectIdle_Time", timer.Elapsed()); |
361 } else { | 368 } else { |
362 NOTREACHED(); | 369 NOTREACHED(); |
363 } | 370 } |
364 } | 371 } |
OLD | NEW |