#include "components/content_settings/renderer/content_settings_agent_impl.h"
#include <utility>
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/metrics/histogram_macros.h"
#include "base/strings/string_number_conversions.h"
#include "components/content_settings/core/common/content_settings.h"
#include "components/content_settings/core/common/content_settings.mojom.h"
#include "components/content_settings/core/common/content_settings_pattern.h"
#include "components/content_settings/core/common/content_settings_utils.h"
#include "content/public/child/child_thread.h"
#include "content/public/common/content_features.h"
#include "content/public/common/origin_util.h"
#include "content/public/common/url_constants.h"
#include "content/public/renderer/render_frame.h"
#include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h"
#include "third_party/blink/public/common/associated_interfaces/associated_interface_registry.h"
#include "third_party/blink/public/platform/browser_interface_broker_proxy.h"
#include "third_party/blink/public/platform/url_conversion.h"
#include "third_party/blink/public/platform/web_security_origin.h"
#include "third_party/blink/public/platform/web_url.h"
#include "third_party/blink/public/web/web_document.h"
#include "third_party/blink/public/web/web_local_frame.h"
#include "third_party/blink/public/web/web_local_frame_client.h"
#include "third_party/blink/public/web/web_view.h"
#include "url/gurl.h"
#include "url/origin.h"
#include "url/url_constants.h"
WebDocument;
WebFrame;
WebLocalFrame;
WebSecurityOrigin;
WebString;
WebURL;
WebView;
namespace content_settings {
namespace {
bool IsFrameWithOpaqueOrigin(WebFrame* frame) { … }
}
ContentSettingsAgentImpl::Delegate::~Delegate() = default;
bool ContentSettingsAgentImpl::Delegate::IsFrameAllowlistedForStorageAccess(
blink::WebFrame* frame) const { … }
bool ContentSettingsAgentImpl::Delegate::IsSchemeAllowlisted(
const std::string& scheme) { … }
bool ContentSettingsAgentImpl::Delegate::AllowReadFromClipboard() { … }
bool ContentSettingsAgentImpl::Delegate::AllowWriteToClipboard() { … }
std::optional<bool> ContentSettingsAgentImpl::Delegate::AllowMutationEvents() { … }
ContentSettingsAgentImpl::ContentSettingsAgentImpl(
content::RenderFrame* render_frame,
std::unique_ptr<Delegate> delegate)
: … { … }
ContentSettingsAgentImpl::~ContentSettingsAgentImpl() = default;
mojom::ContentSettingsManager&
ContentSettingsAgentImpl::GetContentSettingsManager() { … }
void ContentSettingsAgentImpl::DidBlockContentType(
ContentSettingsType settings_type) { … }
namespace {
template <typename URL>
ContentSetting GetContentSettingFromRules(
const ContentSettingsForOneType& rules,
const URL& secondary_url) { … }
}
void ContentSettingsAgentImpl::BindContentSettingsManager(
mojo::Remote<mojom::ContentSettingsManager>* manager) { … }
void ContentSettingsAgentImpl::DidCommitProvisionalLoad(
ui::PageTransition transition) { … }
void ContentSettingsAgentImpl::OnDestruct() { … }
void ContentSettingsAgentImpl::SetAllowRunningInsecureContent() { … }
void ContentSettingsAgentImpl::SendRendererContentSettingRules(
const RendererContentSettingRules& renderer_settings) { … }
void ContentSettingsAgentImpl::OnContentSettingsAgentRequest(
mojo::PendingAssociatedReceiver<mojom::ContentSettingsAgent> receiver) { … }
mojom::ContentSettingsManager::StorageType
ContentSettingsAgentImpl::ConvertToMojoStorageType(StorageType storage_type) { … }
void ContentSettingsAgentImpl::AllowStorageAccess(
StorageType storage_type,
base::OnceCallback<void(bool)> callback) { … }
bool ContentSettingsAgentImpl::AllowStorageAccessSync(
StorageType storage_type) { … }
bool ContentSettingsAgentImpl::AllowReadFromClipboard() { … }
bool ContentSettingsAgentImpl::AllowWriteToClipboard() { … }
bool ContentSettingsAgentImpl::AllowMutationEvents(bool default_value) { … }
bool ContentSettingsAgentImpl::AllowRunningInsecureContent(
bool allowed_per_settings,
const blink::WebURL& resource_url) { … }
bool ContentSettingsAgentImpl::ShouldAutoupgradeMixedContent() { … }
RendererContentSettingRules*
ContentSettingsAgentImpl::GetRendererContentSettingRules() { … }
void ContentSettingsAgentImpl::SetRendererContentSettingRulesForTest(
const RendererContentSettingRules& rules) { … }
void ContentSettingsAgentImpl::DidNotAllowScript() { … }
void ContentSettingsAgentImpl::DidNotAllowImage() { … }
void ContentSettingsAgentImpl::ClearBlockedContentSettings() { … }
}