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 #include "extensions/common/manifest_handlers/shared_module_info.h" | 5 #include "extensions/common/manifest_handlers/shared_module_info.h" |
6 | 6 |
7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 // static | 79 // static |
80 bool SharedModuleInfo::IsExportAllowed(const Extension* extension, | 80 bool SharedModuleInfo::IsExportAllowed(const Extension* extension, |
81 const std::string& relative_path) { | 81 const std::string& relative_path) { |
82 return GetSharedModuleInfo(extension). | 82 return GetSharedModuleInfo(extension). |
83 exported_set_.MatchesURL(extension->url().Resolve(relative_path)); | 83 exported_set_.MatchesURL(extension->url().Resolve(relative_path)); |
84 } | 84 } |
85 | 85 |
86 // static | 86 // static |
87 bool SharedModuleInfo::IsExportAllowedByWhitelist(const Extension* extension, | 87 bool SharedModuleInfo::IsExportAllowedByWhitelist(const Extension* extension, |
88 const std::string& other_id) { | 88 const std::string& other_id) { |
| 89 // Sanity check. In case the caller did not check |extension| to make sure it |
| 90 // is a shared module, we do not want it to appear that the extension with |
| 91 // |other_id| importing |extension| is valid. |
| 92 if (!SharedModuleInfo::IsSharedModule(extension)) |
| 93 return false; |
89 const SharedModuleInfo& info = GetSharedModuleInfo(extension); | 94 const SharedModuleInfo& info = GetSharedModuleInfo(extension); |
90 if (info.export_whitelist_.empty()) | 95 if (info.export_whitelist_.empty()) |
91 return true; | 96 return true; |
92 if (info.export_whitelist_.find(other_id) != info.export_whitelist_.end()) | 97 if (info.export_whitelist_.find(other_id) != info.export_whitelist_.end()) |
93 return true; | 98 return true; |
94 return false; | 99 return false; |
95 } | 100 } |
96 | 101 |
97 // static | 102 // static |
98 bool SharedModuleInfo::ImportsExtensionById(const Extension* extension, | 103 bool SharedModuleInfo::ImportsExtensionById(const Extension* extension, |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 | 252 |
248 const std::vector<std::string> SharedModuleHandler::Keys() const { | 253 const std::vector<std::string> SharedModuleHandler::Keys() const { |
249 static const char* keys[] = { | 254 static const char* keys[] = { |
250 keys::kExport, | 255 keys::kExport, |
251 keys::kImport | 256 keys::kImport |
252 }; | 257 }; |
253 return std::vector<std::string>(keys, keys + arraysize(keys)); | 258 return std::vector<std::string>(keys, keys + arraysize(keys)); |
254 } | 259 } |
255 | 260 |
256 } // namespace extensions | 261 } // namespace extensions |
OLD | NEW |