OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 EXTENSIONS_COMMON_MANIFEST_HANDLERS_SHARED_MODULE_INFO_H_ | 5 #ifndef EXTENSIONS_COMMON_MANIFEST_HANDLERS_SHARED_MODULE_INFO_H_ |
6 #define EXTENSIONS_COMMON_MANIFEST_HANDLERS_SHARED_MODULE_INFO_H_ | 6 #define EXTENSIONS_COMMON_MANIFEST_HANDLERS_SHARED_MODULE_INFO_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 18 matching lines...) Expand all Loading... |
29 // Utility functions. | 29 // Utility functions. |
30 static void ParseImportedPath(const std::string& path, | 30 static void ParseImportedPath(const std::string& path, |
31 std::string* import_id, | 31 std::string* import_id, |
32 std::string* import_relative_path); | 32 std::string* import_relative_path); |
33 static bool IsImportedPath(const std::string& path); | 33 static bool IsImportedPath(const std::string& path); |
34 | 34 |
35 // Functions relating to exporting resources. | 35 // Functions relating to exporting resources. |
36 static bool IsSharedModule(const Extension* extension); | 36 static bool IsSharedModule(const Extension* extension); |
37 static bool IsExportAllowed(const Extension* extension, | 37 static bool IsExportAllowed(const Extension* extension, |
38 const std::string& relative_path); | 38 const std::string& relative_path); |
| 39 // Check against the shared module's whitelist to see if |other_id| can import |
| 40 // its resources. If no whitelist is specified, all extensions can import this |
| 41 // extension. |
| 42 static bool IsExportAllowedByWhitelist(const Extension* extension, |
| 43 const std::string& other_id); |
39 | 44 |
40 // Functions relating to importing resources. | 45 // Functions relating to importing resources. |
41 static bool ImportsExtensionById(const Extension* extension, | 46 static bool ImportsExtensionById(const Extension* extension, |
42 const std::string& other_id); | 47 const std::string& other_id); |
43 static bool ImportsModules(const Extension* extension); | 48 static bool ImportsModules(const Extension* extension); |
44 static const std::vector<ImportInfo>& GetImports(const Extension* extension); | 49 static const std::vector<ImportInfo>& GetImports(const Extension* extension); |
45 | 50 |
46 private: | 51 private: |
47 // This extension exports the following resources to other extensions. | 52 // This extension exports the following resources to other extensions. |
48 URLPatternSet exported_set_; | 53 URLPatternSet exported_set_; |
49 | 54 |
| 55 // Optional list of extensions from which importing is allowed. |
| 56 std::set<std::string> export_whitelist_; |
| 57 |
50 // Optional list of module imports of other extensions. | 58 // Optional list of module imports of other extensions. |
51 std::vector<ImportInfo> imports_; | 59 std::vector<ImportInfo> imports_; |
52 }; | 60 }; |
53 | 61 |
54 // Parses all import/export keys in the manifest. | 62 // Parses all import/export keys in the manifest. |
55 class SharedModuleHandler : public ManifestHandler { | 63 class SharedModuleHandler : public ManifestHandler { |
56 public: | 64 public: |
57 SharedModuleHandler(); | 65 SharedModuleHandler(); |
58 virtual ~SharedModuleHandler(); | 66 virtual ~SharedModuleHandler(); |
59 | 67 |
60 virtual bool Parse(Extension* extension, base::string16* error) OVERRIDE; | 68 virtual bool Parse(Extension* extension, base::string16* error) OVERRIDE; |
61 virtual bool Validate(const Extension* extension, | 69 virtual bool Validate(const Extension* extension, |
62 std::string* error, | 70 std::string* error, |
63 std::vector<InstallWarning>* warnings) const OVERRIDE; | 71 std::vector<InstallWarning>* warnings) const OVERRIDE; |
64 | 72 |
65 private: | 73 private: |
66 virtual const std::vector<std::string> Keys() const OVERRIDE; | 74 virtual const std::vector<std::string> Keys() const OVERRIDE; |
67 }; | 75 }; |
68 | 76 |
69 } // namespace extensions | 77 } // namespace extensions |
70 | 78 |
71 #endif // EXTENSIONS_COMMON_MANIFEST_HANDLERS_SHARED_MODULE_INFO_H_ | 79 #endif // EXTENSIONS_COMMON_MANIFEST_HANDLERS_SHARED_MODULE_INFO_H_ |
OLD | NEW |