Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(274)

Side by Side Diff: extensions/renderer/script_injection_manager.h

Issue 2134613002: Stop injection when injections are invalidated Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Expand scope of ScriptInjectionWatchers Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 46
47 void set_activity_logging_enabled(bool enabled) { 47 void set_activity_logging_enabled(bool enabled) {
48 activity_logging_enabled_ = enabled; 48 activity_logging_enabled_ = enabled;
49 } 49 }
50 50
51 private: 51 private:
52 // A RenderFrameObserver implementation which watches the various render 52 // A RenderFrameObserver implementation which watches the various render
53 // frames in order to notify the ScriptInjectionManager of different 53 // frames in order to notify the ScriptInjectionManager of different
54 // document load states and IPCs. 54 // document load states and IPCs.
55 class RFOHelper; 55 class RFOHelper;
56 class ScriptInjectionWatcher;
56 57
57 using FrameStatusMap = 58 using FrameStatusMap =
58 std::map<content::RenderFrame*, UserScript::RunLocation>; 59 std::map<content::RenderFrame*, UserScript::RunLocation>;
59 60
60 using ScriptInjectionVector = std::vector<std::unique_ptr<ScriptInjection>>; 61 using ScriptInjectionVector = std::vector<std::unique_ptr<ScriptInjection>>;
61 62
62 // Notifies that an injection has been finished. 63 // Notifies that an injection has been finished.
63 void OnInjectionFinished(ScriptInjection* injection); 64 void OnInjectionFinished(ScriptInjection* injection);
64 65
65 // UserScriptSetManager::Observer implementation. 66 // UserScriptSetManager::Observer implementation.
(...skipping 30 matching lines...) Expand all
96 int script_id, 97 int script_id,
97 const GURL& url); 98 const GURL& url);
98 99
99 // Handle the GrantInjectionPermission extension message. 100 // Handle the GrantInjectionPermission extension message.
100 void HandlePermitScriptInjection(int64_t request_id); 101 void HandlePermitScriptInjection(int64_t request_id);
101 102
102 // The map of active web frames to their corresponding statuses. The 103 // The map of active web frames to their corresponding statuses. The
103 // RunLocation of the frame corresponds to the last location that has ran. 104 // RunLocation of the frame corresponds to the last location that has ran.
104 FrameStatusMap frame_statuses_; 105 FrameStatusMap frame_statuses_;
105 106
106 // The frames currently being injected into, so long as that frame is valid.
107 std::set<content::RenderFrame*> active_injection_frames_;
108
109 // The collection of RFOHelpers. 107 // The collection of RFOHelpers.
110 std::vector<std::unique_ptr<RFOHelper>> rfo_helpers_; 108 std::vector<std::unique_ptr<RFOHelper>> rfo_helpers_;
111 109
112 // The set of UserScripts associated with extensions. Owned by the Dispatcher. 110 // The set of UserScripts associated with extensions. Owned by the Dispatcher.
113 UserScriptSetManager* user_script_set_manager_; 111 UserScriptSetManager* user_script_set_manager_;
114 112
115 // Pending injections which are waiting for either the proper run location or 113 // Pending injections which are waiting for either the proper run location or
116 // user consent. 114 // user consent.
117 ScriptInjectionVector pending_injections_; 115 ScriptInjectionVector pending_injections_;
118 116
119 // Running injections which are waiting for async callbacks from blink. 117 // Running injections which are waiting for async callbacks from blink.
120 ScriptInjectionVector running_injections_; 118 ScriptInjectionVector running_injections_;
121 119
120 // Tracks injections that are about to be injected. Injections are added
121 // right before injection, and removed immediately after.
122 std::vector<ScriptInjectionWatcher*> injection_watchers_;
123
122 // Whether or not dom activity should be logged for scripts injected. 124 // Whether or not dom activity should be logged for scripts injected.
123 bool activity_logging_enabled_ = false; 125 bool activity_logging_enabled_ = false;
124 126
125 ScopedObserver<UserScriptSetManager, UserScriptSetManager::Observer> 127 ScopedObserver<UserScriptSetManager, UserScriptSetManager::Observer>
126 user_script_set_manager_observer_; 128 user_script_set_manager_observer_;
127 129
128 DISALLOW_COPY_AND_ASSIGN(ScriptInjectionManager); 130 DISALLOW_COPY_AND_ASSIGN(ScriptInjectionManager);
129 }; 131 };
130 132
131 } // namespace extensions 133 } // namespace extensions
132 134
133 #endif // EXTENSIONS_RENDERER_SCRIPT_INJECTION_MANAGER_H_ 135 #endif // EXTENSIONS_RENDERER_SCRIPT_INJECTION_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698