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 CHROME_BROWSER_EXTENSIONS_SHARED_USER_SCRIPT_MASTER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_SHARED_USER_SCRIPT_MASTER_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_SHARED_USER_SCRIPT_MASTER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_SHARED_USER_SCRIPT_MASTER_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/scoped_observer.h" | 10 #include "base/scoped_observer.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 namespace extensions { | 22 namespace extensions { |
23 | 23 |
24 class ExtensionRegistry; | 24 class ExtensionRegistry; |
25 | 25 |
26 // Manages statically-defined user scripts for all extensions. Owns a | 26 // Manages statically-defined user scripts for all extensions. Owns a |
27 // UserScriptLoader to which file loading and shared memory management | 27 // UserScriptLoader to which file loading and shared memory management |
28 // operations are delegated. | 28 // operations are delegated. |
29 class SharedUserScriptMaster : public ExtensionRegistryObserver { | 29 class SharedUserScriptMaster : public ExtensionRegistryObserver { |
30 public: | 30 public: |
31 explicit SharedUserScriptMaster(Profile* profile); | 31 explicit SharedUserScriptMaster(Profile* profile); |
32 virtual ~SharedUserScriptMaster(); | 32 ~SharedUserScriptMaster() override; |
33 | 33 |
34 // Provides access to loader state method: scripts_ready(). | 34 // Provides access to loader state method: scripts_ready(). |
35 bool scripts_ready() const { return loader_.scripts_ready(); } | 35 bool scripts_ready() const { return loader_.scripts_ready(); } |
36 | 36 |
37 private: | 37 private: |
38 // ExtensionRegistryObserver implementation. | 38 // ExtensionRegistryObserver implementation. |
39 virtual void OnExtensionLoaded(content::BrowserContext* browser_context, | 39 void OnExtensionLoaded(content::BrowserContext* browser_context, |
40 const Extension* extension) override; | 40 const Extension* extension) override; |
41 virtual void OnExtensionUnloaded( | 41 void OnExtensionUnloaded(content::BrowserContext* browser_context, |
42 content::BrowserContext* browser_context, | 42 const Extension* extension, |
43 const Extension* extension, | 43 UnloadedExtensionInfo::Reason reason) override; |
44 UnloadedExtensionInfo::Reason reason) override; | |
45 | 44 |
46 // Gets an extension's scripts' metadata; i.e., gets a list of UserScript | 45 // Gets an extension's scripts' metadata; i.e., gets a list of UserScript |
47 // objects that contains script info, but not the contents of the scripts. | 46 // objects that contains script info, but not the contents of the scripts. |
48 const std::set<UserScript> GetScriptsMetadata(const Extension* extension); | 47 const std::set<UserScript> GetScriptsMetadata(const Extension* extension); |
49 | 48 |
50 // Script loader that handles loading contents of scripts into shared memory | 49 // Script loader that handles loading contents of scripts into shared memory |
51 // and notifying renderers of scripts in shared memory. | 50 // and notifying renderers of scripts in shared memory. |
52 UserScriptLoader loader_; | 51 UserScriptLoader loader_; |
53 | 52 |
54 // The profile for which the scripts managed here are installed. | 53 // The profile for which the scripts managed here are installed. |
55 Profile* profile_; | 54 Profile* profile_; |
56 | 55 |
57 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> | 56 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> |
58 extension_registry_observer_; | 57 extension_registry_observer_; |
59 | 58 |
60 DISALLOW_COPY_AND_ASSIGN(SharedUserScriptMaster); | 59 DISALLOW_COPY_AND_ASSIGN(SharedUserScriptMaster); |
61 }; | 60 }; |
62 | 61 |
63 } // namespace extensions | 62 } // namespace extensions |
64 | 63 |
65 #endif // CHROME_BROWSER_EXTENSIONS_SHARED_USER_SCRIPT_MASTER_H_ | 64 #endif // CHROME_BROWSER_EXTENSIONS_SHARED_USER_SCRIPT_MASTER_H_ |
OLD | NEW |