| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/extension_unpacker.h" | 5 #include "chrome/common/extensions/extension_unpacker.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/json/json_value_serializer.h" | 10 #include "base/json/json_value_serializer.h" |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 } | 77 } |
| 78 ++i; | 78 ++i; |
| 79 } | 79 } |
| 80 } | 80 } |
| 81 | 81 |
| 82 return false; | 82 return false; |
| 83 } | 83 } |
| 84 | 84 |
| 85 } // namespace | 85 } // namespace |
| 86 | 86 |
| 87 ExtensionUnpacker::ExtensionUnpacker(const FilePath& extension_path) | 87 ExtensionUnpacker::ExtensionUnpacker(const FilePath& extension_path, |
| 88 : extension_path_(extension_path) { | 88 Extension::Location location, |
| 89 int creation_flags) |
| 90 : extension_path_(extension_path), location_(location), |
| 91 creation_flags_(creation_flags) { |
| 89 } | 92 } |
| 90 | 93 |
| 91 ExtensionUnpacker::~ExtensionUnpacker() { | 94 ExtensionUnpacker::~ExtensionUnpacker() { |
| 92 } | 95 } |
| 93 | 96 |
| 94 DictionaryValue* ExtensionUnpacker::ReadManifest() { | 97 DictionaryValue* ExtensionUnpacker::ReadManifest() { |
| 95 FilePath manifest_path = | 98 FilePath manifest_path = |
| 96 temp_install_dir_.Append(Extension::kManifestFilename); | 99 temp_install_dir_.Append(Extension::kManifestFilename); |
| 97 if (!file_util::PathExists(manifest_path)) { | 100 if (!file_util::PathExists(manifest_path)) { |
| 98 SetError(errors::kInvalidManifest); | 101 SetError(errors::kInvalidManifest); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 if (!parsed_manifest_.get()) | 174 if (!parsed_manifest_.get()) |
| 172 return false; // Error was already reported. | 175 return false; // Error was already reported. |
| 173 | 176 |
| 174 // NOTE: Since the unpacker doesn't have the extension's public_id, the | 177 // NOTE: Since the unpacker doesn't have the extension's public_id, the |
| 175 // InitFromValue is allowed to generate a temporary id for the extension. | 178 // InitFromValue is allowed to generate a temporary id for the extension. |
| 176 // ANY CODE THAT FOLLOWS SHOULD NOT DEPEND ON THE CORRECT ID OF THIS | 179 // ANY CODE THAT FOLLOWS SHOULD NOT DEPEND ON THE CORRECT ID OF THIS |
| 177 // EXTENSION. | 180 // EXTENSION. |
| 178 std::string error; | 181 std::string error; |
| 179 scoped_refptr<Extension> extension(Extension::Create( | 182 scoped_refptr<Extension> extension(Extension::Create( |
| 180 temp_install_dir_, | 183 temp_install_dir_, |
| 181 Extension::INVALID, | 184 location_, |
| 182 *parsed_manifest_, | 185 *parsed_manifest_, |
| 183 Extension::NO_FLAGS, | 186 creation_flags_, |
| 184 &error)); | 187 &error)); |
| 185 if (!extension.get()) { | 188 if (!extension.get()) { |
| 186 SetError(error); | 189 SetError(error); |
| 187 return false; | 190 return false; |
| 188 } | 191 } |
| 189 | 192 |
| 190 if (!extension_file_util::ValidateExtension(extension.get(), &error)) { | 193 if (!extension_file_util::ValidateExtension(extension.get(), &error)) { |
| 191 SetError(error); | 194 SetError(error); |
| 192 return false; | 195 return false; |
| 193 } | 196 } |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 return false; | 319 return false; |
| 317 } | 320 } |
| 318 parsed_catalogs_->Set(dir_name, root.release()); | 321 parsed_catalogs_->Set(dir_name, root.release()); |
| 319 | 322 |
| 320 return true; | 323 return true; |
| 321 } | 324 } |
| 322 | 325 |
| 323 void ExtensionUnpacker::SetError(const std::string &error) { | 326 void ExtensionUnpacker::SetError(const std::string &error) { |
| 324 error_message_ = error; | 327 error_message_ = error; |
| 325 } | 328 } |
| OLD | NEW |