| 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 |
| 11 #include "base/scoped_ptr.h" | 11 #include "base/scoped_ptr.h" |
| 12 #include "base/shared_memory.h" | 12 #include "base/shared_memory.h" |
| 13 #include "base/stl_util-inl.h" | 13 #include "base/stl_util-inl.h" |
| 14 #include "base/string_piece.h" | 14 #include "base/string_piece.h" |
| 15 #include "chrome/common/extensions/user_script.h" | 15 #include "chrome/common/extensions/user_script.h" |
| 16 | 16 |
| 17 namespace WebKit { |
| 17 class WebFrame; | 18 class WebFrame; |
| 19 } |
| 18 | 20 |
| 19 // Manages installed UserScripts for a render process. | 21 // Manages installed UserScripts for a render process. |
| 20 class UserScriptSlave { | 22 class UserScriptSlave { |
| 21 public: | 23 public: |
| 22 UserScriptSlave(); | 24 UserScriptSlave(); |
| 23 | 25 |
| 24 // Update the parsed scripts from shared memory. | 26 // Update the parsed scripts from shared memory. |
| 25 bool UpdateScripts(base::SharedMemoryHandle shared_memory); | 27 bool UpdateScripts(base::SharedMemoryHandle shared_memory); |
| 26 | 28 |
| 27 // Inject the appropriate scripts into a frame based on its URL. | 29 // Inject the appropriate scripts into a frame based on its URL. |
| 28 // TODO(aa): Extract a UserScriptFrame interface out of this to improve | 30 // TODO(aa): Extract a UserScriptFrame interface out of this to improve |
| 29 // testability. | 31 // testability. |
| 30 bool InjectScripts(WebFrame* frame, UserScript::RunLocation location); | 32 bool InjectScripts(WebKit::WebFrame* frame, UserScript::RunLocation location); |
| 31 | 33 |
| 32 private: | 34 private: |
| 33 // Shared memory containing raw script data. | 35 // Shared memory containing raw script data. |
| 34 scoped_ptr<base::SharedMemory> shared_memory_; | 36 scoped_ptr<base::SharedMemory> shared_memory_; |
| 35 | 37 |
| 36 // Parsed script data. | 38 // Parsed script data. |
| 37 std::vector<UserScript*> scripts_; | 39 std::vector<UserScript*> scripts_; |
| 38 STLElementDeleter<std::vector<UserScript*> > script_deleter_; | 40 STLElementDeleter<std::vector<UserScript*> > script_deleter_; |
| 39 | 41 |
| 40 // Greasemonkey API source that is injected with the scripts. | 42 // Greasemonkey API source that is injected with the scripts. |
| 41 StringPiece api_js_; | 43 StringPiece api_js_; |
| 42 | 44 |
| 43 // The line number of the first line of the user script among all of the | 45 // The line number of the first line of the user script among all of the |
| 44 // injected javascript. This is used to make reported errors correspond with | 46 // injected javascript. This is used to make reported errors correspond with |
| 45 // the proper line in the user script. | 47 // the proper line in the user script. |
| 46 int user_script_start_line_; | 48 int user_script_start_line_; |
| 47 | 49 |
| 48 DISALLOW_COPY_AND_ASSIGN(UserScriptSlave); | 50 DISALLOW_COPY_AND_ASSIGN(UserScriptSlave); |
| 49 }; | 51 }; |
| 50 | 52 |
| 51 #endif // CHROME_BROWSER_EXTENSIONS_USER_SCRIPT_SLAVE_H_ | 53 #endif // CHROME_BROWSER_EXTENSIONS_USER_SCRIPT_SLAVE_H_ |
| OLD | NEW |