Commit eb6d47fa authored by rockot's avatar rockot Committed by Commit bot

Move SafeManifestParser to //extensions

This moves SafeManifestParser to extensions_browser.
Also creates a new ExtensionUtility IPC message class in which
to define extensions utility process messages. The relevant
manifest parsing messages have been moved into this class.

BUG=398671

Review URL: https://codereview.chromium.org/464613002

Cr-Commit-Position: refs/heads/master@{#296508}
parent 1b241325
...@@ -22,14 +22,13 @@ ...@@ -22,14 +22,13 @@
#include "chrome/browser/chrome_notification_types.h" #include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/extensions/updater/extension_cache.h" #include "chrome/browser/extensions/updater/extension_cache.h"
#include "chrome/browser/extensions/updater/request_queue_impl.h" #include "chrome/browser/extensions/updater/request_queue_impl.h"
#include "chrome/browser/extensions/updater/safe_manifest_parser.h"
#include "chrome/browser/metrics/chrome_metrics_service_accessor.h"
#include "chrome/common/chrome_switches.h" #include "chrome/common/chrome_switches.h"
#include "chrome/common/chrome_version_info.h" #include "chrome/common/chrome_version_info.h"
#include "chrome/common/extensions/manifest_url_handler.h" #include "chrome/common/extensions/manifest_url_handler.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_details.h" #include "content/public/browser/notification_details.h"
#include "content/public/browser/notification_service.h" #include "content/public/browser/notification_service.h"
#include "extensions/browser/updater/safe_manifest_parser.h"
#include "extensions/common/extension_urls.h" #include "extensions/common/extension_urls.h"
#include "google_apis/gaia/identity_provider.h" #include "google_apis/gaia/identity_provider.h"
#include "net/base/backoff_entry.h" #include "net/base/backoff_entry.h"
......
...@@ -788,8 +788,6 @@ ...@@ -788,8 +788,6 @@
'browser/extensions/updater/extension_updater.h', 'browser/extensions/updater/extension_updater.h',
'browser/extensions/updater/request_queue.h', 'browser/extensions/updater/request_queue.h',
'browser/extensions/updater/request_queue_impl.h', 'browser/extensions/updater/request_queue_impl.h',
'browser/extensions/updater/safe_manifest_parser.cc',
'browser/extensions/updater/safe_manifest_parser.h',
'browser/extensions/user_script_listener.cc', 'browser/extensions/user_script_listener.cc',
'browser/extensions/user_script_listener.h', 'browser/extensions/user_script_listener.h',
'browser/extensions/user_script_loader.cc', 'browser/extensions/user_script_loader.cc',
......
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
#include "chrome/common/media_galleries/itunes_library.h" #include "chrome/common/media_galleries/itunes_library.h"
#include "chrome/common/media_galleries/metadata_types.h" #include "chrome/common/media_galleries/metadata_types.h"
#include "chrome/common/media_galleries/picasa_types.h" #include "chrome/common/media_galleries/picasa_types.h"
#include "extensions/common/update_manifest.h"
#include "ipc/ipc_message_macros.h" #include "ipc/ipc_message_macros.h"
#include "ipc/ipc_platform_file.h" #include "ipc/ipc_platform_file.h"
...@@ -23,19 +22,6 @@ ...@@ -23,19 +22,6 @@
#define IPC_MESSAGE_START ChromeUtilityExtensionsMsgStart #define IPC_MESSAGE_START ChromeUtilityExtensionsMsgStart
IPC_STRUCT_TRAITS_BEGIN(UpdateManifest::Result)
IPC_STRUCT_TRAITS_MEMBER(extension_id)
IPC_STRUCT_TRAITS_MEMBER(version)
IPC_STRUCT_TRAITS_MEMBER(browser_min_version)
IPC_STRUCT_TRAITS_MEMBER(package_hash)
IPC_STRUCT_TRAITS_MEMBER(crx_url)
IPC_STRUCT_TRAITS_END()
IPC_STRUCT_TRAITS_BEGIN(UpdateManifest::Results)
IPC_STRUCT_TRAITS_MEMBER(list)
IPC_STRUCT_TRAITS_MEMBER(daystart_elapsed_seconds)
IPC_STRUCT_TRAITS_END()
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
IPC_STRUCT_TRAITS_BEGIN(iphoto::parser::Photo) IPC_STRUCT_TRAITS_BEGIN(iphoto::parser::Photo)
IPC_STRUCT_TRAITS_MEMBER(id) IPC_STRUCT_TRAITS_MEMBER(id)
...@@ -103,10 +89,6 @@ IPC_MESSAGE_CONTROL2(ChromeUtilityMsg_UnzipToDir, ...@@ -103,10 +89,6 @@ IPC_MESSAGE_CONTROL2(ChromeUtilityMsg_UnzipToDir,
base::FilePath /* zip_file */, base::FilePath /* zip_file */,
base::FilePath /* dir */) base::FilePath /* dir */)
// Tell the utility process to parse the given xml document.
IPC_MESSAGE_CONTROL1(ChromeUtilityMsg_ParseUpdateManifest,
std::string /* xml document contents */)
// Tell the utility process to decode the given image data, which is base64 // Tell the utility process to decode the given image data, which is base64
// encoded. // encoded.
IPC_MESSAGE_CONTROL1(ChromeUtilityMsg_DecodeImageBase64, IPC_MESSAGE_CONTROL1(ChromeUtilityMsg_DecodeImageBase64,
...@@ -213,16 +195,6 @@ IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_UnzipToDir_Succeeded, ...@@ -213,16 +195,6 @@ IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_UnzipToDir_Succeeded,
IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_UnzipToDir_Failed, IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_UnzipToDir_Failed,
std::string /* error */) std::string /* error */)
// Reply when the utility process has succeeded in parsing an update manifest
// xml document.
IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_ParseUpdateManifest_Succeeded,
UpdateManifest::Results /* updates */)
// Reply when an error occurred parsing the update manifest. |error_message|
// is a description of what went wrong suitable for logging.
IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_ParseUpdateManifest_Failed,
std::string /* error_message, if any */)
// Reply when the utility process successfully parsed a JSON string. // Reply when the utility process successfully parsed a JSON string.
// //
// WARNING: The result can be of any Value subclass type, but we can't easily // WARNING: The result can be of any Value subclass type, but we can't easily
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include "content/public/utility/utility_thread.h" #include "content/public/utility/utility_thread.h"
#include "extensions/common/extension.h" #include "extensions/common/extension.h"
#include "extensions/common/extension_l10n_util.h" #include "extensions/common/extension_l10n_util.h"
#include "extensions/common/extension_utility_messages.h"
#include "extensions/common/manifest.h" #include "extensions/common/manifest.h"
#include "extensions/common/update_manifest.h" #include "extensions/common/update_manifest.h"
#include "media/base/media.h" #include "media/base/media.h"
...@@ -58,9 +59,11 @@ const char kExtensionHandlerUnzipError[] = ...@@ -58,9 +59,11 @@ const char kExtensionHandlerUnzipError[] =
} // namespace } // namespace
ExtensionsHandler::ExtensionsHandler() {} ExtensionsHandler::ExtensionsHandler() {
}
ExtensionsHandler::~ExtensionsHandler() {} ExtensionsHandler::~ExtensionsHandler() {
}
// static // static
void ExtensionsHandler::PreSandboxStartup() { void ExtensionsHandler::PreSandboxStartup() {
...@@ -86,8 +89,6 @@ bool ExtensionsHandler::OnMessageReceived(const IPC::Message& message) { ...@@ -86,8 +89,6 @@ bool ExtensionsHandler::OnMessageReceived(const IPC::Message& message) {
IPC_BEGIN_MESSAGE_MAP(ExtensionsHandler, message) IPC_BEGIN_MESSAGE_MAP(ExtensionsHandler, message)
IPC_MESSAGE_HANDLER(ChromeUtilityMsg_UnpackExtension, OnUnpackExtension) IPC_MESSAGE_HANDLER(ChromeUtilityMsg_UnpackExtension, OnUnpackExtension)
IPC_MESSAGE_HANDLER(ChromeUtilityMsg_UnzipToDir, OnUnzipToDir) IPC_MESSAGE_HANDLER(ChromeUtilityMsg_UnzipToDir, OnUnzipToDir)
IPC_MESSAGE_HANDLER(ChromeUtilityMsg_ParseUpdateManifest,
OnParseUpdateManifest)
IPC_MESSAGE_HANDLER(ChromeUtilityMsg_DecodeImageBase64, OnDecodeImageBase64) IPC_MESSAGE_HANDLER(ChromeUtilityMsg_DecodeImageBase64, OnDecodeImageBase64)
IPC_MESSAGE_HANDLER(ChromeUtilityMsg_ParseJSON, OnParseJSON) IPC_MESSAGE_HANDLER(ChromeUtilityMsg_ParseJSON, OnParseJSON)
IPC_MESSAGE_HANDLER(ChromeUtilityMsg_CheckMediaFile, OnCheckMediaFile) IPC_MESSAGE_HANDLER(ChromeUtilityMsg_CheckMediaFile, OnCheckMediaFile)
...@@ -115,6 +116,9 @@ bool ExtensionsHandler::OnMessageReceived(const IPC::Message& message) { ...@@ -115,6 +116,9 @@ bool ExtensionsHandler::OnMessageReceived(const IPC::Message& message) {
OnGetWiFiCredentials) OnGetWiFiCredentials)
#endif // defined(OS_WIN) #endif // defined(OS_WIN)
IPC_MESSAGE_HANDLER(ExtensionUtilityMsg_ParseUpdateManifest,
OnParseUpdateManifest)
IPC_MESSAGE_UNHANDLED(handled = false) IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP() IPC_END_MESSAGE_MAP()
return handled; return handled;
...@@ -159,10 +163,10 @@ void ExtensionsHandler::OnUnzipToDir(const base::FilePath& zip_path, ...@@ -159,10 +163,10 @@ void ExtensionsHandler::OnUnzipToDir(const base::FilePath& zip_path,
void ExtensionsHandler::OnParseUpdateManifest(const std::string& xml) { void ExtensionsHandler::OnParseUpdateManifest(const std::string& xml) {
UpdateManifest manifest; UpdateManifest manifest;
if (!manifest.Parse(xml)) { if (!manifest.Parse(xml)) {
Send(new ChromeUtilityHostMsg_ParseUpdateManifest_Failed( Send(new ExtensionUtilityHostMsg_ParseUpdateManifest_Failed(
manifest.errors())); manifest.errors()));
} else { } else {
Send(new ChromeUtilityHostMsg_ParseUpdateManifest_Succeeded( Send(new ExtensionUtilityHostMsg_ParseUpdateManifest_Succeeded(
manifest.results())); manifest.results()));
} }
ReleaseProcessIfNeeded(); ReleaseProcessIfNeeded();
...@@ -263,9 +267,7 @@ void ExtensionsHandler::OnParsePicasaPMPDatabase( ...@@ -263,9 +267,7 @@ void ExtensionsHandler::OnParsePicasaPMPDatabase(
picasa::PicasaAlbumTableReader reader(files.Pass()); picasa::PicasaAlbumTableReader reader(files.Pass());
bool parse_success = reader.Init(); bool parse_success = reader.Init();
Send(new ChromeUtilityHostMsg_ParsePicasaPMPDatabase_Finished( Send(new ChromeUtilityHostMsg_ParsePicasaPMPDatabase_Finished(
parse_success, parse_success, reader.albums(), reader.folders()));
reader.albums(),
reader.folders()));
ReleaseProcessIfNeeded(); ReleaseProcessIfNeeded();
} }
......
...@@ -22,7 +22,7 @@ class MediaMetadataParser; ...@@ -22,7 +22,7 @@ class MediaMetadataParser;
namespace extensions { namespace extensions {
// Dispatches IPCs for printing. // Dispatches IPCs for Chrome extensions utility messages.
class ExtensionsHandler : public UtilityMessageHandler { class ExtensionsHandler : public UtilityMessageHandler {
public: public:
ExtensionsHandler(); ExtensionsHandler();
......
...@@ -346,7 +346,7 @@ source_set("browser") { ...@@ -346,7 +346,7 @@ source_set("browser") {
"guest_view/app_view/app_view_guest_delegate.cc", "guest_view/app_view/app_view_guest_delegate.cc",
"guest_view/app_view/app_view_guest_delegate.h", "guest_view/app_view/app_view_guest_delegate.h",
"guest_view/extension_options/extension_options_constants.cc", "guest_view/extension_options/extension_options_constants.cc",
"guest_view/extension_options/extension_options_constants.h", "guest_view/extension_options/extension_options_constants.h",
"guest_view/extension_options/extension_options_guest.cc", "guest_view/extension_options/extension_options_guest.cc",
"guest_view/extension_options/extension_options_guest.h", "guest_view/extension_options/extension_options_guest.h",
"guest_view/extension_options/extension_options_guest_delegate.cc", "guest_view/extension_options/extension_options_guest_delegate.cc",
...@@ -418,6 +418,8 @@ source_set("browser") { ...@@ -418,6 +418,8 @@ source_set("browser") {
"update_observer.h", "update_observer.h",
"updater/manifest_fetch_data.cc", "updater/manifest_fetch_data.cc",
"updater/manifest_fetch_data.h", "updater/manifest_fetch_data.h",
"updater/safe_manifest_parser.cc",
"updater/safe_manifest_parser.h",
"url_request_util.cc", "url_request_util.cc",
"url_request_util.h", "url_request_util.h",
"value_store/leveldb_value_store.cc", "value_store/leveldb_value_store.cc",
......
...@@ -2,16 +2,16 @@ ...@@ -2,16 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "chrome/browser/extensions/updater/safe_manifest_parser.h" #include "extensions/browser/updater/safe_manifest_parser.h"
#include "base/bind.h" #include "base/bind.h"
#include "base/command_line.h" #include "base/command_line.h"
#include "base/location.h" #include "base/location.h"
#include "base/logging.h" #include "base/logging.h"
#include "chrome/common/extensions/chrome_utility_extensions_messages.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/browser/utility_process_host.h" #include "content/public/browser/utility_process_host.h"
#include "content/public/common/content_switches.h" #include "content/public/common/content_switches.h"
#include "extensions/common/extension_utility_messages.h"
#include "ipc/ipc_message_macros.h" #include "ipc/ipc_message_macros.h"
using content::BrowserThread; using content::BrowserThread;
...@@ -21,16 +21,15 @@ namespace extensions { ...@@ -21,16 +21,15 @@ namespace extensions {
SafeManifestParser::SafeManifestParser(const std::string& xml, SafeManifestParser::SafeManifestParser(const std::string& xml,
ManifestFetchData* fetch_data, ManifestFetchData* fetch_data,
const UpdateCallback& update_callback) const UpdateCallback& update_callback)
: xml_(xml), : xml_(xml), fetch_data_(fetch_data), update_callback_(update_callback) {
fetch_data_(fetch_data),
update_callback_(update_callback) {
DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK_CURRENTLY_ON(BrowserThread::UI);
} }
void SafeManifestParser::Start() { void SafeManifestParser::Start() {
DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (!BrowserThread::PostTask( if (!BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE, BrowserThread::IO,
FROM_HERE,
base::Bind(&SafeManifestParser::ParseInSandbox, this))) { base::Bind(&SafeManifestParser::ParseInSandbox, this))) {
NOTREACHED(); NOTREACHED();
} }
...@@ -47,15 +46,15 @@ void SafeManifestParser::ParseInSandbox() { ...@@ -47,15 +46,15 @@ void SafeManifestParser::ParseInSandbox() {
content::UtilityProcessHost* host = content::UtilityProcessHost::Create( content::UtilityProcessHost* host = content::UtilityProcessHost::Create(
this, this,
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI).get()); BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI).get());
host->Send(new ChromeUtilityMsg_ParseUpdateManifest(xml_)); host->Send(new ExtensionUtilityMsg_ParseUpdateManifest(xml_));
} }
bool SafeManifestParser::OnMessageReceived(const IPC::Message& message) { bool SafeManifestParser::OnMessageReceived(const IPC::Message& message) {
bool handled = true; bool handled = true;
IPC_BEGIN_MESSAGE_MAP(SafeManifestParser, message) IPC_BEGIN_MESSAGE_MAP(SafeManifestParser, message)
IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_ParseUpdateManifest_Succeeded, IPC_MESSAGE_HANDLER(ExtensionUtilityHostMsg_ParseUpdateManifest_Succeeded,
OnParseUpdateManifestSucceeded) OnParseUpdateManifestSucceeded)
IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_ParseUpdateManifest_Failed, IPC_MESSAGE_HANDLER(ExtensionUtilityHostMsg_ParseUpdateManifest_Failed,
OnParseUpdateManifestFailed) OnParseUpdateManifestFailed)
IPC_MESSAGE_UNHANDLED(handled = false) IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP() IPC_END_MESSAGE_MAP()
......
...@@ -2,8 +2,9 @@ ...@@ -2,8 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef CHROME_BROWSER_EXTENSIONS_UPDATER_SAFE_MANIFEST_PARSER_H_ #ifndef EXTENSIONS_BROWSER_UPDATER_SAFE_MANIFEST_PARSER_H_
#define CHROME_BROWSER_EXTENSIONS_UPDATER_SAFE_MANIFEST_PARSER_H_ #define EXTENSIONS_BROWSER_UPDATER_SAFE_MANIFEST_PARSER_H_
#include <string> #include <string>
#include "base/basictypes.h" #include "base/basictypes.h"
...@@ -54,4 +55,4 @@ class SafeManifestParser : public content::UtilityProcessHostClient { ...@@ -54,4 +55,4 @@ class SafeManifestParser : public content::UtilityProcessHostClient {
} // namespace extensions } // namespace extensions
#endif // CHROME_BROWSER_EXTENSIONS_UPDATER_SAFE_MANIFEST_PARSER_H_ #endif // EXTENSIONS_BROWSER_UPDATER_SAFE_MANIFEST_PARSER_H_
...@@ -5,3 +5,4 @@ ...@@ -5,3 +5,4 @@
// Multiply-included file, hence no include guard. // Multiply-included file, hence no include guard.
#include "extensions/common/extension_messages.h" #include "extensions/common/extension_messages.h"
#include "extensions/common/extension_utility_messages.h"
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Multiply-included message file, so no include guard.
#include <string>
#include "extensions/common/update_manifest.h"
#include "ipc/ipc_message_macros.h"
#define IPC_MESSAGE_START ExtensionUtilityMsgStart
IPC_STRUCT_TRAITS_BEGIN(UpdateManifest::Result)
IPC_STRUCT_TRAITS_MEMBER(extension_id)
IPC_STRUCT_TRAITS_MEMBER(version)
IPC_STRUCT_TRAITS_MEMBER(browser_min_version)
IPC_STRUCT_TRAITS_MEMBER(package_hash)
IPC_STRUCT_TRAITS_MEMBER(crx_url)
IPC_STRUCT_TRAITS_END()
IPC_STRUCT_TRAITS_BEGIN(UpdateManifest::Results)
IPC_STRUCT_TRAITS_MEMBER(list)
IPC_STRUCT_TRAITS_MEMBER(daystart_elapsed_seconds)
IPC_STRUCT_TRAITS_END()
//------------------------------------------------------------------------------
// Utility process messages:
// These are messages from the browser to the utility process.
// Tell the utility process to parse the given xml document.
IPC_MESSAGE_CONTROL1(ExtensionUtilityMsg_ParseUpdateManifest,
std::string /* xml document contents */)
//------------------------------------------------------------------------------
// Utility process host messages:
// These are messages from the utility process to the browser.
// Reply when the utility process has succeeded in parsing an update manifest
// xml document.
IPC_MESSAGE_CONTROL1(ExtensionUtilityHostMsg_ParseUpdateManifest_Succeeded,
UpdateManifest::Results /* updates */)
// Reply when an error occurred parsing the update manifest. |error_message|
// is a description of what went wrong suitable for logging.
IPC_MESSAGE_CONTROL1(ExtensionUtilityHostMsg_ParseUpdateManifest_Failed,
std::string /* error_message, if any */)
...@@ -87,6 +87,7 @@ ...@@ -87,6 +87,7 @@
'common/extension_set.h', 'common/extension_set.h',
'common/extension_urls.cc', 'common/extension_urls.cc',
'common/extension_urls.h', 'common/extension_urls.h',
'common/extension_utility_messages.h',
'common/extensions_client.cc', 'common/extensions_client.cc',
'common/extensions_client.h', 'common/extensions_client.h',
'common/feature_switch.cc', 'common/feature_switch.cc',
...@@ -690,6 +691,8 @@ ...@@ -690,6 +691,8 @@
'browser/update_observer.h', 'browser/update_observer.h',
'browser/updater/manifest_fetch_data.cc', 'browser/updater/manifest_fetch_data.cc',
'browser/updater/manifest_fetch_data.h', 'browser/updater/manifest_fetch_data.h',
'browser/updater/safe_manifest_parser.cc',
'browser/updater/safe_manifest_parser.h',
'browser/url_request_util.cc', 'browser/url_request_util.cc',
'browser/url_request_util.h', 'browser/url_request_util.h',
'browser/value_store/leveldb_value_store.cc', 'browser/value_store/leveldb_value_store.cc',
......
...@@ -110,6 +110,7 @@ enum IPCMessageStart { ...@@ -110,6 +110,7 @@ enum IPCMessageStart {
PDFMsgStart, PDFMsgStart,
WebCacheMsgStart, WebCacheMsgStart,
ManifestManagerMsgStart, ManifestManagerMsgStart,
ExtensionUtilityMsgStart,
LastIPCMsgStart // Must come last. LastIPCMsgStart // Must come last.
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment