blob: 5ca40605a74a645bd69ef5e2fe8a3dada68be065 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef EXTENSIONS_BROWSER_EXTENSION_USER_SCRIPT_LOADER_H_
#define EXTENSIONS_BROWSER_EXTENSION_USER_SCRIPT_LOADER_H_
#include "base/memory/shared_memory.h"
#include "extensions/browser/extension_registry_observer.h"
#include "extensions/browser/user_script_loader.h"
#include "extensions/common/extension.h"
namespace content {
class BrowserContext;
}
namespace extensions {
class ExtensionRegistry;
// UserScriptLoader for extensions.
class ExtensionUserScriptLoader : public UserScriptLoader,
public ExtensionRegistryObserver {
public:
// The listen_for_extension_system_loaded is only set true when initilizing
// the Extension System, e.g, when constructs SharedUserScriptMaster in
// ExtensionSystemImpl.
ExtensionUserScriptLoader(content::BrowserContext* browser_context,
const HostID& host_id,
bool listen_for_extension_system_loaded);
~ExtensionUserScriptLoader() override;
private:
// UserScriptLoader:
void UpdateHostsInfo(const std::set<HostID>& changed_hosts) override;
LoadUserScriptsContentFunction GetLoadUserScriptsFunction() override;
// ExtensionRegistryObserver:
void OnExtensionUnloaded(content::BrowserContext* browser_context,
const Extension* extension,
UnloadedExtensionInfo::Reason reason) override;
// Initiates script load when we have been waiting for the extension system
// to be ready.
void OnExtensionSystemReady();
ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver>
extension_registry_observer_;
base::WeakPtrFactory<ExtensionUserScriptLoader> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(ExtensionUserScriptLoader);
};
} // namespace extensions
#endif // EXTENSIONS_BROWSER_EXTENSION_USER_SCRIPT_LOADER_H_
|