0

Remove Extensions Legacy IPC message definitions

- This completes Extension Legacy IPC removal.

Bug: 993189
Change-Id: I19b6e03f486f5321357c798aee571131625b7855
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5245342
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Reviewed-by: David Bertoni <dbertoni@chromium.org>
Commit-Queue: Dave Tapuska <dtapuska@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1254205}
This commit is contained in:
Dave Tapuska
2024-01-30 21:52:34 +00:00
committed by Chromium LUCI CQ
parent a561c272d1
commit 7318a54f14
12 changed files with 3 additions and 472 deletions

@ -14,8 +14,5 @@ import("//extensions/buildflags/buildflags.gni")
buildflag_header("buildflags") {
header = "buildflags.h"
flags = [
"ENABLE_EXTENSIONS=$enable_extensions",
"ENABLE_EXTENSIONS_LEGACY_IPC=$enable_extensions_legacy_ipc",
]
flags = [ "ENABLE_EXTENSIONS=$enable_extensions" ]
}

@ -6,5 +6,4 @@ import("//build/config/cast.gni")
declare_args() {
enable_extensions = !is_android && !is_ios && !is_castos && !is_fuchsia
enable_extensions_legacy_ipc = false
}

@ -284,11 +284,6 @@ static_library("common") {
"extension_id.h",
"extension_l10n_util.cc",
"extension_l10n_util.h",
"extension_message_generator.cc",
"extension_message_generator.h",
"extension_messages.h",
"extension_param_traits.cc",
"extension_param_traits.h",
"extension_paths.cc",
"extension_paths.h",
"extension_resource.cc",

@ -1,30 +0,0 @@
// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Get basic type definitions.
#define IPC_MESSAGE_IMPL
#include "extensions/common/extension_message_generator.h"
// Generate constructors.
#include "ipc/struct_constructor_macros.h"
#include "extensions/common/extension_message_generator.h"
// Generate param traits write methods.
#include "ipc/param_traits_write_macros.h"
namespace IPC {
#include "extensions/common/extension_message_generator.h"
} // namespace IPC
// Generate param traits read methods.
#include "ipc/param_traits_read_macros.h"
namespace IPC {
#include "extensions/common/extension_message_generator.h"
} // namespace IPC
// Generate param traits log methods.
#include "ipc/param_traits_log_macros.h"
namespace IPC {
#include "extensions/common/extension_message_generator.h"
} // namespace IPC

@ -1,11 +0,0 @@
// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Multiply-included file, hence no include guard.
#undef EXTENSIONS_COMMON_EXTENSION_MESSAGES_H_
#include "extensions/common/extension_messages.h"
#ifndef EXTENSIONS_COMMON_EXTENSION_MESSAGES_H_
#error "Failed to include header extensions/common/extension_messages.h"
#endif

@ -1,308 +0,0 @@
// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// IPC messages for extensions.
#ifndef EXTENSIONS_COMMON_EXTENSION_MESSAGES_H_
#define EXTENSIONS_COMMON_EXTENSION_MESSAGES_H_
#include <stdint.h>
#include <map>
#include <memory>
#include <set>
#include <string>
#include <vector>
#include "base/memory/read_only_shared_memory_region.h"
#include "base/unguessable_token.h"
#include "base/values.h"
#include "content/public/common/common_param_traits.h"
#include "content/public/common/socket_permission_request.h"
#include "extensions/buildflags/buildflags.h"
#include "extensions/common/api/messaging/message.h"
#include "extensions/common/api/messaging/messaging_endpoint.h"
#include "extensions/common/api/messaging/port_context.h"
#include "extensions/common/api/messaging/port_id.h"
#include "extensions/common/common_param_traits.h"
#include "extensions/common/constants.h"
#include "extensions/common/extension.h"
#include "extensions/common/extension_guid.h"
#include "extensions/common/extension_param_traits.h"
#include "extensions/common/extensions_client.h"
#include "extensions/common/message_bundle.h"
#include "extensions/common/mojom/css_origin.mojom-shared.h"
#include "extensions/common/mojom/event_dispatcher.mojom.h"
#include "extensions/common/mojom/feature_session_type.mojom.h"
#include "extensions/common/mojom/frame.mojom.h"
#include "extensions/common/mojom/host_id.mojom.h"
#include "extensions/common/mojom/injection_type.mojom-shared.h"
#include "extensions/common/mojom/manifest.mojom-shared.h"
#include "extensions/common/mojom/message_port.mojom.h"
#include "extensions/common/mojom/run_location.mojom-shared.h"
#include "extensions/common/permissions/socket_permission_data.h"
#include "extensions/common/permissions/usb_device_permission_data.h"
#include "extensions/common/user_script.h"
#include "ipc/ipc_message_macros.h"
#include "ipc/ipc_message_start.h"
#include "ipc/ipc_message_utils.h"
#include "url/gurl.h"
#include "url/origin.h"
#define IPC_MESSAGE_START ExtensionMsgStart
#if BUILDFLAG(ENABLE_EXTENSIONS_LEGACY_IPC)
IPC_ENUM_TRAITS_MAX_VALUE(extensions::mojom::CSSOrigin,
extensions::mojom::CSSOrigin::kMaxValue)
IPC_ENUM_TRAITS_MAX_VALUE(content::SocketPermissionRequest::OperationType,
content::SocketPermissionRequest::OPERATION_TYPE_LAST)
IPC_ENUM_TRAITS_MAX_VALUE(extensions::mojom::RunLocation,
extensions::mojom::RunLocation::kMaxValue)
IPC_ENUM_TRAITS_MAX_VALUE(extensions::mojom::MessagingEndpointType,
extensions::mojom::MessagingEndpointType::kMaxValue)
IPC_ENUM_TRAITS_MAX_VALUE(extensions::mojom::SerializationFormat,
extensions::mojom::SerializationFormat::kMaxValue)
IPC_ENUM_TRAITS_MAX_VALUE(extensions::mojom::ChannelType,
extensions::mojom::ChannelType::kMaxValue)
// Struct containing information about the sender of connect() calls that
// originate from a tab.
IPC_STRUCT_BEGIN(ExtensionMsg_TabConnectionInfo)
// The tab from where the connection was created.
IPC_STRUCT_MEMBER(base::Value::Dict, tab)
// The ID of the frame that initiated the connection.
// 0 if main frame, positive otherwise. -1 if not initiated from a frame.
IPC_STRUCT_MEMBER(int, frame_id)
// The unique ID of the document of the frame that initiated the connection.
IPC_STRUCT_MEMBER(std::string, document_id)
// The lifecycle of the frame that initiated the connection.
IPC_STRUCT_MEMBER(std::string, document_lifecycle)
IPC_STRUCT_END()
// Struct containing information about the destination of tab.connect().
IPC_STRUCT_BEGIN(ExtensionMsg_TabTargetConnectionInfo)
// The destination tab's ID.
IPC_STRUCT_MEMBER(int, tab_id)
// Frame ID of the destination. -1 for all frames, 0 for main frame and
// positive if the destination is a specific child frame.
IPC_STRUCT_MEMBER(int, frame_id)
// The unique ID of the document of the target frame.
IPC_STRUCT_MEMBER(std::string, document_id)
IPC_STRUCT_END()
IPC_STRUCT_TRAITS_BEGIN(extensions::MessagingEndpoint)
IPC_STRUCT_TRAITS_MEMBER(type)
IPC_STRUCT_TRAITS_MEMBER(extension_id)
IPC_STRUCT_TRAITS_MEMBER(native_app_name)
IPC_STRUCT_TRAITS_END()
// Struct containing the data for external connections to extensions. Used to
// handle the IPCs initiated by both connect() and onConnect().
IPC_STRUCT_BEGIN(ExtensionMsg_ExternalConnectionInfo)
// The ID of the extension that is the target of the request.
IPC_STRUCT_MEMBER(std::string, target_id)
// Specifies the type and the ID of the endpoint that initiated the request.
IPC_STRUCT_MEMBER(extensions::MessagingEndpoint, source_endpoint)
// The URL of the frame that initiated the request.
IPC_STRUCT_MEMBER(GURL, source_url)
// The origin of the object that initiated the request.
IPC_STRUCT_MEMBER(std::optional<url::Origin>, source_origin)
// The process ID of the webview that initiated the request.
IPC_STRUCT_MEMBER(int, guest_process_id)
// The render frame routing ID of the webview that initiated the request.
IPC_STRUCT_MEMBER(int, guest_render_frame_routing_id)
IPC_STRUCT_END()
IPC_STRUCT_TRAITS_BEGIN(content::SocketPermissionRequest)
IPC_STRUCT_TRAITS_MEMBER(type)
IPC_STRUCT_TRAITS_MEMBER(host)
IPC_STRUCT_TRAITS_MEMBER(port)
IPC_STRUCT_TRAITS_END()
IPC_STRUCT_TRAITS_BEGIN(extensions::PortContext::FrameContext)
IPC_STRUCT_TRAITS_MEMBER(routing_id)
IPC_STRUCT_TRAITS_END()
IPC_STRUCT_TRAITS_BEGIN(extensions::PortContext::WorkerContext)
IPC_STRUCT_TRAITS_MEMBER(thread_id)
IPC_STRUCT_TRAITS_MEMBER(version_id)
IPC_STRUCT_TRAITS_MEMBER(extension_id)
IPC_STRUCT_TRAITS_END()
IPC_STRUCT_TRAITS_BEGIN(extensions::PortContext)
IPC_STRUCT_TRAITS_MEMBER(frame)
IPC_STRUCT_TRAITS_MEMBER(worker)
IPC_STRUCT_TRAITS_END()
IPC_STRUCT_TRAITS_BEGIN(extensions::SocketPermissionEntry)
IPC_STRUCT_TRAITS_MEMBER(pattern_)
IPC_STRUCT_TRAITS_MEMBER(match_subdomains_)
IPC_STRUCT_TRAITS_END()
IPC_STRUCT_TRAITS_BEGIN(extensions::SocketPermissionData)
IPC_STRUCT_TRAITS_MEMBER(entry())
IPC_STRUCT_TRAITS_END()
IPC_STRUCT_TRAITS_BEGIN(extensions::UsbDevicePermissionData)
IPC_STRUCT_TRAITS_MEMBER(vendor_id())
IPC_STRUCT_TRAITS_MEMBER(product_id())
IPC_STRUCT_TRAITS_MEMBER(interface_class())
IPC_STRUCT_TRAITS_END()
IPC_STRUCT_TRAITS_BEGIN(extensions::Message)
IPC_STRUCT_TRAITS_MEMBER(data)
IPC_STRUCT_TRAITS_MEMBER(format)
IPC_STRUCT_TRAITS_MEMBER(user_gesture)
IPC_STRUCT_TRAITS_END()
IPC_STRUCT_TRAITS_BEGIN(extensions::PortId)
IPC_STRUCT_TRAITS_MEMBER(context_id)
IPC_STRUCT_TRAITS_MEMBER(port_number)
IPC_STRUCT_TRAITS_MEMBER(is_opener)
IPC_STRUCT_TRAITS_MEMBER(serialization_format)
IPC_STRUCT_TRAITS_END()
IPC_STRUCT_BEGIN(ExtensionMsg_OnConnectData)
IPC_STRUCT_MEMBER(extensions::PortId, target_port_id)
IPC_STRUCT_MEMBER(extensions::mojom::ChannelType, channel_type)
IPC_STRUCT_MEMBER(std::string, channel_name)
IPC_STRUCT_MEMBER(ExtensionMsg_TabConnectionInfo, tab_source)
IPC_STRUCT_MEMBER(ExtensionMsg_ExternalConnectionInfo,
external_connection_info)
IPC_STRUCT_END()
// Messages sent from the browser to the renderer:
// The browser's response to the ExtensionMsg_WakeEventPage IPC.
IPC_MESSAGE_CONTROL2(ExtensionMsg_WakeEventPageResponse,
int /* request_id */,
bool /* success */)
// Check whether the Port for extension messaging exists in a frame or a Service
// Worker. If the port ID is unknown, the frame replies with
// ExtensionHostMsg_CloseMessagePort.
IPC_MESSAGE_ROUTED2(ExtensionMsg_ValidateMessagePort,
// For main thread, this is kMainThreadId.
int /* worker_thread_id */,
extensions::PortId /* port_id */)
// Dispatch the Port.onConnect event for message channels.
IPC_MESSAGE_ROUTED2(ExtensionMsg_DispatchOnConnect,
// For main thread, this is kMainThreadId.
// TODO(lazyboy): Can this be std::optional<int> instead?
int /* worker_thread_id */,
ExtensionMsg_OnConnectData /* connect_data */)
// Deliver a message sent with ExtensionHostMsg_PostMessage.
IPC_MESSAGE_ROUTED3(ExtensionMsg_DeliverMessage,
// For main thread, this is kMainThreadId.
int /* worker_thread_id */,
extensions::PortId /* target_port_id */,
extensions::Message)
// Dispatch the Port.onDisconnect event for message channels.
IPC_MESSAGE_ROUTED3(ExtensionMsg_DispatchOnDisconnect,
// For main thread, this is kMainThreadId.
int /* worker_thread_id */,
extensions::PortId /* port_id */,
std::string /* error_message */)
// Messages sent from the renderer to the browser:
// Notify the browser that an event has finished being dispatched.
IPC_MESSAGE_ROUTED2(ExtensionHostMsg_EventAck,
int /* message_id */,
bool /* event_will_run_in_background_page_script */)
// Open a channel to all listening contexts owned by the extension with
// the given ID. This responds asynchronously with ExtensionMsg_AssignPortId.
// If an error occurred, the opener will be notified asynchronously.
IPC_MESSAGE_CONTROL5(ExtensionHostMsg_OpenChannelToExtension,
extensions::PortContext /* source_context */,
ExtensionMsg_ExternalConnectionInfo,
extensions::mojom::ChannelType /* channel_type */,
std::string /* channel_name */,
extensions::PortId /* port_id */)
IPC_MESSAGE_CONTROL3(ExtensionHostMsg_OpenChannelToNativeApp,
extensions::PortContext /* source_context */,
std::string /* native_app_name */,
extensions::PortId /* port_id */)
// Get a port handle to the given tab. The handle can be used for sending
// messages to the extension.
IPC_MESSAGE_CONTROL5(ExtensionHostMsg_OpenChannelToTab,
extensions::PortContext /* source_context */,
ExtensionMsg_TabTargetConnectionInfo,
extensions::mojom::ChannelType /* channel_type */,
std::string /* channel_name */,
extensions::PortId /* port_id */)
// Sent in response to ExtensionMsg_DispatchOnConnect when the port is accepted.
// The handle is the value returned by ExtensionHostMsg_OpenChannelTo*.
IPC_MESSAGE_CONTROL2(ExtensionHostMsg_OpenMessagePort,
extensions::PortContext /* port_context */,
extensions::PortId /* port_id */)
// Sent in response to ExtensionMsg_DispatchOnConnect and whenever the port is
// closed. The handle is the value returned by ExtensionHostMsg_OpenChannelTo*.
IPC_MESSAGE_CONTROL3(ExtensionHostMsg_CloseMessagePort,
extensions::PortContext /* port_context */,
extensions::PortId /* port_id */,
bool /* force_close */)
// Send a message to an extension process. The handle is the value returned
// by ExtensionHostMsg_OpenChannelTo*.
IPC_MESSAGE_CONTROL2(ExtensionHostMsg_PostMessage,
extensions::PortId /* port_id */,
extensions::Message)
// Send a message to tell the browser that one of the listeners for a message
// indicated they are intending to reply later. The handle is the value returned
// by ExtensionHostMsg_OpenChannelTo*.
IPC_MESSAGE_CONTROL2(ExtensionHostMsg_ResponsePending,
extensions::PortContext /* port_context */,
extensions::PortId /*port_id */)
// Used to get the extension message bundle.
IPC_SYNC_MESSAGE_CONTROL1_1(
ExtensionHostMsg_GetMessageBundle,
std::string /* extension id */,
extensions::MessageBundle::SubstitutionMap /* message bundle */)
// Asks the browser to wake the event page of an extension.
// The browser will reply with ExtensionHostMsg_WakeEventPageResponse.
IPC_MESSAGE_CONTROL2(ExtensionHostMsg_WakeEventPage,
int /* request_id */,
std::string /* extension_id */)
// Messages related to Extension Service Worker.
#undef IPC_MESSAGE_START
#define IPC_MESSAGE_START ExtensionWorkerMsgStart
// Tells the browser that an event with |event_id| was successfully dispatched
// to the worker with version |service_worker_version_id|.
IPC_MESSAGE_CONTROL4(ExtensionHostMsg_EventAckWorker,
std::string /* extension_id */,
int64_t /* service_worker_version_id */,
int /* worker_thread_id */,
int /* event_id */)
#endif
#endif // EXTENSIONS_COMMON_EXTENSION_MESSAGES_H_

@ -1,72 +0,0 @@
// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "extensions/common/extension_param_traits.h"
#include "ipc/ipc_message_utils.h"
#include "ipc/ipc_mojo_message_helper.h"
#include "third_party/blink/public/mojom/blob/blob.mojom.h"
#include "third_party/blink/public/mojom/blob/serialized_blob.mojom.h"
namespace IPC {
void ParamTraits<extensions::mojom::ExtraResponseDataPtr>::Write(
base::Pickle* m,
const param_type& p) {
WriteParam(m, !p.is_null());
if (!p)
return;
m->WriteUInt32(p->blobs.size());
for (const auto& blob : p->blobs) {
m->WriteString(blob->uuid);
m->WriteString(blob->content_type);
m->WriteUInt64(blob->size);
MojoMessageHelper::WriteMessagePipeTo(m, blob->blob.PassPipe());
}
}
bool ParamTraits<extensions::mojom::ExtraResponseDataPtr>::Read(
const base::Pickle* m,
base::PickleIterator* iter,
param_type* r) {
bool is_not_null;
if (!ReadParam(m, iter, &is_not_null))
return false;
if (!is_not_null)
return true;
*r = extensions::mojom::ExtraResponseData::New();
uint32_t blob_count;
if (!ReadParam(m, iter, &blob_count))
return false;
(*r)->blobs.resize(blob_count);
for (auto& blob : (*r)->blobs) {
blob = blink::mojom::SerializedBlob::New();
if (!ReadParam(m, iter, &blob->uuid) ||
!ReadParam(m, iter, &blob->content_type) ||
!ReadParam(m, iter, &blob->size)) {
return false;
}
mojo::ScopedMessagePipeHandle blob_handle;
if (!MojoMessageHelper::ReadMessagePipeFrom(m, iter, &blob_handle) ||
!blob_handle.is_valid())
return false;
blob->blob = mojo::PendingRemote<blink::mojom::Blob>(
std::move(blob_handle), blink::mojom::Blob::Version_);
}
return true;
}
void ParamTraits<extensions::mojom::ExtraResponseDataPtr>::Log(
const param_type& p,
std::string* l) {
l->append("<extensions::ExtraResponseData>");
}
} // namespace IPC

@ -1,25 +0,0 @@
// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef EXTENSIONS_COMMON_EXTENSION_PARAM_TRAITS_H_
#define EXTENSIONS_COMMON_EXTENSION_PARAM_TRAITS_H_
#include "extensions/common/mojom/extra_response_data.mojom.h"
#include "ipc/ipc_mojo_param_traits.h"
namespace IPC {
template <>
struct ParamTraits<extensions::mojom::ExtraResponseDataPtr> {
using param_type = extensions::mojom::ExtraResponseDataPtr;
static void Write(base::Pickle* m, const param_type& p);
static bool Read(const base::Pickle* m,
base::PickleIterator* iter,
param_type* r);
static void Log(const param_type& p, std::string* l);
};
} // namespace IPC
#endif // EXTENSIONS_COMMON_EXTENSION_PARAM_TRAITS_H_

@ -17,10 +17,8 @@ enum IPCMessageStart {
WorkerMsgStart,
NaClMsgStart,
PpapiMsgStart,
ExtensionMsgStart,
NaClHostMsgStart,
GinJavaBridgeMsgStart,
ExtensionWorkerMsgStart,
LastIPCMsgStart // Must come last.
};

@ -34,18 +34,12 @@ void WriteIpcMessageIdAsProtozero(uint32_t message_id,
case PpapiMsgStart:
message_class = ChromeLegacyIpc::CLASS_PPAPI;
break;
case ExtensionMsgStart:
message_class = ChromeLegacyIpc::CLASS_EXTENSION;
break;
case NaClHostMsgStart:
message_class = ChromeLegacyIpc::CLASS_NACL_HOST;
break;
case GinJavaBridgeMsgStart:
message_class = ChromeLegacyIpc::CLASS_GIN_JAVA_BRIDGE;
break;
case ExtensionWorkerMsgStart:
message_class = ChromeLegacyIpc::CLASS_EXTENSION_WORKER;
break;
}
legacy_ipc->set_message_class(message_class);
legacy_ipc->set_message_line(IPC_MESSAGE_ID_LINE(message_id));

@ -22,4 +22,3 @@
#include "components/nacl/common/nacl_host_messages.h"
#endif
#include "content/common/all_messages.h"
#include "extensions/common/extension_message_generator.h"

@ -11,6 +11,7 @@
#include "base/containers/contains.h"
#include "build/build_config.h"
#include "ipc/ipc_message_start.h"
// Include once to get the type definitions
#include "tools/ipc_fuzzer/message_lib/all_messages.h"
@ -35,8 +36,7 @@ static msginfo msgtable[] = {
};
#define MSGTABLE_SIZE (sizeof(msgtable)/sizeof(msgtable[0]))
#if !BUILDFLAG(ENABLE_NACL) && !BUILDFLAG(ENABLE_PPAPI) && \
!BUILDFLAG(ENABLE_EXTENSIONS_LEGACY_IPC)
#if !BUILDFLAG(ENABLE_NACL) && !BUILDFLAG(ENABLE_PPAPI)
static_assert(MSGTABLE_SIZE == 0, "There should be no messages");
#else
static_assert(MSGTABLE_SIZE, "check your headers for an extra semicolon");
@ -60,17 +60,12 @@ static bool check_msgtable() {
exemptions.push_back(NaClHostMsgStart);
#endif // !BUILDFLAG(ENABLE_NACL)
#if !BUILDFLAG(ENABLE_EXTENSIONS_LEGACY_IPC)
exemptions.push_back(ExtensionMsgStart);
#endif // !BUILDFLAG(ENABLE_EXTENSIONS_LEGACY_IPC)
#if !BUILDFLAG(ENABLE_PPAPI)
exemptions.push_back(PpapiMsgStart);
#endif // !BUILDFLAG(ENABLE_PPAPI)
#if !BUILDFLAG(IS_ANDROID)
exemptions.push_back(GinJavaBridgeMsgStart);
exemptions.push_back(ExtensionWorkerMsgStart);
#endif // !BUILDFLAG(IS_ANDROID)
for (size_t i = 0; i < MSGTABLE_SIZE; ++i) {