| 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 EXTENSIONS_BROWSER_DECLARATIVE_USER_SCRIPT_MANAGER_H_ | 5 #ifndef EXTENSIONS_BROWSER_DECLARATIVE_USER_SCRIPT_MANAGER_H_ |
| 6 #define EXTENSIONS_BROWSER_DECLARATIVE_USER_SCRIPT_MANAGER_H_ | 6 #define EXTENSIONS_BROWSER_DECLARATIVE_USER_SCRIPT_MANAGER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/memory/linked_ptr.h" | |
| 12 #include "base/scoped_observer.h" | 11 #include "base/scoped_observer.h" |
| 13 #include "components/keyed_service/core/keyed_service.h" | 12 #include "components/keyed_service/core/keyed_service.h" |
| 14 #include "extensions/browser/extension_registry_observer.h" | 13 #include "extensions/browser/extension_registry_observer.h" |
| 15 #include "extensions/common/host_id.h" | 14 #include "extensions/common/host_id.h" |
| 16 | 15 |
| 17 namespace content { | 16 namespace content { |
| 18 class BrowserContext; | 17 class BrowserContext; |
| 19 } | 18 } |
| 20 | 19 |
| 21 namespace extensions { | 20 namespace extensions { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 33 // |context|. | 32 // |context|. |
| 34 static DeclarativeUserScriptManager* Get(content::BrowserContext* context); | 33 static DeclarativeUserScriptManager* Get(content::BrowserContext* context); |
| 35 | 34 |
| 36 // Gets the user script master for declarative scripts by the given | 35 // Gets the user script master for declarative scripts by the given |
| 37 // HostID; if one does not exist, a new object will be created. | 36 // HostID; if one does not exist, a new object will be created. |
| 38 DeclarativeUserScriptMaster* GetDeclarativeUserScriptMasterByID( | 37 DeclarativeUserScriptMaster* GetDeclarativeUserScriptMasterByID( |
| 39 const HostID& host_id); | 38 const HostID& host_id); |
| 40 | 39 |
| 41 private: | 40 private: |
| 42 using UserScriptMasterMap = | 41 using UserScriptMasterMap = |
| 43 std::map<HostID, linked_ptr<DeclarativeUserScriptMaster>>; | 42 std::map<HostID, std::unique_ptr<DeclarativeUserScriptMaster>>; |
| 44 | 43 |
| 45 // ExtensionRegistryObserver: | 44 // ExtensionRegistryObserver: |
| 46 void OnExtensionUnloaded(content::BrowserContext* browser_context, | 45 void OnExtensionUnloaded(content::BrowserContext* browser_context, |
| 47 const Extension* extension, | 46 const Extension* extension, |
| 48 UnloadedExtensionInfo::Reason reason) override; | 47 UnloadedExtensionInfo::Reason reason) override; |
| 49 | 48 |
| 50 // Creates a DeclarativeUserScriptMaster object. | 49 // Creates a DeclarativeUserScriptMaster object. |
| 51 DeclarativeUserScriptMaster* CreateDeclarativeUserScriptMaster( | 50 DeclarativeUserScriptMaster* CreateDeclarativeUserScriptMaster( |
| 52 const HostID& host_id); | 51 const HostID& host_id); |
| 53 | 52 |
| 54 // A map of DeclarativeUserScriptMasters for each host; each master | 53 // A map of DeclarativeUserScriptMasters for each host; each master |
| 55 // is lazily initialized. | 54 // is lazily initialized. |
| 56 UserScriptMasterMap declarative_user_script_masters_; | 55 UserScriptMasterMap declarative_user_script_masters_; |
| 57 | 56 |
| 58 content::BrowserContext* browser_context_; | 57 content::BrowserContext* browser_context_; |
| 59 | 58 |
| 60 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> | 59 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> |
| 61 extension_registry_observer_; | 60 extension_registry_observer_; |
| 62 | 61 |
| 63 DISALLOW_COPY_AND_ASSIGN(DeclarativeUserScriptManager); | 62 DISALLOW_COPY_AND_ASSIGN(DeclarativeUserScriptManager); |
| 64 }; | 63 }; |
| 65 | 64 |
| 66 } // namespace extensions | 65 } // namespace extensions |
| 67 | 66 |
| 68 #endif // EXTENSIONS_BROWSER_DECLARATIVE_USER_SCRIPT_MANAGER_H_ | 67 #endif // EXTENSIONS_BROWSER_DECLARATIVE_USER_SCRIPT_MANAGER_H_ |
| OLD | NEW |