diff options
author | rockot <rockot@chromium.org> | 2014-09-24 13:31:53 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-09-24 20:32:06 +0000 |
commit | eb6d47fab5dc127b474363d488aa1b6ccbfa7b48 (patch) | |
tree | 76d490eece9de85345c3c1cf31e5a6f8fb9e24dc | |
parent | 1b241325584a8612ff035c809ecfdeefa08063c5 (diff) | |
download | chromium_src-eb6d47fab5dc127b474363d488aa1b6ccbfa7b48.zip chromium_src-eb6d47fab5dc127b474363d488aa1b6ccbfa7b48.tar.gz chromium_src-eb6d47fab5dc127b474363d488aa1b6ccbfa7b48.tar.bz2 |
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}
-rw-r--r-- | chrome/browser/extensions/updater/extension_downloader.cc | 3 | ||||
-rw-r--r-- | chrome/chrome_browser_extensions.gypi | 2 | ||||
-rw-r--r-- | chrome/common/extensions/chrome_utility_extensions_messages.h | 28 | ||||
-rw-r--r-- | chrome/utility/extensions/extensions_handler.cc | 20 | ||||
-rw-r--r-- | chrome/utility/extensions/extensions_handler.h | 2 | ||||
-rw-r--r-- | extensions/browser/BUILD.gn | 4 | ||||
-rw-r--r-- | extensions/browser/updater/safe_manifest_parser.cc (renamed from chrome/browser/extensions/updater/safe_manifest_parser.cc) | 17 | ||||
-rw-r--r-- | extensions/browser/updater/safe_manifest_parser.h (renamed from chrome/browser/extensions/updater/safe_manifest_parser.h) | 7 | ||||
-rw-r--r-- | extensions/common/extension_message_generator.h | 1 | ||||
-rw-r--r-- | extensions/common/extension_utility_messages.h | 47 | ||||
-rw-r--r-- | extensions/extensions.gyp | 3 | ||||
-rw-r--r-- | ipc/ipc_message_start.h | 1 |
12 files changed, 80 insertions, 55 deletions
diff --git a/chrome/browser/extensions/updater/extension_downloader.cc b/chrome/browser/extensions/updater/extension_downloader.cc index 9813193..4918dfc 100644 --- a/chrome/browser/extensions/updater/extension_downloader.cc +++ b/chrome/browser/extensions/updater/extension_downloader.cc @@ -22,14 +22,13 @@ #include "chrome/browser/chrome_notification_types.h" #include "chrome/browser/extensions/updater/extension_cache.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_version_info.h" #include "chrome/common/extensions/manifest_url_handler.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/notification_details.h" #include "content/public/browser/notification_service.h" +#include "extensions/browser/updater/safe_manifest_parser.h" #include "extensions/common/extension_urls.h" #include "google_apis/gaia/identity_provider.h" #include "net/base/backoff_entry.h" diff --git a/chrome/chrome_browser_extensions.gypi b/chrome/chrome_browser_extensions.gypi index 96fa22c..850f940 100644 --- a/chrome/chrome_browser_extensions.gypi +++ b/chrome/chrome_browser_extensions.gypi @@ -788,8 +788,6 @@ 'browser/extensions/updater/extension_updater.h', 'browser/extensions/updater/request_queue.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.h', 'browser/extensions/user_script_loader.cc', diff --git a/chrome/common/extensions/chrome_utility_extensions_messages.h b/chrome/common/extensions/chrome_utility_extensions_messages.h index 7c27377..1d808bc 100644 --- a/chrome/common/extensions/chrome_utility_extensions_messages.h +++ b/chrome/common/extensions/chrome_utility_extensions_messages.h @@ -13,7 +13,6 @@ #include "chrome/common/media_galleries/itunes_library.h" #include "chrome/common/media_galleries/metadata_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_platform_file.h" @@ -23,19 +22,6 @@ #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) IPC_STRUCT_TRAITS_BEGIN(iphoto::parser::Photo) IPC_STRUCT_TRAITS_MEMBER(id) @@ -103,10 +89,6 @@ IPC_MESSAGE_CONTROL2(ChromeUtilityMsg_UnzipToDir, base::FilePath /* zip_file */, 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 // encoded. IPC_MESSAGE_CONTROL1(ChromeUtilityMsg_DecodeImageBase64, @@ -213,16 +195,6 @@ IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_UnzipToDir_Succeeded, IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_UnzipToDir_Failed, 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. // // WARNING: The result can be of any Value subclass type, but we can't easily diff --git a/chrome/utility/extensions/extensions_handler.cc b/chrome/utility/extensions/extensions_handler.cc index e8ef09f..6b74b14 100644 --- a/chrome/utility/extensions/extensions_handler.cc +++ b/chrome/utility/extensions/extensions_handler.cc @@ -17,6 +17,7 @@ #include "content/public/utility/utility_thread.h" #include "extensions/common/extension.h" #include "extensions/common/extension_l10n_util.h" +#include "extensions/common/extension_utility_messages.h" #include "extensions/common/manifest.h" #include "extensions/common/update_manifest.h" #include "media/base/media.h" @@ -58,9 +59,11 @@ const char kExtensionHandlerUnzipError[] = } // namespace -ExtensionsHandler::ExtensionsHandler() {} +ExtensionsHandler::ExtensionsHandler() { +} -ExtensionsHandler::~ExtensionsHandler() {} +ExtensionsHandler::~ExtensionsHandler() { +} // static void ExtensionsHandler::PreSandboxStartup() { @@ -86,8 +89,6 @@ bool ExtensionsHandler::OnMessageReceived(const IPC::Message& message) { IPC_BEGIN_MESSAGE_MAP(ExtensionsHandler, message) IPC_MESSAGE_HANDLER(ChromeUtilityMsg_UnpackExtension, OnUnpackExtension) IPC_MESSAGE_HANDLER(ChromeUtilityMsg_UnzipToDir, OnUnzipToDir) - IPC_MESSAGE_HANDLER(ChromeUtilityMsg_ParseUpdateManifest, - OnParseUpdateManifest) IPC_MESSAGE_HANDLER(ChromeUtilityMsg_DecodeImageBase64, OnDecodeImageBase64) IPC_MESSAGE_HANDLER(ChromeUtilityMsg_ParseJSON, OnParseJSON) IPC_MESSAGE_HANDLER(ChromeUtilityMsg_CheckMediaFile, OnCheckMediaFile) @@ -115,6 +116,9 @@ bool ExtensionsHandler::OnMessageReceived(const IPC::Message& message) { OnGetWiFiCredentials) #endif // defined(OS_WIN) + IPC_MESSAGE_HANDLER(ExtensionUtilityMsg_ParseUpdateManifest, + OnParseUpdateManifest) + IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() return handled; @@ -159,10 +163,10 @@ void ExtensionsHandler::OnUnzipToDir(const base::FilePath& zip_path, void ExtensionsHandler::OnParseUpdateManifest(const std::string& xml) { UpdateManifest manifest; if (!manifest.Parse(xml)) { - Send(new ChromeUtilityHostMsg_ParseUpdateManifest_Failed( + Send(new ExtensionUtilityHostMsg_ParseUpdateManifest_Failed( manifest.errors())); } else { - Send(new ChromeUtilityHostMsg_ParseUpdateManifest_Succeeded( + Send(new ExtensionUtilityHostMsg_ParseUpdateManifest_Succeeded( manifest.results())); } ReleaseProcessIfNeeded(); @@ -263,9 +267,7 @@ void ExtensionsHandler::OnParsePicasaPMPDatabase( picasa::PicasaAlbumTableReader reader(files.Pass()); bool parse_success = reader.Init(); Send(new ChromeUtilityHostMsg_ParsePicasaPMPDatabase_Finished( - parse_success, - reader.albums(), - reader.folders())); + parse_success, reader.albums(), reader.folders())); ReleaseProcessIfNeeded(); } diff --git a/chrome/utility/extensions/extensions_handler.h b/chrome/utility/extensions/extensions_handler.h index 7789857..d53c359 100644 --- a/chrome/utility/extensions/extensions_handler.h +++ b/chrome/utility/extensions/extensions_handler.h @@ -22,7 +22,7 @@ class MediaMetadataParser; namespace extensions { -// Dispatches IPCs for printing. +// Dispatches IPCs for Chrome extensions utility messages. class ExtensionsHandler : public UtilityMessageHandler { public: ExtensionsHandler(); diff --git a/extensions/browser/BUILD.gn b/extensions/browser/BUILD.gn index e3f01ed..e71d5f5 100644 --- a/extensions/browser/BUILD.gn +++ b/extensions/browser/BUILD.gn @@ -346,7 +346,7 @@ source_set("browser") { "guest_view/app_view/app_view_guest_delegate.cc", "guest_view/app_view/app_view_guest_delegate.h", "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.h", "guest_view/extension_options/extension_options_guest_delegate.cc", @@ -418,6 +418,8 @@ source_set("browser") { "update_observer.h", "updater/manifest_fetch_data.cc", "updater/manifest_fetch_data.h", + "updater/safe_manifest_parser.cc", + "updater/safe_manifest_parser.h", "url_request_util.cc", "url_request_util.h", "value_store/leveldb_value_store.cc", diff --git a/chrome/browser/extensions/updater/safe_manifest_parser.cc b/extensions/browser/updater/safe_manifest_parser.cc index a15a828..2ab9a05 100644 --- a/chrome/browser/extensions/updater/safe_manifest_parser.cc +++ b/extensions/browser/updater/safe_manifest_parser.cc @@ -2,16 +2,16 @@ // Use of this source code is governed by a BSD-style license that can be // 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/command_line.h" #include "base/location.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/utility_process_host.h" #include "content/public/common/content_switches.h" +#include "extensions/common/extension_utility_messages.h" #include "ipc/ipc_message_macros.h" using content::BrowserThread; @@ -21,16 +21,15 @@ namespace extensions { SafeManifestParser::SafeManifestParser(const std::string& xml, ManifestFetchData* fetch_data, const UpdateCallback& update_callback) - : xml_(xml), - fetch_data_(fetch_data), - update_callback_(update_callback) { + : xml_(xml), fetch_data_(fetch_data), update_callback_(update_callback) { DCHECK_CURRENTLY_ON(BrowserThread::UI); } void SafeManifestParser::Start() { DCHECK_CURRENTLY_ON(BrowserThread::UI); if (!BrowserThread::PostTask( - BrowserThread::IO, FROM_HERE, + BrowserThread::IO, + FROM_HERE, base::Bind(&SafeManifestParser::ParseInSandbox, this))) { NOTREACHED(); } @@ -47,15 +46,15 @@ void SafeManifestParser::ParseInSandbox() { content::UtilityProcessHost* host = content::UtilityProcessHost::Create( this, 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 handled = true; IPC_BEGIN_MESSAGE_MAP(SafeManifestParser, message) - IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_ParseUpdateManifest_Succeeded, + IPC_MESSAGE_HANDLER(ExtensionUtilityHostMsg_ParseUpdateManifest_Succeeded, OnParseUpdateManifestSucceeded) - IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_ParseUpdateManifest_Failed, + IPC_MESSAGE_HANDLER(ExtensionUtilityHostMsg_ParseUpdateManifest_Failed, OnParseUpdateManifestFailed) IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() diff --git a/chrome/browser/extensions/updater/safe_manifest_parser.h b/extensions/browser/updater/safe_manifest_parser.h index 3c83164..278cd97 100644 --- a/chrome/browser/extensions/updater/safe_manifest_parser.h +++ b/extensions/browser/updater/safe_manifest_parser.h @@ -2,8 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_EXTENSIONS_UPDATER_SAFE_MANIFEST_PARSER_H_ -#define CHROME_BROWSER_EXTENSIONS_UPDATER_SAFE_MANIFEST_PARSER_H_ +#ifndef EXTENSIONS_BROWSER_UPDATER_SAFE_MANIFEST_PARSER_H_ +#define EXTENSIONS_BROWSER_UPDATER_SAFE_MANIFEST_PARSER_H_ + #include <string> #include "base/basictypes.h" @@ -54,4 +55,4 @@ class SafeManifestParser : public content::UtilityProcessHostClient { } // namespace extensions -#endif // CHROME_BROWSER_EXTENSIONS_UPDATER_SAFE_MANIFEST_PARSER_H_ +#endif // EXTENSIONS_BROWSER_UPDATER_SAFE_MANIFEST_PARSER_H_ diff --git a/extensions/common/extension_message_generator.h b/extensions/common/extension_message_generator.h index 0735924..fac22c8 100644 --- a/extensions/common/extension_message_generator.h +++ b/extensions/common/extension_message_generator.h @@ -5,3 +5,4 @@ // Multiply-included file, hence no include guard. #include "extensions/common/extension_messages.h" +#include "extensions/common/extension_utility_messages.h" diff --git a/extensions/common/extension_utility_messages.h b/extensions/common/extension_utility_messages.h new file mode 100644 index 0000000..77dfe13 --- /dev/null +++ b/extensions/common/extension_utility_messages.h @@ -0,0 +1,47 @@ +// 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 */) diff --git a/extensions/extensions.gyp b/extensions/extensions.gyp index 6178f61..6b77c61 100644 --- a/extensions/extensions.gyp +++ b/extensions/extensions.gyp @@ -87,6 +87,7 @@ 'common/extension_set.h', 'common/extension_urls.cc', 'common/extension_urls.h', + 'common/extension_utility_messages.h', 'common/extensions_client.cc', 'common/extensions_client.h', 'common/feature_switch.cc', @@ -690,6 +691,8 @@ 'browser/update_observer.h', 'browser/updater/manifest_fetch_data.cc', '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.h', 'browser/value_store/leveldb_value_store.cc', diff --git a/ipc/ipc_message_start.h b/ipc/ipc_message_start.h index 773d4e1..463f0d5 100644 --- a/ipc/ipc_message_start.h +++ b/ipc/ipc_message_start.h @@ -110,6 +110,7 @@ enum IPCMessageStart { PDFMsgStart, WebCacheMsgStart, ManifestManagerMsgStart, + ExtensionUtilityMsgStart, LastIPCMsgStart // Must come last. }; |