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_SCRIPT_INJECTION_MANAGER_H_ | 5 #ifndef EXTENSIONS_RENDERER_SCRIPT_INJECTION_MANAGER_H_ |
6 #define EXTENSIONS_RENDERER_SCRIPT_INJECTION_MANAGER_H_ | 6 #define EXTENSIONS_RENDERER_SCRIPT_INJECTION_MANAGER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 27 matching lines...) Expand all Loading... |
38 // load point, and injecting them when ready. | 38 // load point, and injecting them when ready. |
39 class ScriptInjectionManager : public UserScriptSetManager::Observer { | 39 class ScriptInjectionManager : public UserScriptSetManager::Observer { |
40 public: | 40 public: |
41 ScriptInjectionManager(const ExtensionSet* extensions, | 41 ScriptInjectionManager(const ExtensionSet* extensions, |
42 UserScriptSetManager* user_script_set_manager); | 42 UserScriptSetManager* user_script_set_manager); |
43 virtual ~ScriptInjectionManager(); | 43 virtual ~ScriptInjectionManager(); |
44 | 44 |
45 // Notifies that a new render view has been created. | 45 // Notifies that a new render view has been created. |
46 void OnRenderViewCreated(content::RenderView* render_view); | 46 void OnRenderViewCreated(content::RenderView* render_view); |
47 | 47 |
| 48 // Notifies that an injection has been finished |
| 49 void OnInjectionFinished(ScriptInjection* injection, |
| 50 ScriptsRunInfo* scripts_run_info); |
| 51 |
48 private: | 52 private: |
49 // A RenderViewObserver implementation which watches the various render views | 53 // A RenderViewObserver implementation which watches the various render views |
50 // in order to notify the ScriptInjectionManager of different document load | 54 // in order to notify the ScriptInjectionManager of different document load |
51 // states. | 55 // states. |
52 class RVOHelper; | 56 class RVOHelper; |
53 | 57 |
54 typedef std::map<blink::WebFrame*, UserScript::RunLocation> FrameStatusMap; | 58 typedef std::map<blink::WebFrame*, UserScript::RunLocation> FrameStatusMap; |
55 | 59 |
56 // UserScriptSetManager::Observer implementation. | 60 // UserScriptSetManager::Observer implementation. |
57 void OnUserScriptsUpdated(const std::set<std::string>& changed_extensions, | 61 void OnUserScriptsUpdated(const std::set<std::string>& changed_extensions, |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 // Extensions metadata, owned by Dispatcher (which owns this object). | 95 // Extensions metadata, owned by Dispatcher (which owns this object). |
92 const ExtensionSet* extensions_; | 96 const ExtensionSet* extensions_; |
93 | 97 |
94 // The map of active web frames to their corresponding statuses. The | 98 // The map of active web frames to their corresponding statuses. The |
95 // RunLocation of the frame corresponds to the last location that has ran. | 99 // RunLocation of the frame corresponds to the last location that has ran. |
96 FrameStatusMap frame_statuses_; | 100 FrameStatusMap frame_statuses_; |
97 | 101 |
98 // The collection of RVOHelpers. | 102 // The collection of RVOHelpers. |
99 ScopedVector<RVOHelper> rvo_helpers_; | 103 ScopedVector<RVOHelper> rvo_helpers_; |
100 | 104 |
101 // True when the manager is actively injecting scripts into a web frame. | |
102 bool injecting_scripts_; | |
103 | |
104 // The set of extensions that have been updated (and thus any injections have | |
105 // been invalidated) while the manager was |injecting_scripts_|. | |
106 std::set<std::string> invalidated_while_injecting_; | |
107 | |
108 // The set of UserScripts associated with extensions. Owned by the Dispatcher. | 105 // The set of UserScripts associated with extensions. Owned by the Dispatcher. |
109 UserScriptSetManager* user_script_set_manager_; | 106 UserScriptSetManager* user_script_set_manager_; |
110 | 107 |
111 // Pending injections which are waiting for either the proper run location or | 108 // Pending injections which are waiting for either the proper run location or |
112 // user consent. | 109 // user consent. |
113 ScopedVector<ScriptInjection> pending_injections_; | 110 ScopedVector<ScriptInjection> pending_injections_; |
114 | 111 |
| 112 // Running injections which are waiting for async callbacks from blink |
| 113 ScopedVector<ScriptInjection> running_injections_; |
| 114 |
115 ScopedObserver<UserScriptSetManager, UserScriptSetManager::Observer> | 115 ScopedObserver<UserScriptSetManager, UserScriptSetManager::Observer> |
116 user_script_set_manager_observer_; | 116 user_script_set_manager_observer_; |
117 | 117 |
118 DISALLOW_COPY_AND_ASSIGN(ScriptInjectionManager); | 118 DISALLOW_COPY_AND_ASSIGN(ScriptInjectionManager); |
119 }; | 119 }; |
120 | 120 |
121 } // namespace extensions | 121 } // namespace extensions |
122 | 122 |
123 #endif // EXTENSIONS_RENDERER_SCRIPT_INJECTION_MANAGER_H_ | 123 #endif // EXTENSIONS_RENDERER_SCRIPT_INJECTION_MANAGER_H_ |
OLD | NEW |