OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 EXTENSIONS_COMMON_EXTENSION_SET_H_ | 5 #ifndef EXTENSIONS_COMMON_EXTENSION_SET_H_ |
6 #define EXTENSIONS_COMMON_EXTENSION_SET_H_ | 6 #define EXTENSIONS_COMMON_EXTENSION_SET_H_ |
7 | 7 |
8 #include <iterator> | 8 #include <iterator> |
9 #include <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/callback.h" | 12 #include "base/callback.h" |
13 #include "base/gtest_prod_util.h" | 13 #include "base/gtest_prod_util.h" |
14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
15 #include "extensions/common/extension.h" | 15 #include "extensions/common/extension.h" |
16 #include "url/gurl.h" | 16 #include "url/gurl.h" |
17 | 17 |
18 struct HostID; | |
19 | |
18 namespace extensions { | 20 namespace extensions { |
19 | 21 |
20 // The one true extension container. Extensions are identified by their id. | 22 // The one true extension container. Extensions are identified by their id. |
21 // Only one extension can be in the set with a given ID. | 23 // Only one extension can be in the set with a given ID. |
22 class ExtensionSet { | 24 class ExtensionSet { |
23 public: | 25 public: |
24 typedef std::pair<base::FilePath, std::string> ExtensionPathAndDefaultLocale; | 26 typedef std::pair<base::FilePath, std::string> ExtensionPathAndDefaultLocale; |
25 typedef std::map<std::string, scoped_refptr<const Extension> > ExtensionMap; | 27 typedef std::map<std::string, scoped_refptr<const Extension> > ExtensionMap; |
26 typedef base::Callback<void(const ExtensionIdSet&)> | 28 typedef base::Callback<void(const ExtensionIdSet&)> |
27 ModificationCallback; | 29 ModificationCallback; |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
117 // Returns true if |new_url| is in the extent of the same extension as | 119 // Returns true if |new_url| is in the extent of the same extension as |
118 // |old_url|. Also returns true if neither URL is in an app. | 120 // |old_url|. Also returns true if neither URL is in an app. |
119 bool InSameExtent(const GURL& old_url, const GURL& new_url) const; | 121 bool InSameExtent(const GURL& old_url, const GURL& new_url) const; |
120 | 122 |
121 // Look up an Extension object by id. | 123 // Look up an Extension object by id. |
122 const Extension* GetByID(const std::string& id) const; | 124 const Extension* GetByID(const std::string& id) const; |
123 | 125 |
124 // Gets the IDs of all extensions in the set. | 126 // Gets the IDs of all extensions in the set. |
125 ExtensionIdSet GetIDs() const; | 127 ExtensionIdSet GetIDs() const; |
126 | 128 |
129 // Gets the HostIDs of all extensions in the set. | |
130 std::set<HostID> GetHostIDs() const; | |
Devlin
2015/03/09 16:00:04
This doesn't really belong here. An ExtensionSet
Xi Han
2015/03/09 19:12:36
Moved to UserScriptSetManager.
| |
131 | |
127 // Returns true if |info| should get extension api bindings and be permitted | 132 // Returns true if |info| should get extension api bindings and be permitted |
128 // to make api calls. Note that this is independent of what extension | 133 // to make api calls. Note that this is independent of what extension |
129 // permissions the given extension has been granted. | 134 // permissions the given extension has been granted. |
130 bool ExtensionBindingsAllowed(const GURL& url) const; | 135 bool ExtensionBindingsAllowed(const GURL& url) const; |
131 | 136 |
132 void set_modification_callback( | 137 void set_modification_callback( |
133 const ModificationCallback& modification_callback) { | 138 const ModificationCallback& modification_callback) { |
134 modification_callback_ = modification_callback; | 139 modification_callback_ = modification_callback; |
135 } | 140 } |
136 | 141 |
137 private: | 142 private: |
138 FRIEND_TEST_ALL_PREFIXES(ExtensionSetTest, ExtensionSet); | 143 FRIEND_TEST_ALL_PREFIXES(ExtensionSetTest, ExtensionSet); |
139 | 144 |
140 ExtensionMap extensions_; | 145 ExtensionMap extensions_; |
141 | 146 |
142 // If non-null, called with the extension ids in this set after a modification | 147 // If non-null, called with the extension ids in this set after a modification |
143 // occurred. This is not called on Clear() which is typically used when | 148 // occurred. This is not called on Clear() which is typically used when |
144 // discarding the set (e.g., on shutdown) and we do not want to track that as | 149 // discarding the set (e.g., on shutdown) and we do not want to track that as |
145 // a real modification. | 150 // a real modification. |
146 ModificationCallback modification_callback_; | 151 ModificationCallback modification_callback_; |
147 | 152 |
148 DISALLOW_COPY_AND_ASSIGN(ExtensionSet); | 153 DISALLOW_COPY_AND_ASSIGN(ExtensionSet); |
149 }; | 154 }; |
150 | 155 |
151 } // namespace extensions | 156 } // namespace extensions |
152 | 157 |
153 #endif // EXTENSIONS_COMMON_EXTENSION_SET_H_ | 158 #endif // EXTENSIONS_COMMON_EXTENSION_SET_H_ |
OLD | NEW |