| 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/utility/extensions/unpacker.h" | 5 #include "chrome/utility/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/file_enumerator.h" | 10 #include "base/files/file_enumerator.h" |
| 11 #include "base/files/scoped_temp_dir.h" | 11 #include "base/files/scoped_temp_dir.h" |
| 12 #include "base/i18n/rtl.h" | 12 #include "base/i18n/rtl.h" |
| 13 #include "base/json/json_file_value_serializer.h" | 13 #include "base/json/json_file_value_serializer.h" |
| 14 #include "base/memory/scoped_handle.h" | 14 #include "base/memory/scoped_handle.h" |
| 15 #include "base/numerics/safe_conversions.h" | 15 #include "base/numerics/safe_conversions.h" |
| 16 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
| 17 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
| 18 #include "base/threading/thread.h" | 18 #include "base/threading/thread.h" |
| 19 #include "base/values.h" | 19 #include "base/values.h" |
| 20 #include "chrome/common/chrome_utility_messages.h" | 20 #include "chrome/common/chrome_utility_messages.h" |
| 21 #include "chrome/common/extensions/api/i18n/default_locale_handler.h" | 21 #include "chrome/common/extensions/api/i18n/default_locale_handler.h" |
| 22 #include "chrome/common/extensions/extension_file_util.h" | 22 #include "chrome/common/extensions/extension_file_util.h" |
| 23 #include "content/public/child/image_decoder_utils.h" | 23 #include "content/public/child/image_decoder_utils.h" |
| 24 #include "content/public/common/common_param_traits.h" | 24 #include "content/public/common/common_param_traits.h" |
| 25 #include "extensions/common/constants.h" | 25 #include "extensions/common/constants.h" |
| 26 #include "extensions/common/extension.h" | 26 #include "extensions/common/extension.h" |
| 27 #include "extensions/common/extension_l10n_util.h" | 27 #include "extensions/common/extension_l10n_util.h" |
| 28 #include "extensions/common/file_util.h" |
| 28 #include "extensions/common/manifest.h" | 29 #include "extensions/common/manifest.h" |
| 29 #include "extensions/common/manifest_constants.h" | 30 #include "extensions/common/manifest_constants.h" |
| 30 #include "grit/generated_resources.h" | 31 #include "grit/generated_resources.h" |
| 31 #include "ipc/ipc_message_utils.h" | 32 #include "ipc/ipc_message_utils.h" |
| 32 #include "net/base/file_stream.h" | 33 #include "net/base/file_stream.h" |
| 33 #include "third_party/skia/include/core/SkBitmap.h" | 34 #include "third_party/skia/include/core/SkBitmap.h" |
| 34 #include "third_party/zlib/google/zip.h" | 35 #include "third_party/zlib/google/zip.h" |
| 35 #include "ui/base/l10n/l10n_util.h" | 36 #include "ui/base/l10n/l10n_util.h" |
| 36 #include "ui/gfx/size.h" | 37 #include "ui/gfx/size.h" |
| 37 | 38 |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 *parsed_manifest_, | 196 *parsed_manifest_, |
| 196 creation_flags_, | 197 creation_flags_, |
| 197 extension_id_, | 198 extension_id_, |
| 198 &error)); | 199 &error)); |
| 199 if (!extension.get()) { | 200 if (!extension.get()) { |
| 200 SetError(error); | 201 SetError(error); |
| 201 return false; | 202 return false; |
| 202 } | 203 } |
| 203 | 204 |
| 204 std::vector<InstallWarning> warnings; | 205 std::vector<InstallWarning> warnings; |
| 205 if (!extension_file_util::ValidateExtension(extension.get(), | 206 if (!file_util::ValidateExtension(extension.get(), &error, &warnings)) { |
| 206 &error, &warnings)) { | |
| 207 SetError(error); | 207 SetError(error); |
| 208 return false; | 208 return false; |
| 209 } | 209 } |
| 210 extension->AddInstallWarnings(warnings); | 210 extension->AddInstallWarnings(warnings); |
| 211 | 211 |
| 212 // Decode any images that the browser needs to display. | 212 // Decode any images that the browser needs to display. |
| 213 std::set<base::FilePath> image_paths = | 213 std::set<base::FilePath> image_paths = |
| 214 extension_file_util::GetBrowserImagePaths(extension.get()); | 214 extension_file_util::GetBrowserImagePaths(extension.get()); |
| 215 for (std::set<base::FilePath>::iterator it = image_paths.begin(); | 215 for (std::set<base::FilePath>::iterator it = image_paths.begin(); |
| 216 it != image_paths.end(); | 216 it != image_paths.end(); |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 | 320 |
| 321 void Unpacker::SetError(const std::string &error) { | 321 void Unpacker::SetError(const std::string &error) { |
| 322 SetUTF16Error(base::UTF8ToUTF16(error)); | 322 SetUTF16Error(base::UTF8ToUTF16(error)); |
| 323 } | 323 } |
| 324 | 324 |
| 325 void Unpacker::SetUTF16Error(const base::string16& error) { | 325 void Unpacker::SetUTF16Error(const base::string16& error) { |
| 326 error_message_ = error; | 326 error_message_ = error; |
| 327 } | 327 } |
| 328 | 328 |
| 329 } // namespace extensions | 329 } // namespace extensions |
| OLD | NEW |