OLD | NEW |
---|---|
(Empty) | |
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. | |
4 | |
5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_USER_SCRIPT_LOADER_H_ | |
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_USER_SCRIPT_LOADER_H_ | |
7 | |
8 #include "base/memory/shared_memory.h" | |
9 #include "chrome/browser/extensions/user_script_loader.h" | |
10 #include "content/public/browser/notification_observer.h" | |
Devlin
2015/01/20 17:51:05
nit: prune includes.
Xi Han
2015/01/21 21:30:16
Done.
| |
11 #include "extensions/browser/extension_registry_observer.h" | |
12 #include "extensions/common/extension.h" | |
13 #include "extensions/common/extension_set.h" | |
14 | |
15 namespace content { | |
16 class BrowserContext; | |
17 } | |
18 | |
19 class Profile; | |
20 | |
21 namespace extensions { | |
22 | |
23 class ContentVerifier; | |
24 class ExtensionRegistry; | |
25 | |
26 // UserScriptLoader for extensions. | |
27 class ExtensionUserScriptLoader : public UserScriptLoader, | |
28 public ExtensionRegistryObserver { | |
29 public: | |
30 // The listen_for_extension_system_loaded is only set true when initilizing | |
31 // the Exttension System, e.g, when constructs SharedUserScriptMaster in | |
32 // ExtensionSystemImpl. | |
33 ExtensionUserScriptLoader(Profile* profile, | |
34 const ConsumerID& consumer_id, | |
35 bool listen_for_extension_system_loaded); | |
36 ~ExtensionUserScriptLoader() override; | |
37 | |
38 private: | |
39 static bool LoadScriptContent(const ConsumerID& consumer_id, | |
Devlin
2015/01/20 17:51:05
nit: function comments.
Xi Han
2015/01/21 21:30:16
Done.
| |
40 UserScript::File* script_file, | |
41 const SubstitutionMap* localization_messages, | |
42 scoped_refptr<ContentVerifier> verifier); | |
43 | |
44 // UserScriptLoader: | |
45 void UpdateConsumersInfo(const ConsumerIDSet& changed_consumers) override; | |
46 LoadUserScriptsFunctionCallback GetLoadUserScriptsFunction() override; | |
47 void SendUpdate(content::RenderProcessHost* process, | |
48 base::SharedMemoryHandle handle_for_process, | |
49 const std::set<ConsumerID>& changed_consumers) override; | |
50 | |
51 // ExtensionRegistryObserver: | |
52 void OnExtensionUnloaded(content::BrowserContext* browser_context, | |
53 const Extension* extension, | |
54 UnloadedExtensionInfo::Reason reason) override; | |
55 | |
56 // Initiates script load when we have been waiting for the extension system | |
57 // to be ready. | |
58 void OnExtensionSystemReady(); | |
59 | |
60 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> | |
61 extension_registry_observer_; | |
62 | |
63 base::WeakPtrFactory<ExtensionUserScriptLoader> weak_factory_; | |
64 | |
65 DISALLOW_COPY_AND_ASSIGN(ExtensionUserScriptLoader); | |
66 }; | |
67 | |
68 } // namespace extensions | |
69 | |
70 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_USER_SCRIPT_LOADER_H_ | |
OLD | NEW |