| 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 11 matching lines...) Expand all Loading... |
| 22 #include "ipc/ipc_channel.h" | 22 #include "ipc/ipc_channel.h" |
| 23 #include "skia/ext/image_operations.h" | 23 #include "skia/ext/image_operations.h" |
| 24 #include "third_party/skia/include/core/SkBitmap.h" | 24 #include "third_party/skia/include/core/SkBitmap.h" |
| 25 #include "third_party/zlib/google/zip.h" | 25 #include "third_party/zlib/google/zip.h" |
| 26 #include "ui/gfx/codec/jpeg_codec.h" | 26 #include "ui/gfx/codec/jpeg_codec.h" |
| 27 #include "ui/gfx/geometry/size.h" | 27 #include "ui/gfx/geometry/size.h" |
| 28 | 28 |
| 29 #if !defined(OS_ANDROID) | 29 #if !defined(OS_ANDROID) |
| 30 #include "chrome/utility/profile_import_handler.h" | 30 #include "chrome/utility/profile_import_handler.h" |
| 31 #include "net/proxy/mojo_proxy_resolver_factory_impl.h" | 31 #include "net/proxy/mojo_proxy_resolver_factory_impl.h" |
| 32 #else |
| 33 #include "sandbox/linux/seccomp-bpf/sandbox_bpf.h" |
| 32 #endif | 34 #endif |
| 33 | 35 |
| 34 #if defined(OS_WIN) | 36 #if defined(OS_WIN) |
| 35 #include "chrome/utility/font_cache_handler_win.h" | 37 #include "chrome/utility/font_cache_handler_win.h" |
| 36 #include "chrome/utility/shell_handler_win.h" | 38 #include "chrome/utility/shell_handler_win.h" |
| 37 #endif | 39 #endif |
| 38 | 40 |
| 39 #if defined(ENABLE_EXTENSIONS) | 41 #if defined(ENABLE_EXTENSIONS) |
| 40 #include "chrome/common/extensions/chrome_utility_extensions_messages.h" | 42 #include "chrome/common/extensions/chrome_utility_extensions_messages.h" |
| 41 #include "chrome/utility/extensions/extensions_handler.h" | 43 #include "chrome/utility/extensions/extensions_handler.h" |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_AnalyzeZipFileForDownloadProtection, | 157 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_AnalyzeZipFileForDownloadProtection, |
| 156 OnAnalyzeZipFileForDownloadProtection) | 158 OnAnalyzeZipFileForDownloadProtection) |
| 157 #endif | 159 #endif |
| 158 #if defined(ENABLE_EXTENSIONS) | 160 #if defined(ENABLE_EXTENSIONS) |
| 159 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_ParseMediaMetadata, | 161 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_ParseMediaMetadata, |
| 160 OnParseMediaMetadata) | 162 OnParseMediaMetadata) |
| 161 #endif | 163 #endif |
| 162 #if defined(OS_CHROMEOS) | 164 #if defined(OS_CHROMEOS) |
| 163 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_CreateZipFile, OnCreateZipFile) | 165 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_CreateZipFile, OnCreateZipFile) |
| 164 #endif | 166 #endif |
| 167 #if defined(OS_ANDROID) |
| 168 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_DetectSeccompSupport, |
| 169 OnDetectSeccompSupport) |
| 170 #endif |
| 165 IPC_MESSAGE_UNHANDLED(handled = false) | 171 IPC_MESSAGE_UNHANDLED(handled = false) |
| 166 IPC_END_MESSAGE_MAP() | 172 IPC_END_MESSAGE_MAP() |
| 167 | 173 |
| 168 for (Handlers::iterator it = handlers_.begin(); | 174 for (Handlers::iterator it = handlers_.begin(); |
| 169 !handled && it != handlers_.end(); ++it) { | 175 !handled && it != handlers_.end(); ++it) { |
| 170 handled = (*it)->OnMessageReceived(message); | 176 handled = (*it)->OnMessageReceived(message); |
| 171 } | 177 } |
| 172 | 178 |
| 173 return handled; | 179 return handled; |
| 174 } | 180 } |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 succeeded = zip::ZipFiles(src_dir, src_relative_paths, dest_fd.fd); | 276 succeeded = zip::ZipFiles(src_dir, src_relative_paths, dest_fd.fd); |
| 271 | 277 |
| 272 if (succeeded) | 278 if (succeeded) |
| 273 Send(new ChromeUtilityHostMsg_CreateZipFile_Succeeded()); | 279 Send(new ChromeUtilityHostMsg_CreateZipFile_Succeeded()); |
| 274 else | 280 else |
| 275 Send(new ChromeUtilityHostMsg_CreateZipFile_Failed()); | 281 Send(new ChromeUtilityHostMsg_CreateZipFile_Failed()); |
| 276 ReleaseProcessIfNeeded(); | 282 ReleaseProcessIfNeeded(); |
| 277 } | 283 } |
| 278 #endif // defined(OS_CHROMEOS) | 284 #endif // defined(OS_CHROMEOS) |
| 279 | 285 |
| 286 #if defined(OS_ANDROID) |
| 287 void ChromeContentUtilityClient::OnDetectSeccompSupport() { |
| 288 bool supports_prctl = sandbox::SandboxBPF::SupportsSeccompSandbox( |
| 289 sandbox::SandboxBPF::SeccompLevel::SINGLE_THREADED); |
| 290 bool supports_syscall = sandbox::SandboxBPF::SupportsSeccompSandbox( |
| 291 sandbox::SandboxBPF::SeccompLevel::MULTI_THREADED); |
| 292 |
| 293 Send(new ChromeUtilityHostMsg_DetectSeccompSupport_Result( |
| 294 supports_prctl, supports_syscall)); |
| 295 ReleaseProcessIfNeeded(); |
| 296 } |
| 297 #endif // defined(OS_ANDROID) |
| 298 |
| 280 void ChromeContentUtilityClient::OnRobustJPEGDecodeImage( | 299 void ChromeContentUtilityClient::OnRobustJPEGDecodeImage( |
| 281 const std::vector<unsigned char>& encoded_data) { | 300 const std::vector<unsigned char>& encoded_data) { |
| 282 // Our robust jpeg decoding is using IJG libjpeg. | 301 // Our robust jpeg decoding is using IJG libjpeg. |
| 283 if (gfx::JPEGCodec::JpegLibraryVariant() == gfx::JPEGCodec::IJG_LIBJPEG && | 302 if (gfx::JPEGCodec::JpegLibraryVariant() == gfx::JPEGCodec::IJG_LIBJPEG && |
| 284 !encoded_data.empty()) { | 303 !encoded_data.empty()) { |
| 285 scoped_ptr<SkBitmap> decoded_image(gfx::JPEGCodec::Decode( | 304 scoped_ptr<SkBitmap> decoded_image(gfx::JPEGCodec::Decode( |
| 286 &encoded_data[0], encoded_data.size())); | 305 &encoded_data[0], encoded_data.size())); |
| 287 if (!decoded_image.get() || decoded_image->empty()) { | 306 if (!decoded_image.get() || decoded_image->empty()) { |
| 288 Send(new ChromeUtilityHostMsg_DecodeImage_Failed()); | 307 Send(new ChromeUtilityHostMsg_DecodeImage_Failed()); |
| 289 } else { | 308 } else { |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 const std::string& mime_type, int64 total_size, bool get_attached_images) { | 384 const std::string& mime_type, int64 total_size, bool get_attached_images) { |
| 366 // Only one IPCDataSource may be created and added to the list of handlers. | 385 // Only one IPCDataSource may be created and added to the list of handlers. |
| 367 metadata::IPCDataSource* source = new metadata::IPCDataSource(total_size); | 386 metadata::IPCDataSource* source = new metadata::IPCDataSource(total_size); |
| 368 handlers_.push_back(source); | 387 handlers_.push_back(source); |
| 369 | 388 |
| 370 metadata::MediaMetadataParser* parser = new metadata::MediaMetadataParser( | 389 metadata::MediaMetadataParser* parser = new metadata::MediaMetadataParser( |
| 371 source, mime_type, get_attached_images); | 390 source, mime_type, get_attached_images); |
| 372 parser->Start(base::Bind(&FinishParseMediaMetadata, base::Owned(parser))); | 391 parser->Start(base::Bind(&FinishParseMediaMetadata, base::Owned(parser))); |
| 373 } | 392 } |
| 374 #endif | 393 #endif |
| OLD | NEW |