#include "content/web_test/browser/web_test_permission_manager.h"
#include <functional>
#include <list>
#include <memory>
#include <utility>
#include "base/barrier_callback.h"
#include "base/containers/contains.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/functional/callback_helpers.h"
#include "base/hash/hash.h"
#include "components/content_settings/core/common/content_settings.h"
#include "components/content_settings/core/common/content_settings_pattern.h"
#include "components/content_settings/core/common/content_settings_types.h"
#include "components/content_settings/core/common/content_settings_utils.h"
#include "content/browser/permissions/permission_util.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/permission_controller.h"
#include "content/public/browser/permission_result.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/storage_partition.h"
#include "content/public/browser/web_contents.h"
#include "content/web_test/browser/web_test_content_browser_client.h"
#include "net/base/schemeful_site.h"
#include "services/network/public/mojom/cookie_manager.mojom.h"
#include "third_party/blink/public/common/permissions/permission_utils.h"
#include "third_party/blink/public/common/web_preferences/web_preferences.h"
namespace content {
namespace {
std::vector<ContentSettingPatternSource> GetContentSettings(
const ContentSettingsPattern& permission_pattern,
const ContentSettingsPattern& embedding_pattern,
blink::mojom::PermissionStatus status) { … }
bool ShouldHideDeniedState(blink::PermissionType permission_type) { … }
}
WebTestPermissionManager::PermissionDescription::PermissionDescription(
blink::PermissionType type,
const GURL& origin,
const GURL& embedding_origin)
: … { … }
bool WebTestPermissionManager::PermissionDescription::operator==(
const PermissionDescription& other) const { … }
bool WebTestPermissionManager::PermissionDescription::operator!=(
const PermissionDescription& other) const { … }
bool WebTestPermissionManager::PermissionDescription::operator==(
PermissionStatusSubscription* other) const { … }
bool WebTestPermissionManager::PermissionDescription::operator!=(
PermissionStatusSubscription* other) const { … }
size_t WebTestPermissionManager::PermissionDescription::Hash::operator()(
const PermissionDescription& description) const { … }
WebTestPermissionManager::WebTestPermissionManager(
BrowserContext& browser_context)
: … { … }
WebTestPermissionManager::~WebTestPermissionManager() = default;
void WebTestPermissionManager::RequestPermissions(
content::RenderFrameHost* render_frame_host,
const content::PermissionRequestDescription& request_description,
base::OnceCallback<void(const std::vector<blink::mojom::PermissionStatus>&)>
callback) { … }
void WebTestPermissionManager::ResetPermission(blink::PermissionType permission,
const GURL& requesting_origin,
const GURL& embedding_origin) { … }
void WebTestPermissionManager::RequestPermissionsFromCurrentDocument(
content::RenderFrameHost* render_frame_host,
const content::PermissionRequestDescription& request_description,
base::OnceCallback<void(const std::vector<blink::mojom::PermissionStatus>&)>
callback) { … }
blink::mojom::PermissionStatus
WebTestPermissionManager::GetPermissionStatusForRequestPermission(
blink::PermissionType permission,
const GURL& requesting_origin,
const GURL& embedding_origin) { … }
blink::mojom::PermissionStatus WebTestPermissionManager::GetPermissionStatus(
blink::PermissionType permission,
const GURL& requesting_origin,
const GURL& embedding_origin) { … }
PermissionResult
WebTestPermissionManager::GetPermissionResultForOriginWithoutContext(
blink::PermissionType permission,
const url::Origin& requesting_origin,
const url::Origin& embedding_origin) { … }
blink::mojom::PermissionStatus
WebTestPermissionManager::GetPermissionStatusForCurrentDocument(
blink::PermissionType permission,
RenderFrameHost* render_frame_host,
bool should_include_device_status) { … }
blink::mojom::PermissionStatus
WebTestPermissionManager::GetPermissionStatusForWorker(
blink::PermissionType permission,
RenderProcessHost* render_process_host,
const GURL& worker_origin) { … }
blink::mojom::PermissionStatus
WebTestPermissionManager::GetPermissionStatusForEmbeddedRequester(
blink::PermissionType permission,
content::RenderFrameHost* render_frame_host,
const url::Origin& overridden_origin) { … }
void WebTestPermissionManager::OnPermissionStatusChangeSubscriptionAdded(
content::PermissionController::SubscriptionId subscription_id) { … }
void WebTestPermissionManager::UnsubscribeFromPermissionStatusChange(
content::PermissionController::SubscriptionId subscription_id) { … }
void WebTestPermissionManager::SetPermission(
blink::PermissionType permission,
blink::mojom::PermissionStatus status,
const GURL& url,
const GURL& embedding_url,
blink::test::mojom::PermissionAutomation::SetPermissionCallback callback) { … }
void WebTestPermissionManager::SetPermission(
blink::mojom::PermissionDescriptorPtr descriptor,
blink::mojom::PermissionStatus status,
const GURL& url,
const GURL& embedding_url,
blink::test::mojom::PermissionAutomation::SetPermissionCallback callback) { … }
void WebTestPermissionManager::ResetPermissions() { … }
void WebTestPermissionManager::Bind(
mojo::PendingReceiver<blink::test::mojom::PermissionAutomation> receiver) { … }
void WebTestPermissionManager::OnPermissionChanged(
const PermissionDescription& permission,
blink::mojom::PermissionStatus status,
blink::test::mojom::PermissionAutomation::SetPermissionCallback
permission_callback) { … }
}