#include "components/permissions/permission_manager.h"
#include <memory>
#include <utility>
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/memory/raw_ptr.h"
#include "base/ranges/algorithm.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "components/content_settings/core/browser/host_content_settings_map.h"
#include "components/content_settings/core/common/content_settings_pattern.h"
#include "components/permissions/features.h"
#include "components/permissions/permission_context_base.h"
#include "components/permissions/permission_request_id.h"
#include "components/permissions/permission_request_manager.h"
#include "components/permissions/permission_uma_util.h"
#include "components/permissions/permission_util.h"
#include "components/permissions/permissions_client.h"
#include "components/permissions/request_type.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.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/web_contents.h"
#include "third_party/blink/public/common/permissions/permission_utils.h"
#include "third_party/blink/public/mojom/permissions/permission_status.mojom.h"
#include "url/origin.h"
PermissionType;
namespace permissions {
namespace {
void PermissionStatusVectorCallbackWrapper(
base::OnceCallback<void(const std::vector<PermissionStatus>&)> callback,
const std::vector<ContentSetting>& content_settings) { … }
GURL GetEmbeddingOrigin(content::RenderFrameHost* const render_frame_host,
const GURL& requesting_origin) { … }
}
class PermissionManager::PendingRequest { … };
class PermissionManager::PermissionResponseCallback { … };
PermissionManager::PermissionManager(content::BrowserContext* browser_context,
PermissionContextMap permission_contexts)
: … { … }
PermissionManager::~PermissionManager() { … }
void PermissionManager::Shutdown() { … }
void PermissionManager::OnEmbargoStarted(const GURL& origin,
ContentSettingsType content_setting) { … }
PermissionContextBase* PermissionManager::GetPermissionContextForTesting(
ContentSettingsType type) { … }
PermissionContextBase* PermissionManager::GetPermissionContext(
ContentSettingsType type) { … }
void PermissionManager::RequestPermissions(
content::RenderFrameHost* render_frame_host,
const content::PermissionRequestDescription& request_description,
base::OnceCallback<void(const std::vector<PermissionStatus>&)>
permission_status_callback) { … }
void PermissionManager::RequestPermissionsInternal(
content::RenderFrameHost* render_frame_host,
const content::PermissionRequestDescription& request_description,
base::OnceCallback<void(const std::vector<PermissionStatus>&)>
permission_status_callback) { … }
void PermissionManager::ResetPermission(PermissionType permission,
const GURL& requesting_origin,
const GURL& embedding_origin) { … }
void PermissionManager::RequestPermissionsFromCurrentDocument(
content::RenderFrameHost* render_frame_host,
const content::PermissionRequestDescription& request_description,
base::OnceCallback<void(const std::vector<PermissionStatus>&)>
permission_status_callback) { … }
PermissionStatus PermissionManager::GetPermissionStatus(
PermissionType permission,
const GURL& requesting_origin,
const GURL& embedding_origin) { … }
content::PermissionResult
PermissionManager::GetPermissionResultForOriginWithoutContext(
blink::PermissionType permission,
const url::Origin& requesting_origin,
const url::Origin& embedding_origin) { … }
PermissionStatus PermissionManager::GetPermissionStatusForCurrentDocument(
PermissionType permission,
content::RenderFrameHost* render_frame_host,
bool should_include_device_status) { … }
content::PermissionResult
PermissionManager::GetPermissionResultForCurrentDocument(
blink::PermissionType permission,
content::RenderFrameHost* render_frame_host,
bool should_include_device_status) { … }
PermissionStatus PermissionManager::GetPermissionStatusForWorker(
PermissionType permission,
content::RenderProcessHost* render_process_host,
const GURL& worker_origin) { … }
PermissionStatus PermissionManager::GetPermissionStatusForEmbeddedRequester(
blink::PermissionType permission,
content::RenderFrameHost* render_frame_host,
const url::Origin& requesting_origin) { … }
bool PermissionManager::IsPermissionOverridable(
PermissionType permission,
const std::optional<url::Origin>& origin) { … }
void PermissionManager::OnPermissionStatusChangeSubscriptionAdded(
content::PermissionController::SubscriptionId subscription_id) { … }
void PermissionManager::UnsubscribeFromPermissionStatusChange(
content::PermissionController::SubscriptionId subscription_id) { … }
std::optional<gfx::Rect> PermissionManager::GetExclusionAreaBoundsInScreen(
content::WebContents* web_contents) const { … }
void PermissionManager::OnPermissionsRequestResponseStatus(
PendingRequestLocalId request_local_id,
int permission_id,
ContentSetting content_setting) { … }
void PermissionManager::OnPermissionChanged(
const ContentSettingsPattern& primary_pattern,
const ContentSettingsPattern& secondary_pattern,
ContentSettingsTypeSet content_type_set) { … }
content::PermissionResult PermissionManager::GetPermissionStatusInternal(
ContentSettingsType permission,
content::RenderProcessHost* render_process_host,
content::RenderFrameHost* render_frame_host,
const GURL& requesting_origin,
const GURL& embedding_origin,
bool should_include_device_status) { … }
}