OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
Devlin
2015/01/14 16:45:09
year
Xi Han
2015/01/14 23:46:03
Done.
| |
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" | |
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/14 16:45:09
Can this go in an anonymous namespace in the .cc?
Xi Han
2015/01/14 23:46:03
No, it can't. This static function is introduced f
| |
40 UserScript::File* script_file, | |
41 const SubstitutionMap* localization_messages, | |
42 scoped_refptr<ContentVerifier> verifier); | |
43 | |
44 // UserScriptLoader implementation. | |
Devlin
2015/01/14 16:45:09
nit: prefer
// UserScriptLoader:
(goes for everyw
Xi Han
2015/01/14 23:46:03
Done.
| |
45 void UpdateConsumersInfo() override; | |
46 bool Ready() override; | |
47 ContentVerifier* GetContentVerifier() override; | |
48 LoadUserScriptsFunctionCallback GetLoadUserScriptsFunction() override; | |
49 void SendUpdate(content::RenderProcessHost* process, | |
50 base::SharedMemoryHandle handle_for_process, | |
51 const std::set<ConsumerID>& changed_consumers) override; | |
52 | |
53 // ExtensionRegistryObserver implementation. | |
54 void OnExtensionUnloaded(content::BrowserContext* browser_context, | |
55 const Extension* extension, | |
56 UnloadedExtensionInfo::Reason reason) override; | |
57 | |
58 // Initiates script load when we have been waiting for the extension system | |
59 // to be ready. | |
60 void OnExtensionSystemReady(); | |
61 | |
62 // If the extensions service has finished loading its initial set of | |
63 // extensions. | |
64 bool extension_system_ready_; | |
65 | |
66 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> | |
67 extension_registry_observer_; | |
68 | |
69 base::WeakPtrFactory<ExtensionUserScriptLoader> weak_factory_; | |
70 | |
71 DISALLOW_COPY_AND_ASSIGN(ExtensionUserScriptLoader); | |
72 }; | |
73 | |
74 } // namespace extensions | |
75 | |
76 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_USER_SCRIPT_LOADER_H_ | |
OLD | NEW |