summaryrefslogtreecommitdiffstats
path: root/chrome/utility
diff options
context:
space:
mode:
authoravayvod@google.com <avayvod@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-15 18:31:22 +0000
committeravayvod@google.com <avayvod@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-15 18:31:22 +0000
commit79c2b56bcad7b23ccc25d2bc934887ea080b7a9d (patch)
treeefc45fa2d3e5250849972bf90510f39efc7ec93d /chrome/utility
parent26cfaf5d657b92f5f94eccc0a0b51c28caccbc5a (diff)
downloadchromium_src-79c2b56bcad7b23ccc25d2bc934887ea080b7a9d.zip
chromium_src-79c2b56bcad7b23ccc25d2bc934887ea080b7a9d.tar.gz
chromium_src-79c2b56bcad7b23ccc25d2bc934887ea080b7a9d.tar.bz2
Added decoding of any supported image format into vector of chars.
This is used for decoding user's image downloaded from Google Profile in sandboxed process upon user's login to Chromium OS. This required adding dependency on webkit/glue/ in chrome/utility. Approved by Brett. BUG=none TEST=none Review URL: http://codereview.chromium.org/1646004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@44675 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/utility')
-rw-r--r--chrome/utility/DEPS1
-rw-r--r--chrome/utility/utility_thread.cc18
-rw-r--r--chrome/utility/utility_thread.h5
3 files changed, 24 insertions, 0 deletions
diff --git a/chrome/utility/DEPS b/chrome/utility/DEPS
index 07cb004..96944f28 100644
--- a/chrome/utility/DEPS
+++ b/chrome/utility/DEPS
@@ -1,3 +1,4 @@
include_rules = [
"+sandbox/src",
+ "+webkit/glue",
]
diff --git a/chrome/utility/utility_thread.cc b/chrome/utility/utility_thread.cc
index 0615efb..259b185 100644
--- a/chrome/utility/utility_thread.cc
+++ b/chrome/utility/utility_thread.cc
@@ -4,6 +4,8 @@
#include "chrome/utility/utility_thread.h"
+#include <vector>
+
#include "base/file_util.h"
#include "base/values.h"
#include "chrome/common/child_process.h"
@@ -12,6 +14,7 @@
#include "chrome/common/utility_messages.h"
#include "chrome/common/web_resource/web_resource_unpacker.h"
#include "third_party/skia/include/core/SkBitmap.h"
+#include "webkit/glue/image_decoder.h"
UtilityThread::UtilityThread() {
ChildProcess::current()->AddRefProcess();
@@ -25,6 +28,7 @@ void UtilityThread::OnControlMessageReceived(const IPC::Message& msg) {
IPC_MESSAGE_HANDLER(UtilityMsg_UnpackExtension, OnUnpackExtension)
IPC_MESSAGE_HANDLER(UtilityMsg_UnpackWebResource, OnUnpackWebResource)
IPC_MESSAGE_HANDLER(UtilityMsg_ParseUpdateManifest, OnParseUpdateManifest)
+ IPC_MESSAGE_HANDLER(UtilityMsg_DecodeImage, OnDecodeImage)
IPC_END_MESSAGE_MAP()
}
@@ -66,3 +70,17 @@ void UtilityThread::OnParseUpdateManifest(const std::string& xml) {
}
ChildProcess::current()->ReleaseProcess();
}
+
+void UtilityThread::OnDecodeImage(
+ const std::vector<unsigned char>& encoded_data) {
+ webkit_glue::ImageDecoder decoder;
+ const SkBitmap& decoded_image = decoder.Decode(&encoded_data[0],
+ encoded_data.size());
+ if (decoded_image.empty()) {
+ Send(new UtilityHostMsg_DecodeImage_Failed());
+ } else {
+ Send(new UtilityHostMsg_DecodeImage_Succeeded(decoded_image));
+ }
+ ChildProcess::current()->ReleaseProcess();
+}
+
diff --git a/chrome/utility/utility_thread.h b/chrome/utility/utility_thread.h
index 180f53d..9b88bc2 100644
--- a/chrome/utility/utility_thread.h
+++ b/chrome/utility/utility_thread.h
@@ -6,10 +6,12 @@
#define CHROME_UTILITY_UTILITY_THREAD_H_
#include <string>
+#include <vector>
#include "chrome/common/child_thread.h"
class GURL;
+class SkBitmap;
// This class represents the background thread where the utility task runs.
class UtilityThread : public ChildThread {
@@ -33,6 +35,9 @@ class UtilityThread : public ChildThread {
// IPC for parsing an extensions auto-update manifest xml file.
void OnParseUpdateManifest(const std::string& xml);
+ // IPC for decoding an image.
+ void OnDecodeImage(const std::vector<unsigned char>& encoded_data);
+
DISALLOW_COPY_AND_ASSIGN(UtilityThread);
};