#include "components/permissions/permission_request_manager.h"
#include <memory>
#include "base/command_line.h"
#include "base/functional/bind.h"
#include "base/metrics/field_trial.h"
#include "base/metrics/field_trial_params.h"
#include "base/run_loop.h"
#include "base/test/mock_callback.h"
#include "base/test/scoped_feature_list.h"
#include "build/build_config.h"
#include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h"
#include "chrome/browser/download/download_permission_request.h"
#include "chrome/browser/media/webrtc/media_capture_devices_dispatcher.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/tabs/tab_enums.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/tabs/tab_strip_model_delegate.h"
#include "chrome/browser/ui/test/test_browser_dialog.h"
#include "chrome/common/chrome_features.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "chrome/test/permissions/permission_request_manager_test_api.h"
#include "components/back_forward_cache/back_forward_cache_disable.h"
#include "components/content_settings/core/common/content_settings_types.h"
#include "components/custom_handlers/register_protocol_handler_permission_request.h"
#include "components/permissions/features.h"
#include "components/permissions/permission_context_base.h"
#include "components/permissions/permission_request.h"
#include "components/permissions/permission_ui_selector.h"
#include "components/permissions/permission_util.h"
#include "components/permissions/request_type.h"
#include "components/permissions/test/mock_permission_prompt_factory.h"
#include "components/permissions/test/mock_permission_request.h"
#include "components/permissions/test/permission_request_observer.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 "content/public/common/content_features.h"
#include "content/public/test/back_forward_cache_util.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/fenced_frame_test_util.h"
#include "content/public/test/prerender_test_util.h"
#include "content/public/test/test_navigation_observer.h"
#include "content/public/test/test_utils.h"
#include "net/dns/mock_host_resolver.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "services/device/public/cpp/test/scoped_geolocation_overrider.h"
#include "third_party/blink/public/common/permissions/permission_utils.h"
#include "third_party/blink/public/mojom/permissions/permission_status.mojom-shared.h"
#include "url/gurl.h"
#include "url/origin.h"
namespace {
const char* kPermissionsKillSwitchFieldStudy = …;
const char* kPermissionsKillSwitchBlockedValue = …;
const char kPermissionsKillSwitchTestGroup[] = …;
class TestQuietNotificationPermissionUiSelector
: public permissions::PermissionUiSelector { … };
class PermissionRequestManagerBrowserTest : public InProcessBrowserTest { … };
class PermissionRequestManagerWithBackForwardCacheBrowserTest
: public PermissionRequestManagerBrowserTest { … };
class PermissionRequestManagerWithPrerenderingTest
: public PermissionRequestManagerBrowserTest { … };
class PermissionRequestManagerWithBackForwardCacheUnblockBrowserTest
: public PermissionRequestManagerWithBackForwardCacheBrowserTest { … };
IN_PROC_BROWSER_TEST_F(PermissionRequestManagerBrowserTest,
DISABLED_RequestsBeforeLoad) { … }
IN_PROC_BROWSER_TEST_F(PermissionRequestManagerBrowserTest,
RequestsBeforeAfterLoad) { … }
IN_PROC_BROWSER_TEST_F(PermissionRequestManagerBrowserTest, DISABLED_NavTwice) { … }
IN_PROC_BROWSER_TEST_F(PermissionRequestManagerBrowserTest,
DISABLED_NavTwiceWithHash) { … }
IN_PROC_BROWSER_TEST_F(PermissionRequestManagerBrowserTest,
SameDocumentNavigation) { … }
IN_PROC_BROWSER_TEST_F(PermissionRequestManagerBrowserTest,
SameOriginCrossDocumentNavigation) { … }
IN_PROC_BROWSER_TEST_F(PermissionRequestManagerBrowserTest, MultipleTabs) { … }
IN_PROC_BROWSER_TEST_F(PermissionRequestManagerBrowserTest,
BackgroundTabNavigation) { … }
IN_PROC_BROWSER_TEST_F(PermissionRequestManagerBrowserTest,
KillSwitchGeolocation) { … }
IN_PROC_BROWSER_TEST_F(PermissionRequestManagerBrowserTest,
CrossOriginPromptCooldown) { … }
IN_PROC_BROWSER_TEST_F(PermissionRequestManagerBrowserTest,
CooldownEndsOnUserInitiatedReload) { … }
IN_PROC_BROWSER_TEST_F(PermissionRequestManagerBrowserTest,
CooldownEndsOnBrowserInitiateNavigation) { … }
IN_PROC_BROWSER_TEST_F(PermissionRequestManagerBrowserTest,
CooldownEndsOnRendererInitiateNavigationWithGesture) { … }
IN_PROC_BROWSER_TEST_F(PermissionRequestManagerBrowserTest,
CooldownOutlastsRendererInitiatedReload) { … }
IN_PROC_BROWSER_TEST_F(
PermissionRequestManagerBrowserTest,
CooldownOutlastsRendererInitiateNavigationWithoutGesture) { … }
IN_PROC_BROWSER_TEST_F(PermissionRequestManagerBrowserTest,
KillSwitchNotifications) { … }
IN_PROC_BROWSER_TEST_F(PermissionRequestManagerBrowserTest,
PendingRequestsDisableBackForwardCache) { … }
class PermissionRequestManagerQuietUiBrowserTest
: public PermissionRequestManagerBrowserTest { … };
IN_PROC_BROWSER_TEST_F(PermissionRequestManagerQuietUiBrowserTest,
DISABLED_QuietPendingRequestsKilledOnNewRequest) { … }
IN_PROC_BROWSER_TEST_F(PermissionRequestManagerQuietUiBrowserTest,
PermissionPromptDisposition) { … }
IN_PROC_BROWSER_TEST_F(PermissionRequestManagerQuietUiBrowserTest,
PermissionPromptDispositionHidden) { … }
IN_PROC_BROWSER_TEST_F(PermissionRequestManagerQuietUiBrowserTest,
ConsoleMessages) { … }
IN_PROC_BROWSER_TEST_F(PermissionRequestManagerBrowserTest,
LoudPendingRequestsQueued) { … }
IN_PROC_BROWSER_TEST_F(PermissionRequestManagerWithBackForwardCacheBrowserTest,
NoPermissionBubbleShownForPagesInCache) { … }
IN_PROC_BROWSER_TEST_F(PermissionRequestManagerWithBackForwardCacheBrowserTest,
RequestsForPagesInCacheNotGrouped) { … }
class PermissionRequestManagerOneTimePermissionBrowserTest
: public PermissionRequestManagerBrowserTest { … };
IN_PROC_BROWSER_TEST_F(PermissionRequestManagerOneTimePermissionBrowserTest,
RequestForPermission) { … }
IN_PROC_BROWSER_TEST_F(PermissionRequestManagerWithPrerenderingTest,
RequestForPermission) { … }
IN_PROC_BROWSER_TEST_F(PermissionRequestManagerWithPrerenderingTest,
DuplicateRequestForPermission) { … }
IN_PROC_BROWSER_TEST_F(PermissionRequestManagerWithPrerenderingTest,
PrerenderLoadsWhileRequestsPending) { … }
class PermissionRequestManagerWithFencedFrameTest
: public PermissionRequestManagerBrowserTest { … };
IN_PROC_BROWSER_TEST_F(PermissionRequestManagerWithFencedFrameTest,
GetCurrentPosition) { … }
IN_PROC_BROWSER_TEST_F(PermissionRequestManagerWithFencedFrameTest,
RequestPermissionThruDelegate) { … }
IN_PROC_BROWSER_TEST_F(
PermissionRequestManagerWithBackForwardCacheUnblockBrowserTest,
PendingRequestsDoNotDisableBackForwardCache) { … }
IN_PROC_BROWSER_TEST_F(
PermissionRequestManagerWithBackForwardCacheUnblockBrowserTest,
PermissionRequestsCancelledInBackForwardCache) { … }
}