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

Unified Diff: chrome/utility/chrome_content_utility_client.cc

Issue 1159363002: [Download Notification] Show preview if downloaded file is image (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments #12 Created 5 years, 6 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 side-by-side diff with in-line comments
Download patch
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,

Powered by Google App Engine
This is Rietveld 408576698