Revert of Output closure-compiled JavaScript files (patchset #10 id:180001 of https...
[chromium-blink-merge.git] / extensions / browser / declarative_user_script_manager.h
blob35efbc5159160eeafffd106e8667752160b52f44
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 EXTENSIONS_BROWSER_DECLARATIVE_USER_SCRIPT_MANAGER_H_
6 #define EXTENSIONS_BROWSER_DECLARATIVE_USER_SCRIPT_MANAGER_H_
8 #include <map>
10 #include "base/macros.h"
11 #include "base/memory/linked_ptr.h"
12 #include "base/scoped_observer.h"
13 #include "extensions/browser/extension_registry_observer.h"
14 #include "extensions/common/host_id.h"
16 namespace content {
17 class BrowserContext;
20 namespace extensions {
21 class DeclarativeUserScriptMaster;
23 // Manages a set of DeclarativeUserScriptMaster objects for script injections.
24 class DeclarativeUserScriptManager : public ExtensionRegistryObserver {
25 public:
26 explicit DeclarativeUserScriptManager(
27 content::BrowserContext* browser_context);
28 ~DeclarativeUserScriptManager() override;
30 // Gets the user script master for declarative scripts by the given
31 // HostID; if one does not exist, a new object will be created.
32 DeclarativeUserScriptMaster* GetDeclarativeUserScriptMasterByID(
33 const HostID& host_id);
35 private:
36 using UserScriptMasterMap =
37 std::map<HostID, linked_ptr<DeclarativeUserScriptMaster>>;
39 // ExtensionRegistryObserver:
40 void OnExtensionUnloaded(content::BrowserContext* browser_context,
41 const Extension* extension,
42 UnloadedExtensionInfo::Reason reason) override;
44 // Creates a DeclarativeUserScriptMaster object.
45 DeclarativeUserScriptMaster* CreateDeclarativeUserScriptMaster(
46 const HostID& host_id);
48 // A map of DeclarativeUserScriptMasters for each host; each master
49 // is lazily initialized.
50 UserScriptMasterMap declarative_user_script_masters_;
52 content::BrowserContext* browser_context_;
54 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver>
55 extension_registry_observer_;
57 DISALLOW_COPY_AND_ASSIGN(DeclarativeUserScriptManager);
60 } // namespace extensions
62 #endif // EXTENSIONS_BROWSER_DECLARATIVE_USER_SCRIPT_MANAGER_H_