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

Side by Side Diff: chrome/browser/extensions/shared_user_script_master.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 relationship between UserScriptMaster and its subclasses 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 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.
4
5 #ifndef CHROME_BROWSER_EXTENSIONS_SHARED_USER_SCRIPT_MASTER_H_
6 #define CHROME_BROWSER_EXTENSIONS_SHARED_USER_SCRIPT_MASTER_H_
7
8 #include <set>
9
10 #include "base/scoped_observer.h"
11 #include "chrome/browser/extensions/user_script_master.h"
12 #include "content/public/browser/notification_observer.h"
13 #include "content/public/browser/notification_registrar.h"
14 #include "extensions/browser/extension_registry.h"
15 #include "extensions/browser/extension_registry_observer.h"
16 #include "extensions/common/extension.h"
17
18 namespace content {
19
Devlin 2014/07/31 20:32:24 namespace content { class BrowserContext; }
20 class BrowserContext;
21
22 } // namespace content
23
24 class Profile;
25
26 namespace extensions {
27
28 class SharedUserScriptMaster : public UserScriptMaster,
29 public ExtensionRegistryObserver {
30 public:
31 explicit SharedUserScriptMaster(Profile* profile);
32 virtual ~SharedUserScriptMaster();
33
34 // ExtensionRegistryObserver implementation.
35 virtual void OnExtensionLoaded(content::BrowserContext* browser_context,
Devlin 2014/07/31 20:32:24 private
36 const Extension* extension) OVERRIDE;
37 virtual void OnExtensionUnloaded(
38 content::BrowserContext* browser_context,
39 const Extension* extension,
40 UnloadedExtensionInfo::Reason reason) OVERRIDE;
41
42 // UserScriptMaster implementation.
43 virtual void StartLoad() OVERRIDE;
44
45 protected:
46 // UserScriptMaster implementation.
Devlin 2014/07/31 20:32:24 private
47 virtual void AcquireUserScripts(scoped_ptr<UserScriptList> scripts) OVERRIDE;
48 virtual ExtensionsInfo GetExtensionsInfo() OVERRIDE;
49 virtual std::set<ExtensionId> GetAddedExtensions() OVERRIDE;
50 virtual std::set<ExtensionId> GetAllManagedExtensions() OVERRIDE;
51 virtual std::set<ExtensionId> GetChangedExtensions() OVERRIDE;
52 virtual void ResetChangedExtensions() OVERRIDE;
53
54 private:
55 void OnExtensionSystemReady();
Devlin 2014/07/31 20:32:24 comment
56
57 // Attempt to initiate a load of scripts. May need to signal a pending load if
58 // a load is already in progress.
59 void AttemptLoad();
60
61 bool is_loading() const {
62 // Ownership of |user_scripts_| is passed to the file thread when loading.
63 return user_scripts_.get() == NULL;
64 }
65
66 // List of scripts from currently-installed extensions we should load.
67 scoped_ptr<UserScriptList> user_scripts_;
68
69 // The IDs of the extensions which have changed since the last update sent to
70 // the renderer.
71 std::set<ExtensionId> changed_extensions_;
72
73 // The mutually-exclusive sets of extensions that were added or removed since
74 // the last script load.
75 std::set<ExtensionId> added_extensions_;
76 std::set<ExtensionId> removed_extensions_;
77
78 // Maps extension info needed for localization to an extension ID.
79 ExtensionsInfo extensions_info_;
80
81 // If the extensions service has finished loading its initial set of
82 // extensions.
83 bool extensions_service_ready_;
84
85 base::WeakPtrFactory<SharedUserScriptMaster> weak_factory_;
86
87 // Listen to extension load, unloaded notifications.
88 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver>
89 extension_registry_observer_;
90
91 DISALLOW_COPY_AND_ASSIGN(SharedUserScriptMaster);
92 };
93
94 } // namespace extensions
95
96 #endif // CHROME_BROWSER_EXTENSIONS_SHARED_USER_SCRIPT_MASTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698