summaryrefslogtreecommitdiffstats
path: root/chrome/utility
diff options
context:
space:
mode:
authormirandac@chromium.org <mirandac@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-18 23:02:54 +0000
committermirandac@chromium.org <mirandac@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-18 23:02:54 +0000
commitea0c98cfa2849f95bf40238c9f476c9cebb22244 (patch)
treeec81fe0c664cb6c0adddbd5d392313e8fbb93ec5 /chrome/utility
parent1f70f0ca51d1c61d3a775507b2b69dcdf60e77df (diff)
downloadchromium_src-ea0c98cfa2849f95bf40238c9f476c9cebb22244.zip
chromium_src-ea0c98cfa2849f95bf40238c9f476c9cebb22244.tar.gz
chromium_src-ea0c98cfa2849f95bf40238c9f476c9cebb22244.tar.bz2
First draft of web resource service; fetches data from a JSON feed
and stores it in user prefs, where it can be used by the new tab page. BUG = http://crbug.com/13363 Review URL: http://codereview.chromium.org/125052 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18766 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/utility')
-rw-r--r--chrome/utility/utility_thread.cc19
-rw-r--r--chrome/utility/utility_thread.h5
2 files changed, 24 insertions, 0 deletions
diff --git a/chrome/utility/utility_thread.cc b/chrome/utility/utility_thread.cc
index d1d7b37..46815b1 100644
--- a/chrome/utility/utility_thread.cc
+++ b/chrome/utility/utility_thread.cc
@@ -6,6 +6,7 @@
#include "base/file_util.h"
#include "base/values.h"
+#include "chrome/common/web_resource/web_resource_unpacker.h"
#include "chrome/common/child_process.h"
#include "chrome/common/extensions/extension_unpacker.h"
#include "chrome/common/render_messages.h"
@@ -29,6 +30,7 @@ void UtilityThread::CleanUp() {
void UtilityThread::OnControlMessageReceived(const IPC::Message& msg) {
IPC_BEGIN_MESSAGE_MAP(UtilityThread, msg)
IPC_MESSAGE_HANDLER(UtilityMsg_UnpackExtension, OnUnpackExtension)
+ IPC_MESSAGE_HANDLER(UtilityMsg_UnpackWebResource, OnUnpackWebResource)
IPC_END_MESSAGE_MAP()
}
@@ -43,3 +45,20 @@ void UtilityThread::OnUnpackExtension(const FilePath& extension_path) {
ChildProcess::current()->ReleaseProcess();
}
+
+void UtilityThread::OnUnpackWebResource(const std::string& resource_data) {
+ // Parse json data.
+ // TODO(mrc): Add the possibility of a template that controls parsing, and
+ // the ability to download and verify images.
+ WebResourceUnpacker unpacker(resource_data);
+ if (unpacker.Run()) {
+ Send(new UtilityHostMsg_UnpackWebResource_Succeeded(
+ *unpacker.parsed_json()));
+ } else {
+ Send(new UtilityHostMsg_UnpackWebResource_Failed(
+ unpacker.error_message()));
+ }
+
+ ChildProcess::current()->ReleaseProcess();
+}
+
diff --git a/chrome/utility/utility_thread.h b/chrome/utility/utility_thread.h
index 9d918dc..1c128ad 100644
--- a/chrome/utility/utility_thread.h
+++ b/chrome/utility/utility_thread.h
@@ -5,6 +5,8 @@
#ifndef CHROME_UTILITY_UTILITY_THREAD_H_
#define CHROME_UTILITY_UTILITY_THREAD_H_
+#include <string>
+
#include "base/thread.h"
#include "chrome/common/child_thread.h"
@@ -26,6 +28,9 @@ class UtilityThread : public ChildThread {
virtual void OnControlMessageReceived(const IPC::Message& msg);
void OnUnpackExtension(const FilePath& extension_path);
+ // IPC messages for web resource service.
+ void OnUnpackWebResource(const std::string& resource_data);
+
// Called by the thread base class
virtual void Init();
virtual void CleanUp();