#include "chrome/browser/guest_view/web_view/chrome_web_view_permission_helper_delegate.h"
#include <map>
#include <utility>
#include "base/check_deref.h"
#include "base/functional/bind.h"
#include "base/metrics/user_metrics.h"
#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
#include "chrome/browser/media/webrtc/media_capture_devices_dispatcher.h"
#include "chrome/common/buildflags.h"
#include "components/content_settings/core/browser/host_content_settings_map.h"
#include "components/content_settings/core/common/content_settings_types.h"
#include "components/guest_view/browser/guest_view_base.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/permission_controller.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h"
#include "extensions/browser/guest_view/web_view/web_view_constants.h"
#include "extensions/browser/guest_view/web_view/web_view_guest.h"
#include "ppapi/buildflags/buildflags.h"
#include "third_party/blink/public/common/permissions/permission_utils.h"
#include "third_party/blink/public/common/permissions_policy/permissions_policy.h"
#include "third_party/blink/public/common/permissions_policy/permissions_policy_features.h"
#include "third_party/blink/public/mojom/permissions_policy/permissions_policy_feature.mojom-shared.h"
#include "url/origin.h"
#if BUILDFLAG(ENABLE_PLUGINS)
#include "chrome/browser/plugins/chrome_plugin_service_filter.h"
#endif
namespace extensions {
namespace {
void CallbackWrapper(base::OnceCallback<void(bool)> callback,
blink::mojom::PermissionStatus status) { … }
bool IsFeatureEnabledByEmbedderPermissionsPolicy(
WebViewGuest* web_view_guest,
blink::mojom::PermissionsPolicyFeature feature,
const url::Origin& requesting_origin) { … }
bool IsContentSettingAllowedInEmbedder(
WebViewGuest* web_view_guest,
ContentSettingsType content_settings_type) { … }
}
#if BUILDFLAG(ENABLE_PLUGINS)
void ChromeWebViewPermissionHelperDelegate::BindPluginAuthHost(
mojo::PendingAssociatedReceiver<chrome::mojom::PluginAuthHost> receiver,
content::RenderFrameHost* rfh) { … }
#endif
ChromeWebViewPermissionHelperDelegate::ChromeWebViewPermissionHelperDelegate(
WebViewPermissionHelper* web_view_permission_helper)
: … { … }
ChromeWebViewPermissionHelperDelegate::~ChromeWebViewPermissionHelperDelegate()
{ … }
#if BUILDFLAG(ENABLE_PLUGINS)
void ChromeWebViewPermissionHelperDelegate::BlockedUnauthorizedPlugin(
const std::u16string& name,
const std::string& identifier) { … }
void ChromeWebViewPermissionHelperDelegate::OnPermissionResponse(
const std::string& identifier,
bool allow,
const std::string& input) { … }
#endif
void ChromeWebViewPermissionHelperDelegate::
RequestMediaAccessPermissionForControlledFrame(
content::WebContents* source,
const content::MediaStreamRequest& request,
content::MediaResponseCallback callback) { … }
void ChromeWebViewPermissionHelperDelegate::
OnMediaPermissionResponseForControlledFrame(
content::WebContents* web_contents,
const content::MediaStreamRequest& request,
content::MediaResponseCallback callback,
bool allow,
const std::string& user_input) { … }
bool ChromeWebViewPermissionHelperDelegate::
CheckMediaAccessPermissionForControlledFrame(
content::RenderFrameHost* render_frame_host,
const url::Origin& security_origin,
blink::mojom::MediaStreamType type) { … }
void ChromeWebViewPermissionHelperDelegate::CanDownload(
const GURL& url,
const std::string& request_method,
base::OnceCallback<void(bool)> callback) { … }
void ChromeWebViewPermissionHelperDelegate::OnDownloadPermissionResponse(
base::OnceCallback<void(bool)> callback,
bool allow,
const std::string& user_input) { … }
void ChromeWebViewPermissionHelperDelegate::RequestPointerLockPermission(
bool user_gesture,
bool last_unlocked_by_target,
base::OnceCallback<void(bool)> callback) { … }
void ChromeWebViewPermissionHelperDelegate::OnPointerLockPermissionResponse(
base::OnceCallback<void(bool)> callback,
bool allow,
const std::string& user_input) { … }
void ChromeWebViewPermissionHelperDelegate::RequestGeolocationPermission(
const GURL& requesting_frame,
bool user_gesture,
base::OnceCallback<void(bool)> callback) { … }
void ChromeWebViewPermissionHelperDelegate::OnGeolocationPermissionResponse(
bool user_gesture,
base::OnceCallback<void(blink::mojom::PermissionStatus)> callback,
bool allow,
const std::string& user_input) { … }
void ChromeWebViewPermissionHelperDelegate::RequestHidPermission(
const GURL& requesting_frame_url,
base::OnceCallback<void(bool)> callback) { … }
void ChromeWebViewPermissionHelperDelegate::OnHidPermissionResponse(
base::OnceCallback<void(bool)> callback,
bool allow,
const std::string& user_input) { … }
void ChromeWebViewPermissionHelperDelegate::RequestFileSystemPermission(
const GURL& url,
bool allowed_by_default,
base::OnceCallback<void(bool)> callback) { … }
void ChromeWebViewPermissionHelperDelegate::OnFileSystemPermissionResponse(
base::OnceCallback<void(bool)> callback,
bool allow,
const std::string& user_input) { … }
}