Index: chrome/utility/chrome_content_utility_client.cc |
diff --git a/chrome/utility/chrome_content_utility_client.cc b/chrome/utility/chrome_content_utility_client.cc |
index 6b92765c242ba42799f61c81fc3c35829522738e..f8b474bfdcea79012d37c78026a682eaefda1260 100644 |
--- a/chrome/utility/chrome_content_utility_client.cc |
+++ b/chrome/utility/chrome_content_utility_client.cc |
@@ -182,6 +182,8 @@ bool ChromeContentUtilityClient::OnMessageReceived( |
bool handled = true; |
IPC_BEGIN_MESSAGE_MAP(ChromeContentUtilityClient, message) |
IPC_MESSAGE_HANDLER(ChromeUtilityMsg_DecodeImage, OnDecodeImage) |
+ IPC_MESSAGE_HANDLER(ChromeUtilityMsg_DecodeImageByHandle, |
+ OnDecodeImageByHandle) |
#if defined(OS_CHROMEOS) |
IPC_MESSAGE_HANDLER(ChromeUtilityMsg_RobustJPEGDecodeImage, |
OnRobustJPEGDecodeImage) |
@@ -294,6 +296,22 @@ void ChromeContentUtilityClient::DecodeImageAndSend( |
ReleaseProcessIfNeeded(); |
} |
+void ChromeContentUtilityClient::OnDecodeImageByHandle( |
+ const IPC::PlatformFileForTransit& image_file, |
+ bool shrink_to_fit, |
+ int request_id) { |
+ base::File file = IPC::PlatformFileForTransitToFile(image_file); |
+ |
+ std::vector<unsigned char> image_data(file.GetLength()); |
+ int read_bytes = file.Read( |
+ 0, reinterpret_cast<char*>(image_data.data()), file.GetLength()); |
+ if (read_bytes <= 0) { |
+ Send(new ChromeUtilityHostMsg_DecodeImage_Failed(request_id)); |
+ return; |
+ } |
+ DecodeImageAndSend(image_data, shrink_to_fit, request_id); |
+} |
+ |
void ChromeContentUtilityClient::OnDecodeImage( |
const std::vector<unsigned char>& encoded_data, |
bool shrink_to_fit, |