Roll src/third_party/WebKit f298044:aa8346d (svn 202628:202629)
[chromium-blink-merge.git] / chrome / browser / extensions / shared_user_script_master.h
blob656f514a3668e1e994376a480f8c9ed041f88fdf
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.
5 #ifndef CHROME_BROWSER_EXTENSIONS_SHARED_USER_SCRIPT_MASTER_H_
6 #define CHROME_BROWSER_EXTENSIONS_SHARED_USER_SCRIPT_MASTER_H_
8 #include <set>
10 #include "base/scoped_observer.h"
11 #include "extensions/browser/extension_registry_observer.h"
12 #include "extensions/browser/extension_user_script_loader.h"
13 #include "extensions/common/extension.h"
14 #include "extensions/common/user_script.h"
16 namespace content {
17 class BrowserContext;
20 class Profile;
22 namespace extensions {
24 class ExtensionRegistry;
26 // Manages statically-defined user scripts for all extensions. Owns a
27 // UserScriptLoader to which file loading and shared memory management
28 // operations are delegated.
29 class SharedUserScriptMaster : public ExtensionRegistryObserver {
30 public:
31 explicit SharedUserScriptMaster(Profile* profile);
32 ~SharedUserScriptMaster() override;
34 // Provides access to loader state method: scripts_ready().
35 bool scripts_ready() const { return loader_.scripts_ready(); }
37 private:
38 // ExtensionRegistryObserver implementation.
39 void OnExtensionLoaded(content::BrowserContext* browser_context,
40 const Extension* extension) override;
41 void OnExtensionUnloaded(content::BrowserContext* browser_context,
42 const Extension* extension,
43 UnloadedExtensionInfo::Reason reason) override;
45 // Gets an extension's scripts' metadata; i.e., gets a list of UserScript
46 // objects that contains script info, but not the contents of the scripts.
47 const std::set<UserScript> GetScriptsMetadata(const Extension* extension);
49 // Script loader that handles loading contents of scripts into shared memory
50 // and notifying renderers of scripts in shared memory.
51 ExtensionUserScriptLoader loader_;
53 // The profile for which the scripts managed here are installed.
54 Profile* profile_;
56 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver>
57 extension_registry_observer_;
59 DISALLOW_COPY_AND_ASSIGN(SharedUserScriptMaster);
62 } // namespace extensions
64 #endif // CHROME_BROWSER_EXTENSIONS_SHARED_USER_SCRIPT_MASTER_H_