| 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 #ifndef CHROME_BROWSER_EXTENSIONS_USER_SCRIPT_SLAVE_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_USER_SCRIPT_SLAVE_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_USER_SCRIPT_SLAVE_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_USER_SCRIPT_SLAVE_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 UserScriptSlave(); | 28 UserScriptSlave(); |
| 29 | 29 |
| 30 // Update the parsed scripts from shared memory. | 30 // Update the parsed scripts from shared memory. |
| 31 bool UpdateScripts(base::SharedMemoryHandle shared_memory); | 31 bool UpdateScripts(base::SharedMemoryHandle shared_memory); |
| 32 | 32 |
| 33 // Inject the appropriate scripts into a frame based on its URL. | 33 // Inject the appropriate scripts into a frame based on its URL. |
| 34 // TODO(aa): Extract a UserScriptFrame interface out of this to improve | 34 // TODO(aa): Extract a UserScriptFrame interface out of this to improve |
| 35 // testability. | 35 // testability. |
| 36 bool InjectScripts(WebKit::WebFrame* frame, UserScript::RunLocation location); | 36 bool InjectScripts(WebKit::WebFrame* frame, UserScript::RunLocation location); |
| 37 | 37 |
| 38 static int GetIsolatedWorldId(const std::string& extension_id); |
| 39 |
| 38 static void InsertInitExtensionCode(std::vector<WebScriptSource>* sources, | 40 static void InsertInitExtensionCode(std::vector<WebScriptSource>* sources, |
| 39 const std::string& extension_id); | 41 const std::string& extension_id); |
| 40 private: | 42 private: |
| 41 // Shared memory containing raw script data. | 43 // Shared memory containing raw script data. |
| 42 scoped_ptr<base::SharedMemory> shared_memory_; | 44 scoped_ptr<base::SharedMemory> shared_memory_; |
| 43 | 45 |
| 44 // Parsed script data. | 46 // Parsed script data. |
| 45 std::vector<UserScript*> scripts_; | 47 std::vector<UserScript*> scripts_; |
| 46 STLElementDeleter<std::vector<UserScript*> > script_deleter_; | 48 STLElementDeleter<std::vector<UserScript*> > script_deleter_; |
| 47 | 49 |
| 48 // Greasemonkey API source that is injected with the scripts. | 50 // Greasemonkey API source that is injected with the scripts. |
| 49 base::StringPiece api_js_; | 51 base::StringPiece api_js_; |
| 50 | 52 |
| 51 // The line number of the first line of the user script among all of the | 53 // The line number of the first line of the user script among all of the |
| 52 // injected javascript. This is used to make reported errors correspond with | 54 // injected javascript. This is used to make reported errors correspond with |
| 53 // the proper line in the user script. | 55 // the proper line in the user script. |
| 54 int user_script_start_line_; | 56 int user_script_start_line_; |
| 55 | 57 |
| 56 DISALLOW_COPY_AND_ASSIGN(UserScriptSlave); | 58 DISALLOW_COPY_AND_ASSIGN(UserScriptSlave); |
| 57 }; | 59 }; |
| 58 | 60 |
| 59 #endif // CHROME_BROWSER_EXTENSIONS_USER_SCRIPT_SLAVE_H_ | 61 #endif // CHROME_BROWSER_EXTENSIONS_USER_SCRIPT_SLAVE_H_ |
| OLD | NEW |