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_RENDERER_USER_SCRIPT_SLAVE_H_ | 5 #ifndef CHROME_RENDERER_USER_SCRIPT_SLAVE_H_ |
6 #define CHROME_RENDERER_USER_SCRIPT_SLAVE_H_ | 6 #define CHROME_RENDERER_USER_SCRIPT_SLAVE_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 13 matching lines...) Expand all Loading... |
24 using WebKit::WebScriptSource; | 24 using WebKit::WebScriptSource; |
25 | 25 |
26 // Manages installed UserScripts for a render process. | 26 // Manages installed UserScripts for a render process. |
27 class UserScriptSlave { | 27 class UserScriptSlave { |
28 public: | 28 public: |
29 UserScriptSlave(); | 29 UserScriptSlave(); |
30 | 30 |
31 // Returns the unique set of extension IDs this UserScriptSlave knows about. | 31 // Returns the unique set of extension IDs this UserScriptSlave knows about. |
32 void GetActiveExtensions(std::set<std::string>* extension_ids); | 32 void GetActiveExtensions(std::set<std::string>* extension_ids); |
33 | 33 |
34 // Update the parsed scripts from shared memory. | 34 // Update the parsed scripts from shared memory. If |only_inject_incognito| |
35 bool UpdateScripts(base::SharedMemoryHandle shared_memory); | 35 // is true, we will only use the scripts that have been marked as enabled for |
| 36 // incognito mode. |
| 37 bool UpdateScripts(base::SharedMemoryHandle shared_memory, |
| 38 bool only_inject_incognito); |
36 | 39 |
37 // Inject the appropriate scripts into a frame based on its URL. | 40 // Inject the appropriate scripts into a frame based on its URL. |
38 // TODO(aa): Extract a UserScriptFrame interface out of this to improve | 41 // TODO(aa): Extract a UserScriptFrame interface out of this to improve |
39 // testability. | 42 // testability. |
40 bool InjectScripts(WebKit::WebFrame* frame, UserScript::RunLocation location); | 43 bool InjectScripts(WebKit::WebFrame* frame, UserScript::RunLocation location); |
41 | 44 |
42 static int GetIsolatedWorldId(const std::string& extension_id); | 45 static int GetIsolatedWorldId(const std::string& extension_id); |
43 | 46 |
44 static void InsertInitExtensionCode(std::vector<WebScriptSource>* sources, | 47 static void InsertInitExtensionCode(std::vector<WebScriptSource>* sources, |
45 const std::string& extension_id); | 48 const std::string& extension_id); |
46 private: | 49 private: |
47 // Shared memory containing raw script data. | 50 // Shared memory containing raw script data. |
48 scoped_ptr<base::SharedMemory> shared_memory_; | 51 scoped_ptr<base::SharedMemory> shared_memory_; |
49 | 52 |
50 // Parsed script data. | 53 // Parsed script data. |
51 std::vector<UserScript*> scripts_; | 54 std::vector<UserScript*> scripts_; |
52 STLElementDeleter<std::vector<UserScript*> > script_deleter_; | 55 STLElementDeleter<std::vector<UserScript*> > script_deleter_; |
53 | 56 |
54 // Greasemonkey API source that is injected with the scripts. | 57 // Greasemonkey API source that is injected with the scripts. |
55 base::StringPiece api_js_; | 58 base::StringPiece api_js_; |
56 | 59 |
57 DISALLOW_COPY_AND_ASSIGN(UserScriptSlave); | 60 DISALLOW_COPY_AND_ASSIGN(UserScriptSlave); |
58 }; | 61 }; |
59 | 62 |
60 #endif // CHROME_RENDERER_USER_SCRIPT_SLAVE_H_ | 63 #endif // CHROME_RENDERER_USER_SCRIPT_SLAVE_H_ |
OLD | NEW |