OLD | NEW |
---|---|
(Empty) | |
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. | |
4 | |
5 #ifndef EXTENSIONS_RENDERER_RENDERER_EXTENSION_REGISTRY_H_ | |
6 #define EXTENSIONS_RENDERER_RENDERER_EXTENSION_REGISTRY_H_ | |
7 | |
8 #include <iterator> | |
9 #include <string> | |
10 | |
11 #include "base/synchronization/lock.h" | |
12 #include "extensions/common/extension.h" | |
13 #include "extensions/common/extension_set.h" | |
14 #include "url/gurl.h" | |
15 | |
16 namespace extensions { | |
17 | |
18 // Thread safe container for all loaded extensions in this process, | |
19 // essentially the renderer counterpart to ExtensionRegistry. | |
20 class RendererExtensionRegistry { | |
21 public: | |
22 RendererExtensionRegistry(); | |
23 ~RendererExtensionRegistry(); | |
24 | |
25 static RendererExtensionRegistry* Get(); | |
26 | |
27 const ExtensionSet* GetMainThreadExtensionSet() const; | |
Devlin
2015/08/18 15:40:55
This should definitely have a comment, and probabl
annekao
2015/08/18 17:43:31
Done.
| |
28 | |
29 size_t size() const; | |
30 bool is_empty() const; | |
31 | |
32 // Iteration support. | |
33 ExtensionSet::const_iterator begin() const { return extensions_.begin(); } | |
Devlin
2015/08/18 15:40:55
This is thread-unsafe. If the main thread acquire
annekao
2015/08/18 17:43:31
Done. Used in IsRuntimeAvailableToConnect() and U
| |
34 ExtensionSet::const_iterator end() const { return extensions_.end(); } | |
35 | |
36 // Returns true if the set contains the specified extension. | |
37 bool Contains(const std::string& id) const; | |
Devlin
2015/08/18 15:40:55
I think for these you can (and probably should) ju
annekao
2015/08/18 17:43:31
Done.
| |
38 | |
39 // Adds the specified extension to the set. The set becomes an owner. Any | |
40 // previous extension with the same ID is removed. | |
41 // Returns true if there is no previous extension. | |
42 bool Insert(const scoped_refptr<const Extension>& extension); | |
43 | |
44 // Removes the specified extension. | |
45 // Returns true if the set contained the specified extnesion. | |
46 bool Remove(const std::string& id); | |
47 | |
48 // Returns the extension ID, or empty if none. This includes web URLs that | |
49 // are part of an extension's web extent. | |
50 std::string GetExtensionOrAppIDByURL(const GURL& url) const; | |
51 | |
52 // Returns the Extension, or NULL if none. This includes web URLs that are | |
53 // part of an extension's web extent. | |
54 // NOTE: This can return NULL if called before UpdateExtensions receives | |
55 // bulk extension data (e.g. if called from | |
56 // EventBindings::HandleContextCreated) | |
57 const Extension* GetExtensionOrAppByURL(const GURL& url) const; | |
58 | |
59 const Extension* GetHostedAppByURL(const GURL& url) const; | |
60 | |
61 // Look up an Extension object by id. | |
62 const Extension* GetByID(const std::string& id) const; | |
63 | |
64 // Gets the IDs of all extensions in the set. | |
65 ExtensionIdSet GetIDs() const; | |
66 | |
67 // Returns true if |info| should get extension api bindings and be permitted | |
68 // to make api calls. Note that this is independent of what extension | |
69 // permissions the given extension has been granted. | |
70 bool ExtensionBindingsAllowed(const GURL& url) const; | |
71 | |
72 private: | |
73 ExtensionSet extensions_; | |
74 | |
75 mutable base::Lock lock_; | |
76 | |
77 DISALLOW_COPY_AND_ASSIGN(RendererExtensionRegistry); | |
78 }; | |
79 | |
80 } // namespace extensions | |
81 | |
82 #endif // EXTENSIONS_RENDERER_RENDERER_EXTENSION_REGISTRY_H_ | |
OLD | NEW |