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 namespace extensions { |
20 class Extension; | 21 class Extension; |
| 22 } |
21 | 23 |
22 // Contains extension data that needs to be accessed on the IO thread. It can | 24 // 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 | 25 // be created/destroyed on any thread, but all other methods must be called on |
24 // the IO thread. | 26 // the IO thread. |
25 class ExtensionInfoMap : public base::RefCountedThreadSafe<ExtensionInfoMap> { | 27 class ExtensionInfoMap : public base::RefCountedThreadSafe<ExtensionInfoMap> { |
26 public: | 28 public: |
27 ExtensionInfoMap(); | 29 ExtensionInfoMap(); |
28 | 30 |
29 const ExtensionSet& extensions() const { return extensions_; } | 31 const ExtensionSet& extensions() const { return extensions_; } |
30 const ExtensionSet& disabled_extensions() const { | 32 const ExtensionSet& disabled_extensions() const { |
31 return disabled_extensions_; | 33 return disabled_extensions_; |
32 } | 34 } |
33 | 35 |
34 const extensions::ProcessMap& process_map() const; | 36 const extensions::ProcessMap& process_map() const; |
35 | 37 |
36 // Callback for when new extensions are loaded. | 38 // Callback for when new extensions are loaded. |
37 void AddExtension(const Extension* extension, | 39 void AddExtension(const extensions::Extension* extension, |
38 base::Time install_time, | 40 base::Time install_time, |
39 bool incognito_enabled); | 41 bool incognito_enabled); |
40 | 42 |
41 // Callback for when an extension is unloaded. | 43 // Callback for when an extension is unloaded. |
42 void RemoveExtension(const std::string& extension_id, | 44 void RemoveExtension(const std::string& extension_id, |
43 const extension_misc::UnloadedExtensionReason reason); | 45 const extension_misc::UnloadedExtensionReason reason); |
44 | 46 |
45 // Returns the time the extension was installed, or base::Time() if not found. | 47 // Returns the time the extension was installed, or base::Time() if not found. |
46 base::Time GetInstallTime(const std::string& extension_id) const; | 48 base::Time GetInstallTime(const std::string& extension_id) const; |
47 | 49 |
48 // Returns true if the user has allowed this extension to run in incognito | 50 // Returns true if the user has allowed this extension to run in incognito |
49 // mode. | 51 // mode. |
50 bool IsIncognitoEnabled(const std::string& extension_id) const; | 52 bool IsIncognitoEnabled(const std::string& extension_id) const; |
51 | 53 |
52 // Returns true if the given extension can see events and data from another | 54 // Returns true if the given extension can see events and data from another |
53 // sub-profile (incognito to original profile, or vice versa). | 55 // sub-profile (incognito to original profile, or vice versa). |
54 bool CanCrossIncognito(const Extension* extension); | 56 bool CanCrossIncognito(const extensions::Extension* extension); |
55 | 57 |
56 // Adds an entry to process_map_. | 58 // Adds an entry to process_map_. |
57 void RegisterExtensionProcess(const std::string& extension_id, | 59 void RegisterExtensionProcess(const std::string& extension_id, |
58 int process_id, | 60 int process_id, |
59 int site_instance_id); | 61 int site_instance_id); |
60 | 62 |
61 // Removes an entry from process_map_. | 63 // Removes an entry from process_map_. |
62 void UnregisterExtensionProcess(const std::string& extension_id, | 64 void UnregisterExtensionProcess(const std::string& extension_id, |
63 int process_id, | 65 int process_id, |
64 int site_instance_id); | 66 int site_instance_id); |
(...skipping 26 matching lines...) Expand all Loading... |
91 // Used by dispatchers to limit API quota for individual extensions. | 93 // Used by dispatchers to limit API quota for individual extensions. |
92 // The ExtensionQutoaService is not thread safe. We need to create and destroy | 94 // The ExtensionQutoaService is not thread safe. We need to create and destroy |
93 // it on the IO thread. | 95 // it on the IO thread. |
94 scoped_ptr<ExtensionsQuotaService> quota_service_; | 96 scoped_ptr<ExtensionsQuotaService> quota_service_; |
95 | 97 |
96 // Assignment of extensions to processes. | 98 // Assignment of extensions to processes. |
97 extensions::ProcessMap process_map_; | 99 extensions::ProcessMap process_map_; |
98 }; | 100 }; |
99 | 101 |
100 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_INFO_MAP_H_ | 102 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_INFO_MAP_H_ |
OLD | NEW |