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/strings/string_util.h" | 15 #include "base/strings/string_util.h" |
16 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
17 #include "base/threading/thread.h" | 17 #include "base/threading/thread.h" |
18 #include "base/values.h" | 18 #include "base/values.h" |
19 #include "chrome/common/chrome_utility_messages.h" | 19 #include "chrome/common/chrome_utility_messages.h" |
20 #include "chrome/common/extensions/api/i18n/default_locale_handler.h" | 20 #include "chrome/common/extensions/api/i18n/default_locale_handler.h" |
21 #include "chrome/common/extensions/extension.h" | 21 #include "chrome/common/extensions/extension.h" |
22 #include "chrome/common/extensions/extension_file_util.h" | 22 #include "chrome/common/extensions/extension_file_util.h" |
23 #include "chrome/common/extensions/extension_l10n_util.h" | 23 #include "chrome/common/extensions/extension_l10n_util.h" |
24 #include "chrome/common/extensions/extension_manifest_constants.h" | |
25 #include "content/public/child/image_decoder_utils.h" | 24 #include "content/public/child/image_decoder_utils.h" |
26 #include "content/public/common/common_param_traits.h" | 25 #include "content/public/common/common_param_traits.h" |
27 #include "extensions/common/constants.h" | 26 #include "extensions/common/constants.h" |
28 #include "extensions/common/manifest.h" | 27 #include "extensions/common/manifest.h" |
| 28 #include "extensions/common/manifest_constants.h" |
29 #include "grit/generated_resources.h" | 29 #include "grit/generated_resources.h" |
30 #include "ipc/ipc_message_utils.h" | 30 #include "ipc/ipc_message_utils.h" |
31 #include "net/base/file_stream.h" | 31 #include "net/base/file_stream.h" |
32 #include "third_party/skia/include/core/SkBitmap.h" | 32 #include "third_party/skia/include/core/SkBitmap.h" |
33 #include "third_party/zlib/google/zip.h" | 33 #include "third_party/zlib/google/zip.h" |
34 #include "ui/base/l10n/l10n_util.h" | 34 #include "ui/base/l10n/l10n_util.h" |
35 #include "ui/gfx/size.h" | 35 #include "ui/gfx/size.h" |
36 | 36 |
37 namespace errors = extension_manifest_errors; | 37 namespace extensions { |
38 namespace keys = extensions::manifest_keys; | |
39 | 38 |
40 namespace { | 39 namespace { |
41 | 40 |
| 41 namespace errors = manifest_errors; |
| 42 namespace keys = manifest_keys; |
| 43 |
42 // A limit to stop us passing dangerously large canvases to the browser. | 44 // A limit to stop us passing dangerously large canvases to the browser. |
43 const int kMaxImageCanvas = 4096 * 4096; | 45 const int kMaxImageCanvas = 4096 * 4096; |
44 | 46 |
45 SkBitmap DecodeImage(const base::FilePath& path) { | 47 SkBitmap DecodeImage(const base::FilePath& path) { |
46 // Read the file from disk. | 48 // Read the file from disk. |
47 std::string file_contents; | 49 std::string file_contents; |
48 if (!base::PathExists(path) || | 50 if (!base::PathExists(path) || |
49 !base::ReadFileToString(path, &file_contents)) { | 51 !base::ReadFileToString(path, &file_contents)) { |
50 return SkBitmap(); | 52 return SkBitmap(); |
51 } | 53 } |
(...skipping 26 matching lines...) Expand all Loading... |
78 } | 80 } |
79 ++i; | 81 ++i; |
80 } | 82 } |
81 } | 83 } |
82 | 84 |
83 return false; | 85 return false; |
84 } | 86 } |
85 | 87 |
86 } // namespace | 88 } // namespace |
87 | 89 |
88 namespace extensions { | |
89 | |
90 struct Unpacker::InternalData { | 90 struct Unpacker::InternalData { |
91 DecodedImages decoded_images; | 91 DecodedImages decoded_images; |
92 }; | 92 }; |
93 | 93 |
94 Unpacker::Unpacker(const base::FilePath& extension_path, | 94 Unpacker::Unpacker(const base::FilePath& extension_path, |
95 const std::string& extension_id, | 95 const std::string& extension_id, |
96 Manifest::Location location, | 96 Manifest::Location location, |
97 int creation_flags) | 97 int creation_flags) |
98 : extension_path_(extension_path), | 98 : extension_path_(extension_path), |
99 extension_id_(extension_id), | 99 extension_id_(extension_id), |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 | 315 |
316 void Unpacker::SetError(const std::string &error) { | 316 void Unpacker::SetError(const std::string &error) { |
317 SetUTF16Error(UTF8ToUTF16(error)); | 317 SetUTF16Error(UTF8ToUTF16(error)); |
318 } | 318 } |
319 | 319 |
320 void Unpacker::SetUTF16Error(const string16 &error) { | 320 void Unpacker::SetUTF16Error(const string16 &error) { |
321 error_message_ = error; | 321 error_message_ = error; |
322 } | 322 } |
323 | 323 |
324 } // namespace extensions | 324 } // namespace extensions |
OLD | NEW |