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