| 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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 bool has_export = extension->manifest()->HasKey(keys::kExport); | 129 bool has_export = extension->manifest()->HasKey(keys::kExport); |
| 130 if (!has_import && !has_export) | 130 if (!has_import && !has_export) |
| 131 return true; | 131 return true; |
| 132 | 132 |
| 133 if (has_import && has_export) { | 133 if (has_import && has_export) { |
| 134 *error = base::ASCIIToUTF16(errors::kInvalidImportAndExport); | 134 *error = base::ASCIIToUTF16(errors::kInvalidImportAndExport); |
| 135 return false; | 135 return false; |
| 136 } | 136 } |
| 137 | 137 |
| 138 if (has_export) { | 138 if (has_export) { |
| 139 const base::DictionaryValue* export_value = NULL; | 139 const base::DictionaryValue* export_value = nullptr; |
| 140 if (!extension->manifest()->GetDictionary(keys::kExport, &export_value)) { | 140 if (!extension->manifest()->GetDictionary(keys::kExport, &export_value)) { |
| 141 *error = base::ASCIIToUTF16(errors::kInvalidExport); | 141 *error = base::ASCIIToUTF16(errors::kInvalidExport); |
| 142 return false; | 142 return false; |
| 143 } | 143 } |
| 144 const base::ListValue* resources_list = NULL; | 144 const base::ListValue* resources_list = nullptr; |
| 145 if (!export_value->GetList(keys::kResources, &resources_list)) { | 145 if (!export_value->GetList(keys::kResources, &resources_list)) { |
| 146 *error = base::ASCIIToUTF16(errors::kInvalidExportResources); | 146 *error = base::ASCIIToUTF16(errors::kInvalidExportResources); |
| 147 return false; | 147 return false; |
| 148 } | 148 } |
| 149 if (export_value->HasKey(keys::kWhitelist)) { | 149 if (export_value->HasKey(keys::kWhitelist)) { |
| 150 const base::ListValue* whitelist = NULL; | 150 const base::ListValue* whitelist = nullptr; |
| 151 if (!export_value->GetList(keys::kWhitelist, &whitelist)) { | 151 if (!export_value->GetList(keys::kWhitelist, &whitelist)) { |
| 152 *error = base::ASCIIToUTF16(errors::kInvalidExportWhitelist); | 152 *error = base::ASCIIToUTF16(errors::kInvalidExportWhitelist); |
| 153 return false; | 153 return false; |
| 154 } | 154 } |
| 155 for (size_t i = 0; i < whitelist->GetSize(); ++i) { | 155 for (size_t i = 0; i < whitelist->GetSize(); ++i) { |
| 156 std::string extension_id; | 156 std::string extension_id; |
| 157 if (!whitelist->GetString(i, &extension_id) || | 157 if (!whitelist->GetString(i, &extension_id) || |
| 158 !crx_file::id_util::IdIsValid(extension_id)) { | 158 !crx_file::id_util::IdIsValid(extension_id)) { |
| 159 *error = ErrorUtils::FormatErrorMessageUTF16( | 159 *error = ErrorUtils::FormatErrorMessageUTF16( |
| 160 errors::kInvalidExportWhitelistString, base::IntToString(i)); | 160 errors::kInvalidExportWhitelistString, base::IntToString(i)); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 175 *error = ErrorUtils::FormatErrorMessageUTF16( | 175 *error = ErrorUtils::FormatErrorMessageUTF16( |
| 176 errors::kInvalidExportResourcesString, base::IntToString(i)); | 176 errors::kInvalidExportResourcesString, base::IntToString(i)); |
| 177 return false; | 177 return false; |
| 178 } | 178 } |
| 179 exported_set_.AddPattern( | 179 exported_set_.AddPattern( |
| 180 URLPattern(URLPattern::SCHEME_EXTENSION, resolved_path.spec())); | 180 URLPattern(URLPattern::SCHEME_EXTENSION, resolved_path.spec())); |
| 181 } | 181 } |
| 182 } | 182 } |
| 183 | 183 |
| 184 if (has_import) { | 184 if (has_import) { |
| 185 const base::ListValue* import_list = NULL; | 185 const base::ListValue* import_list = nullptr; |
| 186 if (!extension->manifest()->GetList(keys::kImport, &import_list)) { | 186 if (!extension->manifest()->GetList(keys::kImport, &import_list)) { |
| 187 *error = base::ASCIIToUTF16(errors::kInvalidImport); | 187 *error = base::ASCIIToUTF16(errors::kInvalidImport); |
| 188 return false; | 188 return false; |
| 189 } | 189 } |
| 190 for (size_t i = 0; i < import_list->GetSize(); ++i) { | 190 for (size_t i = 0; i < import_list->GetSize(); ++i) { |
| 191 const base::DictionaryValue* import_entry = NULL; | 191 const base::DictionaryValue* import_entry = nullptr; |
| 192 if (!import_list->GetDictionary(i, &import_entry)) { | 192 if (!import_list->GetDictionary(i, &import_entry)) { |
| 193 *error = base::ASCIIToUTF16(errors::kInvalidImport); | 193 *error = base::ASCIIToUTF16(errors::kInvalidImport); |
| 194 return false; | 194 return false; |
| 195 } | 195 } |
| 196 std::string extension_id; | 196 std::string extension_id; |
| 197 imports_.push_back(ImportInfo()); | 197 imports_.push_back(ImportInfo()); |
| 198 if (!import_entry->GetString(keys::kId, &extension_id) || | 198 if (!import_entry->GetString(keys::kId, &extension_id) || |
| 199 !crx_file::id_util::IdIsValid(extension_id)) { | 199 !crx_file::id_util::IdIsValid(extension_id)) { |
| 200 *error = ErrorUtils::FormatErrorMessageUTF16( | 200 *error = ErrorUtils::FormatErrorMessageUTF16( |
| 201 errors::kInvalidImportId, base::IntToString(i)); | 201 errors::kInvalidImportId, base::IntToString(i)); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 | 254 |
| 255 const std::vector<std::string> SharedModuleHandler::Keys() const { | 255 const std::vector<std::string> SharedModuleHandler::Keys() const { |
| 256 static const char* keys[] = { | 256 static const char* keys[] = { |
| 257 keys::kExport, | 257 keys::kExport, |
| 258 keys::kImport | 258 keys::kImport |
| 259 }; | 259 }; |
| 260 return std::vector<std::string>(keys, keys + arraysize(keys)); | 260 return std::vector<std::string>(keys, keys + arraysize(keys)); |
| 261 } | 261 } |
| 262 | 262 |
| 263 } // namespace extensions | 263 } // namespace extensions |
| OLD | NEW |