| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/unpacker.h" | 5 #include "chrome/common/extensions/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/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
| 11 #include "base/i18n/rtl.h" | 11 #include "base/i18n/rtl.h" |
| 12 #include "base/json/json_file_value_serializer.h" | 12 #include "base/json/json_file_value_serializer.h" |
| 13 #include "base/memory/scoped_handle.h" | 13 #include "base/memory/scoped_handle.h" |
| 14 #include "base/string_util.h" | 14 #include "base/string_util.h" |
| 15 #include "base/threading/thread.h" | 15 #include "base/threading/thread.h" |
| 16 #include "base/utf_string_conversions.h" | 16 #include "base/utf_string_conversions.h" |
| 17 #include "base/values.h" | 17 #include "base/values.h" |
| 18 #include "chrome/common/extensions/extension.h" | 18 #include "chrome/common/extensions/extension.h" |
| 19 #include "chrome/common/extensions/extension_file_util.h" | 19 #include "chrome/common/extensions/extension_file_util.h" |
| 20 #include "chrome/common/extensions/extension_l10n_util.h" | 20 #include "chrome/common/extensions/extension_l10n_util.h" |
| 21 #include "chrome/common/extensions/extension_manifest_constants.h" | 21 #include "chrome/common/extensions/extension_manifest_constants.h" |
| 22 #include "chrome/common/extensions/manifest.h" |
| 22 #include "chrome/common/url_constants.h" | 23 #include "chrome/common/url_constants.h" |
| 23 #include "chrome/common/zip.h" | 24 #include "chrome/common/zip.h" |
| 24 #include "content/public/common/common_param_traits.h" | 25 #include "content/public/common/common_param_traits.h" |
| 25 #include "grit/generated_resources.h" | 26 #include "grit/generated_resources.h" |
| 26 #include "ipc/ipc_message_utils.h" | 27 #include "ipc/ipc_message_utils.h" |
| 27 #include "net/base/file_stream.h" | 28 #include "net/base/file_stream.h" |
| 28 #include "third_party/skia/include/core/SkBitmap.h" | 29 #include "third_party/skia/include/core/SkBitmap.h" |
| 29 #include "ui/base/l10n/l10n_util.h" | 30 #include "ui/base/l10n/l10n_util.h" |
| 30 #include "webkit/glue/image_decoder.h" | 31 #include "webkit/glue/image_decoder.h" |
| 31 | 32 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 | 77 |
| 77 return false; | 78 return false; |
| 78 } | 79 } |
| 79 | 80 |
| 80 } // namespace | 81 } // namespace |
| 81 | 82 |
| 82 namespace extensions { | 83 namespace extensions { |
| 83 | 84 |
| 84 Unpacker::Unpacker(const FilePath& extension_path, | 85 Unpacker::Unpacker(const FilePath& extension_path, |
| 85 const std::string& extension_id, | 86 const std::string& extension_id, |
| 86 Extension::Location location, | 87 Manifest::Location location, |
| 87 int creation_flags) | 88 int creation_flags) |
| 88 : extension_path_(extension_path), | 89 : extension_path_(extension_path), |
| 89 extension_id_(extension_id), | 90 extension_id_(extension_id), |
| 90 location_(location), | 91 location_(location), |
| 91 creation_flags_(creation_flags) { | 92 creation_flags_(creation_flags) { |
| 92 } | 93 } |
| 93 | 94 |
| 94 Unpacker::~Unpacker() { | 95 Unpacker::~Unpacker() { |
| 95 } | 96 } |
| 96 | 97 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 location_, | 178 location_, |
| 178 *parsed_manifest_, | 179 *parsed_manifest_, |
| 179 creation_flags_, | 180 creation_flags_, |
| 180 extension_id_, | 181 extension_id_, |
| 181 &error)); | 182 &error)); |
| 182 if (!extension.get()) { | 183 if (!extension.get()) { |
| 183 SetError(error); | 184 SetError(error); |
| 184 return false; | 185 return false; |
| 185 } | 186 } |
| 186 | 187 |
| 187 Extension::InstallWarningVector warnings; | 188 InstallWarning::Vector warnings; |
| 188 if (!extension_file_util::ValidateExtension(extension.get(), | 189 if (!extension_file_util::ValidateExtension(extension.get(), |
| 189 &error, &warnings)) { | 190 &error, &warnings)) { |
| 190 SetError(error); | 191 SetError(error); |
| 191 return false; | 192 return false; |
| 192 } | 193 } |
| 193 extension->AddInstallWarnings(warnings); | 194 extension->AddInstallWarnings(warnings); |
| 194 | 195 |
| 195 // Decode any images that the browser needs to display. | 196 // Decode any images that the browser needs to display. |
| 196 std::set<FilePath> image_paths = extension->GetBrowserImages(); | 197 std::set<FilePath> image_paths = extension->GetBrowserImages(); |
| 197 for (std::set<FilePath>::iterator it = image_paths.begin(); | 198 for (std::set<FilePath>::iterator it = image_paths.begin(); |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 | 331 |
| 331 void Unpacker::SetError(const std::string &error) { | 332 void Unpacker::SetError(const std::string &error) { |
| 332 SetUTF16Error(UTF8ToUTF16(error)); | 333 SetUTF16Error(UTF8ToUTF16(error)); |
| 333 } | 334 } |
| 334 | 335 |
| 335 void Unpacker::SetUTF16Error(const string16 &error) { | 336 void Unpacker::SetUTF16Error(const string16 &error) { |
| 336 error_message_ = error; | 337 error_message_ = error; |
| 337 } | 338 } |
| 338 | 339 |
| 339 } // namespace extensions | 340 } // namespace extensions |
| OLD | NEW |