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

Side by Side Diff: chrome/browser/extensions/extension_user_script_loader.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: Another round of comments of Devlin@. Created 5 years, 11 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 2015 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_SHARED_USER_SCRIPT_MASTER_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_USER_SCRIPT_LOADER_H_
6 #define CHROME_BROWSER_EXTENSIONS_SHARED_USER_SCRIPT_MASTER_H_ 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_USER_SCRIPT_LOADER_H_
7 7
8 #include <set> 8 #include "base/memory/shared_memory.h"
9
10 #include "base/scoped_observer.h"
11 #include "chrome/browser/extensions/user_script_loader.h" 9 #include "chrome/browser/extensions/user_script_loader.h"
12 #include "extensions/browser/extension_registry_observer.h" 10 #include "extensions/browser/extension_registry_observer.h"
13 #include "extensions/common/extension.h" 11 #include "extensions/common/extension.h"
14 #include "extensions/common/user_script.h" 12 #include "extensions/common/extension_set.h"
Devlin 2015/01/21 23:25:20 Do we need this?
Xi Han 2015/01/22 17:19:36 Removed.
15 13
16 namespace content { 14 namespace content {
17 class BrowserContext; 15 class BrowserContext;
18 } 16 }
19 17
20 class Profile; 18 class Profile;
21 19
22 namespace extensions { 20 namespace extensions {
23 21
22 class ContentVerifier;
24 class ExtensionRegistry; 23 class ExtensionRegistry;
25 24
26 // Manages statically-defined user scripts for all extensions. Owns a 25 // UserScriptLoader for extensions.
27 // UserScriptLoader to which file loading and shared memory management 26 class ExtensionUserScriptLoader : public UserScriptLoader,
28 // operations are delegated. 27 public ExtensionRegistryObserver {
29 class SharedUserScriptMaster : public ExtensionRegistryObserver {
30 public: 28 public:
31 explicit SharedUserScriptMaster(Profile* profile); 29 // The listen_for_extension_system_loaded is only set true when initilizing
32 ~SharedUserScriptMaster() override; 30 // the Exttension System, e.g, when constructs SharedUserScriptMaster in
33 31 // ExtensionSystemImpl.
34 // Provides access to loader state method: scripts_ready(). 32 ExtensionUserScriptLoader(Profile* profile,
35 bool scripts_ready() const { return loader_.scripts_ready(); } 33 const ConsumerID& consumer_id,
34 bool listen_for_extension_system_loaded);
35 ~ExtensionUserScriptLoader() override;
36 36
37 private: 37 private:
38 // ExtensionRegistryObserver implementation. 38 // UserScriptLoader:
39 void OnExtensionLoaded(content::BrowserContext* browser_context, 39 void UpdateConsumersInfo(const ConsumerIDSet& changed_consumers) override;
40 const Extension* extension) override; 40 LoadUserScriptsContentFunction GetLoadUserScriptsFunction() override;
41
42 // ExtensionRegistryObserver:
41 void OnExtensionUnloaded(content::BrowserContext* browser_context, 43 void OnExtensionUnloaded(content::BrowserContext* browser_context,
42 const Extension* extension, 44 const Extension* extension,
43 UnloadedExtensionInfo::Reason reason) override; 45 UnloadedExtensionInfo::Reason reason) override;
44 46
45 // Gets an extension's scripts' metadata; i.e., gets a list of UserScript 47 // Initiates script load when we have been waiting for the extension system
46 // objects that contains script info, but not the contents of the scripts. 48 // to be ready.
47 const std::set<UserScript> GetScriptsMetadata(const Extension* extension); 49 void OnExtensionSystemReady();
48
49 // Script loader that handles loading contents of scripts into shared memory
50 // and notifying renderers of scripts in shared memory.
51 UserScriptLoader loader_;
52
53 // The profile for which the scripts managed here are installed.
54 Profile* profile_;
55 50
56 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> 51 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver>
57 extension_registry_observer_; 52 extension_registry_observer_;
58 53
59 DISALLOW_COPY_AND_ASSIGN(SharedUserScriptMaster); 54 base::WeakPtrFactory<ExtensionUserScriptLoader> weak_factory_;
55
56 DISALLOW_COPY_AND_ASSIGN(ExtensionUserScriptLoader);
60 }; 57 };
61 58
62 } // namespace extensions 59 } // namespace extensions
63 60
64 #endif // CHROME_BROWSER_EXTENSIONS_SHARED_USER_SCRIPT_MASTER_H_ 61 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_USER_SCRIPT_LOADER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698