| // components/content_settings/common/content_settings_manager.mojom.cc is auto generated by mojom_bindings_generator.py, do not edit |
| |
| // Copyright 2013 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. |
| |
| #if defined(__clang__) |
| #pragma clang diagnostic push |
| #pragma clang diagnostic ignored "-Wunused-private-field" |
| #endif |
| |
| #include "components/content_settings/common/content_settings_manager.mojom.h" |
| |
| #include <math.h> |
| #include <stdint.h> |
| #include <utility> |
| |
| #include "base/debug/alias.h" |
| #include "base/hash/md5_constexpr.h" |
| #include "base/run_loop.h" |
| #include "base/strings/string_number_conversions.h" |
| #include "base/trace_event/trace_event.h" |
| #include "base/trace_event/typed_macros.h" |
| #include "mojo/public/cpp/bindings/lib/generated_code_util.h" |
| #include "mojo/public/cpp/bindings/lib/message_internal.h" |
| #include "mojo/public/cpp/bindings/lib/send_message_helper.h" |
| #include "mojo/public/cpp/bindings/lib/proxy_to_responder.h" |
| #include "mojo/public/cpp/bindings/lib/serialization_util.h" |
| #include "mojo/public/cpp/bindings/lib/unserialized_message_context.h" |
| #include "mojo/public/cpp/bindings/lib/validate_params.h" |
| #include "mojo/public/cpp/bindings/lib/validation_errors.h" |
| #include "mojo/public/cpp/bindings/mojo_buildflags.h" |
| #include "mojo/public/interfaces/bindings/interface_control_messages.mojom.h" |
| #include "third_party/perfetto/include/perfetto/tracing/traced_value.h" |
| |
| #include "components/content_settings/common/content_settings_manager.mojom-params-data.h" |
| #include "components/content_settings/common/content_settings_manager.mojom-shared-message-ids.h" |
| |
| #include "components/content_settings/common/content_settings_manager.mojom-import-headers.h" |
| #include "components/content_settings/common/content_settings_manager.mojom-test-utils.h" |
| |
| |
| #ifndef COMPONENTS_CONTENT_SETTINGS_COMMON_CONTENT_SETTINGS_MANAGER_MOJOM_JUMBO_H_ |
| #define COMPONENTS_CONTENT_SETTINGS_COMMON_CONTENT_SETTINGS_MANAGER_MOJOM_JUMBO_H_ |
| #include "components/content_settings/core/common/content_settings_param_traits.h" |
| #endif |
| |
| |
| |
| namespace content_settings { |
| namespace mojom { |
| const char ContentSettingsManager::Name_[] = "content_settings.mojom.ContentSettingsManager"; |
| |
| std::pair<uint32_t, const void*> ContentSettingsManager::MessageToMethodInfo_(mojo::Message& message) { |
| switch (message.name()) { |
| case internal::kContentSettingsManager_Clone_Name: { |
| constexpr uint32_t value = base::MD5Hash32Constexpr( |
| "(Impl)content_settings::mojom::ContentSettingsManager::Clone"); |
| #if BUILDFLAG(IS_FUCHSIA) |
| return std::make_pair(value, nullptr); |
| #else |
| return std::make_pair(value, reinterpret_cast<const void*>(&ContentSettingsManager::Clone_Sym::IPCSymbol)); |
| #endif // BUILDFLAG(IS_FUCHSIA) |
| } |
| case internal::kContentSettingsManager_AllowStorageAccess_Name: { |
| constexpr uint32_t value = base::MD5Hash32Constexpr( |
| "(Impl)content_settings::mojom::ContentSettingsManager::AllowStorageAccess"); |
| #if BUILDFLAG(IS_FUCHSIA) |
| return std::make_pair(value, nullptr); |
| #else |
| return std::make_pair(value, reinterpret_cast<const void*>(&ContentSettingsManager::AllowStorageAccess_Sym::IPCSymbol)); |
| #endif // BUILDFLAG(IS_FUCHSIA) |
| } |
| case internal::kContentSettingsManager_OnContentBlocked_Name: { |
| constexpr uint32_t value = base::MD5Hash32Constexpr( |
| "(Impl)content_settings::mojom::ContentSettingsManager::OnContentBlocked"); |
| #if BUILDFLAG(IS_FUCHSIA) |
| return std::make_pair(value, nullptr); |
| #else |
| return std::make_pair(value, reinterpret_cast<const void*>(&ContentSettingsManager::OnContentBlocked_Sym::IPCSymbol)); |
| #endif // BUILDFLAG(IS_FUCHSIA) |
| } |
| } |
| return std::make_pair(0, nullptr); |
| } |
| |
| |
| const char* ContentSettingsManager::MessageToMethodName_(mojo::Message& message) { |
| #if BUILDFLAG(MOJO_TRACE_ENABLED) |
| bool is_response = message.has_flag(mojo::Message::kFlagIsResponse); |
| if (!is_response) { |
| switch (message.name()) { |
| case internal::kContentSettingsManager_Clone_Name: |
| return "Receive content_settings::mojom::ContentSettingsManager::Clone"; |
| case internal::kContentSettingsManager_AllowStorageAccess_Name: |
| return "Receive content_settings::mojom::ContentSettingsManager::AllowStorageAccess"; |
| case internal::kContentSettingsManager_OnContentBlocked_Name: |
| return "Receive content_settings::mojom::ContentSettingsManager::OnContentBlocked"; |
| } |
| } else { |
| switch (message.name()) { |
| case internal::kContentSettingsManager_Clone_Name: |
| return "Receive reply content_settings::mojom::ContentSettingsManager::Clone"; |
| case internal::kContentSettingsManager_AllowStorageAccess_Name: |
| return "Receive reply content_settings::mojom::ContentSettingsManager::AllowStorageAccess"; |
| case internal::kContentSettingsManager_OnContentBlocked_Name: |
| return "Receive reply content_settings::mojom::ContentSettingsManager::OnContentBlocked"; |
| } |
| } |
| return "Receive unknown mojo message"; |
| #else |
| bool is_response = message.has_flag(mojo::Message::kFlagIsResponse); |
| if (is_response) { |
| return "Receive mojo reply"; |
| } else { |
| return "Receive mojo message"; |
| } |
| #endif // BUILDFLAG(MOJO_TRACE_ENABLED) |
| } |
| |
| #if !BUILDFLAG(IS_FUCHSIA) |
| void ContentSettingsManager::Clone_Sym::IPCSymbol() { |
| // This method's address is used for indetifiying the mojo method name after |
| // symblozation. So each IPCSymbol should have a unique address. |
| NO_CODE_FOLDING(); |
| } |
| void ContentSettingsManager::AllowStorageAccess_Sym::IPCSymbol() { |
| // This method's address is used for indetifiying the mojo method name after |
| // symblozation. So each IPCSymbol should have a unique address. |
| NO_CODE_FOLDING(); |
| } |
| void ContentSettingsManager::OnContentBlocked_Sym::IPCSymbol() { |
| // This method's address is used for indetifiying the mojo method name after |
| // symblozation. So each IPCSymbol should have a unique address. |
| NO_CODE_FOLDING(); |
| } |
| # endif // !BUILDFLAG(IS_FUCHSIA) |
| bool ContentSettingsManager::AllowStorageAccess(int32_t render_frame_id, ContentSettingsManager::StorageType storage_type, const ::url::Origin& origin, const ::net::SiteForCookies& site_for_cookies, const ::url::Origin& top_frame_origin, bool* out_allowed) { |
| NOTREACHED(); |
| return false; |
| } |
| class ContentSettingsManager_AllowStorageAccess_HandleSyncResponse |
| : public mojo::MessageReceiver { |
| public: |
| ContentSettingsManager_AllowStorageAccess_HandleSyncResponse( |
| bool* result, bool* out_allowed) |
| : result_(result), out_allowed_(out_allowed) { |
| DCHECK(!*result_); |
| } |
| |
| ContentSettingsManager_AllowStorageAccess_HandleSyncResponse(const ContentSettingsManager_AllowStorageAccess_HandleSyncResponse&) = delete; |
| ContentSettingsManager_AllowStorageAccess_HandleSyncResponse& operator=(const ContentSettingsManager_AllowStorageAccess_HandleSyncResponse&) = delete; |
| |
| bool Accept(mojo::Message* message) override; |
| private: |
| bool* result_; |
| bool* out_allowed_;}; |
| |
| class ContentSettingsManager_AllowStorageAccess_ForwardToCallback |
| : public mojo::MessageReceiver { |
| public: |
| ContentSettingsManager_AllowStorageAccess_ForwardToCallback( |
| ContentSettingsManager::AllowStorageAccessCallback callback |
| ) : callback_(std::move(callback)) { |
| } |
| |
| ContentSettingsManager_AllowStorageAccess_ForwardToCallback(const ContentSettingsManager_AllowStorageAccess_ForwardToCallback&) = delete; |
| ContentSettingsManager_AllowStorageAccess_ForwardToCallback& operator=(const ContentSettingsManager_AllowStorageAccess_ForwardToCallback&) = delete; |
| |
| bool Accept(mojo::Message* message) override; |
| private: |
| ContentSettingsManager::AllowStorageAccessCallback callback_; |
| }; |
| |
| ContentSettingsManagerProxy::ContentSettingsManagerProxy(mojo::MessageReceiverWithResponder* receiver) |
| : receiver_(receiver) { |
| } |
| |
| void ContentSettingsManagerProxy::Clone( |
| ::mojo::PendingReceiver<ContentSettingsManager> in_clone) { |
| #if BUILDFLAG(MOJO_TRACE_ENABLED) |
| TRACE_EVENT1( |
| "mojom", "Send content_settings::mojom::ContentSettingsManager::Clone", "input_parameters", |
| [&](perfetto::TracedValue context){ |
| auto dict = std::move(context).WriteDictionary(); |
| perfetto::WriteIntoTracedValueWithFallback( |
| dict.AddItem("clone"), in_clone, |
| "<value of type ::mojo::PendingReceiver<ContentSettingsManager>>"); |
| }); |
| #endif |
| const bool kExpectsResponse = false; |
| const bool kIsSync = false; |
| const bool kAllowInterrupt = true; |
| |
| const uint32_t kFlags = |
| ((kExpectsResponse) ? mojo::Message::kFlagExpectsResponse : 0) | |
| ((kIsSync) ? mojo::Message::kFlagIsSync : 0) | |
| ((kAllowInterrupt) ? 0 : mojo::Message::kFlagNoInterrupt); |
| |
| mojo::Message message( |
| internal::kContentSettingsManager_Clone_Name, kFlags, 0, 0, nullptr); |
| mojo::internal::MessageFragment< |
| ::content_settings::mojom::internal::ContentSettingsManager_Clone_Params_Data> params( |
| message); |
| params.Allocate(); |
| mojo::internal::Serialize<mojo::InterfaceRequestDataView<::content_settings::mojom::ContentSettingsManagerInterfaceBase>>( |
| in_clone, ¶ms->clone, ¶ms.message()); |
| MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING( |
| !mojo::internal::IsHandleOrInterfaceValid(params->clone), |
| mojo::internal::VALIDATION_ERROR_UNEXPECTED_INVALID_HANDLE, |
| "invalid clone in ContentSettingsManager.Clone request"); |
| |
| #if defined(ENABLE_IPC_FUZZER) |
| message.set_interface_name(ContentSettingsManager::Name_); |
| message.set_method_name("Clone"); |
| #endif |
| // This return value may be ignored as false implies the Connector has |
| // encountered an error, which will be visible through other means. |
| ::mojo::internal::SendMessage(*receiver_, message); |
| } |
| bool ContentSettingsManagerProxy::AllowStorageAccess( |
| int32_t param_render_frame_id, ContentSettingsManager::StorageType param_storage_type, const ::url::Origin& param_origin, const ::net::SiteForCookies& param_site_for_cookies, const ::url::Origin& param_top_frame_origin, bool* out_param_allowed) { |
| #if BUILDFLAG(MOJO_TRACE_ENABLED) |
| TRACE_EVENT_BEGIN1( |
| "mojom", "Call content_settings::mojom::ContentSettingsManager::AllowStorageAccess (sync)", "input_parameters", |
| [&](perfetto::TracedValue context){ |
| auto dict = std::move(context).WriteDictionary(); |
| perfetto::WriteIntoTracedValueWithFallback( |
| dict.AddItem("render_frame_id"), param_render_frame_id, |
| "<value of type int32_t>"); |
| perfetto::WriteIntoTracedValueWithFallback( |
| dict.AddItem("storage_type"), param_storage_type, |
| "<value of type ContentSettingsManager::StorageType>"); |
| perfetto::WriteIntoTracedValueWithFallback( |
| dict.AddItem("origin"), param_origin, |
| "<value of type const ::url::Origin&>"); |
| perfetto::WriteIntoTracedValueWithFallback( |
| dict.AddItem("site_for_cookies"), param_site_for_cookies, |
| "<value of type const ::net::SiteForCookies&>"); |
| perfetto::WriteIntoTracedValueWithFallback( |
| dict.AddItem("top_frame_origin"), param_top_frame_origin, |
| "<value of type const ::url::Origin&>"); |
| }); |
| #else |
| TRACE_EVENT0("mojom", "ContentSettingsManager::AllowStorageAccess"); |
| #endif |
| const bool kExpectsResponse = true; |
| const bool kIsSync = true; |
| const bool kAllowInterrupt = |
| true; |
| |
| const uint32_t kFlags = |
| ((kExpectsResponse) ? mojo::Message::kFlagExpectsResponse : 0) | |
| ((kIsSync) ? mojo::Message::kFlagIsSync : 0) | |
| ((kAllowInterrupt) ? 0 : mojo::Message::kFlagNoInterrupt); |
| |
| mojo::Message message( |
| internal::kContentSettingsManager_AllowStorageAccess_Name, kFlags, 0, 0, nullptr); |
| mojo::internal::MessageFragment< |
| ::content_settings::mojom::internal::ContentSettingsManager_AllowStorageAccess_Params_Data> params( |
| message); |
| params.Allocate(); |
| params->render_frame_id = param_render_frame_id; |
| mojo::internal::Serialize<::content_settings::mojom::ContentSettingsManager_StorageType>( |
| param_storage_type, ¶ms->storage_type); |
| mojo::internal::MessageFragment< |
| typename decltype(params->origin)::BaseType> origin_fragment( |
| params.message()); |
| mojo::internal::Serialize<::url::mojom::OriginDataView>( |
| param_origin, origin_fragment); |
| params->origin.Set( |
| origin_fragment.is_null() ? nullptr : origin_fragment.data()); |
| MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING( |
| params->origin.is_null(), |
| mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER, |
| "null origin in ContentSettingsManager.AllowStorageAccess request"); |
| mojo::internal::MessageFragment< |
| typename decltype(params->site_for_cookies)::BaseType> site_for_cookies_fragment( |
| params.message()); |
| mojo::internal::Serialize<::network::mojom::SiteForCookiesDataView>( |
| param_site_for_cookies, site_for_cookies_fragment); |
| params->site_for_cookies.Set( |
| site_for_cookies_fragment.is_null() ? nullptr : site_for_cookies_fragment.data()); |
| MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING( |
| params->site_for_cookies.is_null(), |
| mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER, |
| "null site_for_cookies in ContentSettingsManager.AllowStorageAccess request"); |
| mojo::internal::MessageFragment< |
| typename decltype(params->top_frame_origin)::BaseType> top_frame_origin_fragment( |
| params.message()); |
| mojo::internal::Serialize<::url::mojom::OriginDataView>( |
| param_top_frame_origin, top_frame_origin_fragment); |
| params->top_frame_origin.Set( |
| top_frame_origin_fragment.is_null() ? nullptr : top_frame_origin_fragment.data()); |
| MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING( |
| params->top_frame_origin.is_null(), |
| mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER, |
| "null top_frame_origin in ContentSettingsManager.AllowStorageAccess request"); |
| |
| #if defined(ENABLE_IPC_FUZZER) |
| message.set_interface_name(ContentSettingsManager::Name_); |
| message.set_method_name("AllowStorageAccess"); |
| #endif |
| |
| bool result = false; |
| std::unique_ptr<mojo::MessageReceiver> responder( |
| new ContentSettingsManager_AllowStorageAccess_HandleSyncResponse( |
| &result, out_param_allowed)); |
| ::mojo::internal::SendMessage(*receiver_, message, std::move(responder)); |
| #if BUILDFLAG(MOJO_TRACE_ENABLED) |
| TRACE_EVENT_END1( |
| "mojom", "ContentSettingsManager::AllowStorageAccess", "sync_response_parameters", |
| [&](perfetto::TracedValue context){ |
| auto dict = std::move(context).WriteDictionary(); |
| perfetto::WriteIntoTracedValueWithFallback( |
| dict.AddItem("allowed"), out_param_allowed, |
| "<value of type bool>"); |
| }); |
| #endif |
| return result; |
| } |
| |
| void ContentSettingsManagerProxy::AllowStorageAccess( |
| int32_t in_render_frame_id, ContentSettingsManager::StorageType in_storage_type, const ::url::Origin& in_origin, const ::net::SiteForCookies& in_site_for_cookies, const ::url::Origin& in_top_frame_origin, AllowStorageAccessCallback callback) { |
| #if BUILDFLAG(MOJO_TRACE_ENABLED) |
| TRACE_EVENT1( |
| "mojom", "Send content_settings::mojom::ContentSettingsManager::AllowStorageAccess", "input_parameters", |
| [&](perfetto::TracedValue context){ |
| auto dict = std::move(context).WriteDictionary(); |
| perfetto::WriteIntoTracedValueWithFallback( |
| dict.AddItem("render_frame_id"), in_render_frame_id, |
| "<value of type int32_t>"); |
| perfetto::WriteIntoTracedValueWithFallback( |
| dict.AddItem("storage_type"), in_storage_type, |
| "<value of type ContentSettingsManager::StorageType>"); |
| perfetto::WriteIntoTracedValueWithFallback( |
| dict.AddItem("origin"), in_origin, |
| "<value of type const ::url::Origin&>"); |
| perfetto::WriteIntoTracedValueWithFallback( |
| dict.AddItem("site_for_cookies"), in_site_for_cookies, |
| "<value of type const ::net::SiteForCookies&>"); |
| perfetto::WriteIntoTracedValueWithFallback( |
| dict.AddItem("top_frame_origin"), in_top_frame_origin, |
| "<value of type const ::url::Origin&>"); |
| }); |
| #endif |
| const bool kExpectsResponse = true; |
| const bool kIsSync = false; |
| const bool kAllowInterrupt = true; |
| |
| const uint32_t kFlags = |
| ((kExpectsResponse) ? mojo::Message::kFlagExpectsResponse : 0) | |
| ((kIsSync) ? mojo::Message::kFlagIsSync : 0) | |
| ((kAllowInterrupt) ? 0 : mojo::Message::kFlagNoInterrupt); |
| |
| mojo::Message message( |
| internal::kContentSettingsManager_AllowStorageAccess_Name, kFlags, 0, 0, nullptr); |
| mojo::internal::MessageFragment< |
| ::content_settings::mojom::internal::ContentSettingsManager_AllowStorageAccess_Params_Data> params( |
| message); |
| params.Allocate(); |
| params->render_frame_id = in_render_frame_id; |
| mojo::internal::Serialize<::content_settings::mojom::ContentSettingsManager_StorageType>( |
| in_storage_type, ¶ms->storage_type); |
| mojo::internal::MessageFragment< |
| typename decltype(params->origin)::BaseType> origin_fragment( |
| params.message()); |
| mojo::internal::Serialize<::url::mojom::OriginDataView>( |
| in_origin, origin_fragment); |
| params->origin.Set( |
| origin_fragment.is_null() ? nullptr : origin_fragment.data()); |
| MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING( |
| params->origin.is_null(), |
| mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER, |
| "null origin in ContentSettingsManager.AllowStorageAccess request"); |
| mojo::internal::MessageFragment< |
| typename decltype(params->site_for_cookies)::BaseType> site_for_cookies_fragment( |
| params.message()); |
| mojo::internal::Serialize<::network::mojom::SiteForCookiesDataView>( |
| in_site_for_cookies, site_for_cookies_fragment); |
| params->site_for_cookies.Set( |
| site_for_cookies_fragment.is_null() ? nullptr : site_for_cookies_fragment.data()); |
| MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING( |
| params->site_for_cookies.is_null(), |
| mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER, |
| "null site_for_cookies in ContentSettingsManager.AllowStorageAccess request"); |
| mojo::internal::MessageFragment< |
| typename decltype(params->top_frame_origin)::BaseType> top_frame_origin_fragment( |
| params.message()); |
| mojo::internal::Serialize<::url::mojom::OriginDataView>( |
| in_top_frame_origin, top_frame_origin_fragment); |
| params->top_frame_origin.Set( |
| top_frame_origin_fragment.is_null() ? nullptr : top_frame_origin_fragment.data()); |
| MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING( |
| params->top_frame_origin.is_null(), |
| mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER, |
| "null top_frame_origin in ContentSettingsManager.AllowStorageAccess request"); |
| |
| #if defined(ENABLE_IPC_FUZZER) |
| message.set_interface_name(ContentSettingsManager::Name_); |
| message.set_method_name("AllowStorageAccess"); |
| #endif |
| std::unique_ptr<mojo::MessageReceiver> responder( |
| new ContentSettingsManager_AllowStorageAccess_ForwardToCallback( |
| std::move(callback))); |
| ::mojo::internal::SendMessage(*receiver_, message, std::move(responder)); |
| } |
| |
| void ContentSettingsManagerProxy::OnContentBlocked( |
| int32_t in_render_frame_id, ::ContentSettingsType in_type) { |
| #if BUILDFLAG(MOJO_TRACE_ENABLED) |
| TRACE_EVENT1( |
| "mojom", "Send content_settings::mojom::ContentSettingsManager::OnContentBlocked", "input_parameters", |
| [&](perfetto::TracedValue context){ |
| auto dict = std::move(context).WriteDictionary(); |
| perfetto::WriteIntoTracedValueWithFallback( |
| dict.AddItem("render_frame_id"), in_render_frame_id, |
| "<value of type int32_t>"); |
| perfetto::WriteIntoTracedValueWithFallback( |
| dict.AddItem("type"), in_type, |
| "<value of type ::ContentSettingsType>"); |
| }); |
| #endif |
| const bool kExpectsResponse = false; |
| const bool kIsSync = false; |
| const bool kAllowInterrupt = true; |
| |
| const uint32_t kFlags = |
| ((kExpectsResponse) ? mojo::Message::kFlagExpectsResponse : 0) | |
| ((kIsSync) ? mojo::Message::kFlagIsSync : 0) | |
| ((kAllowInterrupt) ? 0 : mojo::Message::kFlagNoInterrupt); |
| |
| mojo::Message message( |
| internal::kContentSettingsManager_OnContentBlocked_Name, kFlags, 0, 0, nullptr); |
| mojo::internal::MessageFragment< |
| ::content_settings::mojom::internal::ContentSettingsManager_OnContentBlocked_Params_Data> params( |
| message); |
| params.Allocate(); |
| params->render_frame_id = in_render_frame_id; |
| mojo::internal::Serialize<::content_settings::mojom::ContentSettingsType>( |
| in_type, ¶ms->type); |
| |
| #if defined(ENABLE_IPC_FUZZER) |
| message.set_interface_name(ContentSettingsManager::Name_); |
| message.set_method_name("OnContentBlocked"); |
| #endif |
| // This return value may be ignored as false implies the Connector has |
| // encountered an error, which will be visible through other means. |
| ::mojo::internal::SendMessage(*receiver_, message); |
| } |
| class ContentSettingsManager_AllowStorageAccess_ProxyToResponder : public ::mojo::internal::ProxyToResponder { |
| public: |
| static ContentSettingsManager::AllowStorageAccessCallback CreateCallback( |
| ::mojo::Message& message, |
| std::unique_ptr<mojo::MessageReceiverWithStatus> responder) { |
| std::unique_ptr<ContentSettingsManager_AllowStorageAccess_ProxyToResponder> proxy( |
| new ContentSettingsManager_AllowStorageAccess_ProxyToResponder( |
| message, std::move(responder))); |
| return base::BindOnce(&ContentSettingsManager_AllowStorageAccess_ProxyToResponder::Run, |
| std::move(proxy)); |
| } |
| |
| ~ContentSettingsManager_AllowStorageAccess_ProxyToResponder() { |
| #if DCHECK_IS_ON() |
| if (responder_) { |
| // If we're being destroyed without being run, we want to ensure the |
| // binding endpoint has been closed. This checks for that asynchronously. |
| // We pass a bound generated callback to handle the response so that any |
| // resulting DCHECK stack will have useful interface type information. |
| responder_->IsConnectedAsync(base::BindOnce(&OnIsConnectedComplete)); |
| } |
| #endif |
| } |
| |
| private: |
| ContentSettingsManager_AllowStorageAccess_ProxyToResponder( |
| ::mojo::Message& message, |
| std::unique_ptr<mojo::MessageReceiverWithStatus> responder) |
| : ::mojo::internal::ProxyToResponder(message, std::move(responder)) { |
| } |
| |
| #if DCHECK_IS_ON() |
| static void OnIsConnectedComplete(bool connected) { |
| DCHECK(!connected) |
| << "ContentSettingsManager::AllowStorageAccessCallback was destroyed without " |
| << "first either being run or its corresponding binding being closed. " |
| << "It is an error to drop response callbacks which still correspond " |
| << "to an open interface pipe."; |
| } |
| #endif |
| |
| void Run( |
| bool in_allowed); |
| }; |
| |
| bool ContentSettingsManager_AllowStorageAccess_ForwardToCallback::Accept( |
| mojo::Message* message) { |
| |
| DCHECK(message->is_serialized()); |
| internal::ContentSettingsManager_AllowStorageAccess_ResponseParams_Data* params = |
| reinterpret_cast< |
| internal::ContentSettingsManager_AllowStorageAccess_ResponseParams_Data*>( |
| message->mutable_payload()); |
| |
| bool success = true; |
| bool p_allowed{}; |
| ContentSettingsManager_AllowStorageAccess_ResponseParamsDataView input_data_view(params, message); |
| |
| if (success) |
| p_allowed = input_data_view.allowed(); |
| if (!success) { |
| ReportValidationErrorForMessage( |
| message, |
| mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED, |
| ContentSettingsManager::Name_, 1, true); |
| return false; |
| } |
| if (!callback_.is_null()) |
| std::move(callback_).Run( |
| std::move(p_allowed)); |
| return true; |
| } |
| |
| void ContentSettingsManager_AllowStorageAccess_ProxyToResponder::Run( |
| bool in_allowed) { |
| #if BUILDFLAG(MOJO_TRACE_ENABLED) |
| TRACE_EVENT1( |
| "mojom", "Send reply content_settings::mojom::ContentSettingsManager::AllowStorageAccess", "async_response_parameters", |
| [&](perfetto::TracedValue context){ |
| auto dict = std::move(context).WriteDictionary(); |
| perfetto::WriteIntoTracedValueWithFallback( |
| dict.AddItem("allowed"), in_allowed, |
| "<value of type bool>"); |
| }); |
| #endif |
| |
| const uint32_t kFlags = mojo::Message::kFlagIsResponse | |
| ((is_sync_) ? mojo::Message::kFlagIsSync : 0) | |
| ((true) ? 0 : mojo::Message::kFlagNoInterrupt); |
| |
| mojo::Message message( |
| internal::kContentSettingsManager_AllowStorageAccess_Name, kFlags, 0, 0, nullptr); |
| mojo::internal::MessageFragment< |
| ::content_settings::mojom::internal::ContentSettingsManager_AllowStorageAccess_ResponseParams_Data> params( |
| message); |
| params.Allocate(); |
| params->allowed = in_allowed; |
| |
| #if defined(ENABLE_IPC_FUZZER) |
| message.set_interface_name(ContentSettingsManager::Name_); |
| message.set_method_name("AllowStorageAccess"); |
| #endif |
| |
| message.set_request_id(request_id_); |
| message.set_trace_nonce(trace_nonce_); |
| ::mojo::internal::SendMessage(*responder_, message); |
| // SendMessage fails silently if the responder connection is closed, |
| // or if the message is malformed. |
| // |
| // TODO(darin): If Accept() returns false due to a malformed message, that |
| // may be good reason to close the connection. However, we don't have a |
| // way to do that from here. We should add a way. |
| responder_ = nullptr; |
| } |
| bool ContentSettingsManager_AllowStorageAccess_HandleSyncResponse::Accept( |
| mojo::Message* message) { |
| |
| DCHECK(message->is_serialized()); |
| internal::ContentSettingsManager_AllowStorageAccess_ResponseParams_Data* params = |
| reinterpret_cast<internal::ContentSettingsManager_AllowStorageAccess_ResponseParams_Data*>( |
| message->mutable_payload()); |
| |
| bool success = true; |
| bool p_allowed{}; |
| ContentSettingsManager_AllowStorageAccess_ResponseParamsDataView input_data_view(params, message); |
| |
| if (success) |
| p_allowed = input_data_view.allowed(); |
| if (!success) { |
| ReportValidationErrorForMessage( |
| message, |
| mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED, |
| ContentSettingsManager::Name_, 1, true); |
| return false; |
| } |
| *out_allowed_ = std::move(p_allowed); |
| *result_ = true; |
| return true; |
| } |
| |
| // static |
| bool ContentSettingsManagerStubDispatch::Accept( |
| ContentSettingsManager* impl, |
| mojo::Message* message) { |
| switch (message->header()->name) { |
| case internal::kContentSettingsManager_Clone_Name: { |
| |
| DCHECK(message->is_serialized()); |
| internal::ContentSettingsManager_Clone_Params_Data* params = |
| reinterpret_cast<internal::ContentSettingsManager_Clone_Params_Data*>( |
| message->mutable_payload()); |
| |
| bool success = true; |
| ::mojo::PendingReceiver<ContentSettingsManager> p_clone{}; |
| ContentSettingsManager_Clone_ParamsDataView input_data_view(params, message); |
| |
| if (success) { |
| p_clone = |
| input_data_view.TakeClone<decltype(p_clone)>(); |
| } |
| if (!success) { |
| ReportValidationErrorForMessage( |
| message, |
| mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED, |
| ContentSettingsManager::Name_, 0, false); |
| return false; |
| } |
| // A null |impl| means no implementation was bound. |
| DCHECK(impl); |
| impl->Clone( |
| std::move(p_clone)); |
| return true; |
| } |
| case internal::kContentSettingsManager_AllowStorageAccess_Name: { |
| break; |
| } |
| case internal::kContentSettingsManager_OnContentBlocked_Name: { |
| |
| DCHECK(message->is_serialized()); |
| internal::ContentSettingsManager_OnContentBlocked_Params_Data* params = |
| reinterpret_cast<internal::ContentSettingsManager_OnContentBlocked_Params_Data*>( |
| message->mutable_payload()); |
| |
| bool success = true; |
| int32_t p_render_frame_id{}; |
| ::ContentSettingsType p_type{}; |
| ContentSettingsManager_OnContentBlocked_ParamsDataView input_data_view(params, message); |
| |
| if (success) |
| p_render_frame_id = input_data_view.render_frame_id(); |
| if (success && !input_data_view.ReadType(&p_type)) |
| success = false; |
| if (!success) { |
| ReportValidationErrorForMessage( |
| message, |
| mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED, |
| ContentSettingsManager::Name_, 2, false); |
| return false; |
| } |
| // A null |impl| means no implementation was bound. |
| DCHECK(impl); |
| impl->OnContentBlocked( |
| std::move(p_render_frame_id), |
| std::move(p_type)); |
| return true; |
| } |
| } |
| return false; |
| } |
| |
| // static |
| bool ContentSettingsManagerStubDispatch::AcceptWithResponder( |
| ContentSettingsManager* impl, |
| mojo::Message* message, |
| std::unique_ptr<mojo::MessageReceiverWithStatus> responder) { |
| [[maybe_unused]] const bool message_is_sync = |
| message->has_flag(mojo::Message::kFlagIsSync); |
| [[maybe_unused]] const uint64_t request_id = message->request_id(); |
| switch (message->header()->name) { |
| case internal::kContentSettingsManager_Clone_Name: { |
| break; |
| } |
| case internal::kContentSettingsManager_AllowStorageAccess_Name: { |
| |
| internal::ContentSettingsManager_AllowStorageAccess_Params_Data* params = |
| reinterpret_cast< |
| internal::ContentSettingsManager_AllowStorageAccess_Params_Data*>( |
| message->mutable_payload()); |
| |
| bool success = true; |
| int32_t p_render_frame_id{}; |
| ContentSettingsManager::StorageType p_storage_type{}; |
| ::url::Origin p_origin{}; |
| ::net::SiteForCookies p_site_for_cookies{}; |
| ::url::Origin p_top_frame_origin{}; |
| ContentSettingsManager_AllowStorageAccess_ParamsDataView input_data_view(params, message); |
| |
| if (success) |
| p_render_frame_id = input_data_view.render_frame_id(); |
| if (success && !input_data_view.ReadStorageType(&p_storage_type)) |
| success = false; |
| if (success && !input_data_view.ReadOrigin(&p_origin)) |
| success = false; |
| if (success && !input_data_view.ReadSiteForCookies(&p_site_for_cookies)) |
| success = false; |
| if (success && !input_data_view.ReadTopFrameOrigin(&p_top_frame_origin)) |
| success = false; |
| if (!success) { |
| ReportValidationErrorForMessage( |
| message, |
| mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED, |
| ContentSettingsManager::Name_, 1, false); |
| return false; |
| } |
| ContentSettingsManager::AllowStorageAccessCallback callback = |
| ContentSettingsManager_AllowStorageAccess_ProxyToResponder::CreateCallback( |
| *message, std::move(responder)); |
| // A null |impl| means no implementation was bound. |
| DCHECK(impl); |
| impl->AllowStorageAccess( |
| std::move(p_render_frame_id), |
| std::move(p_storage_type), |
| std::move(p_origin), |
| std::move(p_site_for_cookies), |
| std::move(p_top_frame_origin), std::move(callback)); |
| return true; |
| } |
| case internal::kContentSettingsManager_OnContentBlocked_Name: { |
| break; |
| } |
| } |
| return false; |
| } |
| |
| |
| static const mojo::internal::GenericValidationInfo kContentSettingsManagerValidationInfo[] = { |
| {&internal::ContentSettingsManager_Clone_Params_Data::Validate, |
| nullptr /* no response */}, |
| {&internal::ContentSettingsManager_AllowStorageAccess_Params_Data::Validate, |
| &internal::ContentSettingsManager_AllowStorageAccess_ResponseParams_Data::Validate}, |
| {&internal::ContentSettingsManager_OnContentBlocked_Params_Data::Validate, |
| nullptr /* no response */}, |
| }; |
| |
| bool ContentSettingsManagerRequestValidator::Accept(mojo::Message* message) { |
| const char* name = ::content_settings::mojom::ContentSettingsManager::Name_; |
| return mojo::internal::ValidateRequestGenericPacked(message, name, kContentSettingsManagerValidationInfo); |
| } |
| |
| bool ContentSettingsManagerResponseValidator::Accept(mojo::Message* message) { |
| const char* name = ::content_settings::mojom::ContentSettingsManager::Name_; |
| return mojo::internal::ValidateResponseGenericPacked(message, name, kContentSettingsManagerValidationInfo); |
| } |
| |
| |
| } // namespace mojom |
| } // namespace content_settings |
| |
| |
| namespace mojo { |
| |
| } // namespace mojo |
| |
| |
| // Symbols declared in the -test-utils.h header are defined here instead of a |
| // separate .cc file to save compile time. |
| |
| |
| namespace content_settings { |
| namespace mojom { |
| |
| |
| void ContentSettingsManagerInterceptorForTesting::Clone(::mojo::PendingReceiver<ContentSettingsManager> clone) { |
| GetForwardingInterface()->Clone(std::move(clone)); |
| } |
| void ContentSettingsManagerInterceptorForTesting::AllowStorageAccess(int32_t render_frame_id, ContentSettingsManager::StorageType storage_type, const ::url::Origin& origin, const ::net::SiteForCookies& site_for_cookies, const ::url::Origin& top_frame_origin, AllowStorageAccessCallback callback) { |
| GetForwardingInterface()->AllowStorageAccess(std::move(render_frame_id), std::move(storage_type), std::move(origin), std::move(site_for_cookies), std::move(top_frame_origin), std::move(callback)); |
| } |
| void ContentSettingsManagerInterceptorForTesting::OnContentBlocked(int32_t render_frame_id, ::ContentSettingsType type) { |
| GetForwardingInterface()->OnContentBlocked(std::move(render_frame_id), std::move(type)); |
| } |
| ContentSettingsManagerAsyncWaiter::ContentSettingsManagerAsyncWaiter( |
| ContentSettingsManager* proxy) : proxy_(proxy) {} |
| |
| ContentSettingsManagerAsyncWaiter::~ContentSettingsManagerAsyncWaiter() = default; |
| |
| void ContentSettingsManagerAsyncWaiter::AllowStorageAccess( |
| int32_t render_frame_id, ContentSettingsManager::StorageType storage_type, const ::url::Origin& origin, const ::net::SiteForCookies& site_for_cookies, const ::url::Origin& top_frame_origin, bool* out_allowed) { |
| base::RunLoop loop; |
| proxy_->AllowStorageAccess(std::move(render_frame_id),std::move(storage_type),std::move(origin),std::move(site_for_cookies),std::move(top_frame_origin), |
| base::BindOnce( |
| [](base::RunLoop* loop, |
| bool* out_allowed |
| , |
| bool allowed) {*out_allowed = std::move(allowed); |
| loop->Quit(); |
| }, |
| &loop, |
| out_allowed)); |
| loop.Run(); |
| } |
| |
| |
| |
| |
| |
| } // namespace mojom |
| } // namespace content_settings |
| |
| |
| #if defined(__clang__) |
| #pragma clang diagnostic pop |
| #endif |