From ea0c98cfa2849f95bf40238c9f476c9cebb22244 Mon Sep 17 00:00:00 2001 From: "mirandac@chromium.org" Date: Thu, 18 Jun 2009 23:02:54 +0000 Subject: 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 --- chrome/utility/utility_thread.cc | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'chrome/utility/utility_thread.cc') 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(); +} + -- cgit v1.1