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" |
11 #include "base/pickle.h" | 11 #include "base/pickle.h" |
12 #include "base/shared_memory.h" | 12 #include "base/shared_memory.h" |
13 #include "base/string_util.h" | 13 #include "base/string_util.h" |
| 14 #include "chrome/renderer/extension_groups.h" |
14 #include "googleurl/src/gurl.h" | 15 #include "googleurl/src/gurl.h" |
15 #include "webkit/api/public/WebScriptSource.h" | 16 #include "webkit/api/public/WebScriptSource.h" |
16 #include "webkit/glue/webframe.h" | 17 #include "webkit/glue/webframe.h" |
17 | 18 |
18 #include "grit/renderer_resources.h" | 19 #include "grit/renderer_resources.h" |
19 | 20 |
20 using WebKit::WebScriptSource; | 21 using WebKit::WebScriptSource; |
21 using WebKit::WebString; | 22 using WebKit::WebString; |
22 | 23 |
23 // These two strings are injected before and after the Greasemonkey API and | 24 // These two strings are injected before and after the Greasemonkey API and |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 sources.insert(sources.begin(), | 154 sources.insert(sources.begin(), |
154 WebScriptSource(WebString::fromUTF8(api_js_.as_string()))); | 155 WebScriptSource(WebString::fromUTF8(api_js_.as_string()))); |
155 } else { | 156 } else { |
156 // Setup chrome.self to contain an Extension object with the correct | 157 // Setup chrome.self to contain an Extension object with the correct |
157 // ID. | 158 // ID. |
158 sources.insert(sources.begin(), | 159 sources.insert(sources.begin(), |
159 WebScriptSource(WebString::fromUTF8( | 160 WebScriptSource(WebString::fromUTF8( |
160 StringPrintf(kInitExtension, script->extension_id().c_str())))); | 161 StringPrintf(kInitExtension, script->extension_id().c_str())))); |
161 } | 162 } |
162 | 163 |
163 frame->ExecuteScriptInNewWorld(&sources.front(), sources.size()); | 164 frame->ExecuteScriptInNewWorld(&sources.front(), sources.size(), |
| 165 EXTENSION_GROUP_CONTENT_SCRIPTS); |
164 } | 166 } |
165 } | 167 } |
166 | 168 |
167 // Log debug info. | 169 // Log debug info. |
168 if (location == UserScript::DOCUMENT_START) { | 170 if (location == UserScript::DOCUMENT_START) { |
169 HISTOGRAM_COUNTS_100("UserScripts:DocStart:Count", num_matched); | 171 HISTOGRAM_COUNTS_100("UserScripts:DocStart:Count", num_matched); |
170 HISTOGRAM_TIMES("UserScripts:DocStart:Time", timer.Elapsed()); | 172 HISTOGRAM_TIMES("UserScripts:DocStart:Time", timer.Elapsed()); |
171 } else { | 173 } else { |
172 HISTOGRAM_COUNTS_100("UserScripts:DocEnd:Count", num_matched); | 174 HISTOGRAM_COUNTS_100("UserScripts:DocEnd:Count", num_matched); |
173 HISTOGRAM_TIMES("UserScripts:DocEnd:Time", timer.Elapsed()); | 175 HISTOGRAM_TIMES("UserScripts:DocEnd:Time", timer.Elapsed()); |
174 } | 176 } |
175 | 177 |
176 LOG(INFO) << "Injected " << num_matched << " user scripts into " << | 178 LOG(INFO) << "Injected " << num_matched << " user scripts into " << |
177 frame->GetURL().spec(); | 179 frame->GetURL().spec(); |
178 return true; | 180 return true; |
179 } | 181 } |
OLD | NEW |