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 <set> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/time.h" | 13 #include "base/time.h" |
14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
15 #include "chrome/common/extensions/extension_constants.h" | 15 #include "chrome/common/extensions/extension_constants.h" |
16 #include "chrome/common/extensions/extension_set.h" | 16 #include "chrome/common/extensions/extension_set.h" |
17 | 17 |
18 class Extension; | 18 class Extension; |
19 | 19 |
(...skipping 23 matching lines...) Expand all Loading... |
43 base::Time GetInstallTime(const std::string& extension_id) const; | 43 base::Time GetInstallTime(const std::string& extension_id) const; |
44 | 44 |
45 // Returns true if the user has allowed this extension to run in incognito | 45 // Returns true if the user has allowed this extension to run in incognito |
46 // mode. | 46 // mode. |
47 bool IsIncognitoEnabled(const std::string& extension_id) const; | 47 bool IsIncognitoEnabled(const std::string& extension_id) const; |
48 | 48 |
49 // Returns true if the given extension can see events and data from another | 49 // Returns true if the given extension can see events and data from another |
50 // sub-profile (incognito to original profile, or vice versa). | 50 // sub-profile (incognito to original profile, or vice versa). |
51 bool CanCrossIncognito(const Extension* extension); | 51 bool CanCrossIncognito(const Extension* extension); |
52 | 52 |
53 // Registers a RenderProcessHost with |render_process_id| as hosting an | 53 // Record that |extension_id| is running in |process_id|. We normally have |
54 // extension. | 54 // this information in ExtensionProcessManager on the UI thread, but we also |
55 void BindingsEnabledForProcess(int render_process_id); | 55 // sometimes need it on the IO thread. Note that this can be any of |
| 56 // (extension, packaged app, hosted app). |
| 57 void RegisterExtensionProcess(const std::string& extension_id, |
| 58 int process_id); |
56 | 59 |
57 // Unregisters the RenderProcessHost with |render_process_id|. | 60 // Remove any record of |extension_id| created with RegisterExtensionProcess. |
58 void BindingsDisabledForProcess(int render_process_id); | 61 // If |extension_id| is unknown, we ignore it. |
| 62 void UnregisterExtensionProcess(const std::string& extension_id, |
| 63 int process_id); |
59 | 64 |
60 // True if this process host is hosting an extension with extension bindings. | 65 // Returns true if |extension_id| is running in |process_id|.. |
61 bool AreBindingsEnabledForProcess(int render_process_id) const; | 66 bool IsExtensionInProcess(const std::string& extension_id, |
| 67 int process_id) const; |
62 | 68 |
63 private: | 69 private: |
64 // Extra dynamic data related to an extension. | 70 // Extra dynamic data related to an extension. |
65 struct ExtraData; | 71 struct ExtraData; |
66 // Map of extension_id to ExtraData. | 72 // Map of extension_id to ExtraData. |
67 typedef std::map<std::string, ExtraData> ExtraDataMap; | 73 typedef std::map<std::string, ExtraData> ExtraDataMap; |
68 | 74 |
69 ExtensionSet extensions_; | 75 ExtensionSet extensions_; |
70 ExtensionSet disabled_extensions_; | 76 ExtensionSet disabled_extensions_; |
71 | 77 |
72 // Extra data associated with enabled extensions. | 78 // Extra data associated with enabled extensions. |
73 ExtraDataMap extra_data_; | 79 ExtraDataMap extra_data_; |
74 | 80 |
75 // The set of process ids that have extension bindings enabled. | 81 typedef std::multimap<std::string, int> ExtensionProcessIDMap; |
76 std::set<int> extension_bindings_process_ids_; | 82 ExtensionProcessIDMap extension_process_ids_; |
77 }; | 83 }; |
78 | 84 |
79 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_INFO_MAP_H_ | 85 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_INFO_MAP_H_ |
OLD | NEW |