| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> |
| 9 #include <string> | 10 #include <string> |
| 10 #include <vector> | 11 #include <vector> |
| 11 | 12 |
| 12 #include "base/gtest_prod_util.h" | 13 #include "base/gtest_prod_util.h" |
| 13 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 14 #include "chrome/common/extensions/extension.h" | 15 #include "chrome/common/extensions/extension.h" |
| 15 #include "googleurl/src/gurl.h" | 16 #include "googleurl/src/gurl.h" |
| 16 | 17 |
| 17 // The one true extension container. Extensions are identified by their id. | 18 // The one true extension container. Extensions are identified by their id. |
| 18 // Only one extension can be in the set with a given ID. | 19 // Only one extension can be in the set with a given ID. |
| 19 class ExtensionSet { | 20 class ExtensionSet { |
| 20 public: | 21 public: |
| 22 typedef std::pair<FilePath, std::string> ExtensionPathAndDefaultLocale; |
| 23 |
| 21 ExtensionSet(); | 24 ExtensionSet(); |
| 22 ~ExtensionSet(); | 25 ~ExtensionSet(); |
| 23 | 26 |
| 24 // Gets the number of extensions contained. | 27 // Gets the number of extensions contained. |
| 25 size_t size() const; | 28 size_t size() const; |
| 26 | 29 |
| 27 // Returns true if the set contains the specified extension. | 30 // Returns true if the set contains the specified extension. |
| 28 bool Contains(const std::string& id); | 31 bool Contains(const std::string& id); |
| 29 | 32 |
| 30 // Adds the specified extension to the set. The set becomes an owner. Any | 33 // Adds the specified extension to the set. The set becomes an owner. Any |
| (...skipping 19 matching lines...) Expand all Loading... |
| 50 bool InSameExtent(const GURL& old_url, const GURL& new_url) const; | 53 bool InSameExtent(const GURL& old_url, const GURL& new_url) const; |
| 51 | 54 |
| 52 // Look up an Extension object by id. | 55 // Look up an Extension object by id. |
| 53 const Extension* GetByID(const std::string& id) const; | 56 const Extension* GetByID(const std::string& id) const; |
| 54 | 57 |
| 55 // Returns true if |url| should get extension api bindings and be permitted | 58 // Returns true if |url| should get extension api bindings and be permitted |
| 56 // to make api calls. Note that this is independent of what extension | 59 // to make api calls. Note that this is independent of what extension |
| 57 // permissions the given extension has been granted. | 60 // permissions the given extension has been granted. |
| 58 bool ExtensionBindingsAllowed(const GURL& url) const; | 61 bool ExtensionBindingsAllowed(const GURL& url) const; |
| 59 | 62 |
| 63 // Populates map with the path and default locale for all extension IDs. |
| 64 void GetExtensionsPathAndDefaultLocale( |
| 65 std::map<std::string, ExtensionPathAndDefaultLocale>& info) const; |
| 66 |
| 60 private: | 67 private: |
| 61 FRIEND_TEST_ALL_PREFIXES(ExtensionSetTest, ExtensionSet); | 68 FRIEND_TEST_ALL_PREFIXES(ExtensionSetTest, ExtensionSet); |
| 62 | 69 |
| 63 // static | 70 // static |
| 64 typedef std::map<std::string, scoped_refptr<const Extension> > ExtensionMap; | 71 typedef std::map<std::string, scoped_refptr<const Extension> > ExtensionMap; |
| 65 ExtensionMap extensions_; | 72 ExtensionMap extensions_; |
| 66 | 73 |
| 67 DISALLOW_COPY_AND_ASSIGN(ExtensionSet); | 74 DISALLOW_COPY_AND_ASSIGN(ExtensionSet); |
| 68 }; | 75 }; |
| 69 | 76 |
| 70 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_SET_H_ | 77 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_SET_H_ |
| OLD | NEW |