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