Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(484)

Side by Side Diff: chrome/utility/chrome_content_utility_client.cc

Issue 569623002: Switch ChromeOS Chromium login to use IJG libjpeg (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix copyright and add unit test assertions Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/utility/chrome_content_utility_client.h ('k') | ui/gfx/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "base/time/time.h" 11 #include "base/time/time.h"
12 #include "chrome/common/chrome_utility_messages.h" 12 #include "chrome/common/chrome_utility_messages.h"
13 #include "chrome/common/safe_browsing/zip_analyzer.h" 13 #include "chrome/common/safe_browsing/zip_analyzer.h"
14 #include "chrome/common/safe_browsing/zip_analyzer_results.h" 14 #include "chrome/common/safe_browsing/zip_analyzer_results.h"
15 #include "chrome/utility/chrome_content_utility_ipc_whitelist.h" 15 #include "chrome/utility/chrome_content_utility_ipc_whitelist.h"
16 #include "chrome/utility/utility_message_handler.h" 16 #include "chrome/utility/utility_message_handler.h"
17 #include "content/public/child/image_decoder_utils.h" 17 #include "content/public/child/image_decoder_utils.h"
18 #include "content/public/common/content_switches.h" 18 #include "content/public/common/content_switches.h"
19 #include "content/public/common/service_registry.h" 19 #include "content/public/common/service_registry.h"
20 #include "content/public/utility/utility_thread.h" 20 #include "content/public/utility/utility_thread.h"
21 #include "courgette/courgette.h" 21 #include "courgette/courgette.h"
22 #include "courgette/third_party/bsdiff.h" 22 #include "courgette/third_party/bsdiff.h"
23 #include "ipc/ipc_channel.h" 23 #include "ipc/ipc_channel.h"
24 #include "skia/ext/image_operations.h" 24 #include "skia/ext/image_operations.h"
25 #include "third_party/skia/include/core/SkBitmap.h" 25 #include "third_party/skia/include/core/SkBitmap.h"
26 #include "third_party/zlib/google/zip.h" 26 #include "third_party/zlib/google/zip.h"
27 #include "ui/gfx/codec/jpeg_codec.h"
28 #include "ui/gfx/geometry/size.h" 27 #include "ui/gfx/geometry/size.h"
29 28
29 #if defined(OS_CHROMEOS)
30 #include "ui/gfx/chromeos/codec/jpeg_codec_robust_slow.h"
31 #endif
32
30 #if !defined(OS_ANDROID) 33 #if !defined(OS_ANDROID)
31 #include "chrome/utility/profile_import_handler.h" 34 #include "chrome/utility/profile_import_handler.h"
32 #include "net/proxy/mojo_proxy_resolver_factory_impl.h" 35 #include "net/proxy/mojo_proxy_resolver_factory_impl.h"
33 #endif 36 #endif
34 37
35 #if defined(OS_ANDROID) && defined(USE_SECCOMP_BPF) 38 #if defined(OS_ANDROID) && defined(USE_SECCOMP_BPF)
36 #include "sandbox/linux/seccomp-bpf/sandbox_bpf.h" 39 #include "sandbox/linux/seccomp-bpf/sandbox_bpf.h"
37 #endif 40 #endif
38 41
39 #if defined(OS_WIN) 42 #if defined(OS_WIN)
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 } 144 }
142 145
143 bool ChromeContentUtilityClient::OnMessageReceived( 146 bool ChromeContentUtilityClient::OnMessageReceived(
144 const IPC::Message& message) { 147 const IPC::Message& message) {
145 if (filter_messages_ && !ContainsKey(message_id_whitelist_, message.type())) 148 if (filter_messages_ && !ContainsKey(message_id_whitelist_, message.type()))
146 return false; 149 return false;
147 150
148 bool handled = true; 151 bool handled = true;
149 IPC_BEGIN_MESSAGE_MAP(ChromeContentUtilityClient, message) 152 IPC_BEGIN_MESSAGE_MAP(ChromeContentUtilityClient, message)
150 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_DecodeImage, OnDecodeImage) 153 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_DecodeImage, OnDecodeImage)
154 #if defined(OS_CHROMEOS)
151 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_RobustJPEGDecodeImage, 155 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_RobustJPEGDecodeImage,
152 OnRobustJPEGDecodeImage) 156 OnRobustJPEGDecodeImage)
157 #endif // defined(OS_CHROMEOS)
153 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_ParseJSON, OnParseJSON) 158 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_ParseJSON, OnParseJSON)
154 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_PatchFileBsdiff, 159 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_PatchFileBsdiff,
155 OnPatchFileBsdiff) 160 OnPatchFileBsdiff)
156 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_PatchFileCourgette, 161 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_PatchFileCourgette,
157 OnPatchFileCourgette) 162 OnPatchFileCourgette)
158 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_StartupPing, OnStartupPing) 163 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_StartupPing, OnStartupPing)
159 #if defined(FULL_SAFE_BROWSING) 164 #if defined(FULL_SAFE_BROWSING)
160 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_AnalyzeZipFileForDownloadProtection, 165 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_AnalyzeZipFileForDownloadProtection,
161 OnAnalyzeZipFileForDownloadProtection) 166 OnAnalyzeZipFileForDownloadProtection)
162 #endif 167 #endif
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 305
301 bool supports_syscall = sandbox::SandboxBPF::SupportsSeccompSandbox( 306 bool supports_syscall = sandbox::SandboxBPF::SupportsSeccompSandbox(
302 sandbox::SandboxBPF::SeccompLevel::MULTI_THREADED); 307 sandbox::SandboxBPF::SeccompLevel::MULTI_THREADED);
303 Send(new ChromeUtilityHostMsg_DetectSeccompSupport_ResultSyscall( 308 Send(new ChromeUtilityHostMsg_DetectSeccompSupport_ResultSyscall(
304 supports_syscall)); 309 supports_syscall));
305 310
306 ReleaseProcessIfNeeded(); 311 ReleaseProcessIfNeeded();
307 } 312 }
308 #endif // defined(OS_ANDROID) && defined(USE_SECCOMP_BPF) 313 #endif // defined(OS_ANDROID) && defined(USE_SECCOMP_BPF)
309 314
315 #if defined(OS_CHROMEOS)
310 void ChromeContentUtilityClient::OnRobustJPEGDecodeImage( 316 void ChromeContentUtilityClient::OnRobustJPEGDecodeImage(
311 const std::vector<unsigned char>& encoded_data, 317 const std::vector<unsigned char>& encoded_data,
312 int request_id) { 318 int request_id) {
313 // Our robust jpeg decoding is using IJG libjpeg. 319 // Our robust jpeg decoding is using IJG libjpeg.
314 if (gfx::JPEGCodec::JpegLibraryVariant() == gfx::JPEGCodec::IJG_LIBJPEG && 320 if (!encoded_data.empty()) {
315 !encoded_data.empty()) { 321 scoped_ptr<SkBitmap> decoded_image(gfx::JPEGCodecRobustSlow::Decode(
316 scoped_ptr<SkBitmap> decoded_image(gfx::JPEGCodec::Decode(
317 &encoded_data[0], encoded_data.size())); 322 &encoded_data[0], encoded_data.size()));
318 if (!decoded_image.get() || decoded_image->empty()) { 323 if (!decoded_image.get() || decoded_image->empty()) {
319 Send(new ChromeUtilityHostMsg_DecodeImage_Failed(request_id)); 324 Send(new ChromeUtilityHostMsg_DecodeImage_Failed(request_id));
320 } else { 325 } else {
321 Send(new ChromeUtilityHostMsg_DecodeImage_Succeeded(*decoded_image, 326 Send(new ChromeUtilityHostMsg_DecodeImage_Succeeded(*decoded_image,
322 request_id)); 327 request_id));
323 } 328 }
324 } else { 329 } else {
325 Send(new ChromeUtilityHostMsg_DecodeImage_Failed(request_id)); 330 Send(new ChromeUtilityHostMsg_DecodeImage_Failed(request_id));
326 } 331 }
327 ReleaseProcessIfNeeded(); 332 ReleaseProcessIfNeeded();
328 } 333 }
334 #endif // defined(OS_CHROMEOS)
329 335
330 void ChromeContentUtilityClient::OnParseJSON(const std::string& json) { 336 void ChromeContentUtilityClient::OnParseJSON(const std::string& json) {
331 int error_code; 337 int error_code;
332 std::string error; 338 std::string error;
333 base::Value* value = base::JSONReader::ReadAndReturnError( 339 base::Value* value = base::JSONReader::ReadAndReturnError(
334 json, base::JSON_PARSE_RFC, &error_code, &error); 340 json, base::JSON_PARSE_RFC, &error_code, &error);
335 if (value) { 341 if (value) {
336 base::ListValue wrapper; 342 base::ListValue wrapper;
337 wrapper.Append(value); 343 wrapper.Append(value);
338 Send(new ChromeUtilityHostMsg_ParseJSON_Succeeded(wrapper)); 344 Send(new ChromeUtilityHostMsg_ParseJSON_Succeeded(wrapper));
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 const std::string& mime_type, int64 total_size, bool get_attached_images) { 405 const std::string& mime_type, int64 total_size, bool get_attached_images) {
400 // Only one IPCDataSource may be created and added to the list of handlers. 406 // Only one IPCDataSource may be created and added to the list of handlers.
401 metadata::IPCDataSource* source = new metadata::IPCDataSource(total_size); 407 metadata::IPCDataSource* source = new metadata::IPCDataSource(total_size);
402 handlers_.push_back(source); 408 handlers_.push_back(source);
403 409
404 metadata::MediaMetadataParser* parser = new metadata::MediaMetadataParser( 410 metadata::MediaMetadataParser* parser = new metadata::MediaMetadataParser(
405 source, mime_type, get_attached_images); 411 source, mime_type, get_attached_images);
406 parser->Start(base::Bind(&FinishParseMediaMetadata, base::Owned(parser))); 412 parser->Start(base::Bind(&FinishParseMediaMetadata, base::Owned(parser)));
407 } 413 }
408 #endif 414 #endif
OLDNEW
« no previous file with comments | « chrome/utility/chrome_content_utility_client.h ('k') | ui/gfx/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698