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

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

Issue 10892023: Force avatar and wallpaper decoding to use robust JPEG. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Applied commnets Created 8 years, 3 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 | Annotate | Revision Log
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/base64.h" 7 #include "base/base64.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/json/json_reader.h" 10 #include "base/json/json_reader.h"
(...skipping 10 matching lines...) Expand all
21 #include "chrome/common/extensions/extension_l10n_util.h" 21 #include "chrome/common/extensions/extension_l10n_util.h"
22 #include "chrome/common/extensions/unpacker.h" 22 #include "chrome/common/extensions/unpacker.h"
23 #include "chrome/common/extensions/update_manifest.h" 23 #include "chrome/common/extensions/update_manifest.h"
24 #include "chrome/common/web_resource/web_resource_unpacker.h" 24 #include "chrome/common/web_resource/web_resource_unpacker.h"
25 #include "chrome/utility/profile_import_handler.h" 25 #include "chrome/utility/profile_import_handler.h"
26 #include "content/public/utility/utility_thread.h" 26 #include "content/public/utility/utility_thread.h"
27 #include "printing/backend/print_backend.h" 27 #include "printing/backend/print_backend.h"
28 #include "printing/page_range.h" 28 #include "printing/page_range.h"
29 #include "third_party/skia/include/core/SkBitmap.h" 29 #include "third_party/skia/include/core/SkBitmap.h"
30 #include "ui/base/ui_base_switches.h" 30 #include "ui/base/ui_base_switches.h"
31 #include "ui/gfx/codec/jpeg_codec.h"
31 #include "ui/gfx/rect.h" 32 #include "ui/gfx/rect.h"
32 #include "webkit/glue/image_decoder.h" 33 #include "webkit/glue/image_decoder.h"
33 34
34 #if defined(OS_WIN) 35 #if defined(OS_WIN)
35 #include "base/file_util.h" 36 #include "base/file_util.h"
36 #include "base/path_service.h" 37 #include "base/path_service.h"
37 #include "base/win/iat_patch_function.h" 38 #include "base/win/iat_patch_function.h"
38 #include "base/win/scoped_handle.h" 39 #include "base/win/scoped_handle.h"
39 #include "content/public/common/content_switches.h" 40 #include "content/public/common/content_switches.h"
40 #include "printing/emf_win.h" 41 #include "printing/emf_win.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 const IPC::Message& message) { 75 const IPC::Message& message) {
75 bool handled = true; 76 bool handled = true;
76 IPC_BEGIN_MESSAGE_MAP(ChromeContentUtilityClient, message) 77 IPC_BEGIN_MESSAGE_MAP(ChromeContentUtilityClient, message)
77 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_UnpackExtension, OnUnpackExtension) 78 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_UnpackExtension, OnUnpackExtension)
78 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_UnpackWebResource, 79 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_UnpackWebResource,
79 OnUnpackWebResource) 80 OnUnpackWebResource)
80 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_ParseUpdateManifest, 81 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_ParseUpdateManifest,
81 OnParseUpdateManifest) 82 OnParseUpdateManifest)
82 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_DecodeImage, OnDecodeImage) 83 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_DecodeImage, OnDecodeImage)
83 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_DecodeImageBase64, OnDecodeImageBase64) 84 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_DecodeImageBase64, OnDecodeImageBase64)
85 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_DecodeImageWithIJGlibjpeg,
86 OnDecodeImageWithIJGlibjpeg)
84 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_RenderPDFPagesToMetafile, 87 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_RenderPDFPagesToMetafile,
85 OnRenderPDFPagesToMetafile) 88 OnRenderPDFPagesToMetafile)
86 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_ParseJSON, OnParseJSON) 89 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_ParseJSON, OnParseJSON)
87 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_GetPrinterCapsAndDefaults, 90 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_GetPrinterCapsAndDefaults,
88 OnGetPrinterCapsAndDefaults) 91 OnGetPrinterCapsAndDefaults)
89 IPC_MESSAGE_UNHANDLED(handled = false) 92 IPC_MESSAGE_UNHANDLED(handled = false)
90 IPC_END_MESSAGE_MAP() 93 IPC_END_MESSAGE_MAP()
91 94
92 #if !defined(OS_ANDROID) 95 #if !defined(OS_ANDROID)
93 if (!handled) 96 if (!handled)
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 } 180 }
178 181
179 std::vector<unsigned char> decoded_vector(decoded_string.size()); 182 std::vector<unsigned char> decoded_vector(decoded_string.size());
180 for (size_t i = 0; i < decoded_string.size(); ++i) { 183 for (size_t i = 0; i < decoded_string.size(); ++i) {
181 decoded_vector[i] = static_cast<unsigned char>(decoded_string[i]); 184 decoded_vector[i] = static_cast<unsigned char>(decoded_string[i]);
182 } 185 }
183 186
184 OnDecodeImage(decoded_vector); 187 OnDecodeImage(decoded_vector);
185 } 188 }
186 189
190 void ChromeContentUtilityClient::OnDecodeImageWithIJGlibjpeg(
191 const std::vector<unsigned char>& encoded_data) {
192 webkit_glue::ImageDecoder decoder;
193 scoped_ptr<SkBitmap> decoded_image(gfx::JPEGCodec::Decode(&encoded_data[0],
oshima 2012/08/29 01:32:29 align encoded_data.size() to &encoded_data[0]. If
Emmanuel Saint-loubert-Bié 2012/08/29 01:57:18 Done.
194 encoded_data.size()));
195 if (decoded_image->empty()) {
196 Send(new ChromeUtilityHostMsg_DecodeImage_Failed());
197 } else {
198 Send(new ChromeUtilityHostMsg_DecodeImage_Succeeded(*decoded_image));
199 }
200 content::UtilityThread::Get()->ReleaseProcessIfNeeded();
201 }
202
187 void ChromeContentUtilityClient::OnRenderPDFPagesToMetafile( 203 void ChromeContentUtilityClient::OnRenderPDFPagesToMetafile(
188 base::PlatformFile pdf_file, 204 base::PlatformFile pdf_file,
189 const FilePath& metafile_path, 205 const FilePath& metafile_path,
190 const printing::PdfRenderSettings& pdf_render_settings, 206 const printing::PdfRenderSettings& pdf_render_settings,
191 const std::vector<printing::PageRange>& page_ranges) { 207 const std::vector<printing::PageRange>& page_ranges) {
192 bool succeeded = false; 208 bool succeeded = false;
193 #if defined(OS_WIN) 209 #if defined(OS_WIN)
194 int highest_rendered_page_number = 0; 210 int highest_rendered_page_number = 0;
195 double scale_factor = 1.0; 211 double scale_factor = 1.0;
196 succeeded = RenderPDFToWinMetafile(pdf_file, 212 succeeded = RenderPDFToWinMetafile(pdf_file,
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 } else 405 } else
390 #endif 406 #endif
391 { 407 {
392 Send(new ChromeUtilityHostMsg_GetPrinterCapsAndDefaults_Failed( 408 Send(new ChromeUtilityHostMsg_GetPrinterCapsAndDefaults_Failed(
393 printer_name)); 409 printer_name));
394 } 410 }
395 content::UtilityThread::Get()->ReleaseProcessIfNeeded(); 411 content::UtilityThread::Get()->ReleaseProcessIfNeeded();
396 } 412 }
397 413
398 } // namespace chrome 414 } // namespace chrome
OLDNEW
« chrome/browser/image_decoder.h ('K') | « chrome/utility/chrome_content_utility_client.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698