Chromium Code Reviews| 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> GetInjectionForScript( |
|
Devlin
2014/08/21 17:06:17
comments
| |
| 60 const ExtensionId& extensionId); | 60 int64 script_id, |
| 61 blink::WebFrame* web_frame, | |
| 62 int tab_id, | |
| 63 UserScript::RunLocation run_location, | |
| 64 const GURL& url, | |
| 65 const Extension* extension); | |
| 61 | 66 |
| 62 // Put all injections from |static_scripts| and each of | 67 // Put all injections from |static_scripts| and each of |
| 63 // |programmatic_scripts_| into |injections|. | 68 // |programmatic_scripts_| into |injections|. |
| 64 void GetAllInjections(ScopedVector<ScriptInjection>* injections, | 69 void GetAllInjections(ScopedVector<ScriptInjection>* injections, |
| 65 blink::WebFrame* web_frame, | 70 blink::WebFrame* web_frame, |
| 66 int tab_id, | 71 int tab_id, |
| 67 UserScript::RunLocation run_location); | 72 UserScript::RunLocation run_location); |
| 68 | 73 |
| 69 // Get active extension IDs from |static_scripts| and each of | 74 // Get active extension IDs from |static_scripts| and each of |
| 70 // |programmatic_scripts_|. | 75 // |programmatic_scripts_|. |
| 71 void GetAllActiveExtensionIds(std::set<std::string>* ids) const; | 76 void GetAllActiveExtensionIds(std::set<std::string>* ids) const; |
| 72 | 77 |
| 73 const UserScriptSet* static_scripts() const { return &static_scripts_; } | 78 const UserScriptSet* static_scripts() const { return &static_scripts_; } |
| 74 | 79 |
| 75 private: | 80 private: |
| 81 // A RenderViewObserver implementation which watches the various render views | |
|
Devlin
2014/08/21 17:06:17
Why?
Mark Dittmer
2014/08/23 12:21:39
More leftovers from a failed/unnecessary pattern I
| |
| 82 // in order to notify the ScriptInjectionManager of different document load | |
| 83 // states. | |
| 84 class RVOHelper; | |
| 85 | |
| 76 // Map for per-extension sets that may be defined programmatically. | 86 // Map for per-extension sets that may be defined programmatically. |
| 77 typedef std::map<ExtensionId, linked_ptr<UserScriptSet> > UserScriptSetMap; | 87 typedef std::map<ExtensionId, linked_ptr<UserScriptSet> > UserScriptSetMap; |
| 78 | 88 |
| 79 // content::RenderProcessObserver implementation. | 89 // content::RenderProcessObserver implementation. |
| 80 virtual bool OnControlMessageReceived(const IPC::Message& message) OVERRIDE; | 90 virtual bool OnControlMessageReceived(const IPC::Message& message) OVERRIDE; |
| 81 | 91 |
| 92 UserScriptSet* GetProgrammaticScriptsByExtension( | |
| 93 const ExtensionId& extensionId); | |
| 94 | |
| 82 // Handle the UpdateUserScripts extension message. | 95 // Handle the UpdateUserScripts extension message. |
| 83 void OnUpdateUserScripts(base::SharedMemoryHandle shared_memory, | 96 void OnUpdateUserScripts(base::SharedMemoryHandle shared_memory, |
| 84 const ExtensionId& extension_id, | 97 const ExtensionId& extension_id, |
| 85 const std::set<std::string>& changed_extensions); | 98 const std::set<std::string>& changed_extensions); |
| 86 | 99 |
| 87 // Scripts statically defined in extension manifests. | 100 // Scripts statically defined in extension manifests. |
| 88 UserScriptSet static_scripts_; | 101 UserScriptSet static_scripts_; |
| 89 | 102 |
| 90 // Scripts programmatically-defined through API calls (initialized and stored | 103 // Scripts programmatically-defined through API calls (initialized and stored |
| 91 // per-extension). | 104 // per-extension). |
| 92 UserScriptSetMap programmatic_scripts_; | 105 UserScriptSetMap programmatic_scripts_; |
| 93 | 106 |
| 94 // The set of all known extensions. Owned by the Dispatcher. | 107 // The set of all known extensions. Owned by the Dispatcher. |
| 95 const ExtensionSet* extensions_; | 108 const ExtensionSet* extensions_; |
| 96 | 109 |
| 97 // The associated observers. | 110 // The associated observers. |
| 98 ObserverList<Observer> observers_; | 111 ObserverList<Observer> observers_; |
| 99 | 112 |
| 100 DISALLOW_COPY_AND_ASSIGN(UserScriptSetManager); | 113 DISALLOW_COPY_AND_ASSIGN(UserScriptSetManager); |
| 101 }; | 114 }; |
| 102 | 115 |
| 103 } // namespace extensions | 116 } // namespace extensions |
| 104 | 117 |
| 105 #endif // EXTENSIONS_RENDERER_USER_SCRIPT_SET_MANAGER_H_ | 118 #endif // EXTENSIONS_RENDERER_USER_SCRIPT_SET_MANAGER_H_ |
| OLD | NEW |