diff options
author | saintlou@chromium.org <saintlou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-29 23:12:15 +0000 |
---|---|---|
committer | saintlou@chromium.org <saintlou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-29 23:12:15 +0000 |
commit | 11f16d10114d6e266b590785fcf50bca63734d62 (patch) | |
tree | 8d68941d3e691746293b41dd890e7bcef0821d7d /chrome/browser | |
parent | 6a01960c32c340d4333257bf9d0244f5199d8dd8 (diff) | |
download | chromium_src-11f16d10114d6e266b590785fcf50bca63734d62.zip chromium_src-11f16d10114d6e266b590785fcf50bca63734d62.tar.gz chromium_src-11f16d10114d6e266b590785fcf50bca63734d62.tar.bz2 |
Force avatar and wallpaper decoding to use robust JPEG.
The next step in an upcoming CL will bind this separate path to a different JPEG library (at a minimum on CrOS).
BUG=144296
Review URL: https://chromiumcodereview.appspot.com/10892023
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@154001 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
7 files changed, 25 insertions, 8 deletions
diff --git a/chrome/browser/chromeos/extensions/wallpaper_private_api.cc b/chrome/browser/chromeos/extensions/wallpaper_private_api.cc index 7550d3a..8432ed2 100644 --- a/chrome/browser/chromeos/extensions/wallpaper_private_api.cc +++ b/chrome/browser/chromeos/extensions/wallpaper_private_api.cc @@ -62,7 +62,8 @@ class WallpaperSetWallpaperFunction::WallpaperDecoder } void Start(const std::string& image_data) { - image_decoder_ = new ImageDecoder(this, image_data); + image_decoder_ = new ImageDecoder(this, image_data, + ImageDecoder::ROBUST_JPEG_CODEC); image_decoder_->Start(); } diff --git a/chrome/browser/chromeos/login/user_image_loader.cc b/chrome/browser/chromeos/login/user_image_loader.cc index da34f7d..dfcd436 100644 --- a/chrome/browser/chromeos/login/user_image_loader.cc +++ b/chrome/browser/chromeos/login/user_image_loader.cc @@ -56,7 +56,7 @@ void UserImageLoader::LoadImage(const std::string& filepath, file_util::ReadFileToString(FilePath(filepath), &image_data); scoped_refptr<ImageDecoder> image_decoder = - new ImageDecoder(this, image_data); + new ImageDecoder(this, image_data, ImageDecoder::ROBUST_JPEG_CODEC); image_info_map_.insert(std::make_pair(image_decoder.get(), image_info)); image_decoder->Start(); } diff --git a/chrome/browser/image_decoder.cc b/chrome/browser/image_decoder.cc index a345c77..1f456ee 100644 --- a/chrome/browser/image_decoder.cc +++ b/chrome/browser/image_decoder.cc @@ -14,9 +14,11 @@ using content::BrowserThread; using content::UtilityProcessHost; ImageDecoder::ImageDecoder(Delegate* delegate, - const std::string& image_data) + const std::string& image_data, + ImageCodec image_codec) : delegate_(delegate), image_data_(image_data.begin(), image_data.end()), + image_codec_(image_codec), target_thread_id_(BrowserThread::UI) { } @@ -62,5 +64,10 @@ void ImageDecoder::DecodeImageInSandbox( UtilityProcessHost* utility_process_host = UtilityProcessHost::Create( this, target_thread_id_); utility_process_host->EnableZygote(); - utility_process_host->Send(new ChromeUtilityMsg_DecodeImage(image_data)); + if (image_codec_ == ROBUST_JPEG_CODEC) { + utility_process_host->Send( + new ChromeUtilityMsg_RobustJPEGDecodeImage(image_data)); + } else { + utility_process_host->Send(new ChromeUtilityMsg_DecodeImage(image_data)); + } } diff --git a/chrome/browser/image_decoder.h b/chrome/browser/image_decoder.h index 69caa43..24f4d89 100644 --- a/chrome/browser/image_decoder.h +++ b/chrome/browser/image_decoder.h @@ -33,8 +33,14 @@ class ImageDecoder : public content::UtilityProcessHostClient { virtual ~Delegate() {} }; + enum ImageCodec { + DEFAULT_CODEC = 0, // Uses WebKit image decoding (via WebImage). + ROBUST_JPEG_CODEC, // Restrict decoding to robust jpeg codec. + }; + ImageDecoder(Delegate* delegate, - const std::string& image_data); + const std::string& image_data, + ImageCodec image_codec); // Starts image decoding. void Start(); @@ -61,6 +67,7 @@ class ImageDecoder : public content::UtilityProcessHostClient { Delegate* delegate_; std::vector<unsigned char> image_data_; + const ImageCodec image_codec_; content::BrowserThread::ID target_thread_id_; DISALLOW_COPY_AND_ASSIGN(ImageDecoder); diff --git a/chrome/browser/profiles/profile_downloader.cc b/chrome/browser/profiles/profile_downloader.cc index 878c565..50a0958 100644 --- a/chrome/browser/profiles/profile_downloader.cc +++ b/chrome/browser/profiles/profile_downloader.cc @@ -331,7 +331,7 @@ void ProfileDownloader::OnURLFetchComplete(const net::URLFetcher* source) { } else if (source == profile_image_fetcher_.get()) { VLOG(1) << "Decoding the image..."; scoped_refptr<ImageDecoder> image_decoder = new ImageDecoder( - this, data); + this, data, ImageDecoder::DEFAULT_CODEC); image_decoder->Start(); } } diff --git a/chrome/browser/ui/webui/chromeos/login/user_image_screen_handler.cc b/chrome/browser/ui/webui/chromeos/login/user_image_screen_handler.cc index 50ca318..0c0b6b1 100644 --- a/chrome/browser/ui/webui/chromeos/login/user_image_screen_handler.cc +++ b/chrome/browser/ui/webui/chromeos/login/user_image_screen_handler.cc @@ -232,7 +232,8 @@ void UserImageScreenHandler::HandlePhotoTaken(const base::ListValue* args) { if (image_decoder_.get()) image_decoder_->set_delegate(NULL); - image_decoder_ = new ImageDecoder(this, raw_data); + image_decoder_ = new ImageDecoder(this, raw_data, + ImageDecoder::ROBUST_JPEG_CODEC); image_decoder_->Start(); } diff --git a/chrome/browser/ui/webui/options/chromeos/change_picture_options_handler.cc b/chrome/browser/ui/webui/options/chromeos/change_picture_options_handler.cc index f6058e4..a27e801 100644 --- a/chrome/browser/ui/webui/options/chromeos/change_picture_options_handler.cc +++ b/chrome/browser/ui/webui/options/chromeos/change_picture_options_handler.cc @@ -200,7 +200,8 @@ void ChangePictureOptionsHandler::HandlePhotoTaken( if (image_decoder_.get()) image_decoder_->set_delegate(NULL); - image_decoder_ = new ImageDecoder(this, raw_data); + image_decoder_ = new ImageDecoder(this, raw_data, + ImageDecoder::ROBUST_JPEG_CODEC); image_decoder_->Start(); } |