| 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_BROWSER_EXTENSIONS_EXTENSION_INFO_MAP_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_INFO_MAP_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_INFO_MAP_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_INFO_MAP_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/time.h" | 12 #include "base/time.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "chrome/browser/extensions/extensions_quota_service.h" | 15 #include "chrome/browser/extensions/extensions_quota_service.h" |
| 16 #include "chrome/browser/extensions/process_map.h" | 16 #include "chrome/browser/extensions/process_map.h" |
| 17 #include "chrome/common/extensions/extension_constants.h" | 17 #include "chrome/common/extensions/extension_constants.h" |
| 18 #include "chrome/common/extensions/extension_set.h" | 18 #include "chrome/common/extensions/extension_set.h" |
| 19 | 19 |
| 20 class Extension; | 20 class Extension; |
| 21 | 21 |
| 22 // Contains extension data that needs to be accessed on the IO thread. It can | 22 // Contains extension data that needs to be accessed on the IO thread. It can |
| 23 // be created/destroyed on any thread, but all other methods must be called on | 23 // be created/destroyed on any thread, but all other methods must be called on |
| 24 // the IO thread. | 24 // the IO thread. |
| 25 class ExtensionInfoMap : public base::RefCountedThreadSafe<ExtensionInfoMap> { | 25 class ExtensionInfoMap : public base::RefCountedThreadSafe<ExtensionInfoMap> { |
| 26 public: | 26 public: |
| 27 ExtensionInfoMap(); | 27 ExtensionInfoMap(); |
| 28 ~ExtensionInfoMap(); | |
| 29 | 28 |
| 30 const ExtensionSet& extensions() const { return extensions_; } | 29 const ExtensionSet& extensions() const { return extensions_; } |
| 31 const ExtensionSet& disabled_extensions() const { | 30 const ExtensionSet& disabled_extensions() const { |
| 32 return disabled_extensions_; | 31 return disabled_extensions_; |
| 33 } | 32 } |
| 34 | 33 |
| 35 const extensions::ProcessMap& process_map() const; | 34 const extensions::ProcessMap& process_map() const; |
| 36 | 35 |
| 37 // Callback for when new extensions are loaded. | 36 // Callback for when new extensions are loaded. |
| 38 void AddExtension(const Extension* extension, | 37 void AddExtension(const Extension* extension, |
| (...skipping 28 matching lines...) Expand all Loading... |
| 67 | 66 |
| 68 // Returns true if there is exists an extension with the same origin as | 67 // Returns true if there is exists an extension with the same origin as |
| 69 // |origin| in |process_id| with |permission|. | 68 // |origin| in |process_id| with |permission|. |
| 70 bool SecurityOriginHasAPIPermission( | 69 bool SecurityOriginHasAPIPermission( |
| 71 const GURL& origin, int process_id, | 70 const GURL& origin, int process_id, |
| 72 ExtensionAPIPermission::ID permission) const; | 71 ExtensionAPIPermission::ID permission) const; |
| 73 | 72 |
| 74 ExtensionsQuotaService* GetQuotaService(); | 73 ExtensionsQuotaService* GetQuotaService(); |
| 75 | 74 |
| 76 private: | 75 private: |
| 76 friend class base::RefCountedThreadSafe<ExtensionInfoMap>; |
| 77 |
| 77 // Extra dynamic data related to an extension. | 78 // Extra dynamic data related to an extension. |
| 78 struct ExtraData; | 79 struct ExtraData; |
| 79 // Map of extension_id to ExtraData. | 80 // Map of extension_id to ExtraData. |
| 80 typedef std::map<std::string, ExtraData> ExtraDataMap; | 81 typedef std::map<std::string, ExtraData> ExtraDataMap; |
| 81 | 82 |
| 83 ~ExtensionInfoMap(); |
| 84 |
| 82 ExtensionSet extensions_; | 85 ExtensionSet extensions_; |
| 83 ExtensionSet disabled_extensions_; | 86 ExtensionSet disabled_extensions_; |
| 84 | 87 |
| 85 // Extra data associated with enabled extensions. | 88 // Extra data associated with enabled extensions. |
| 86 ExtraDataMap extra_data_; | 89 ExtraDataMap extra_data_; |
| 87 | 90 |
| 88 // Used by dispatchers to limit API quota for individual extensions. | 91 // Used by dispatchers to limit API quota for individual extensions. |
| 89 // The ExtensionQutoaService is not thread safe. We need to create and destroy | 92 // The ExtensionQutoaService is not thread safe. We need to create and destroy |
| 90 // it on the IO thread. | 93 // it on the IO thread. |
| 91 scoped_ptr<ExtensionsQuotaService> quota_service_; | 94 scoped_ptr<ExtensionsQuotaService> quota_service_; |
| 92 | 95 |
| 93 // Assignment of extensions to processes. | 96 // Assignment of extensions to processes. |
| 94 extensions::ProcessMap process_map_; | 97 extensions::ProcessMap process_map_; |
| 95 }; | 98 }; |
| 96 | 99 |
| 97 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_INFO_MAP_H_ | 100 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_INFO_MAP_H_ |
| OLD | NEW |