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

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

Issue 420543002: Declarative content scripts: Browser-side: per-extension shared memory regions (lazily loaded) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Refactor UserScriptMaster into UserScriptLoader, managed by SharedUserScriptMaster and DeclarativeU… Created 6 years, 4 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
(Empty)
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved.
Devlin 2014/08/04 18:33:26 no (c)
Mark Dittmer 2014/08/05 20:33:20 Done.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_EXTENSIONS_USER_SCRIPT_MASTER_MANAGER_H_
6 #define CHROME_BROWSER_EXTENSIONS_USER_SCRIPT_MASTER_MANAGER_H_
7
8 #include "base/containers/scoped_ptr_hash_map.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/scoped_observer.h"
11 #include "chrome/browser/extensions/declarative_user_script_master.h"
12 #include "chrome/browser/extensions/shared_user_script_master.h"
13 #include "extensions/browser/extension_registry.h"
14 #include "extensions/browser/extension_registry_observer.h"
15 #include "extensions/common/extension.h"
16 #include "extensions/common/user_script.h"
17
18 namespace content {
19
20 class BrowserContext;
Devlin 2014/08/04 18:33:26 condense
Mark Dittmer 2014/08/05 20:33:20 Done.
21
22 } // namespace content
23
24 class Profile;
25
26 namespace extensions {
27
28 class UserScriptMasterManager : public ExtensionRegistryObserver {
Devlin 2014/08/04 18:33:26 So...Do we need this class? Or could we just have
Mark Dittmer 2014/08/05 20:33:20 You're right. We can get rid of this class. Done.
29 public:
30 explicit UserScriptMasterManager(Profile* profile);
31 virtual ~UserScriptMasterManager();
32
33 SharedUserScriptMaster* shared_master() { return shared_master_.get(); }
34
35 DeclarativeUserScriptMaster* GetDeclarativeMasterByExtension(
36 const ExtensionId& extension_id) {
37 if (!declarative_masters_.get(extension_id)) {
38 declarative_masters_.set(extension_id,
39 make_scoped_ptr(new DeclarativeUserScriptMaster(
40 profile_, extension_id)));
41 }
42 return declarative_masters_.get(extension_id);
43 }
44
45 // ExtensionRegistryObserver implementation.
46 virtual void OnExtensionLoaded(content::BrowserContext* browser_context,
47 const Extension* extension) OVERRIDE;
48 virtual void OnExtensionUnloaded(
49 content::BrowserContext* browser_context,
50 const Extension* extension,
51 UnloadedExtensionInfo::Reason reason) OVERRIDE;
52
53 private:
54 Profile* profile_;
55
56 // Shared memory region manager for scripts statically declared in extension
57 // manifests. This region is shared between all extensions.
58 scoped_ptr<SharedUserScriptMaster> shared_master_;
59
60 // Shared memory region manager for programmatically declared scripts, one per
61 // extension. Managers are instantiated the first time the declarative API is
62 // used by an extension to request content scripts.
63 base::ScopedPtrHashMap<ExtensionId, DeclarativeUserScriptMaster>
64 declarative_masters_;
65
66 // Listen to extension load, unloaded notifications.
67 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver>
68 extension_registry_observer_;
69
70 DISALLOW_COPY_AND_ASSIGN(UserScriptMasterManager);
71 };
72
73 } // namespace extensions
74
75 #endif // CHROME_BROWSER_EXTENSIONS_USER_SCRIPT_MASTER_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698