Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_EXTENSIONS_SHARED_USER_SCRIPT_MASTER_H_ | |
| 6 #define CHROME_BROWSER_EXTENSIONS_SHARED_USER_SCRIPT_MASTER_H_ | |
| 7 | |
| 8 #include <set> | |
| 9 | |
| 10 #include "base/scoped_observer.h" | |
| 11 #include "chrome/browser/extensions/user_script_loader.h" | |
| 12 #include "content/public/browser/notification_observer.h" | |
|
Devlin
2014/08/04 18:33:24
don't need either of the notification_*.h
Mark Dittmer
2014/08/05 20:33:18
Done.
| |
| 13 #include "content/public/browser/notification_registrar.h" | |
| 14 #include "extensions/browser/extension_registry.h" | |
|
Devlin
2014/08/04 18:33:24
forward-declare ExtensionRegistry.
Mark Dittmer
2014/08/05 20:33:18
Done.
| |
| 15 #include "extensions/browser/extension_registry_observer.h" | |
| 16 #include "extensions/common/extension.h" | |
| 17 #include "extensions/common/user_script.h" | |
| 18 | |
| 19 namespace content { | |
|
Devlin
2014/08/04 18:33:24
nit:
namespace content {
class BrowserContext;
}
Mark Dittmer
2014/08/05 20:33:18
Done.
| |
| 20 | |
| 21 class BrowserContext; | |
| 22 | |
| 23 } // namespace content | |
| 24 | |
| 25 class Profile; | |
| 26 | |
| 27 namespace extensions { | |
| 28 | |
| 29 class SharedUserScriptMaster : public ExtensionRegistryObserver { | |
|
Devlin
2014/08/04 18:33:25
class comments
Mark Dittmer
2014/08/05 20:33:18
Done.
| |
| 30 public: | |
| 31 explicit SharedUserScriptMaster(Profile* profile); | |
| 32 virtual ~SharedUserScriptMaster(); | |
| 33 | |
| 34 // ExtensionRegistryObserver implementation. | |
| 35 virtual void OnExtensionLoaded(content::BrowserContext* browser_context, | |
|
Devlin
2014/08/04 18:33:24
privatize.
Mark Dittmer
2014/08/05 20:33:18
Done.
| |
| 36 const Extension* extension) OVERRIDE; | |
| 37 virtual void OnExtensionUnloaded( | |
| 38 content::BrowserContext* browser_context, | |
| 39 const Extension* extension, | |
| 40 UnloadedExtensionInfo::Reason reason) OVERRIDE; | |
| 41 | |
| 42 // Provides access to loader state method: ScriptsReady(). | |
| 43 bool ScriptsReady() const { return loader_.ScriptsReady(); } | |
| 44 | |
| 45 private: | |
| 46 // 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. | |
| 48 const std::set<UserScript>& GetScriptsMetadata(const Extension* extension); | |
| 49 | |
| 50 // Map of extension ID -> list of script metadata for currently-loaded | |
| 51 // extensions. | |
| 52 std::map<ExtensionId, std::set<UserScript> > scripts_metadata_; | |
| 53 | |
| 54 // Script loader that handles loading contents of scripts into shared memory | |
| 55 // and notifying renderers of scripts in shared memory. | |
| 56 UserScriptLoader loader_; | |
| 57 | |
| 58 // The profile for which the scripts managed here are installed. | |
| 59 Profile* profile_; | |
| 60 | |
| 61 // Listen to extension load, unloaded notifications. | |
| 62 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> | |
| 63 extension_registry_observer_; | |
| 64 | |
| 65 DISALLOW_COPY_AND_ASSIGN(SharedUserScriptMaster); | |
| 66 }; | |
| 67 | |
| 68 } // namespace extensions | |
| 69 | |
| 70 #endif // CHROME_BROWSER_EXTENSIONS_SHARED_USER_SCRIPT_MASTER_H_ | |
| OLD | NEW |