#include "base/ranges/algorithm.h"
#include "base/run_loop.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/time/time.h"
#include "chrome/browser/permissions/quiet_notification_permission_ui_config.h"
#include "chrome/browser/permissions/quiet_notification_permission_ui_state.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.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/test/test_browser_dialog.h"
#include "chrome/browser/ui/views/content_setting_bubble_contents.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/browser/ui/views/page_info/page_info_bubble_view.h"
#include "chrome/browser/ui/views/page_info/page_info_view_factory.h"
#include "chrome/browser/ui/views/permissions/chip/chip_controller.h"
#include "chrome/browser/ui/views/permissions/chip/permission_chip_theme.h"
#include "chrome/browser/ui/views/permissions/permission_prompt_chip.h"
#include "chrome/browser/ui/views/toolbar/toolbar_view.h"
#include "chrome/common/chrome_features.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/interactive_test_utils.h"
#include "chrome/test/base/ui_test_utils.h"
#include "chrome/test/permissions/permission_request_manager_test_api.h"
#include "components/metrics/content/subprocess_metrics_provider.h"
#include "components/permissions/features.h"
#include "components/permissions/origin_keyed_permission_action_service.h"
#include "components/permissions/permission_ui_selector.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/mock_permission_prompt_factory.h"
#include "components/permissions/test/mock_permission_request.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/test/accessibility_notification_waiter.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 "content/public/test/test_navigation_observer.h"
#include "net/dns/mock_host_resolver.h"
#include "ui/accessibility/ax_action_data.h"
#include "ui/events/base_event_utils.h"
#include "ui/events/test/test_event.h"
#include "ui/views/bubble/bubble_dialog_delegate_view.h"
#include "ui/views/controls/button/button.h"
#include "ui/views/controls/button/toggle_button.h"
#include "ui/views/test/ax_event_counter.h"
#include "ui/views/test/button_test_api.h"
#include "ui/views/test/views_test_utils.h"
namespace {
constexpr char kAddNotificationsEventListener[] = …;
constexpr char kCheckNotifications[] = …;
constexpr char kRequestNotifications[] = …;
class TestQuietNotificationPermissionUiSelector
: public permissions::PermissionUiSelector { … };
class ChipExpansionObserver : PermissionChipView::Observer { … };
}
class PermissionChipInteractiveUITest : public InProcessBrowserTest { … };
class LocationBarIconOverrideTest : public PermissionChipInteractiveUITest { … };
IN_PROC_BROWSER_TEST_F(LocationBarIconOverrideTest,
OverrideLocationBarIconDuringChipOnlyForOverrideFlags) { … }
class ConfirmationChipEnabledInteractiveTest
: public PermissionChipInteractiveUITest { … };
IN_PROC_BROWSER_TEST_F(ConfirmationChipEnabledInteractiveTest,
ShouldDisplayAllowAndDenyConfirmationCorrectly) { … }
IN_PROC_BROWSER_TEST_F(ConfirmationChipEnabledInteractiveTest,
IncomingRequestShouldOverrideConfirmation) { … }
IN_PROC_BROWSER_TEST_F(ConfirmationChipEnabledInteractiveTest,
ClickOnConfirmationChipShouldOpenPageInfoDialog) { … }
class ConfirmationChipUmaInteractiveTest
: public PermissionChipInteractiveUITest { … };
IN_PROC_BROWSER_TEST_F(ConfirmationChipUmaInteractiveTest, VerifyUmaMetrics) { … }
class PageInfoChangedWithin1mUmaTest : public PermissionChipInteractiveUITest { … };
IN_PROC_BROWSER_TEST_F(PageInfoChangedWithin1mUmaTest,
VerifyResetFromAllowedUmaMetric) { … }
IN_PROC_BROWSER_TEST_F(PageInfoChangedWithin1mUmaTest,
VerifyResetFromDeniedUmaMetric) { … }
IN_PROC_BROWSER_TEST_F(PageInfoChangedWithin1mUmaTest, VerifyRevokedUmaMetric) { … }
IN_PROC_BROWSER_TEST_F(PageInfoChangedWithin1mUmaTest, VerifyReallowUmaMetric) { … }
IN_PROC_BROWSER_TEST_F(PageInfoChangedWithin1mUmaTest,
VerifyNoReallowFromDenyRecordedAfter2mUmaMetric) { … }
class ChipGestureSensitiveEnabledInteractiveTest
: public PermissionChipInteractiveUITest { … };
IN_PROC_BROWSER_TEST_F(ChipGestureSensitiveEnabledInteractiveTest,
ChipAutoPopupBubbleEnabled) { … }
class QuietChipAutoPopupBubbleInteractiveTest
: public PermissionChipInteractiveUITest { … };
IN_PROC_BROWSER_TEST_F(QuietChipAutoPopupBubbleInteractiveTest,
IgnoreChipHistogramsTest) { … }
IN_PROC_BROWSER_TEST_F(QuietChipAutoPopupBubbleInteractiveTest,
GrantedChipHistogramsTest) { … }
IN_PROC_BROWSER_TEST_F(QuietChipAutoPopupBubbleInteractiveTest,
DeniedChipHistogramsTest) { … }
IN_PROC_BROWSER_TEST_F(QuietChipAutoPopupBubbleInteractiveTest,
DismissedChipHistogramsTest) { … }
IN_PROC_BROWSER_TEST_F(QuietChipAutoPopupBubbleInteractiveTest,
QuietChipNonAbusiveUmaTest) { … }
IN_PROC_BROWSER_TEST_F(QuietChipAutoPopupBubbleInteractiveTest,
QuietChipNonAbusiveClickManageUmaTest) { … }
IN_PROC_BROWSER_TEST_F(QuietChipAutoPopupBubbleInteractiveTest,
PermissionIgnoredQuietChipAbusiveUmaTest) { … }
IN_PROC_BROWSER_TEST_F(QuietChipAutoPopupBubbleInteractiveTest,
PermissionGrantedQuietChipAbusiveUmaTest) { … }
IN_PROC_BROWSER_TEST_F(QuietChipAutoPopupBubbleInteractiveTest,
PermissionGrantedOnceQuietChipAbusiveUmaTest) { … }
IN_PROC_BROWSER_TEST_F(QuietChipAutoPopupBubbleInteractiveTest,
PermissionDeniedOnceQuietChipAbusiveUmaTest) { … }
IN_PROC_BROWSER_TEST_F(QuietChipAutoPopupBubbleInteractiveTest,
PermissionDismissedOnceQuietChipAbusiveUmaTest) { … }
IN_PROC_BROWSER_TEST_F(QuietChipAutoPopupBubbleInteractiveTest,
QuietChipAbusiveClickLearnMoreUmaTest) { … }
IN_PROC_BROWSER_TEST_F(QuietChipAutoPopupBubbleInteractiveTest,
QuietChipAutoPopupBubbleEnabled) { … }
class QuietChipFailFastInteractiveTest : public
PermissionChipInteractiveUITest { … };
IN_PROC_BROWSER_TEST_F(QuietChipFailFastInteractiveTest,
NormalChipNoPreignoreTest) { … }
IN_PROC_BROWSER_TEST_F(QuietChipFailFastInteractiveTest,
EventListenerAddedTest) { … }
IN_PROC_BROWSER_TEST_F(QuietChipFailFastInteractiveTest,
EventListenerRemovedTest) { … }
IN_PROC_BROWSER_TEST_F(PermissionChipInteractiveUITest,
PermissionChipWithAndWithoutUserGesture) { … }
IN_PROC_BROWSER_TEST_F(PermissionChipInteractiveUITest,
PermissionRequestWithSameDocumentNavigation) { … }