| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_COMMON_EXTENSIONS_EXTENSION_SET_H_ | 5 #ifndef CHROME_COMMON_EXTENSIONS_EXTENSION_SET_H_ |
| 6 #define CHROME_COMMON_EXTENSIONS_EXTENSION_SET_H_ | 6 #define CHROME_COMMON_EXTENSIONS_EXTENSION_SET_H_ |
| 7 | 7 |
| 8 #include <iterator> | 8 #include <iterator> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 | 83 |
| 84 // Adds the specified extension to the set. The set becomes an owner. Any | 84 // Adds the specified extension to the set. The set becomes an owner. Any |
| 85 // previous extension with the same ID is removed. | 85 // previous extension with the same ID is removed. |
| 86 void Insert(const scoped_refptr<const extensions::Extension>& extension); | 86 void Insert(const scoped_refptr<const extensions::Extension>& extension); |
| 87 | 87 |
| 88 // Copies different items from |extensions| to the current set and returns | 88 // Copies different items from |extensions| to the current set and returns |
| 89 // whether anything changed. | 89 // whether anything changed. |
| 90 bool InsertAll(const ExtensionSet& extensions); | 90 bool InsertAll(const ExtensionSet& extensions); |
| 91 | 91 |
| 92 // Removes the specified extension. | 92 // Removes the specified extension. |
| 93 void Remove(const std::string& id); | 93 // Returns true if the set contained the specified extnesion. |
| 94 bool Remove(const std::string& id); |
| 94 | 95 |
| 95 // Removes all extensions. | 96 // Removes all extensions. |
| 96 void Clear(); | 97 void Clear(); |
| 97 | 98 |
| 98 // Returns the extension ID, or empty if none. This includes web URLs that | 99 // Returns the extension ID, or empty if none. This includes web URLs that |
| 99 // are part of an extension's web extent. | 100 // are part of an extension's web extent. |
| 100 std::string GetExtensionOrAppIDByURL(const ExtensionURLInfo& info) const; | 101 std::string GetExtensionOrAppIDByURL(const ExtensionURLInfo& info) const; |
| 101 | 102 |
| 102 // Returns the Extension, or NULL if none. This includes web URLs that are | 103 // Returns the Extension, or NULL if none. This includes web URLs that are |
| 103 // part of an extension's web extent. | 104 // part of an extension's web extent. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 116 const extensions::Extension* GetHostedAppByOverlappingWebExtent( | 117 const extensions::Extension* GetHostedAppByOverlappingWebExtent( |
| 117 const extensions::URLPatternSet& extent) const; | 118 const extensions::URLPatternSet& extent) const; |
| 118 | 119 |
| 119 // Returns true if |new_url| is in the extent of the same extension as | 120 // Returns true if |new_url| is in the extent of the same extension as |
| 120 // |old_url|. Also returns true if neither URL is in an app. | 121 // |old_url|. Also returns true if neither URL is in an app. |
| 121 bool InSameExtent(const GURL& old_url, const GURL& new_url) const; | 122 bool InSameExtent(const GURL& old_url, const GURL& new_url) const; |
| 122 | 123 |
| 123 // Look up an Extension object by id. | 124 // Look up an Extension object by id. |
| 124 const extensions::Extension* GetByID(const std::string& id) const; | 125 const extensions::Extension* GetByID(const std::string& id) const; |
| 125 | 126 |
| 127 // Gets the IDs of all extensions in the set. |
| 128 std::set<std::string> GetIDs() const; |
| 129 |
| 126 // Returns true if |info| should get extension api bindings and be permitted | 130 // Returns true if |info| should get extension api bindings and be permitted |
| 127 // to make api calls. Note that this is independent of what extension | 131 // to make api calls. Note that this is independent of what extension |
| 128 // permissions the given extension has been granted. | 132 // permissions the given extension has been granted. |
| 129 bool ExtensionBindingsAllowed(const ExtensionURLInfo& info) const; | 133 bool ExtensionBindingsAllowed(const ExtensionURLInfo& info) const; |
| 130 | 134 |
| 131 // Returns true if |info| is an extension page that is to be served in a | 135 // Returns true if |info| is an extension page that is to be served in a |
| 132 // unique sandboxed origin. | 136 // unique sandboxed origin. |
| 133 bool IsSandboxedPage(const ExtensionURLInfo& info) const; | 137 bool IsSandboxedPage(const ExtensionURLInfo& info) const; |
| 134 | 138 |
| 135 private: | 139 private: |
| 136 FRIEND_TEST_ALL_PREFIXES(ExtensionSetTest, ExtensionSet); | 140 FRIEND_TEST_ALL_PREFIXES(ExtensionSetTest, ExtensionSet); |
| 137 | 141 |
| 138 ExtensionMap extensions_; | 142 ExtensionMap extensions_; |
| 139 | 143 |
| 140 DISALLOW_COPY_AND_ASSIGN(ExtensionSet); | 144 DISALLOW_COPY_AND_ASSIGN(ExtensionSet); |
| 141 }; | 145 }; |
| 142 | 146 |
| 143 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_SET_H_ | 147 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_SET_H_ |
| OLD | NEW |