#include "chrome/browser/extensions/extension_install_prompt.h"
#include <optional>
#include <utility>
#include "base/functional/bind.h"
#include "base/location.h"
#include "base/observer_list.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task/single_thread_task_runner.h"
#include "base/values.h"
#include "chrome/browser/extensions/extension_install_prompt_show_params.h"
#include "chrome/browser/extensions/extension_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/extensions/extension_install_ui.h"
#include "chrome/common/buildflags.h"
#include "chrome/grit/generated_resources.h"
#include "chrome/grit/theme_resources.h"
#include "components/strings/grit/components_strings.h"
#include "content/public/browser/web_contents.h"
#include "extensions/browser/disable_reason.h"
#include "extensions/browser/extension_dialog_auto_confirm.h"
#include "extensions/browser/extension_prefs.h"
#include "extensions/browser/extension_util.h"
#include "extensions/browser/image_loader.h"
#include "extensions/common/extension.h"
#include "extensions/common/extension_features.h"
#include "extensions/common/extension_resource.h"
#include "extensions/common/icons/extension_icon_set.h"
#include "extensions/common/manifest.h"
#include "extensions/common/manifest_constants.h"
#include "extensions/common/manifest_handlers/icons_handler.h"
#include "extensions/common/permissions/permission_set.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/mojom/dialog_button.mojom.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/resource/resource_scale_factor.h"
#include "ui/base/ui_base_types.h"
#include "ui/gfx/image/image_skia.h"
#include "ui/gfx/image/image_skia_rep.h"
Extension;
Manifest;
PermissionMessage;
PermissionMessages;
PermissionSet;
namespace {
bool AllowWebstoreData(ExtensionInstallPrompt::PromptType type) { … }
SkBitmap GetDefaultIconBitmapForMaxScaleFactor(bool is_app) { … }
}
ExtensionInstallPrompt::PromptType
ExtensionInstallPrompt::g_last_prompt_type_for_tests = …;
ExtensionInstallPrompt::Prompt::Prompt(PromptType type)
: … { … }
ExtensionInstallPrompt::Prompt::~Prompt() { … }
void ExtensionInstallPrompt::Prompt::AddPermissionSet(
const PermissionSet& permissions) { … }
void ExtensionInstallPrompt::Prompt::AddPermissionMessages(
const PermissionMessages& permissions) { … }
void ExtensionInstallPrompt::Prompt::SetWebstoreData(
const std::string& localized_user_count,
bool show_user_count,
double average_rating,
int rating_count,
const std::string& localized_rating_count) { … }
std::u16string ExtensionInstallPrompt::Prompt::GetDialogTitle() const { … }
int ExtensionInstallPrompt::Prompt::GetDialogButtons() const { … }
std::u16string ExtensionInstallPrompt::Prompt::GetAcceptButtonLabel() const { … }
std::u16string ExtensionInstallPrompt::Prompt::GetAbortButtonLabel() const { … }
std::u16string ExtensionInstallPrompt::Prompt::GetPermissionsHeading() const { … }
void ExtensionInstallPrompt::Prompt::AppendRatingStars(
StarAppender appender, void* data) const { … }
std::u16string ExtensionInstallPrompt::Prompt::GetRatingCount() const { … }
std::u16string ExtensionInstallPrompt::Prompt::GetUserCount() const { … }
size_t ExtensionInstallPrompt::Prompt::GetPermissionCount() const { … }
std::u16string ExtensionInstallPrompt::Prompt::GetPermission(
size_t index) const { … }
std::u16string ExtensionInstallPrompt::Prompt::GetPermissionsDetails(
size_t index) const { … }
void ExtensionInstallPrompt::Prompt::AddObserver(Observer* observer) { … }
void ExtensionInstallPrompt::Prompt::RemoveObserver(Observer* observer) { … }
void ExtensionInstallPrompt::Prompt::OnDialogOpened() { … }
void ExtensionInstallPrompt::Prompt::OnDialogAccepted() { … }
void ExtensionInstallPrompt::Prompt::OnDialogCanceled() { … }
bool ExtensionInstallPrompt::Prompt::ShouldWithheldPermissionsOnDialogAccept()
const { … }
ExtensionInstallPrompt::DoneCallbackPayload::DoneCallbackPayload(Result result)
: … { … }
ExtensionInstallPrompt::DoneCallbackPayload::DoneCallbackPayload(
Result result,
std::string justification)
: … { … }
ExtensionInstallPrompt::PromptType
ExtensionInstallPrompt::GetReEnablePromptTypeForExtension(
content::BrowserContext* context,
const extensions::Extension* extension) { … }
scoped_refptr<Extension>
ExtensionInstallPrompt::GetLocalizedExtensionForDisplay(
const base::Value::Dict& manifest,
int flags,
const std::string& id,
const std::string& localized_name,
const std::string& localized_description,
std::string* error) { … }
ExtensionInstallPrompt::ExtensionInstallPrompt(content::WebContents* contents)
: … { … }
ExtensionInstallPrompt::ExtensionInstallPrompt(Profile* profile,
gfx::NativeWindow native_window)
: … { … }
ExtensionInstallPrompt::~ExtensionInstallPrompt() { … }
void ExtensionInstallPrompt::ShowDialog(
DoneCallback done_callback,
const Extension* extension,
const SkBitmap* icon,
const ShowDialogCallback& show_dialog_callback) { … }
void ExtensionInstallPrompt::ShowDialog(
DoneCallback done_callback,
const Extension* extension,
const SkBitmap* icon,
std::unique_ptr<Prompt> prompt,
const ShowDialogCallback& show_dialog_callback) { … }
void ExtensionInstallPrompt::ShowDialog(
DoneCallback done_callback,
const Extension* extension,
const SkBitmap* icon,
std::unique_ptr<Prompt> prompt,
std::unique_ptr<const PermissionSet> custom_permissions,
const ShowDialogCallback& show_dialog_callback) { … }
void ExtensionInstallPrompt::OnInstallSuccess(
scoped_refptr<const Extension> extension,
SkBitmap* icon) { … }
void ExtensionInstallPrompt::OnInstallFailure(
const extensions::CrxInstallError& error) { … }
std::unique_ptr<ExtensionInstallPrompt::Prompt>
ExtensionInstallPrompt::GetPromptForTesting() { … }
void ExtensionInstallPrompt::SetIcon(const SkBitmap* image) { … }
void ExtensionInstallPrompt::OnImageLoaded(const gfx::Image& image) { … }
void ExtensionInstallPrompt::LoadImageIfNeeded() { … }
void ExtensionInstallPrompt::ShowConfirmation() { … }
bool ExtensionInstallPrompt::AutoConfirmPromptIfEnabled() { … }