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

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

Issue 899983002: Revert of 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: rebase 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"
15 12
16 class Profile; 13 class Profile;
17 14
18 namespace extensions { 15 namespace extensions {
19 class DeclarativeUserScriptMaster; 16 class DeclarativeUserScriptMaster;
20 17
21 // Manages a set of DeclarativeUserScriptMaster objects for script injections. 18 // Manages a set of DeclarativeUserScriptMaster objects for script injections.
22 class DeclarativeUserScriptManager : public ExtensionRegistryObserver { 19 class DeclarativeUserScriptManager {
23 public: 20 public:
24 explicit DeclarativeUserScriptManager(Profile* profile); 21 explicit DeclarativeUserScriptManager(Profile* profile);
25 ~DeclarativeUserScriptManager() override; 22 ~DeclarativeUserScriptManager();
26 23
27 // Gets the user script master for declarative scripts by the given 24 // Get the user script master for declarative scripts; if one does not exist,
28 // HostID; if one does not exist, a new object will be created. 25 // a new object will be created.
29 DeclarativeUserScriptMaster* GetDeclarativeUserScriptMasterByID( 26 DeclarativeUserScriptMaster* GetDeclarativeUserScriptMasterByID(
30 const HostID& host_id); 27 const std::string& id);
31 28
32 private: 29 private:
33 using UserScriptMasterMap = 30 using UserScriptMasterMap =
34 std::map<HostID, linked_ptr<DeclarativeUserScriptMaster>>; 31 std::map<std::string, linked_ptr<DeclarativeUserScriptMaster>>;
35 32
36 // ExtensionRegistryObserver: 33 // A map of DeclarativeUserScriptMasters for ids; each master is lazily
37 void OnExtensionUnloaded(content::BrowserContext* browser_context, 34 // initialized.
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.
47 UserScriptMasterMap declarative_user_script_masters_; 35 UserScriptMasterMap declarative_user_script_masters_;
48 36
49 Profile* profile_; 37 Profile* profile_;
50 38
51 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver>
52 extension_registry_observer_;
53
54 DISALLOW_COPY_AND_ASSIGN(DeclarativeUserScriptManager); 39 DISALLOW_COPY_AND_ASSIGN(DeclarativeUserScriptManager);
55 }; 40 };
56 41
57 } // namespace extensions 42 } // extensions
58 43
59 #endif // CHROME_BROWSER_EXTENSIONS_DECLARATIVE_USER_SCRIPT_MANAGER_H_ 44 #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