chromium/chrome/browser/ui/views/extensions/extension_install_dialog_view.cc

// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/ui/views/extensions/extension_install_dialog_view.h"

#include <string>
#include <utility>

#include "base/functional/bind.h"
#include "base/i18n/message_formatter.h"
#include "base/memory/raw_ptr.h"
#include "base/metrics/histogram_functions.h"
#include "base/metrics/histogram_macros.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/extensions/extension_install_prompt.h"
#include "chrome/browser/extensions/extension_install_prompt_show_params.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_dialogs.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/scoped_tabbed_browser_displayer.h"
#include "chrome/browser/ui/views/chrome_layout_provider.h"
#include "chrome/browser/ui/views/chrome_typography.h"
#include "chrome/browser/ui/views/extensions/expandable_container_view.h"
#include "chrome/browser/ui/views/extensions/extension_permissions_view.h"
#include "chrome/common/buildflags.h"
#include "chrome/common/extensions/extension_constants.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/browser/page_navigator.h"
#include "extensions/common/constants.h"
#include "extensions/common/extension.h"
#include "extensions/common/extension_urls.h"
#include "third_party/skia/include/core/SkColor.h"
#include "ui/accessibility/ax_enums.mojom.h"
#include "ui/accessibility/ax_node_data.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/metadata/metadata_header_macros.h"
#include "ui/base/metadata/metadata_impl_macros.h"
#include "ui/base/mojom/dialog_button.mojom.h"
#include "ui/base/mojom/ui_base_types.mojom-shared.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/geometry/insets.h"
#include "ui/views/accessibility/view_accessibility.h"
#include "ui/views/border.h"
#include "ui/views/bubble/bubble_frame_view.h"
#include "ui/views/controls/button/checkbox.h"
#include "ui/views/controls/image_view.h"
#include "ui/views/controls/label.h"
#include "ui/views/controls/link.h"
#include "ui/views/controls/scroll_view.h"
#include "ui/views/controls/separator.h"
#include "ui/views/controls/textarea/textarea.h"
#include "ui/views/layout/box_layout.h"
#include "ui/views/layout/fill_layout.h"
#include "ui/views/layout/table_layout.h"
#include "ui/views/widget/widget.h"

OpenURLParams;
Referrer;

namespace {

// Time delay before the install button is enabled after initial display.
int g_install_delay_in_ms =;

// These values are logged to UMA. Entries should not be renumbered and numeric
// values should never be reused. Please keep in sync with "BooleanSent" in
// src/tools/metrics/histograms/enums.xml.
enum class CloudExtensionRequestMetricEvent {};

// A custom view to contain the ratings information (stars, ratings count, etc).
// With screen readers, this will handle conveying the information properly
// (i.e., "Rated 4.2 stars by 379 reviews" rather than "image image...379").
class RatingsView : public views::View {};

BEGIN_METADATA()

// A custom view for the ratings star image that will be ignored by screen
// readers (since the RatingsView handles the context).
class RatingStar : public views::ImageView {};

BEGIN_METADATA()

// A custom view for the ratings label that will be ignored by screen readers
// (since the RatingsView handles the context).
class RatingLabel : public views::Label {};

BEGIN_METADATA()

// TODO(crbug.com/355018927): Remove this when we implement in views::Label.
class TitleLabelWrapper : public views::View {};

BEGIN_METADATA()

void AddResourceIcon(const gfx::ImageSkia* skia_image, void* data) {}

void ShowExtensionInstallDialogImpl(
    std::unique_ptr<ExtensionInstallPromptShowParams> show_params,
    ExtensionInstallPrompt::DoneCallback done_callback,
    std::unique_ptr<ExtensionInstallPrompt::Prompt> prompt) {}

// A custom scrollable view implementation for the dialog.
class CustomScrollableView : public views::View {};

BEGIN_METADATA()

// Represents one section in the scrollable info area, which could be a block of
// permissions, a list of retained files, or a list of retained devices.
struct ExtensionInfoSection {};

// Adds a section to |sections| for permissions of |perm_type| if there are any.
void AddPermissions(ExtensionInstallPrompt::Prompt* prompt,
                    std::vector<ExtensionInfoSection>& sections) {}

}  // namespace

// A custom view for the justification section of the extension info. It
// contains a text field into which users can enter their justification for
// requesting an extension.
class ExtensionInstallDialogView::ExtensionJustificationView
    : public views::View {};

BEGIN_METADATA()
END_METADATA

ExtensionInstallDialogView::ExtensionInstallDialogView(
    std::unique_ptr<ExtensionInstallPromptShowParams> show_params,
    ExtensionInstallPrompt::DoneCallback done_callback,
    std::unique_ptr<ExtensionInstallPrompt::Prompt> prompt)
    :{}

ExtensionInstallDialogView::~ExtensionInstallDialogView() {}

ExtensionInstallPromptShowParams*
ExtensionInstallDialogView::GetShowParamsForTesting() {}

void ExtensionInstallDialogView::ClickLinkForTesting() {}

void ExtensionInstallDialogView::SetInstallButtonDelayForTesting(
    int delay_in_ms) {}

bool ExtensionInstallDialogView::IsJustificationFieldVisibleForTesting() {}

void ExtensionInstallDialogView::SetJustificationTextForTesting(
    const std::u16string& new_text) {}

void ExtensionInstallDialogView::ResizeWidget() {}

void ExtensionInstallDialogView::VisibilityChanged(views::View* starting_from,
                                                   bool is_visible) {}

void ExtensionInstallDialogView::AddedToWidget() {}

void ExtensionInstallDialogView::OnDialogCanceled() {}

void ExtensionInstallDialogView::OnDialogAccepted() {}

bool ExtensionInstallDialogView::IsDialogButtonEnabled(
    ui::mojom::DialogButton button) const {}

std::u16string ExtensionInstallDialogView::GetAccessibleWindowTitle() const {}

void ExtensionInstallDialogView::CloseDialog() {}

void ExtensionInstallDialogView::OnExtensionUninstalled(
    content::BrowserContext* browser_context,
    const extensions::Extension* extension,
    extensions::UninstallReason reason) {}

void ExtensionInstallDialogView::OnShutdown(
    extensions::ExtensionRegistry* registry) {}

void ExtensionInstallDialogView::LinkClicked() {}

void ExtensionInstallDialogView::CreateContents() {}

void ExtensionInstallDialogView::ContentsChanged(
    views::Textfield* sender,
    const std::u16string& new_contents) {}

void ExtensionInstallDialogView::EnableInstallButton() {}

BEGIN_METADATA()

// static
ExtensionInstallPrompt::ShowDialogCallback
ExtensionInstallPrompt::GetDefaultShowDialogCallback() {}