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/chrome_content_utility_client.h" | 5 #include "chrome/utility/chrome_content_utility_client.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 decoded_image.reset(); | 231 decoded_image.reset(); |
232 LOG(ERROR) << "Decoded image too large for IPC message"; | 232 LOG(ERROR) << "Decoded image too large for IPC message"; |
233 } | 233 } |
234 } | 234 } |
235 | 235 |
236 return decoded_image; | 236 return decoded_image; |
237 } | 237 } |
238 | 238 |
239 // static | 239 // static |
240 void ChromeContentUtilityClient::DecodeImageAndSend( | 240 void ChromeContentUtilityClient::DecodeImageAndSend( |
241 const std::vector<unsigned char>& encoded_data, bool shrink_to_fit){ | 241 const std::vector<unsigned char>& encoded_data, |
| 242 bool shrink_to_fit, |
| 243 int request_id) { |
242 SkBitmap decoded_image = DecodeImage(encoded_data, shrink_to_fit); | 244 SkBitmap decoded_image = DecodeImage(encoded_data, shrink_to_fit); |
243 | 245 |
244 if (decoded_image.empty()) { | 246 if (decoded_image.empty()) { |
245 Send(new ChromeUtilityHostMsg_DecodeImage_Failed()); | 247 Send(new ChromeUtilityHostMsg_DecodeImage_Failed(request_id)); |
246 } else { | 248 } else { |
247 Send(new ChromeUtilityHostMsg_DecodeImage_Succeeded(decoded_image)); | 249 Send(new ChromeUtilityHostMsg_DecodeImage_Succeeded(decoded_image, |
| 250 request_id)); |
248 } | 251 } |
249 ReleaseProcessIfNeeded(); | 252 ReleaseProcessIfNeeded(); |
250 } | 253 } |
251 | 254 |
252 void ChromeContentUtilityClient::OnDecodeImage( | 255 void ChromeContentUtilityClient::OnDecodeImage( |
253 const std::vector<unsigned char>& encoded_data, bool shrink_to_fit) { | 256 const std::vector<unsigned char>& encoded_data, |
254 DecodeImageAndSend(encoded_data, shrink_to_fit); | 257 bool shrink_to_fit, |
| 258 int request_id) { |
| 259 DecodeImageAndSend(encoded_data, shrink_to_fit, request_id); |
255 } | 260 } |
256 | 261 |
257 #if defined(OS_CHROMEOS) | 262 #if defined(OS_CHROMEOS) |
258 void ChromeContentUtilityClient::OnCreateZipFile( | 263 void ChromeContentUtilityClient::OnCreateZipFile( |
259 const base::FilePath& src_dir, | 264 const base::FilePath& src_dir, |
260 const std::vector<base::FilePath>& src_relative_paths, | 265 const std::vector<base::FilePath>& src_relative_paths, |
261 const base::FileDescriptor& dest_fd) { | 266 const base::FileDescriptor& dest_fd) { |
262 // dest_fd should be closed in the function. See ipc/ipc_message_util.h for | 267 // dest_fd should be closed in the function. See ipc/ipc_message_util.h for |
263 // details. | 268 // details. |
264 base::ScopedFD fd_closer(dest_fd.fd); | 269 base::ScopedFD fd_closer(dest_fd.fd); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 bool supports_syscall = sandbox::SandboxBPF::SupportsSeccompSandbox( | 301 bool supports_syscall = sandbox::SandboxBPF::SupportsSeccompSandbox( |
297 sandbox::SandboxBPF::SeccompLevel::MULTI_THREADED); | 302 sandbox::SandboxBPF::SeccompLevel::MULTI_THREADED); |
298 Send(new ChromeUtilityHostMsg_DetectSeccompSupport_ResultSyscall( | 303 Send(new ChromeUtilityHostMsg_DetectSeccompSupport_ResultSyscall( |
299 supports_syscall)); | 304 supports_syscall)); |
300 | 305 |
301 ReleaseProcessIfNeeded(); | 306 ReleaseProcessIfNeeded(); |
302 } | 307 } |
303 #endif // defined(OS_ANDROID) && defined(USE_SECCOMP_BPF) | 308 #endif // defined(OS_ANDROID) && defined(USE_SECCOMP_BPF) |
304 | 309 |
305 void ChromeContentUtilityClient::OnRobustJPEGDecodeImage( | 310 void ChromeContentUtilityClient::OnRobustJPEGDecodeImage( |
306 const std::vector<unsigned char>& encoded_data) { | 311 const std::vector<unsigned char>& encoded_data, |
| 312 int request_id) { |
307 // Our robust jpeg decoding is using IJG libjpeg. | 313 // Our robust jpeg decoding is using IJG libjpeg. |
308 if (gfx::JPEGCodec::JpegLibraryVariant() == gfx::JPEGCodec::IJG_LIBJPEG && | 314 if (gfx::JPEGCodec::JpegLibraryVariant() == gfx::JPEGCodec::IJG_LIBJPEG && |
309 !encoded_data.empty()) { | 315 !encoded_data.empty()) { |
310 scoped_ptr<SkBitmap> decoded_image(gfx::JPEGCodec::Decode( | 316 scoped_ptr<SkBitmap> decoded_image(gfx::JPEGCodec::Decode( |
311 &encoded_data[0], encoded_data.size())); | 317 &encoded_data[0], encoded_data.size())); |
312 if (!decoded_image.get() || decoded_image->empty()) { | 318 if (!decoded_image.get() || decoded_image->empty()) { |
313 Send(new ChromeUtilityHostMsg_DecodeImage_Failed()); | 319 Send(new ChromeUtilityHostMsg_DecodeImage_Failed(request_id)); |
314 } else { | 320 } else { |
315 Send(new ChromeUtilityHostMsg_DecodeImage_Succeeded(*decoded_image)); | 321 Send(new ChromeUtilityHostMsg_DecodeImage_Succeeded(*decoded_image, |
| 322 request_id)); |
316 } | 323 } |
317 } else { | 324 } else { |
318 Send(new ChromeUtilityHostMsg_DecodeImage_Failed()); | 325 Send(new ChromeUtilityHostMsg_DecodeImage_Failed(request_id)); |
319 } | 326 } |
320 ReleaseProcessIfNeeded(); | 327 ReleaseProcessIfNeeded(); |
321 } | 328 } |
322 | 329 |
323 void ChromeContentUtilityClient::OnParseJSON(const std::string& json) { | 330 void ChromeContentUtilityClient::OnParseJSON(const std::string& json) { |
324 int error_code; | 331 int error_code; |
325 std::string error; | 332 std::string error; |
326 base::Value* value = base::JSONReader::ReadAndReturnError( | 333 base::Value* value = base::JSONReader::ReadAndReturnError( |
327 json, base::JSON_PARSE_RFC, &error_code, &error); | 334 json, base::JSON_PARSE_RFC, &error_code, &error); |
328 if (value) { | 335 if (value) { |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 const std::string& mime_type, int64 total_size, bool get_attached_images) { | 399 const std::string& mime_type, int64 total_size, bool get_attached_images) { |
393 // Only one IPCDataSource may be created and added to the list of handlers. | 400 // Only one IPCDataSource may be created and added to the list of handlers. |
394 metadata::IPCDataSource* source = new metadata::IPCDataSource(total_size); | 401 metadata::IPCDataSource* source = new metadata::IPCDataSource(total_size); |
395 handlers_.push_back(source); | 402 handlers_.push_back(source); |
396 | 403 |
397 metadata::MediaMetadataParser* parser = new metadata::MediaMetadataParser( | 404 metadata::MediaMetadataParser* parser = new metadata::MediaMetadataParser( |
398 source, mime_type, get_attached_images); | 405 source, mime_type, get_attached_images); |
399 parser->Start(base::Bind(&FinishParseMediaMetadata, base::Owned(parser))); | 406 parser->Start(base::Bind(&FinishParseMediaMetadata, base::Owned(parser))); |
400 } | 407 } |
401 #endif | 408 #endif |
OLD | NEW |