OLD | NEW |
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 21 matching lines...) Expand all Loading... |
32 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 32 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
33 #include "ui/base/resource/resource_bundle.h" | 33 #include "ui/base/resource/resource_bundle.h" |
34 | 34 |
35 using WebKit::WebFrame; | 35 using WebKit::WebFrame; |
36 using WebKit::WebSecurityOrigin; | 36 using WebKit::WebSecurityOrigin; |
37 using WebKit::WebSecurityPolicy; | 37 using WebKit::WebSecurityPolicy; |
38 using WebKit::WebString; | 38 using WebKit::WebString; |
39 using WebKit::WebVector; | 39 using WebKit::WebVector; |
40 using WebKit::WebView; | 40 using WebKit::WebView; |
41 using content::RenderThread; | 41 using content::RenderThread; |
| 42 using extensions::Extension; |
42 | 43 |
43 // These two strings are injected before and after the Greasemonkey API and | 44 // These two strings are injected before and after the Greasemonkey API and |
44 // user script to wrap it in an anonymous scope. | 45 // user script to wrap it in an anonymous scope. |
45 static const char kUserScriptHead[] = "(function (unsafeWindow) {\n"; | 46 static const char kUserScriptHead[] = "(function (unsafeWindow) {\n"; |
46 static const char kUserScriptTail[] = "\n})(window);"; | 47 static const char kUserScriptTail[] = "\n})(window);"; |
47 | 48 |
48 int UserScriptSlave::GetIsolatedWorldIdForExtension( | 49 int UserScriptSlave::GetIsolatedWorldIdForExtension( |
49 const Extension* extension, WebFrame* frame) { | 50 const Extension* extension, WebFrame* frame) { |
50 static int g_next_isolated_world_id = 1; | 51 static int g_next_isolated_world_id = 1; |
51 | 52 |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 if (num_scripts) | 334 if (num_scripts) |
334 UMA_HISTOGRAM_TIMES("Extensions.InjectEnd_Time", timer.Elapsed()); | 335 UMA_HISTOGRAM_TIMES("Extensions.InjectEnd_Time", timer.Elapsed()); |
335 } else if (location == UserScript::DOCUMENT_IDLE) { | 336 } else if (location == UserScript::DOCUMENT_IDLE) { |
336 UMA_HISTOGRAM_COUNTS_100("Extensions.InjectIdle_ScriptCount", num_scripts); | 337 UMA_HISTOGRAM_COUNTS_100("Extensions.InjectIdle_ScriptCount", num_scripts); |
337 if (num_scripts) | 338 if (num_scripts) |
338 UMA_HISTOGRAM_TIMES("Extensions.InjectIdle_Time", timer.Elapsed()); | 339 UMA_HISTOGRAM_TIMES("Extensions.InjectIdle_Time", timer.Elapsed()); |
339 } else { | 340 } else { |
340 NOTREACHED(); | 341 NOTREACHED(); |
341 } | 342 } |
342 } | 343 } |
OLD | NEW |