#include "chrome/browser/ui/views/extensions/extension_install_dialog_view.h"
#include <string>
#include <utility>
#include "base/feature_list.h"
#include "base/files/file_path.h"
#include "base/functional/callback_helpers.h"
#include "base/i18n/message_formatter.h"
#include "base/memory/raw_ptr.h"
#include "base/path_service.h"
#include "base/run_loop.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/metrics/histogram_tester.h"
#include "build/build_config.h"
#include "chrome/browser/extensions/chrome_test_extension_loader.h"
#include "chrome/browser/extensions/extension_browsertest.h"
#include "chrome/browser/extensions/extension_install_prompt.h"
#include "chrome/browser/extensions/extension_install_prompt_show_params.h"
#include "chrome/browser/extensions/extension_install_prompt_test_helper.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/platform_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_tabstrip.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/tabs/tab_enums.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/test/test_browser_dialog.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/extensions/extension_test_util.h"
#include "chrome/grit/generated_resources.h"
#include "components/constrained_window/constrained_window_views.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/test_utils.h"
#include "extensions/browser/extension_icon_manager.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_system.h"
#include "extensions/browser/test_extension_registry_observer.h"
#include "extensions/common/extension.h"
#include "extensions/common/extension_builder.h"
#include "extensions/common/extension_features.h"
#include "extensions/common/extension_urls.h"
#include "extensions/common/permissions/permission_message_provider.h"
#include "extensions/common/permissions/permissions_data.h"
#include "ui/accessibility/ax_enums.mojom.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/mojom/dialog_button.mojom.h"
#include "ui/views/accessibility/view_accessibility.h"
#include "ui/views/bubble/bubble_frame_view.h"
#include "ui/views/controls/scroll_view.h"
#include "ui/views/test/widget_test.h"
#include "ui/views/view.h"
#include "ui/views/widget/widget.h"
PermissionIDSet;
PermissionMessage;
PermissionMessages;
PermissionSet;
namespace {
void CloseAndWait(views::Widget* widget) { … }
}
class ExtensionInstallDialogViewTestBase
: public extensions::ExtensionBrowserTest { … };
ExtensionInstallDialogViewTestBase::ExtensionInstallDialogViewTestBase()
: … { … }
void ExtensionInstallDialogViewTestBase::SetUpOnMainThread() { … }
std::unique_ptr<ExtensionInstallPrompt::Prompt>
ExtensionInstallDialogViewTestBase::CreatePrompt(
ExtensionInstallPrompt::PromptType prompt_type) { … }
std::unique_ptr<ExtensionInstallPrompt::Prompt>
ExtensionInstallDialogViewTestBase::CreatePrompt(
ExtensionInstallPrompt::PromptType prompt_type,
const extensions::Extension* extension) { … }
class ScrollbarTest : public ExtensionInstallDialogViewTestBase { … };
bool ScrollbarTest::IsScrollbarVisible(
std::unique_ptr<ExtensionInstallPrompt::Prompt> prompt) { … }
IN_PROC_BROWSER_TEST_F(ScrollbarTest, LongPromptScrollbar) { … }
#if BUILDFLAG(IS_MAC) && defined(NDEBUG)
#define MAYBE_ScrollbarRegression …
#else
#define MAYBE_ScrollbarRegression …
#endif
IN_PROC_BROWSER_TEST_F(ScrollbarTest, MAYBE_ScrollbarRegression) { … }
class ExtensionInstallDialogViewTest
: public ExtensionInstallDialogViewTestBase { … };
IN_PROC_BROWSER_TEST_F(ExtensionInstallDialogViewTest, NotifyDelegate) { … }
IN_PROC_BROWSER_TEST_F(ExtensionInstallDialogViewTest,
ActivateWebContentsOnTabChange) { … }
IN_PROC_BROWSER_TEST_F(ExtensionInstallDialogViewTest, InstallButtonDelay) { … }
IN_PROC_BROWSER_TEST_F(ExtensionInstallDialogViewTest,
TabClosureClearsWebContentsFromDialogView) { … }
class ExtensionInstallDialogViewInteractiveBrowserTest
: public DialogBrowserTest { … };
IN_PROC_BROWSER_TEST_F(ExtensionInstallDialogViewInteractiveBrowserTest,
InvokeUi_Simple) { … }
IN_PROC_BROWSER_TEST_F(ExtensionInstallDialogViewInteractiveBrowserTest,
InvokeUi_External) { … }
IN_PROC_BROWSER_TEST_F(ExtensionInstallDialogViewInteractiveBrowserTest,
InvokeUi_ExternalWithPermission) { … }
IN_PROC_BROWSER_TEST_F(ExtensionInstallDialogViewInteractiveBrowserTest,
InvokeUi_ReEnable) { … }
IN_PROC_BROWSER_TEST_F(ExtensionInstallDialogViewInteractiveBrowserTest,
InvokeUi_MultilinePermission) { … }
#if BUILDFLAG(IS_WIN)
#define MAYBE_InvokeUi_ManyPermissions …
#else
#define MAYBE_InvokeUi_ManyPermissions …
#endif
IN_PROC_BROWSER_TEST_F(ExtensionInstallDialogViewInteractiveBrowserTest,
MAYBE_InvokeUi_ManyPermissions) { … }
#if BUILDFLAG(IS_WIN)
#define MAYBE_InvokeUi_DetailedPermission …
#else
#define MAYBE_InvokeUi_DetailedPermission …
#endif
IN_PROC_BROWSER_TEST_F(ExtensionInstallDialogViewInteractiveBrowserTest,
MAYBE_InvokeUi_DetailedPermission) { … }
#if BUILDFLAG(IS_WIN)
#define MAYBE_InvokeUi_WithWithholdingOption …
#else
#define MAYBE_InvokeUi_WithWithholdingOption …
#endif
IN_PROC_BROWSER_TEST_F(ExtensionInstallDialogViewInteractiveBrowserTest,
MAYBE_InvokeUi_WithWithholdingOption) { … }
#if BUILDFLAG(IS_WIN)
#define MAYBE_InvokeUi_AllInfoTypes …
#else
#define MAYBE_InvokeUi_AllInfoTypes …
#endif
IN_PROC_BROWSER_TEST_F(ExtensionInstallDialogViewInteractiveBrowserTest,
MAYBE_InvokeUi_AllInfoTypes) { … }
class ExtensionInstallDialogViewOnUninstallationTest
: public ExtensionInstallDialogViewTest { … };
void ExtensionInstallDialogViewOnUninstallationTest::UninstallExtension(
const std::string& extension_id) { … }
IN_PROC_BROWSER_TEST_F(ExtensionInstallDialogViewOnUninstallationTest,
UninstallingExtensionClosesDialog) { … }
IN_PROC_BROWSER_TEST_F(ExtensionInstallDialogViewOnUninstallationTest,
UninstallingOtherExtensionDoesNotCloseDialog) { … }
class ExtensionInstallDialogRatingsSectionTest
: public ExtensionInstallDialogViewTest { … };
void ExtensionInstallDialogRatingsSectionTest::TestRatingsSectionA11y(
int num_ratings,
double average_rating,
const std::string& expected_text) { … }
IN_PROC_BROWSER_TEST_F(ExtensionInstallDialogRatingsSectionTest,
RatingsSectionA11y) { … }
class ExtensionInstallDialogWithWithholdPermissionsUI
: public ExtensionInstallDialogViewTestBase { … };
IN_PROC_BROWSER_TEST_F(ExtensionInstallDialogWithWithholdPermissionsUI,
ShowsWithholdUI) { … }
class ExtensionInstallDialogViewRequestTest
: public ExtensionInstallDialogViewTestBase { … };
IN_PROC_BROWSER_TEST_F(ExtensionInstallDialogViewRequestTest, NotifyDelegate) { … }
IN_PROC_BROWSER_TEST_F(ExtensionInstallDialogViewRequestTest,
RequestButtonDelay) { … }
IN_PROC_BROWSER_TEST_F(ExtensionInstallDialogViewRequestTest,
SendButtonDisabledWhenJustificationExceedsLimit) { … }