Remove linux_chromium_gn_dbg from the chromium CQ.
[chromium-blink-merge.git] / extensions / renderer / renderer_extension_registry.h
blob6a887a16d4f92e3be4c6ad98ed90ce6ea63ce206
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
3 // found in the LICENSE file.
5 #ifndef EXTENSIONS_RENDERER_RENDERER_EXTENSION_REGISTRY_H_
6 #define EXTENSIONS_RENDERER_RENDERER_EXTENSION_REGISTRY_H_
8 #include <string>
10 #include "base/synchronization/lock.h"
11 #include "extensions/common/extension_set.h"
13 class GURL;
15 namespace extensions {
17 // Thread safe container for all loaded extensions in this process,
18 // essentially the renderer counterpart to ExtensionRegistry.
19 class RendererExtensionRegistry {
20 public:
21 RendererExtensionRegistry();
22 ~RendererExtensionRegistry();
24 static RendererExtensionRegistry* Get();
26 // Returns the ExtensionSet that underlies this RenderExtensionRegistry.
28 // This is not thread-safe and must only be called on the RenderThread, but
29 // even so, it's not thread safe because other threads may decide to
30 // modify this. Don't persist a reference to this.
32 // TODO(annekao): remove or make thread-safe and callback-based.
33 const ExtensionSet* GetMainThreadExtensionSet() const;
35 size_t size() const;
36 bool is_empty() const;
38 // Forwards to the ExtensionSet methods by the same name.
39 bool Contains(const std::string& id) const;
40 bool Insert(const scoped_refptr<const Extension>& extension);
41 bool Remove(const std::string& id);
42 std::string GetExtensionOrAppIDByURL(const GURL& url) const;
43 const Extension* GetExtensionOrAppByURL(const GURL& url) const;
44 const Extension* GetHostedAppByURL(const GURL& url) const;
45 const Extension* GetByID(const std::string& id) const;
46 ExtensionIdSet GetIDs() const;
47 bool ExtensionBindingsAllowed(const GURL& url) const;
49 private:
50 ExtensionSet extensions_;
52 mutable base::Lock lock_;
54 DISALLOW_COPY_AND_ASSIGN(RendererExtensionRegistry);
57 } // namespace extensions
59 #endif // EXTENSIONS_RENDERER_RENDERER_EXTENSION_REGISTRY_H_