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_SET_MANAGER_H_ | 5 #ifndef EXTENSIONS_RENDERER_USER_SCRIPT_SET_MANAGER_H_ |
6 #define EXTENSIONS_RENDERER_USER_SCRIPT_SET_MANAGER_H_ | 6 #define EXTENSIONS_RENDERER_USER_SCRIPT_SET_MANAGER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
49 const std::vector<UserScript*>& scripts) = 0; | 49 const std::vector<UserScript*>& scripts) = 0; |
50 }; | 50 }; |
51 | 51 |
52 UserScriptSetManager(const ExtensionSet* extensions); | 52 UserScriptSetManager(const ExtensionSet* extensions); |
53 | 53 |
54 virtual ~UserScriptSetManager(); | 54 virtual ~UserScriptSetManager(); |
55 | 55 |
56 void AddObserver(Observer* observer); | 56 void AddObserver(Observer* observer); |
57 void RemoveObserver(Observer* observer); | 57 void RemoveObserver(Observer* observer); |
58 | 58 |
59 const UserScriptSet* GetProgrammaticScriptsByExtension( | 59 scoped_ptr<ScriptInjection> GetInjectionForDeclarativeScript( |
Devlin
2014/08/25 22:31:06
function comments
Mark Dittmer
2014/08/27 21:21:48
Done.
| |
60 const ExtensionId& extensionId); | 60 int64 script_id, |
61 blink::WebFrame* web_frame, | |
62 int tab_id, | |
63 const GURL& url, | |
64 const Extension* extension); | |
61 | 65 |
62 // Put all injections from |static_scripts| and each of | 66 // Put all injections from |static_scripts| and each of |
63 // |programmatic_scripts_| into |injections|. | 67 // |programmatic_scripts_| into |injections|. |
64 void GetAllInjections(ScopedVector<ScriptInjection>* injections, | 68 void GetAllInjections(ScopedVector<ScriptInjection>* injections, |
65 blink::WebFrame* web_frame, | 69 blink::WebFrame* web_frame, |
66 int tab_id, | 70 int tab_id, |
67 UserScript::RunLocation run_location); | 71 UserScript::RunLocation run_location); |
68 | 72 |
69 // Get active extension IDs from |static_scripts| and each of | 73 // Get active extension IDs from |static_scripts| and each of |
70 // |programmatic_scripts_|. | 74 // |programmatic_scripts_|. |
71 void GetAllActiveExtensionIds(std::set<std::string>* ids) const; | 75 void GetAllActiveExtensionIds(std::set<std::string>* ids) const; |
72 | 76 |
73 const UserScriptSet* static_scripts() const { return &static_scripts_; } | 77 const UserScriptSet* static_scripts() const { return &static_scripts_; } |
74 | 78 |
75 private: | 79 private: |
76 // Map for per-extension sets that may be defined programmatically. | 80 // Map for per-extension sets that may be defined programmatically. |
77 typedef std::map<ExtensionId, linked_ptr<UserScriptSet> > UserScriptSetMap; | 81 typedef std::map<ExtensionId, linked_ptr<UserScriptSet> > UserScriptSetMap; |
78 | 82 |
79 // content::RenderProcessObserver implementation. | 83 // content::RenderProcessObserver implementation. |
80 virtual bool OnControlMessageReceived(const IPC::Message& message) OVERRIDE; | 84 virtual bool OnControlMessageReceived(const IPC::Message& message) OVERRIDE; |
81 | 85 |
86 UserScriptSet* GetProgrammaticScriptsByExtension( | |
87 const ExtensionId& extensionId); | |
88 | |
82 // Handle the UpdateUserScripts extension message. | 89 // Handle the UpdateUserScripts extension message. |
83 void OnUpdateUserScripts(base::SharedMemoryHandle shared_memory, | 90 void OnUpdateUserScripts(base::SharedMemoryHandle shared_memory, |
84 const ExtensionId& extension_id, | 91 const ExtensionId& extension_id, |
85 const std::set<std::string>& changed_extensions); | 92 const std::set<std::string>& changed_extensions); |
86 | 93 |
87 // Scripts statically defined in extension manifests. | 94 // Scripts statically defined in extension manifests. |
88 UserScriptSet static_scripts_; | 95 UserScriptSet static_scripts_; |
89 | 96 |
90 // Scripts programmatically-defined through API calls (initialized and stored | 97 // Scripts programmatically-defined through API calls (initialized and stored |
91 // per-extension). | 98 // per-extension). |
92 UserScriptSetMap programmatic_scripts_; | 99 UserScriptSetMap programmatic_scripts_; |
93 | 100 |
94 // The set of all known extensions. Owned by the Dispatcher. | 101 // The set of all known extensions. Owned by the Dispatcher. |
95 const ExtensionSet* extensions_; | 102 const ExtensionSet* extensions_; |
96 | 103 |
97 // The associated observers. | 104 // The associated observers. |
98 ObserverList<Observer> observers_; | 105 ObserverList<Observer> observers_; |
99 | 106 |
100 DISALLOW_COPY_AND_ASSIGN(UserScriptSetManager); | 107 DISALLOW_COPY_AND_ASSIGN(UserScriptSetManager); |
101 }; | 108 }; |
102 | 109 |
103 } // namespace extensions | 110 } // namespace extensions |
104 | 111 |
105 #endif // EXTENSIONS_RENDERER_USER_SCRIPT_SET_MANAGER_H_ | 112 #endif // EXTENSIONS_RENDERER_USER_SCRIPT_SET_MANAGER_H_ |
OLD | NEW |