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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 | 173 |
174 return true; | 174 return true; |
175 } | 175 } |
176 | 176 |
177 // static | 177 // static |
178 void UserScriptSlave::InsertInitExtensionCode( | 178 void UserScriptSlave::InsertInitExtensionCode( |
179 std::vector<WebScriptSource>* sources, const std::string& extension_id) { | 179 std::vector<WebScriptSource>* sources, const std::string& extension_id) { |
180 DCHECK(sources); | 180 DCHECK(sources); |
181 bool incognito = ChromeRenderProcessObserver::is_incognito_process(); | 181 bool incognito = ChromeRenderProcessObserver::is_incognito_process(); |
182 sources->insert(sources->begin(), WebScriptSource(WebString::fromUTF8( | 182 sources->insert(sources->begin(), WebScriptSource(WebString::fromUTF8( |
183 StringPrintf(kInitExtension, extension_id.c_str(), | 183 base::StringPrintf(kInitExtension, |
184 incognito ? "true" : "false")))); | 184 extension_id.c_str(), |
| 185 incognito ? "true" : "false")))); |
185 } | 186 } |
186 | 187 |
187 void UserScriptSlave::InjectScripts(WebFrame* frame, | 188 void UserScriptSlave::InjectScripts(WebFrame* frame, |
188 UserScript::RunLocation location) { | 189 UserScript::RunLocation location) { |
189 GURL frame_url = GURL(frame->url()); | 190 GURL frame_url = GURL(frame->url()); |
190 if (frame_url.is_empty()) | 191 if (frame_url.is_empty()) |
191 return; | 192 return; |
192 | 193 |
193 PerfTimer timer; | 194 PerfTimer timer; |
194 int num_css = 0; | 195 int num_css = 0; |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 if (num_scripts) | 270 if (num_scripts) |
270 UMA_HISTOGRAM_TIMES("Extensions.InjectEnd_Time", timer.Elapsed()); | 271 UMA_HISTOGRAM_TIMES("Extensions.InjectEnd_Time", timer.Elapsed()); |
271 } else if (location == UserScript::DOCUMENT_IDLE) { | 272 } else if (location == UserScript::DOCUMENT_IDLE) { |
272 UMA_HISTOGRAM_COUNTS_100("Extensions.InjectIdle_ScriptCount", num_scripts); | 273 UMA_HISTOGRAM_COUNTS_100("Extensions.InjectIdle_ScriptCount", num_scripts); |
273 if (num_scripts) | 274 if (num_scripts) |
274 UMA_HISTOGRAM_TIMES("Extensions.InjectIdle_Time", timer.Elapsed()); | 275 UMA_HISTOGRAM_TIMES("Extensions.InjectIdle_Time", timer.Elapsed()); |
275 } else { | 276 } else { |
276 NOTREACHED(); | 277 NOTREACHED(); |
277 } | 278 } |
278 } | 279 } |
OLD | NEW |