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/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 #endif | 31 #endif |
32 | 32 |
33 #if !defined(OS_ANDROID) | 33 #if !defined(OS_ANDROID) |
34 #include "chrome/common/resource_usage_reporter.mojom.h" | 34 #include "chrome/common/resource_usage_reporter.mojom.h" |
35 #include "chrome/utility/profile_import_handler.h" | 35 #include "chrome/utility/profile_import_handler.h" |
36 #include "net/proxy/mojo_proxy_resolver_factory_impl.h" | 36 #include "net/proxy/mojo_proxy_resolver_factory_impl.h" |
37 #include "net/proxy/proxy_resolver_v8.h" | 37 #include "net/proxy/proxy_resolver_v8.h" |
38 #include "third_party/mojo/src/mojo/public/cpp/bindings/strong_binding.h" | 38 #include "third_party/mojo/src/mojo/public/cpp/bindings/strong_binding.h" |
39 #endif | 39 #endif |
40 | 40 |
41 #if defined(OS_ANDROID) && defined(USE_SECCOMP_BPF) | |
42 #include "sandbox/linux/seccomp-bpf/sandbox_bpf.h" | |
43 #endif | |
44 | |
45 #if defined(OS_WIN) | 41 #if defined(OS_WIN) |
46 #include "chrome/utility/font_cache_handler_win.h" | 42 #include "chrome/utility/font_cache_handler_win.h" |
47 #include "chrome/utility/shell_handler_win.h" | 43 #include "chrome/utility/shell_handler_win.h" |
48 #endif | 44 #endif |
49 | 45 |
50 #if defined(ENABLE_EXTENSIONS) | 46 #if defined(ENABLE_EXTENSIONS) |
51 #include "chrome/common/extensions/chrome_utility_extensions_messages.h" | 47 #include "chrome/common/extensions/chrome_utility_extensions_messages.h" |
52 #include "chrome/utility/extensions/extensions_handler.h" | 48 #include "chrome/utility/extensions/extensions_handler.h" |
53 #include "chrome/utility/image_writer/image_writer_handler.h" | 49 #include "chrome/utility/image_writer/image_writer_handler.h" |
54 #include "chrome/utility/media_galleries/ipc_data_source.h" | 50 #include "chrome/utility/media_galleries/ipc_data_source.h" |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_AnalyzeZipFileForDownloadProtection, | 193 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_AnalyzeZipFileForDownloadProtection, |
198 OnAnalyzeZipFileForDownloadProtection) | 194 OnAnalyzeZipFileForDownloadProtection) |
199 #endif | 195 #endif |
200 #if defined(ENABLE_EXTENSIONS) | 196 #if defined(ENABLE_EXTENSIONS) |
201 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_ParseMediaMetadata, | 197 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_ParseMediaMetadata, |
202 OnParseMediaMetadata) | 198 OnParseMediaMetadata) |
203 #endif | 199 #endif |
204 #if defined(OS_CHROMEOS) | 200 #if defined(OS_CHROMEOS) |
205 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_CreateZipFile, OnCreateZipFile) | 201 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_CreateZipFile, OnCreateZipFile) |
206 #endif | 202 #endif |
207 #if defined(OS_ANDROID) && defined(USE_SECCOMP_BPF) | |
208 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_DetectSeccompSupport, | |
209 OnDetectSeccompSupport) | |
210 #endif | |
211 IPC_MESSAGE_UNHANDLED(handled = false) | 203 IPC_MESSAGE_UNHANDLED(handled = false) |
212 IPC_END_MESSAGE_MAP() | 204 IPC_END_MESSAGE_MAP() |
213 | 205 |
214 for (Handlers::iterator it = handlers_.begin(); | 206 for (Handlers::iterator it = handlers_.begin(); |
215 !handled && it != handlers_.end(); ++it) { | 207 !handled && it != handlers_.end(); ++it) { |
216 handled = (*it)->OnMessageReceived(message); | 208 handled = (*it)->OnMessageReceived(message); |
217 } | 209 } |
218 | 210 |
219 return handled; | 211 return handled; |
220 } | 212 } |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 succeeded = zip::ZipFiles(src_dir, src_relative_paths, dest_fd.fd); | 319 succeeded = zip::ZipFiles(src_dir, src_relative_paths, dest_fd.fd); |
328 | 320 |
329 if (succeeded) | 321 if (succeeded) |
330 Send(new ChromeUtilityHostMsg_CreateZipFile_Succeeded()); | 322 Send(new ChromeUtilityHostMsg_CreateZipFile_Succeeded()); |
331 else | 323 else |
332 Send(new ChromeUtilityHostMsg_CreateZipFile_Failed()); | 324 Send(new ChromeUtilityHostMsg_CreateZipFile_Failed()); |
333 ReleaseProcessIfNeeded(); | 325 ReleaseProcessIfNeeded(); |
334 } | 326 } |
335 #endif // defined(OS_CHROMEOS) | 327 #endif // defined(OS_CHROMEOS) |
336 | 328 |
337 #if defined(OS_ANDROID) && defined(USE_SECCOMP_BPF) | |
338 void ChromeContentUtilityClient::OnDetectSeccompSupport() { | |
339 bool supports_prctl = sandbox::SandboxBPF::SupportsSeccompSandbox( | |
340 sandbox::SandboxBPF::SeccompLevel::SINGLE_THREADED); | |
341 Send(new ChromeUtilityHostMsg_DetectSeccompSupport_ResultPrctl( | |
342 supports_prctl)); | |
343 | |
344 // Probing for the seccomp syscall can provoke kernel panics in certain LGE | |
345 // devices. For now, this data will not be collected. In the future, this | |
346 // should detect SeccompLevel::MULTI_THREADED. http://crbug.com/478478 | |
347 | |
348 ReleaseProcessIfNeeded(); | |
349 } | |
350 #endif // defined(OS_ANDROID) && defined(USE_SECCOMP_BPF) | |
351 | |
352 #if defined(OS_CHROMEOS) | 329 #if defined(OS_CHROMEOS) |
353 void ChromeContentUtilityClient::OnRobustJPEGDecodeImage( | 330 void ChromeContentUtilityClient::OnRobustJPEGDecodeImage( |
354 const std::vector<unsigned char>& encoded_data, | 331 const std::vector<unsigned char>& encoded_data, |
355 int request_id) { | 332 int request_id) { |
356 // Our robust jpeg decoding is using IJG libjpeg. | 333 // Our robust jpeg decoding is using IJG libjpeg. |
357 if (!encoded_data.empty()) { | 334 if (!encoded_data.empty()) { |
358 scoped_ptr<SkBitmap> decoded_image(gfx::JPEGCodecRobustSlow::Decode( | 335 scoped_ptr<SkBitmap> decoded_image(gfx::JPEGCodecRobustSlow::Decode( |
359 &encoded_data[0], encoded_data.size())); | 336 &encoded_data[0], encoded_data.size())); |
360 if (!decoded_image.get() || decoded_image->empty()) { | 337 if (!decoded_image.get() || decoded_image->empty()) { |
361 Send(new ChromeUtilityHostMsg_DecodeImage_Failed(request_id)); | 338 Send(new ChromeUtilityHostMsg_DecodeImage_Failed(request_id)); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 const std::string& mime_type, int64 total_size, bool get_attached_images) { | 404 const std::string& mime_type, int64 total_size, bool get_attached_images) { |
428 // Only one IPCDataSource may be created and added to the list of handlers. | 405 // Only one IPCDataSource may be created and added to the list of handlers. |
429 metadata::IPCDataSource* source = new metadata::IPCDataSource(total_size); | 406 metadata::IPCDataSource* source = new metadata::IPCDataSource(total_size); |
430 handlers_.push_back(source); | 407 handlers_.push_back(source); |
431 | 408 |
432 metadata::MediaMetadataParser* parser = new metadata::MediaMetadataParser( | 409 metadata::MediaMetadataParser* parser = new metadata::MediaMetadataParser( |
433 source, mime_type, get_attached_images); | 410 source, mime_type, get_attached_images); |
434 parser->Start(base::Bind(&FinishParseMediaMetadata, base::Owned(parser))); | 411 parser->Start(base::Bind(&FinishParseMediaMetadata, base::Owned(parser))); |
435 } | 412 } |
436 #endif | 413 #endif |
OLD | NEW |