#include "chrome/browser/ui/extensions/extension_install_ui.h"
#include "base/auto_reset.h"
#include "base/check_is_test.h"
#include "base/functional/bind.h"
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/prefs/incognito_mode_prefs.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/themes/theme_service.h"
#include "chrome/browser/themes/theme_service_factory.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_navigator.h"
#include "chrome/browser/ui/browser_navigator_params.h"
#include "chrome/browser/ui/browser_tabstrip.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/extensions/installation_error_infobar_delegate.h"
#include "chrome/browser/ui/scoped_tabbed_browser_displayer.h"
#include "chrome/browser/ui/simple_message_box.h"
#include "chrome/browser/ui/singleton_tabs.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "components/infobars/content/content_infobar_manager.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/web_contents.h"
#include "extensions/browser/install/crx_install_error.h"
#include "extensions/common/extension.h"
#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "ash/constants/notifier_catalogs.h"
#include "ash/public/cpp/system/toast_data.h"
#include "ash/public/cpp/system/toast_manager.h"
#include "chrome/grit/generated_resources.h"
#include "ui/base/l10n/l10n_util.h"
#else
#include "chrome/common/url_constants.h"
#endif
#if BUILDFLAG(IS_CHROMEOS_LACROS)
#include "base/functional/callback_helpers.h"
#include "chrome/browser/notifications/notification_display_service.h"
#include "chrome/browser/notifications/notification_display_service_factory.h"
#include "chrome/grit/generated_resources.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/message_center/public/cpp/notification.h"
#include "ui/message_center/public/cpp/notifier_id.h"
#endif
BrowserThread;
WebContents;
Extension;
namespace {
static bool g_disable_ui_for_tests = …;
Browser* FindOrCreateVisibleBrowser(Profile* profile) { … }
#if BUILDFLAG(IS_CHROMEOS)
constexpr char kExtensionInstallSuccessToastId[] = "extension_install_success";
#endif
#if BUILDFLAG(IS_CHROMEOS_ASH)
void ShowToast(const std::string& id,
ash::ToastCatalogName catalog_name,
const std::u16string& text) {
ash::ToastManager::Get()->Show(ash::ToastData(id, catalog_name, text));
}
#endif
#if BUILDFLAG(IS_CHROMEOS_LACROS)
void ShowInstalledNotification(
scoped_refptr<const extensions::Extension> extension,
Profile* profile) {
auto notification = std::make_unique<message_center::Notification>(
message_center::NOTIFICATION_TYPE_SIMPLE,
std::string(kExtensionInstallSuccessToastId),
std::u16string(),
l10n_util::GetStringFUTF16(IDS_EXTENSION_NOTIFICATION_INSTALLED,
base::UTF8ToUTF16(extension->name())),
ui::ImageModel(),
std::u16string(),
GURL(),
message_center::NotifierId(message_center::NotifierType::APPLICATION,
extension->id()),
message_center::RichNotificationData(),
base::MakeRefCounted<message_center::HandleNotificationClickDelegate>(
base::DoNothingAs<void()>()));
NotificationDisplayServiceFactory::GetForProfile(profile)->Display(
NotificationHandler::Type::TRANSIENT, *notification,
nullptr);
}
#endif
void ShowAppInstalledNotification(
scoped_refptr<const extensions::Extension> extension,
Profile* profile) { … }
}
ExtensionInstallUI::ExtensionInstallUI(content::BrowserContext* context)
: … { … }
ExtensionInstallUI::~ExtensionInstallUI() { … }
void ExtensionInstallUI::OnInstallSuccess(
scoped_refptr<const extensions::Extension> extension,
const SkBitmap* icon) { … }
void ExtensionInstallUI::OnInstallFailure(
const extensions::CrxInstallError& error) { … }
void ExtensionInstallUI::SetUseAppInstalledBubble(bool use_bubble) { … }
void ExtensionInstallUI::SetSkipPostInstallUI(bool skip_ui) { … }
base::AutoReset<bool> ExtensionInstallUI::disable_ui_for_tests(bool disable) { … }