#include "base/run_loop.h"
#include "base/test/bind.h"
#include "base/test/simple_test_clock.h"
#include "base/time/default_clock.h"
#include "base/time/time.h"
#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
#include "chrome/browser/content_settings/one_time_permission_provider.h"
#include "chrome/browser/media/webrtc/media_capture_devices_dispatcher.h"
#include "chrome/browser/media/webrtc/media_stream_capture_indicator.h"
#include "chrome/browser/media/webrtc/webrtc_browsertest_base.h"
#include "chrome/browser/permissions/one_time_permissions_tracker.h"
#include "chrome/browser/permissions/one_time_permissions_tracker_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/resource_coordinator/tab_lifecycle_unit_external.h"
#include "chrome/browser/resource_coordinator/tab_lifecycle_unit_source.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/tabs/tab_strip_model_delegate.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/interactive_test_utils.h"
#include "chrome/test/base/test_switches.h"
#include "chrome/test/base/ui_test_utils.h"
#include "components/content_settings/core/browser/content_settings_uma_util.h"
#include "components/content_settings/core/browser/host_content_settings_map.h"
#include "components/content_settings/core/common/content_settings.h"
#include "components/content_settings/core/common/content_settings_types.h"
#include "components/content_settings/core/common/features.h"
#include "components/performance_manager/public/performance_manager.h"
#include "components/permissions/features.h"
#include "components/permissions/permission_context_base.h"
#include "components/permissions/permission_decision_auto_blocker.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 "components/permissions/test/permission_request_observer.h"
#include "components/strings/grit/components_strings.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/content_switches.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/permissions_test_utils.h"
#include "media/base/media_switches.h"
#include "net/dns/mock_host_resolver.h"
#include "services/device/public/cpp/test/scoped_geolocation_overrider.h"
namespace {
std::string RunScript(content::RenderFrameHost* render_frame_host,
const std::string& script) { … }
class IndicatorObserver : public MediaStreamCaptureIndicator::Observer { … };
}
class OneTimePermissionInteractiveUiTest : public WebRtcTestBase { … };
IN_PROC_BROWSER_TEST_F(OneTimePermissionInteractiveUiTest,
OneTimeGrantResetsEmbargoCounter) { … }
IN_PROC_BROWSER_TEST_F(OneTimePermissionInteractiveUiTest,
SameTabForegroundBehaviour) { … }
IN_PROC_BROWSER_TEST_F(OneTimePermissionInteractiveUiTest,
VerifyDifferentTabBehaviour) { … }
IN_PROC_BROWSER_TEST_F(OneTimePermissionInteractiveUiTest,
VerifyPermissionPromptAfterClosingAllTabsToOrigin) { … }
IN_PROC_BROWSER_TEST_F(OneTimePermissionInteractiveUiTest,
DiscardingTabToOriginRevokesPermission) { … }
IN_PROC_BROWSER_TEST_F(
OneTimePermissionInteractiveUiTest,
DiscardingTabToOriginDoesNotRevokePermissionIfDifferentTabToOriginIsUsingIt) { … }
IN_PROC_BROWSER_TEST_F(OneTimePermissionInteractiveUiTest,
GeolocationIsRevokedAfterFiveMinutesInBackground) { … }
IN_PROC_BROWSER_TEST_F(OneTimePermissionInteractiveUiTest,
CamMicNotRevokedWhenPausedInForeground) { … }
IN_PROC_BROWSER_TEST_F(OneTimePermissionInteractiveUiTest,
CamMicRevokedWhenPausedInBackground) { … }
IN_PROC_BROWSER_TEST_F(OneTimePermissionInteractiveUiTest,
CamMicDoesNotExpireWhenNotPausedInBackground) { … }
IN_PROC_BROWSER_TEST_F(OneTimePermissionInteractiveUiTest,
CamMicDoesNotExpireWhenPausedInForeground) { … }
class OneTimePermissionExpiryEnforcementUmaInteractiveUiTest
: public OneTimePermissionInteractiveUiTest,
public ::testing::WithParamInterface<bool> { … };
INSTANTIATE_TEST_SUITE_P(…);
IN_PROC_BROWSER_TEST_P(OneTimePermissionExpiryEnforcementUmaInteractiveUiTest,
TestExpiryEnforcement) { … }