OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/browser/extensions/sandboxed_extension_unpacker.h" | 5 #include "chrome/browser/extensions/sandboxed_extension_unpacker.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
| 9 #include "app/gfx/codec/png_codec.h" |
9 #include "base/crypto/signature_verifier.h" | 10 #include "base/crypto/signature_verifier.h" |
10 #include "base/file_util.h" | 11 #include "base/file_util.h" |
11 #include "base/gfx/png_encoder.h" | |
12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
13 #include "base/scoped_handle.h" | 13 #include "base/scoped_handle.h" |
14 #include "base/task.h" | 14 #include "base/task.h" |
15 #include "chrome/browser/chrome_thread.h" | 15 #include "chrome/browser/chrome_thread.h" |
16 #include "chrome/browser/extensions/extensions_service.h" | 16 #include "chrome/browser/extensions/extensions_service.h" |
17 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" | 17 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" |
18 #include "chrome/common/chrome_switches.h" | 18 #include "chrome/common/chrome_switches.h" |
19 #include "chrome/common/extensions/extension.h" | 19 #include "chrome/common/extensions/extension.h" |
20 #include "chrome/common/extensions/extension_constants.h" | 20 #include "chrome/common/extensions/extension_constants.h" |
21 #include "chrome/common/extensions/extension_unpacker.h" | 21 #include "chrome/common/extensions/extension_unpacker.h" |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 if (path_suffix.IsAbsolute() || path_suffix.ReferencesParent()) { | 164 if (path_suffix.IsAbsolute() || path_suffix.ReferencesParent()) { |
165 ReportFailure("Invalid path for bitmap image."); | 165 ReportFailure("Invalid path for bitmap image."); |
166 return; | 166 return; |
167 } | 167 } |
168 FilePath path = extension_root_.Append(path_suffix); | 168 FilePath path = extension_root_.Append(path_suffix); |
169 | 169 |
170 std::vector<unsigned char> image_data; | 170 std::vector<unsigned char> image_data; |
171 // TODO(mpcomplete): It's lame that we're encoding all images as PNG, even | 171 // TODO(mpcomplete): It's lame that we're encoding all images as PNG, even |
172 // though they may originally be .jpg, etc. Figure something out. | 172 // though they may originally be .jpg, etc. Figure something out. |
173 // http://code.google.com/p/chromium/issues/detail?id=12459 | 173 // http://code.google.com/p/chromium/issues/detail?id=12459 |
174 if (!PNGEncoder::EncodeBGRASkBitmap(image, false, &image_data)) { | 174 if (!gfx::PNGCodec::EncodeBGRASkBitmap(image, false, &image_data)) { |
175 ReportFailure("Error re-encoding theme image."); | 175 ReportFailure("Error re-encoding theme image."); |
176 return; | 176 return; |
177 } | 177 } |
178 | 178 |
179 // Note: we're overwriting existing files that the utility process wrote, | 179 // Note: we're overwriting existing files that the utility process wrote, |
180 // so we can be sure the directory exists. | 180 // so we can be sure the directory exists. |
181 const char* image_data_ptr = reinterpret_cast<const char*>(&image_data[0]); | 181 const char* image_data_ptr = reinterpret_cast<const char*>(&image_data[0]); |
182 if (!file_util::WriteFile(path, image_data_ptr, image_data.size())) { | 182 if (!file_util::WriteFile(path, image_data_ptr, image_data.size())) { |
183 ReportFailure("Error saving theme image."); | 183 ReportFailure("Error saving theme image."); |
184 return; | 184 return; |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 | 294 |
295 void SandboxedExtensionUnpacker::ReportFailure(const std::string& error) { | 295 void SandboxedExtensionUnpacker::ReportFailure(const std::string& error) { |
296 client_->OnUnpackFailure(error); | 296 client_->OnUnpackFailure(error); |
297 } | 297 } |
298 | 298 |
299 void SandboxedExtensionUnpacker::ReportSuccess() { | 299 void SandboxedExtensionUnpacker::ReportSuccess() { |
300 // Client takes ownership of temporary directory and extension. | 300 // Client takes ownership of temporary directory and extension. |
301 client_->OnUnpackSuccess(temp_dir_.Take(), extension_root_, | 301 client_->OnUnpackSuccess(temp_dir_.Take(), extension_root_, |
302 extension_.release()); | 302 extension_.release()); |
303 } | 303 } |
OLD | NEW |