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

Side by Side Diff: chrome/renderer/extensions/user_script_slave.cc

Issue 10443105: Take 2 at implementing activeTab. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: a unit test Created 8 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 (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
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 // Don't consider the tab ID when deciding whether to run content scripts;
Aaron Boodman 2012/06/06 01:03:13 I think this comment can just be: // Content scri
not at google - send to devlin 2012/06/06 07:38:40 Done.
not at google - send to devlin 2012/06/06 07:38:40 Done.
283 // they may be targeted at a specific site, so allowing them to run based
284 // on the tab would be wrong.
285 int no_tab_id = -1;
286
287 if (!extension->CanExecuteScriptOnPage(data_source_url,
288 no_tab_id,
289 script,
290 NULL)) {
283 continue; 291 continue;
292 }
284 293
285 // We rely on WebCore for CSS injection, but it's still useful to know how 294 // We rely on WebCore for CSS injection, but it's still useful to know how
286 // many css files there are. 295 // many css files there are.
287 if (location == UserScript::DOCUMENT_START) 296 if (location == UserScript::DOCUMENT_START)
288 num_css += script->css_scripts().size(); 297 num_css += script->css_scripts().size();
289 298
290 if (script->run_location() == location) { 299 if (script->run_location() == location) {
291 num_scripts += script->js_scripts().size(); 300 num_scripts += script->js_scripts().size();
292 for (size_t j = 0; j < script->js_scripts().size(); ++j) { 301 for (size_t j = 0; j < script->js_scripts().size(); ++j) {
293 UserScript::File &file = script->js_scripts()[j]; 302 UserScript::File &file = script->js_scripts()[j];
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 if (num_scripts) 364 if (num_scripts)
356 UMA_HISTOGRAM_TIMES("Extensions.InjectEnd_Time", timer.Elapsed()); 365 UMA_HISTOGRAM_TIMES("Extensions.InjectEnd_Time", timer.Elapsed());
357 } else if (location == UserScript::DOCUMENT_IDLE) { 366 } else if (location == UserScript::DOCUMENT_IDLE) {
358 UMA_HISTOGRAM_COUNTS_100("Extensions.InjectIdle_ScriptCount", num_scripts); 367 UMA_HISTOGRAM_COUNTS_100("Extensions.InjectIdle_ScriptCount", num_scripts);
359 if (num_scripts) 368 if (num_scripts)
360 UMA_HISTOGRAM_TIMES("Extensions.InjectIdle_Time", timer.Elapsed()); 369 UMA_HISTOGRAM_TIMES("Extensions.InjectIdle_Time", timer.Elapsed());
361 } else { 370 } else {
362 NOTREACHED(); 371 NOTREACHED();
363 } 372 }
364 } 373 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698