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 |
(...skipping 23 matching lines...) Expand all Loading... | |
34 class UserScriptSet { | 34 class UserScriptSet { |
35 public: | 35 public: |
36 class Observer { | 36 class Observer { |
37 public: | 37 public: |
38 virtual void OnUserScriptsUpdated( | 38 virtual void OnUserScriptsUpdated( |
39 const std::set<std::string>& changed_extensions, | 39 const std::set<std::string>& changed_extensions, |
40 const std::vector<UserScript*>& scripts) = 0; | 40 const std::vector<UserScript*>& scripts) = 0; |
41 }; | 41 }; |
42 | 42 |
43 explicit UserScriptSet(const ExtensionSet* extensions); | 43 explicit UserScriptSet(const ExtensionSet* extensions); |
44 ~UserScriptSet(); | 44 virtual ~UserScriptSet(); |
Devlin
2014/08/04 18:33:26
?
Mark Dittmer
2014/08/05 20:33:20
Must have been an error during a merge. Reverted.
| |
45 | 45 |
46 // Adds or removes observers. | 46 // Adds or removes observers. |
47 void AddObserver(Observer* observer); | 47 void AddObserver(Observer* observer); |
48 void RemoveObserver(Observer* observer); | 48 void RemoveObserver(Observer* observer); |
49 | 49 |
50 // Appends the ids of the extensions that have user scripts to |ids|. | 50 // Appends the ids of the extensions that have user scripts to |ids|. |
51 void GetActiveExtensionIds(std::set<std::string>* ids) const; | 51 void GetActiveExtensionIds(std::set<std::string>* ids) const; |
52 | 52 |
53 // Populate |injections| with any ScriptInjections that should run on the | 53 // Populate |injections| with any ScriptInjections that should run on the |
54 // given |web_frame| and |tab_id|, at the given |run_location|. | 54 // given |web_frame| and |tab_id|, at the given |run_location|. |
55 // |extensions| is passed in to verify the corresponding extension is still | 55 // |extensions| is passed in to verify the corresponding extension is still |
56 // valid. | 56 // valid. |
57 void GetInjections(ScopedVector<ScriptInjection>* injections, | 57 void GetInjections(ScopedVector<ScriptInjection>* injections, |
58 blink::WebFrame* web_frame, | 58 blink::WebFrame* web_frame, |
59 int tab_id, | 59 int tab_id, |
60 UserScript::RunLocation run_location); | 60 UserScript::RunLocation run_location); |
61 | 61 |
62 // Updates scripts given the shared memory region containing user scripts. | 62 // Updates scripts given the shared memory region containing user scripts. |
63 // Returns true if the scripts were successfully updated. | 63 // Returns true if the scripts were successfully updated. |
64 bool UpdateUserScripts(base::SharedMemoryHandle shared_memory, | 64 bool OnUpdateUserScripts(base::SharedMemoryHandle shared_memory, |
Devlin
2014/08/04 18:33:26
?
Mark Dittmer
2014/08/05 20:33:20
ditto
| |
65 const std::set<std::string>& changed_extensions); | 65 const std::set<std::string>& changed_extensions); |
66 | 66 |
67 const std::vector<UserScript*>& scripts() const { return scripts_.get(); } | 67 const std::vector<UserScript*>& scripts() const { return scripts_.get(); } |
68 | 68 |
69 private: | 69 private: |
70 // Returns a new ScriptInjection for the given |script| to execute in the | 70 // Returns a new ScriptInjection for the given |script| to execute in the |
71 // |web_frame|, or NULL if the script should not execute. | 71 // |web_frame|, or NULL if the script should not execute. |
72 scoped_ptr<ScriptInjection> GetInjectionForScript( | 72 scoped_ptr<ScriptInjection> GetInjectionForScript( |
73 UserScript* script, | 73 UserScript* script, |
74 blink::WebFrame* web_frame, | 74 blink::WebFrame* web_frame, |
75 int tab_id, | 75 int tab_id, |
(...skipping 12 matching lines...) Expand all Loading... | |
88 | 88 |
89 // The associated observers. | 89 // The associated observers. |
90 ObserverList<Observer> observers_; | 90 ObserverList<Observer> observers_; |
91 | 91 |
92 DISALLOW_COPY_AND_ASSIGN(UserScriptSet); | 92 DISALLOW_COPY_AND_ASSIGN(UserScriptSet); |
93 }; | 93 }; |
94 | 94 |
95 } // namespace extensions | 95 } // namespace extensions |
96 | 96 |
97 #endif // EXTENSIONS_RENDERER_USER_SCRIPT_SET_H_ | 97 #endif // EXTENSIONS_RENDERER_USER_SCRIPT_SET_H_ |
OLD | NEW |