Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(290)

Side by Side Diff: chrome/browser/extensions/declarative_user_script_manager.h

Issue 822453002: Introduce HostID and de-couple Extensions from "script injection System" [browser side] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_DECLARATIVE_USER_SCRIPT_MANAGER_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_DECLARATIVE_USER_SCRIPT_MANAGER_H_
6 #define CHROME_BROWSER_EXTENSIONS_DECLARATIVE_USER_SCRIPT_MANAGER_H_ 6 #define CHROME_BROWSER_EXTENSIONS_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" 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"
12 15
13 class Profile; 16 class Profile;
14 17
15 namespace extensions { 18 namespace extensions {
16 class DeclarativeUserScriptMaster; 19 class DeclarativeUserScriptMaster;
17 20
18 // Manages a set of DeclarativeUserScriptMaster objects for script injections. 21 // Manages a set of DeclarativeUserScriptMaster objects for script injections.
19 class DeclarativeUserScriptManager { 22 class DeclarativeUserScriptManager : public ExtensionRegistryObserver {
20 public: 23 public:
21 explicit DeclarativeUserScriptManager(Profile* profile); 24 explicit DeclarativeUserScriptManager(Profile* profile);
22 ~DeclarativeUserScriptManager(); 25 ~DeclarativeUserScriptManager() override;
23 26
24 // Get the user script master for declarative scripts; if one does not exist, 27 // Gets the user script master for declarative scripts by the given
25 // a new object will be created. 28 // HostID; if one does not exist, a new object will be created.
26 DeclarativeUserScriptMaster* GetDeclarativeUserScriptMasterByID( 29 DeclarativeUserScriptMaster* GetDeclarativeUserScriptMasterByID(
27 const std::string& id); 30 const HostID& host_id);
28 31
29 private: 32 private:
30 using UserScriptMasterMap = 33 using UserScriptMasterMap =
31 std::map<std::string, linked_ptr<DeclarativeUserScriptMaster>>; 34 std::map<HostID, linked_ptr<DeclarativeUserScriptMaster>>;
32 35
33 // A map of DeclarativeUserScriptMasters for ids; each master is lazily 36 // ExtensionRegistryObserver:
34 // initialized. 37 void OnExtensionUnloaded(content::BrowserContext* browser_context,
38 const Extension* extension,
39 UnloadedExtensionInfo::Reason reason) override;
40
41 // Creates a DeclarativeUserScriptMaster object.
42 DeclarativeUserScriptMaster* CreateDeclarativeUserScriptMaster(
43 const HostID& host_id);
44
45 // A map of DeclarativeUserScriptMasters for each host; each master
46 // is lazily initialized.
35 UserScriptMasterMap declarative_user_script_masters_; 47 UserScriptMasterMap declarative_user_script_masters_;
36 48
37 Profile* profile_; 49 Profile* profile_;
38 50
51 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver>
52 extension_registry_observer_;
53
39 DISALLOW_COPY_AND_ASSIGN(DeclarativeUserScriptManager); 54 DISALLOW_COPY_AND_ASSIGN(DeclarativeUserScriptManager);
40 }; 55 };
41 56
42 } // extensions 57 } // namespace extensions
43 58
44 #endif // CHROME_BROWSER_EXTENSIONS_DECLARATIVE_USER_SCRIPT_MANAGER_H_ 59 #endif // CHROME_BROWSER_EXTENSIONS_DECLARATIVE_USER_SCRIPT_MANAGER_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/convert_user_script.cc ('k') | chrome/browser/extensions/declarative_user_script_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698