| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "chrome/common/extensions/manifest_handlers/shared_module_info.h" | 5 #include "chrome/common/extensions/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" |
| 11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 12 #include "base/version.h" | 12 #include "base/version.h" |
| 13 #include "chrome/common/extensions/extension_constants.h" | |
| 14 #include "chrome/common/extensions/extension_manifest_constants.h" | 13 #include "chrome/common/extensions/extension_manifest_constants.h" |
| 15 #include "chrome/common/extensions/permissions/permission_set.h" | 14 #include "chrome/common/extensions/permissions/permission_set.h" |
| 15 #include "extensions/common/constants.h" |
| 16 #include "extensions/common/error_utils.h" | 16 #include "extensions/common/error_utils.h" |
| 17 | 17 |
| 18 namespace keys = extension_manifest_keys; | 18 namespace keys = extension_manifest_keys; |
| 19 namespace values = extension_manifest_values; | 19 namespace values = extension_manifest_values; |
| 20 namespace errors = extension_manifest_errors; | 20 namespace errors = extension_manifest_errors; |
| 21 | 21 |
| 22 namespace extensions { | 22 namespace extensions { |
| 23 | 23 |
| 24 namespace { | 24 namespace { |
| 25 | 25 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 43 | 43 |
| 44 SharedModuleInfo::~SharedModuleInfo() { | 44 SharedModuleInfo::~SharedModuleInfo() { |
| 45 } | 45 } |
| 46 | 46 |
| 47 // static | 47 // static |
| 48 void SharedModuleInfo::ParseImportedPath(const std::string& path, | 48 void SharedModuleInfo::ParseImportedPath(const std::string& path, |
| 49 std::string* import_id, | 49 std::string* import_id, |
| 50 std::string* import_relative_path) { | 50 std::string* import_relative_path) { |
| 51 std::vector<std::string> tokens; | 51 std::vector<std::string> tokens; |
| 52 Tokenize(path, std::string("/"), &tokens); | 52 Tokenize(path, std::string("/"), &tokens); |
| 53 if (tokens.size() > 2 && tokens[0] == extension_filenames::kModulesDir && | 53 if (tokens.size() > 2 && tokens[0] == kModulesDir && |
| 54 Extension::IdIsValid(tokens[1])) { | 54 Extension::IdIsValid(tokens[1])) { |
| 55 *import_id = tokens[1]; | 55 *import_id = tokens[1]; |
| 56 *import_relative_path = tokens[2]; | 56 *import_relative_path = tokens[2]; |
| 57 for (size_t i = 3; i < tokens.size(); ++i) | 57 for (size_t i = 3; i < tokens.size(); ++i) |
| 58 *import_relative_path += "/" + tokens[i]; | 58 *import_relative_path += "/" + tokens[i]; |
| 59 } | 59 } |
| 60 } | 60 } |
| 61 | 61 |
| 62 // static | 62 // static |
| 63 bool SharedModuleInfo::IsImportedPath(const std::string& path) { | 63 bool SharedModuleInfo::IsImportedPath(const std::string& path) { |
| 64 std::vector<std::string> tokens; | 64 std::vector<std::string> tokens; |
| 65 Tokenize(path, std::string("/"), &tokens); | 65 Tokenize(path, std::string("/"), &tokens); |
| 66 if (tokens.size() > 2 && tokens[0] == extension_filenames::kModulesDir && | 66 if (tokens.size() > 2 && tokens[0] == kModulesDir && |
| 67 Extension::IdIsValid(tokens[1])) { | 67 Extension::IdIsValid(tokens[1])) { |
| 68 return true; | 68 return true; |
| 69 } | 69 } |
| 70 return false; | 70 return false; |
| 71 } | 71 } |
| 72 | 72 |
| 73 // static | 73 // static |
| 74 bool SharedModuleInfo::IsSharedModule(const Extension* extension) { | 74 bool SharedModuleInfo::IsSharedModule(const Extension* extension) { |
| 75 CHECK(extension); | 75 CHECK(extension); |
| 76 return extension->manifest()->is_shared_module(); | 76 return extension->manifest()->is_shared_module(); |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 } | 217 } |
| 218 | 218 |
| 219 const std::vector<std::string> SharedModuleHandler::Keys() const { | 219 const std::vector<std::string> SharedModuleHandler::Keys() const { |
| 220 static const char* keys[] = { | 220 static const char* keys[] = { |
| 221 keys::kExport, | 221 keys::kExport, |
| 222 keys::kImport | 222 keys::kImport |
| 223 }; | 223 }; |
| 224 return std::vector<std::string>(keys, keys + arraysize(keys)); | 224 return std::vector<std::string>(keys, keys + arraysize(keys)); |
| 225 } | 225 } |
| 226 | 226 |
| 227 } // extensions | 227 } // namespace extensions |
| 228 | |
| OLD | NEW |