OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 EXTENSIONS_RENDERER_USER_SCRIPT_SLAVE_H_ | 5 #ifndef EXTENSIONS_RENDERER_USER_SCRIPT_SLAVE_H_ |
6 #define EXTENSIONS_RENDERER_USER_SCRIPT_SLAVE_H_ | 6 #define EXTENSIONS_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 28 matching lines...) Expand all Loading... |
39 explicit UserScriptSlave(const ExtensionSet* extensions); | 39 explicit UserScriptSlave(const ExtensionSet* extensions); |
40 ~UserScriptSlave(); | 40 ~UserScriptSlave(); |
41 | 41 |
42 // Returns the unique set of extension IDs this UserScriptSlave knows about. | 42 // Returns the unique set of extension IDs this UserScriptSlave knows about. |
43 void GetActiveExtensions(std::set<std::string>* extension_ids); | 43 void GetActiveExtensions(std::set<std::string>* extension_ids); |
44 | 44 |
45 // Gets the extension with the given |id|, if one exists. | 45 // Gets the extension with the given |id|, if one exists. |
46 const Extension* GetExtension(const std::string& extension_id); | 46 const Extension* GetExtension(const std::string& extension_id); |
47 | 47 |
48 // Update the parsed scripts from shared memory. | 48 // Update the parsed scripts from shared memory. |
49 bool UpdateScripts(base::SharedMemoryHandle shared_memory); | 49 // If |changed_extensions| is not empty, only those extensions will be |
| 50 // updated. |
| 51 // Otherwise, all extensions will be updated. |
| 52 bool UpdateScripts(base::SharedMemoryHandle shared_memory, |
| 53 const std::set<std::string>& changed_extensions); |
50 | 54 |
51 // Gets the isolated world ID to use for the given |extension| in the given | 55 // Gets the isolated world ID to use for the given |extension| in the given |
52 // |frame|. If no isolated world has been created for that extension, | 56 // |frame|. If no isolated world has been created for that extension, |
53 // one will be created and initialized. | 57 // one will be created and initialized. |
54 int GetIsolatedWorldIdForExtension(const Extension* extension, | 58 int GetIsolatedWorldIdForExtension(const Extension* extension, |
55 blink::WebFrame* frame); | 59 blink::WebFrame* frame); |
56 | 60 |
57 // Gets the id of the extension running in a given isolated world. If no such | 61 // Gets the id of the extension running in a given isolated world. If no such |
58 // isolated world exists, or no extension is running in it, returns empty | 62 // isolated world exists, or no extension is running in it, returns empty |
59 // string. | 63 // string. |
60 std::string GetExtensionIdForIsolatedWorld(int isolated_world_id); | 64 std::string GetExtensionIdForIsolatedWorld(int isolated_world_id); |
61 | 65 |
62 void RemoveIsolatedWorld(const std::string& extension_id); | 66 void RemoveIsolatedWorld(const std::string& extension_id); |
63 | 67 |
64 // Inject the appropriate scripts into a frame based on its URL. | 68 // Inject the appropriate scripts into a frame based on its URL. |
65 // TODO(aa): Extract a UserScriptFrame interface out of this to improve | 69 // TODO(aa): Extract a UserScriptFrame interface out of this to improve |
66 // testability. | 70 // testability. |
67 void InjectScripts(blink::WebFrame* frame, UserScript::RunLocation location); | 71 void InjectScripts(blink::WebFrame* frame, UserScript::RunLocation location); |
68 | 72 |
| 73 // Allow an extension to inject scripts that were previously delayed for user |
| 74 // approval. |
| 75 void OnContentScriptGrantedPermission( |
| 76 content::RenderView* render_view, int request_id); |
| 77 |
| 78 // Notify the UserScriptSlave that the |frame| is detached, and about to die. |
| 79 void FrameDetached(blink::WebFrame* frame); |
| 80 |
69 private: | 81 private: |
70 // Log the data from scripts being run, including doing UMA and notifying the | 82 // Log the data from scripts being run, including doing UMA and notifying the |
71 // browser. | 83 // browser. |
72 void LogScriptsRun(blink::WebFrame* frame, | 84 void LogScriptsRun(blink::WebFrame* frame, |
73 UserScript::RunLocation location, | 85 UserScript::RunLocation location, |
74 const ScriptInjection::ScriptsRunInfo& info); | 86 const ScriptInjection::ScriptsRunInfo& info); |
75 | 87 |
76 // Shared memory containing raw script data. | 88 // Shared memory containing raw script data. |
77 scoped_ptr<base::SharedMemory> shared_memory_; | 89 scoped_ptr<base::SharedMemory> shared_memory_; |
78 | 90 |
79 // Parsed script data, ready to inject. | 91 // Parsed script data, ready to inject. |
80 ScopedVector<ScriptInjection> script_injections_; | 92 ScopedVector<ScriptInjection> script_injections_; |
81 | 93 |
82 // Extension metadata. | 94 // Extension metadata. |
83 const ExtensionSet* extensions_; | 95 const ExtensionSet* extensions_; |
84 | 96 |
85 typedef std::map<std::string, int> IsolatedWorldMap; | 97 typedef std::map<std::string, int> IsolatedWorldMap; |
86 IsolatedWorldMap isolated_world_ids_; | 98 IsolatedWorldMap isolated_world_ids_; |
87 | 99 |
88 DISALLOW_COPY_AND_ASSIGN(UserScriptSlave); | 100 DISALLOW_COPY_AND_ASSIGN(UserScriptSlave); |
89 }; | 101 }; |
90 | 102 |
91 } // namespace extensions | 103 } // namespace extensions |
92 | 104 |
93 #endif // EXTENSIONS_RENDERER_USER_SCRIPT_SLAVE_H_ | 105 #endif // EXTENSIONS_RENDERER_USER_SCRIPT_SLAVE_H_ |
OLD | NEW |