OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
232 void UserScriptSlave::InjectScripts(WebFrame* frame, | 232 void UserScriptSlave::InjectScripts(WebFrame* frame, |
233 UserScript::RunLocation location) { | 233 UserScript::RunLocation location) { |
234 // Normally we would use frame->document().url() to determine the document's | 234 // Normally we would use frame->document().url() to determine the document's |
235 // URL, but to decide whether to inject a content script, we use the URL from | 235 // URL, but to decide whether to inject a content script, we use the URL from |
236 // the data source. This "quirk" helps prevents content scripts from | 236 // the data source. This "quirk" helps prevents content scripts from |
237 // inadvertently adding DOM elements to the compose iframe in Gmail because | 237 // inadvertently adding DOM elements to the compose iframe in Gmail because |
238 // the compose iframe's dataSource URL is about:blank, but the document URL | 238 // the compose iframe's dataSource URL is about:blank, but the document URL |
239 // changes to match the parent document after Gmail document.writes into | 239 // changes to match the parent document after Gmail document.writes into |
240 // it to create the editor. | 240 // it to create the editor. |
241 // http://code.google.com/p/chromium/issues/detail?id=86742 | 241 // http://code.google.com/p/chromium/issues/detail?id=86742 |
242 GURL data_source_url = GURL(frame->dataSource()->request().url()); | 242 WebKit::WebDataSource* data_source = frame->dataSource() ? |
243 frame->dataSource() : frame->provisionalDataSource(); | |
244 DCHECK(data_source); | |
Aaron Boodman
2011/09/27 06:00:47
You should CHECK this. If NULL, it will crash soon
| |
245 GURL data_source_url = GURL(data_source->request().url()); | |
243 if (data_source_url.is_empty()) | 246 if (data_source_url.is_empty()) |
244 return; | 247 return; |
245 | 248 |
246 if (frame->isViewSourceModeEnabled()) | 249 if (frame->isViewSourceModeEnabled()) |
247 data_source_url = GURL(chrome::kViewSourceScheme + std::string(":") + | 250 data_source_url = GURL(chrome::kViewSourceScheme + std::string(":") + |
248 data_source_url.spec()); | 251 data_source_url.spec()); |
249 | 252 |
250 PerfTimer timer; | 253 PerfTimer timer; |
251 int num_css = 0; | 254 int num_css = 0; |
252 int num_scripts = 0; | 255 int num_scripts = 0; |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
327 if (num_scripts) | 330 if (num_scripts) |
328 UMA_HISTOGRAM_TIMES("Extensions.InjectEnd_Time", timer.Elapsed()); | 331 UMA_HISTOGRAM_TIMES("Extensions.InjectEnd_Time", timer.Elapsed()); |
329 } else if (location == UserScript::DOCUMENT_IDLE) { | 332 } else if (location == UserScript::DOCUMENT_IDLE) { |
330 UMA_HISTOGRAM_COUNTS_100("Extensions.InjectIdle_ScriptCount", num_scripts); | 333 UMA_HISTOGRAM_COUNTS_100("Extensions.InjectIdle_ScriptCount", num_scripts); |
331 if (num_scripts) | 334 if (num_scripts) |
332 UMA_HISTOGRAM_TIMES("Extensions.InjectIdle_Time", timer.Elapsed()); | 335 UMA_HISTOGRAM_TIMES("Extensions.InjectIdle_Time", timer.Elapsed()); |
333 } else { | 336 } else { |
334 NOTREACHED(); | 337 NOTREACHED(); |
335 } | 338 } |
336 } | 339 } |
OLD | NEW |