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_H_ | 5 #ifndef EXTENSIONS_RENDERER_USER_SCRIPT_SET_H_ |
6 #define EXTENSIONS_RENDERER_USER_SCRIPT_SET_H_ | 6 #define EXTENSIONS_RENDERER_USER_SCRIPT_SET_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/memory/scoped_vector.h" | 14 #include "base/memory/scoped_vector.h" |
15 #include "base/memory/shared_memory.h" | 15 #include "base/memory/shared_memory.h" |
16 #include "base/observer_list.h" | 16 #include "base/observer_list.h" |
17 #include "content/public/renderer/render_process_observer.h" | 17 #include "content/public/renderer/render_process_observer.h" |
18 #include "extensions/common/user_script.h" | 18 #include "extensions/common/user_script.h" |
19 | 19 |
20 class GURL; | 20 class GURL; |
21 | 21 |
22 namespace content { | 22 namespace content { |
23 class RenderFrame; | 23 class RenderFrame; |
24 } | 24 } |
25 | 25 |
26 namespace extensions { | 26 namespace extensions { |
27 class ExtensionSet; | |
28 class ScriptInjection; | 27 class ScriptInjection; |
29 | 28 |
30 // The UserScriptSet is a collection of UserScripts which knows how to update | 29 // The UserScriptSet is a collection of UserScripts which knows how to update |
31 // itself from SharedMemory and create ScriptInjections for UserScripts to | 30 // itself from SharedMemory and create ScriptInjections for UserScripts to |
32 // inject on a page. | 31 // inject on a page. |
33 class UserScriptSet { | 32 class UserScriptSet { |
34 public: | 33 public: |
35 class Observer { | 34 class Observer { |
36 public: | 35 public: |
37 virtual void OnUserScriptsUpdated( | 36 virtual void OnUserScriptsUpdated( |
38 const std::set<HostID>& changed_hosts, | 37 const std::set<HostID>& changed_hosts, |
39 const std::vector<UserScript*>& scripts) = 0; | 38 const std::vector<UserScript*>& scripts) = 0; |
40 }; | 39 }; |
41 | 40 |
42 explicit UserScriptSet(const ExtensionSet* extensions); | 41 UserScriptSet(); |
43 ~UserScriptSet(); | 42 ~UserScriptSet(); |
44 | 43 |
45 // Adds or removes observers. | 44 // Adds or removes observers. |
46 void AddObserver(Observer* observer); | 45 void AddObserver(Observer* observer); |
47 void RemoveObserver(Observer* observer); | 46 void RemoveObserver(Observer* observer); |
48 | 47 |
49 // Appends the ids of the extensions that have user scripts to |ids|. | 48 // Appends the ids of the extensions that have user scripts to |ids|. |
50 void GetActiveExtensionIds(std::set<std::string>* ids) const; | 49 void GetActiveExtensionIds(std::set<std::string>* ids) const; |
51 | 50 |
52 // Append any ScriptInjections that should run on the given |render_frame| and | 51 // Append any ScriptInjections that should run on the given |render_frame| and |
(...skipping 27 matching lines...) Expand all Loading... |
80 const UserScript* script, | 79 const UserScript* script, |
81 content::RenderFrame* render_frame, | 80 content::RenderFrame* render_frame, |
82 int tab_id, | 81 int tab_id, |
83 UserScript::RunLocation run_location, | 82 UserScript::RunLocation run_location, |
84 const GURL& document_url, | 83 const GURL& document_url, |
85 bool is_declarative); | 84 bool is_declarative); |
86 | 85 |
87 // Shared memory containing raw script data. | 86 // Shared memory containing raw script data. |
88 scoped_ptr<base::SharedMemory> shared_memory_; | 87 scoped_ptr<base::SharedMemory> shared_memory_; |
89 | 88 |
90 // The set of all known extensions. Owned by the Dispatcher. | |
91 const ExtensionSet* extensions_; | |
92 | |
93 // The UserScripts this injector manages. | 89 // The UserScripts this injector manages. |
94 ScopedVector<UserScript> scripts_; | 90 ScopedVector<UserScript> scripts_; |
95 | 91 |
96 // The associated observers. | 92 // The associated observers. |
97 base::ObserverList<Observer> observers_; | 93 base::ObserverList<Observer> observers_; |
98 | 94 |
99 DISALLOW_COPY_AND_ASSIGN(UserScriptSet); | 95 DISALLOW_COPY_AND_ASSIGN(UserScriptSet); |
100 }; | 96 }; |
101 | 97 |
102 } // namespace extensions | 98 } // namespace extensions |
103 | 99 |
104 #endif // EXTENSIONS_RENDERER_USER_SCRIPT_SET_H_ | 100 #endif // EXTENSIONS_RENDERER_USER_SCRIPT_SET_H_ |
OLD | NEW |