| 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 "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/pickle.h" | 8 #include "base/pickle.h" |
| 9 #include "base/shared_memory.h" | 9 #include "base/shared_memory.h" |
| 10 #include "chrome/common/resource_bundle.h" | 10 #include "chrome/common/resource_bundle.h" |
| 11 #include "chrome/renderer/renderer_resources.h" | 11 #include "chrome/renderer/renderer_resources.h" |
| 12 #include "googleurl/src/gurl.h" | 12 #include "googleurl/src/gurl.h" |
| 13 #include "webkit/glue/webframe.h" | |
| 14 | 13 |
| 15 // These two strings are injected before and after the Greasemonkey API and | 14 // These two strings are injected before and after the Greasemonkey API and |
| 16 // user script to wrap it in an anonymous scope. | 15 // user script to wrap it in an anonymous scope. |
| 17 static const char kUserScriptHead[] = "(function (unsafeWindow) {\n"; | 16 static const char kUserScriptHead[] = "(function (unsafeWindow) {\n"; |
| 18 static const char kUserScriptTail[] = "\n})(window);"; | 17 static const char kUserScriptTail[] = "\n})(window);"; |
| 19 | 18 |
| 20 UserScriptSlave::UserScriptSlave() | 19 UserScriptSlave::UserScriptSlave() |
| 21 : shared_memory_(NULL), | 20 : shared_memory_(NULL), |
| 22 script_deleter_(&scripts_), | 21 script_deleter_(&scripts_), |
| 23 user_script_start_line_(0) { | 22 user_script_start_line_(0) { |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 inject.append(script_contents_[*script].as_string()); | 96 inject.append(script_contents_[*script].as_string()); |
| 98 inject.append(kUserScriptTail); | 97 inject.append(kUserScriptTail); |
| 99 frame->ExecuteJavaScript(inject, | 98 frame->ExecuteJavaScript(inject, |
| 100 GURL((*script)->url().spec()), | 99 GURL((*script)->url().spec()), |
| 101 -user_script_start_line_); | 100 -user_script_start_line_); |
| 102 } | 101 } |
| 103 } | 102 } |
| 104 | 103 |
| 105 return true; | 104 return true; |
| 106 } | 105 } |
| OLD | NEW |