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

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

Issue 404613006: Declarative content scripts: Renderer-side: per-extension shared memory regions (lazily loaded) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixes for last round of comments Created 6 years, 4 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
« no previous file with comments | « extensions/renderer/dispatcher.cc ('k') | extensions/renderer/script_injection_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
11 11
12 #include "base/callback.h" 12 #include "base/callback.h"
13 #include "base/memory/scoped_vector.h" 13 #include "base/memory/scoped_vector.h"
14 #include "base/memory/shared_memory.h" 14 #include "base/memory/shared_memory.h"
15 #include "base/scoped_observer.h" 15 #include "base/scoped_observer.h"
16 #include "extensions/common/user_script.h" 16 #include "extensions/common/user_script.h"
17 #include "extensions/renderer/script_injection.h" 17 #include "extensions/renderer/script_injection.h"
18 #include "extensions/renderer/user_script_set.h" 18 #include "extensions/renderer/user_script_set_manager.h"
19 19
20 struct ExtensionMsg_ExecuteCode_Params; 20 struct ExtensionMsg_ExecuteCode_Params;
21 21
22 namespace blink { 22 namespace blink {
23 class WebFrame; 23 class WebFrame;
24 class WebLocalFrame; 24 class WebLocalFrame;
25 } 25 }
26 26
27 namespace content { 27 namespace content {
28 class RenderView; 28 class RenderView;
29 } 29 }
30 30
31 namespace extensions { 31 namespace extensions {
32 class Extension; 32 class Extension;
33 class ExtensionSet; 33 class ExtensionSet;
34 34
35 // The ScriptInjectionManager manages extensions injecting scripts into frames 35 // The ScriptInjectionManager manages extensions injecting scripts into frames
36 // via both content/user scripts and tabs.executeScript(). It is responsible for 36 // via both content/user scripts and tabs.executeScript(). It is responsible for
37 // maintaining any pending injections awaiting permission or the appropriate 37 // maintaining any pending injections awaiting permission or the appropriate
38 // load point, and injecting them when ready. 38 // load point, and injecting them when ready.
39 class ScriptInjectionManager : public UserScriptSet::Observer { 39 class ScriptInjectionManager : public UserScriptSetManager::Observer {
40 public: 40 public:
41 ScriptInjectionManager(const ExtensionSet* extensions, 41 ScriptInjectionManager(const ExtensionSet* extensions,
42 UserScriptSet* user_script_set); 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 private: 48 private:
49 // A RenderViewObserver implementation which watches the various render views 49 // A RenderViewObserver implementation which watches the various render views
50 // in order to notify the ScriptInjectionManager of different document load 50 // in order to notify the ScriptInjectionManager of different document load
51 // states. 51 // states.
52 class RVOHelper; 52 class RVOHelper;
53 53
54 typedef std::map<blink::WebFrame*, UserScript::RunLocation> FrameStatusMap; 54 typedef std::map<blink::WebFrame*, UserScript::RunLocation> FrameStatusMap;
55 55
56 // UserScriptSet::Observer implementation. 56 // UserScriptSetManager::Observer implementation.
57 virtual void OnUserScriptsUpdated( 57 virtual void OnUserScriptsUpdated(
58 const std::set<std::string>& changed_extensions, 58 const std::set<std::string>& changed_extensions,
59 const std::vector<UserScript*>& scripts) OVERRIDE; 59 const std::vector<UserScript*>& scripts) OVERRIDE;
60 60
61 // Notifies that an RVOHelper should be removed. 61 // Notifies that an RVOHelper should be removed.
62 void RemoveObserver(RVOHelper* helper); 62 void RemoveObserver(RVOHelper* helper);
63 63
64 // Invalidate any pending tasks associated with |frame|. 64 // Invalidate any pending tasks associated with |frame|.
65 void InvalidateForFrame(blink::WebFrame* frame); 65 void InvalidateForFrame(blink::WebFrame* frame);
66 66
(...skipping 12 matching lines...) Expand all
79 const ExtensionSet* extensions_; 79 const ExtensionSet* extensions_;
80 80
81 // The map of active web frames to their corresponding statuses. The 81 // The map of active web frames to their corresponding statuses. The
82 // RunLocation of the frame corresponds to the last location that has ran. 82 // RunLocation of the frame corresponds to the last location that has ran.
83 FrameStatusMap frame_statuses_; 83 FrameStatusMap frame_statuses_;
84 84
85 // The collection of RVOHelpers. 85 // The collection of RVOHelpers.
86 ScopedVector<RVOHelper> rvo_helpers_; 86 ScopedVector<RVOHelper> rvo_helpers_;
87 87
88 // The set of UserScripts associated with extensions. Owned by the Dispatcher. 88 // The set of UserScripts associated with extensions. Owned by the Dispatcher.
89 UserScriptSet* user_script_set_; 89 UserScriptSetManager* user_script_set_manager_;
90 90
91 // Pending injections which are waiting for either the proper run location or 91 // Pending injections which are waiting for either the proper run location or
92 // user consent. 92 // user consent.
93 ScopedVector<ScriptInjection> pending_injections_; 93 ScopedVector<ScriptInjection> pending_injections_;
94 94
95 ScopedObserver<UserScriptSet, UserScriptSet::Observer> 95 ScopedObserver<UserScriptSetManager, UserScriptSetManager::Observer>
96 user_script_set_observer_; 96 user_script_set_manager_observer_;
97 97
98 DISALLOW_COPY_AND_ASSIGN(ScriptInjectionManager); 98 DISALLOW_COPY_AND_ASSIGN(ScriptInjectionManager);
99 }; 99 };
100 100
101 } // namespace extensions 101 } // namespace extensions
102 102
103 #endif // EXTENSIONS_RENDERER_SCRIPT_INJECTION_MANAGER_H_ 103 #endif // EXTENSIONS_RENDERER_SCRIPT_INJECTION_MANAGER_H_
OLDNEW
« no previous file with comments | « extensions/renderer/dispatcher.cc ('k') | extensions/renderer/script_injection_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698