OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_EXTENSION_USER_SCRIPT_LOADER_H_ | 5 #ifndef EXTENSIONS_BROWSER_EXTENSION_USER_SCRIPT_LOADER_H_ |
6 #define EXTENSIONS_BROWSER_EXTENSION_USER_SCRIPT_LOADER_H_ | 6 #define EXTENSIONS_BROWSER_EXTENSION_USER_SCRIPT_LOADER_H_ |
7 | 7 |
8 #include "base/memory/shared_memory.h" | 8 #include "base/memory/shared_memory.h" |
9 #include "extensions/browser/extension_registry_observer.h" | 9 #include "extensions/browser/extension_registry_observer.h" |
10 #include "extensions/browser/user_script_loader.h" | 10 #include "extensions/browser/user_script_loader.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 public ExtensionRegistryObserver { | 23 public ExtensionRegistryObserver { |
24 public: | 24 public: |
25 // The listen_for_extension_system_loaded is only set true when initilizing | 25 // The listen_for_extension_system_loaded is only set true when initilizing |
26 // the Extension System, e.g, when constructs SharedUserScriptMaster in | 26 // the Extension System, e.g, when constructs SharedUserScriptMaster in |
27 // ExtensionSystemImpl. | 27 // ExtensionSystemImpl. |
28 ExtensionUserScriptLoader(content::BrowserContext* browser_context, | 28 ExtensionUserScriptLoader(content::BrowserContext* browser_context, |
29 const HostID& host_id, | 29 const HostID& host_id, |
30 bool listen_for_extension_system_loaded); | 30 bool listen_for_extension_system_loaded); |
31 ~ExtensionUserScriptLoader() override; | 31 ~ExtensionUserScriptLoader() override; |
32 | 32 |
| 33 // A wrapper around the method to load user scripts, which is normally run on |
| 34 // the file thread. Exposed only for tests. |
| 35 void LoadScriptsForTest(UserScriptList* user_scripts); |
| 36 |
33 private: | 37 private: |
34 // UserScriptLoader: | 38 // UserScriptLoader: |
35 void UpdateHostsInfo(const std::set<HostID>& changed_hosts) override; | 39 void LoadScripts(const std::set<HostID>& changed_hosts, |
36 LoadUserScriptsContentFunction GetLoadUserScriptsFunction() override; | 40 const std::set<int>& added_script_ids) override; |
| 41 |
| 42 // Updates |hosts_info_| to contain info for each element of |
| 43 // |changed_hosts_|. |
| 44 void UpdateHostsInfo(const std::set<HostID>& changed_hosts); |
37 | 45 |
38 // ExtensionRegistryObserver: | 46 // ExtensionRegistryObserver: |
39 void OnExtensionUnloaded(content::BrowserContext* browser_context, | 47 void OnExtensionUnloaded(content::BrowserContext* browser_context, |
40 const Extension* extension, | 48 const Extension* extension, |
41 UnloadedExtensionInfo::Reason reason) override; | 49 UnloadedExtensionInfo::Reason reason) override; |
42 | 50 |
43 // Initiates script load when we have been waiting for the extension system | 51 // Initiates script load when we have been waiting for the extension system |
44 // to be ready. | 52 // to be ready. |
45 void OnExtensionSystemReady(); | 53 void OnExtensionSystemReady(); |
46 | 54 |
| 55 // Maps host info needed for localization to a host ID. |
| 56 HostsInfo hosts_info_; |
| 57 |
| 58 // Manages content verification of the loaded user scripts. |
| 59 scoped_refptr<ContentVerifier> content_verifier_; |
| 60 |
47 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> | 61 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> |
48 extension_registry_observer_; | 62 extension_registry_observer_; |
49 | 63 |
50 base::WeakPtrFactory<ExtensionUserScriptLoader> weak_factory_; | 64 base::WeakPtrFactory<ExtensionUserScriptLoader> weak_factory_; |
51 | 65 |
52 DISALLOW_COPY_AND_ASSIGN(ExtensionUserScriptLoader); | 66 DISALLOW_COPY_AND_ASSIGN(ExtensionUserScriptLoader); |
53 }; | 67 }; |
54 | 68 |
55 } // namespace extensions | 69 } // namespace extensions |
56 | 70 |
57 #endif // EXTENSIONS_BROWSER_EXTENSION_USER_SCRIPT_LOADER_H_ | 71 #endif // EXTENSIONS_BROWSER_EXTENSION_USER_SCRIPT_LOADER_H_ |
OLD | NEW |