Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/user_script_slave.h" | 5 #include "chrome/renderer/user_script_slave.h" |
| 6 | 6 |
| 7 #include "app/resource_bundle.h" | 7 #include "app/resource_bundle.h" |
| 8 #include "base/histogram.h" | 8 #include "base/histogram.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/perftimer.h" | 10 #include "base/perftimer.h" |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 153 sources.insert(sources.begin(), | 153 sources.insert(sources.begin(), |
| 154 WebScriptSource(WebString::fromUTF8(api_js_.as_string()))); | 154 WebScriptSource(WebString::fromUTF8(api_js_.as_string()))); |
| 155 } else { | 155 } else { |
| 156 // Setup chrome.self to contain an Extension object with the correct | 156 // Setup chrome.self to contain an Extension object with the correct |
| 157 // ID. | 157 // ID. |
| 158 sources.insert(sources.begin(), | 158 sources.insert(sources.begin(), |
| 159 WebScriptSource(WebString::fromUTF8( | 159 WebScriptSource(WebString::fromUTF8( |
| 160 StringPrintf(kInitExtension, script->extension_id().c_str())))); | 160 StringPrintf(kInitExtension, script->extension_id().c_str())))); |
| 161 } | 161 } |
| 162 | 162 |
| 163 frame->ExecuteScriptInNewContext(&sources.front(), sources.size()); | 163 frame->ExecuteScriptInNewWorld(&sources.front(), sources.size()); |
|
Aaron Boodman
2009/07/16 18:27:14
Whee! I'm on the edge of my seat :)
| |
| 164 } | 164 } |
| 165 } | 165 } |
| 166 | 166 |
| 167 // Log debug info. | 167 // Log debug info. |
| 168 if (location == UserScript::DOCUMENT_START) { | 168 if (location == UserScript::DOCUMENT_START) { |
| 169 HISTOGRAM_COUNTS_100("UserScripts:DocStart:Count", num_matched); | 169 HISTOGRAM_COUNTS_100("UserScripts:DocStart:Count", num_matched); |
| 170 HISTOGRAM_TIMES("UserScripts:DocStart:Time", timer.Elapsed()); | 170 HISTOGRAM_TIMES("UserScripts:DocStart:Time", timer.Elapsed()); |
| 171 } else { | 171 } else { |
| 172 HISTOGRAM_COUNTS_100("UserScripts:DocEnd:Count", num_matched); | 172 HISTOGRAM_COUNTS_100("UserScripts:DocEnd:Count", num_matched); |
| 173 HISTOGRAM_TIMES("UserScripts:DocEnd:Time", timer.Elapsed()); | 173 HISTOGRAM_TIMES("UserScripts:DocEnd:Time", timer.Elapsed()); |
| 174 } | 174 } |
| 175 | 175 |
| 176 LOG(INFO) << "Injected " << num_matched << " user scripts into " << | 176 LOG(INFO) << "Injected " << num_matched << " user scripts into " << |
| 177 frame->GetURL().spec(); | 177 frame->GetURL().spec(); |
| 178 return true; | 178 return true; |
| 179 } | 179 } |
| OLD | NEW |