Linux: Depend on liberation-fonts package for RPMs.
[chromium-blink-merge.git] / extensions / browser / extension_user_script_loader.h
blobbdd83a47415adc9232275317e6a507a485cb82c7
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
3 // found in the LICENSE file.
5 #ifndef EXTENSIONS_BROWSER_EXTENSION_USER_SCRIPT_LOADER_H_
6 #define EXTENSIONS_BROWSER_EXTENSION_USER_SCRIPT_LOADER_H_
8 #include "extensions/browser/extension_registry_observer.h"
9 #include "extensions/browser/user_script_loader.h"
10 #include "extensions/common/extension.h"
12 namespace content {
13 class BrowserContext;
16 namespace extensions {
18 class ContentVerifier;
19 class ExtensionRegistry;
21 // UserScriptLoader for extensions.
22 class ExtensionUserScriptLoader : public UserScriptLoader,
23 public ExtensionRegistryObserver {
24 public:
25 using PathAndDefaultLocale = std::pair<base::FilePath, std::string>;
26 using HostsInfo = std::map<HostID, PathAndDefaultLocale>;
28 // The listen_for_extension_system_loaded is only set true when initilizing
29 // the Extension System, e.g, when constructs SharedUserScriptMaster in
30 // ExtensionSystemImpl.
31 ExtensionUserScriptLoader(content::BrowserContext* browser_context,
32 const HostID& host_id,
33 bool listen_for_extension_system_loaded);
34 ~ExtensionUserScriptLoader() override;
36 // A wrapper around the method to load user scripts, which is normally run on
37 // the file thread. Exposed only for tests.
38 void LoadScriptsForTest(UserScriptList* user_scripts);
40 private:
41 // UserScriptLoader:
42 void LoadScripts(scoped_ptr<UserScriptList> user_scripts,
43 const std::set<HostID>& changed_hosts,
44 const std::set<int>& added_script_ids,
45 LoadScriptsCallback callback) override;
47 // Updates |hosts_info_| to contain info for each element of
48 // |changed_hosts_|.
49 void UpdateHostsInfo(const std::set<HostID>& changed_hosts);
51 // ExtensionRegistryObserver:
52 void OnExtensionUnloaded(content::BrowserContext* browser_context,
53 const Extension* extension,
54 UnloadedExtensionInfo::Reason reason) override;
56 // Initiates script load when we have been waiting for the extension system
57 // to be ready.
58 void OnExtensionSystemReady();
60 // Maps host info needed for localization to a host ID.
61 HostsInfo hosts_info_;
63 // Manages content verification of the loaded user scripts.
64 scoped_refptr<ContentVerifier> content_verifier_;
66 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver>
67 extension_registry_observer_;
69 base::WeakPtrFactory<ExtensionUserScriptLoader> weak_factory_;
71 DISALLOW_COPY_AND_ASSIGN(ExtensionUserScriptLoader);
74 } // namespace extensions
76 #endif // EXTENSIONS_BROWSER_EXTENSION_USER_SCRIPT_LOADER_H_