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_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/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
13 #include "chrome/common/extensions/extension.h" | 14 #include "chrome/common/extensions/extension.h" |
14 #include "chrome/common/extensions/extension_set.h" | 15 #include "chrome/common/extensions/extension_set.h" |
15 | 16 |
16 class Extension; | 17 class Extension; |
17 | 18 |
18 // Contains extension data that needs to be accessed on the IO thread. It can | 19 // Contains extension data that needs to be accessed on the IO thread. It can |
19 // be created/destroyed on any thread, but all other methods must be called on | 20 // be created/destroyed on any thread, but all other methods must be called on |
20 // the IO thread. | 21 // the IO thread. |
21 class ExtensionInfoMap : public base::RefCountedThreadSafe<ExtensionInfoMap> { | 22 class ExtensionInfoMap : public base::RefCountedThreadSafe<ExtensionInfoMap> { |
22 public: | 23 public: |
23 ExtensionInfoMap(); | 24 ExtensionInfoMap(); |
24 ~ExtensionInfoMap(); | 25 ~ExtensionInfoMap(); |
25 | 26 |
26 const ExtensionSet& extensions() const { return extensions_; } | 27 const ExtensionSet& extensions() const { return extensions_; } |
27 const ExtensionSet& disabled_extensions() const { | 28 const ExtensionSet& disabled_extensions() const { |
28 return disabled_extensions_; | 29 return disabled_extensions_; |
29 } | 30 } |
30 | 31 |
31 // Callback for when new extensions are loaded. | 32 // Callback for when new extensions are loaded. |
32 void AddExtension(const Extension* extension); | 33 void AddExtension(const Extension* extension, |
| 34 base::Time install_time, |
| 35 bool incognito_enabled); |
33 | 36 |
34 // Callback for when an extension is unloaded. | 37 // Callback for when an extension is unloaded. |
35 void RemoveExtension(const std::string& id, | 38 void RemoveExtension(const std::string& extension_id, |
36 const UnloadedExtensionInfo::Reason reason); | 39 const UnloadedExtensionInfo::Reason reason); |
37 | 40 |
| 41 // Returns the time the extension was installed, or base::Time() if not found. |
| 42 base::Time GetInstallTime(const std::string& extension_id) const; |
| 43 |
| 44 // Returns true if the user has allowed this extension to run in incognito |
| 45 // mode. |
| 46 bool IsIncognitoEnabled(const std::string& extension_id) const; |
| 47 |
| 48 // Returns true if the given extension can see events and data from another |
| 49 // sub-profile (incognito to original profile, or vice versa). |
| 50 bool CanCrossIncognito(const Extension* extension); |
| 51 |
38 private: | 52 private: |
| 53 // Extra dynamic data related to an extension. |
| 54 struct ExtraData; |
| 55 // Map of extension_id to ExtraData. |
| 56 typedef std::map<std::string, ExtraData> ExtraDataMap; |
| 57 |
39 ExtensionSet extensions_; | 58 ExtensionSet extensions_; |
40 ExtensionSet disabled_extensions_; | 59 ExtensionSet disabled_extensions_; |
| 60 |
| 61 // Extra data associated with enabled extensions. |
| 62 ExtraDataMap extra_data_; |
41 }; | 63 }; |
42 | 64 |
43 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_INFO_MAP_H_ | 65 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_INFO_MAP_H_ |
OLD | NEW |