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