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_BROWSER_USER_SCRIPT_LOADER_H_ | 5 #ifndef EXTENSIONS_BROWSER_USER_SCRIPT_LOADER_H_ |
6 #define EXTENSIONS_BROWSER_USER_SCRIPT_LOADER_H_ | 6 #define EXTENSIONS_BROWSER_USER_SCRIPT_LOADER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <memory> | 9 #include <memory> |
10 #include <set> | 10 #include <set> |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 | 88 |
89 // Pickle user scripts and return pointer to the shared memory. | 89 // Pickle user scripts and return pointer to the shared memory. |
90 static std::unique_ptr<base::SharedMemory> Serialize( | 90 static std::unique_ptr<base::SharedMemory> Serialize( |
91 const extensions::UserScriptList& scripts); | 91 const extensions::UserScriptList& scripts); |
92 | 92 |
93 // Adds or removes observers. | 93 // Adds or removes observers. |
94 void AddObserver(Observer* observer); | 94 void AddObserver(Observer* observer); |
95 void RemoveObserver(Observer* observer); | 95 void RemoveObserver(Observer* observer); |
96 | 96 |
97 protected: | 97 protected: |
98 // Allows the derived classes have different ways to load user scripts. | 98 // Allows the derived classes to have different ways to load user scripts. |
| 99 // This may not be synchronous with the calls to Add/Remove/Clear scripts. |
99 virtual void LoadScripts(std::unique_ptr<UserScriptList> user_scripts, | 100 virtual void LoadScripts(std::unique_ptr<UserScriptList> user_scripts, |
100 const std::set<HostID>& changed_hosts, | 101 const std::set<HostID>& changed_hosts, |
101 const std::set<int>& added_script_ids, | 102 const std::set<int>& added_script_ids, |
102 LoadScriptsCallback callback) = 0; | 103 LoadScriptsCallback callback) = 0; |
103 | 104 |
104 // Sets the flag if the initial set of hosts has finished loading; if it's | 105 // Sets the flag if the initial set of hosts has finished loading; if it's |
105 // set to be true, calls AttempLoad() to bootstrap. | 106 // set to be true, calls AttempLoad() to bootstrap. |
106 void SetReady(bool ready); | 107 void SetReady(bool ready); |
107 | 108 |
108 content::BrowserContext* browser_context() const { return browser_context_; } | 109 content::BrowserContext* browser_context() const { return browser_context_; } |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 base::ObserverList<Observer> observers_; | 182 base::ObserverList<Observer> observers_; |
182 | 183 |
183 base::WeakPtrFactory<UserScriptLoader> weak_factory_; | 184 base::WeakPtrFactory<UserScriptLoader> weak_factory_; |
184 | 185 |
185 DISALLOW_COPY_AND_ASSIGN(UserScriptLoader); | 186 DISALLOW_COPY_AND_ASSIGN(UserScriptLoader); |
186 }; | 187 }; |
187 | 188 |
188 } // namespace extensions | 189 } // namespace extensions |
189 | 190 |
190 #endif // EXTENSIONS_BROWSER_USER_SCRIPT_LOADER_H_ | 191 #endif // EXTENSIONS_BROWSER_USER_SCRIPT_LOADER_H_ |
OLD | NEW |