chromium/chrome/browser/ui/views/download/bubble/download_toolbar_button_view.cc

// Copyright 2021 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/download/bubble/download_toolbar_button_view.h"

#include <string>

#include "base/functional/bind.h"
#include "base/i18n/number_formatting.h"
#include "base/location.h"
#include "base/memory/raw_ptr.h"
#include "base/strings/strcat.h"
#include "base/time/time.h"
#include "base/timer/timer.h"
#include "build/build_config.h"
#include "cc/paint/paint_flags.h"
#include "chrome/app/vector_icons/vector_icons.h"
#include "chrome/browser/download/bubble/download_bubble_prefs.h"
#include "chrome/browser/download/bubble/download_bubble_ui_controller.h"
#include "chrome/browser/download/bubble/download_display_controller.h"
#include "chrome/browser/download/download_ui_model.h"
#include "chrome/browser/feature_engagement/tracker_factory.h"
#include "chrome/browser/platform_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/themes/theme_properties.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_element_identifiers.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/color/chrome_color_id.h"
#include "chrome/browser/ui/download/download_bubble_info.h"
#include "chrome/browser/ui/view_ids.h"
#include "chrome/browser/ui/views/accessibility/non_accessible_image_view.h"
#include "chrome/browser/ui/views/chrome_layout_provider.h"
#include "chrome/browser/ui/views/download/bubble/download_bubble_contents_view.h"
#include "chrome/browser/ui/views/download/bubble/download_bubble_row_list_view.h"
#include "chrome/browser/ui/views/download/bubble/download_bubble_row_view.h"
#include "chrome/browser/ui/views/download/bubble/download_bubble_started_animation_views.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/browser/ui/views/toolbar/toolbar_view.h"
#include "chrome/grit/generated_resources.h"
#include "components/autofill/content/browser/content_autofill_client.h"
#include "components/feature_engagement/public/feature_constants.h"
#include "components/safe_browsing/core/common/features.h"
#include "components/safe_browsing/core/common/safe_browsing_policy_handler.h"
#include "components/safe_browsing/core/common/safe_browsing_prefs.h"
#include "components/user_education/common/user_education_class_properties.h"
#include "content/public/browser/browser_thread.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/metadata/metadata_impl_macros.h"
#include "ui/base/mojom/dialog_button.mojom.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/color/color_id.h"
#include "ui/color/color_provider.h"
#include "ui/compositor/compositor.h"
#include "ui/compositor/layer.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/geometry/point.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/skia_conversions.h"
#include "ui/gfx/image/canvas_image_source.h"
#include "ui/gfx/image/image_skia.h"
#include "ui/gfx/paint_vector_icon.h"
#include "ui/gfx/render_text.h"
#include "ui/gfx/text_constants.h"
#include "ui/views/accessibility/view_accessibility.h"
#include "ui/views/controls/button/button_controller.h"
#include "ui/views/controls/image_view.h"
#include "ui/views/controls/progress_ring_utils.h"
#include "ui/views/controls/scroll_view.h"
#include "ui/views/event_monitor.h"
#include "ui/views/layout/fill_layout.h"
#include "ui/views/layout/flex_layout.h"
#include "ui/views/layout/layout_provider.h"
#include "ui/views/view_class_properties.h"
#include "ui/views/widget/widget.h"

#if BUILDFLAG(IS_CHROMEOS)
#include "chromeos/components/kiosk/kiosk_utils.h"
#endif

#if BUILDFLAG(IS_MAC)
#include "chrome/browser/ui/fullscreen_util_mac.h"
#endif

namespace {

ContentId;

GetBadgeTextCallback;

constexpr int kProgressRingRadius =;
constexpr int kProgressRingRadiusTouchMode =;
constexpr float kProgressRingStrokeWidth =;

// Close the partial bubble after 5 seconds if the user doesn't interact with
// it.
constexpr base::TimeDelta kAutoClosePartialViewDelay =;

// Helper class to draw a circular badge with text.
class CircleBadgeImageSource : public gfx::CanvasImageSource {};

gfx::Insets GetPrimaryViewMargin() {}

gfx::Insets GetSecurityViewMargin() {}
}  // namespace

DownloadToolbarButtonView::DownloadToolbarButtonView(BrowserView* browser_view)
    :{}

DownloadToolbarButtonView::~DownloadToolbarButtonView() {}

ui::ImageModel DownloadToolbarButtonView::GetBadgeImage(
    bool is_active,
    int progress_download_count,
    SkColor badge_text_color,
    SkColor badge_background_color) {}

gfx::RenderText& DownloadToolbarButtonView::GetBadgeText(
    int progress_download_count,
    SkColor badge_text_color) {}

bool DownloadToolbarButtonView::ShouldShowScanningAnimation() const {}

void DownloadToolbarButtonView::PaintButtonContents(gfx::Canvas* canvas) {}

void DownloadToolbarButtonView::Show() {}

void DownloadToolbarButtonView::Hide() {}

bool DownloadToolbarButtonView::IsShowing() const {}

void DownloadToolbarButtonView::Enable() {}

void DownloadToolbarButtonView::Disable() {}

void DownloadToolbarButtonView::UpdateDownloadIcon(
    const IconUpdateInfo& updates) {}

void DownloadToolbarButtonView::AnnounceAccessibleAlertNow(
    const std::u16string& alert_text) {}

bool DownloadToolbarButtonView::IsFullscreenWithParentViewHidden() const {}

bool DownloadToolbarButtonView::ShouldShowExclusiveAccessBubble() const {}

void DownloadToolbarButtonView::OpenSecuritySubpage(
    const offline_items_collection::ContentId& id) {}

// This function shows the partial view. If the main view is already showing,
// we do not show the partial view. If the partial view is already showing,
// there is nothing to do here, the controller should update the partial view.
void DownloadToolbarButtonView::ShowDetails() {}

bool DownloadToolbarButtonView::OpenMostSpecificDialog(
    const offline_items_collection::ContentId& content_id) {}

void DownloadToolbarButtonView::HideDetails() {}

bool DownloadToolbarButtonView::IsShowingDetails() const {}

void DownloadToolbarButtonView::UpdateIcon() {}

void DownloadToolbarButtonView::Layout(PassKey) {}

bool DownloadToolbarButtonView::ShouldShowInkdropAfterIphInteraction() {}

std::vector<DownloadUIModel::DownloadUIModelPtr>
DownloadToolbarButtonView::GetPrimaryViewModels() {}

void DownloadToolbarButtonView::OpenPrimaryDialog() {}

DownloadBubbleRowView* DownloadToolbarButtonView::ShowPrimaryDialogRow(
    std::optional<ContentId> content_id) {}

void DownloadToolbarButtonView::OpenSecurityDialog(
    const ContentId& content_id) {}

void DownloadToolbarButtonView::CloseDialog(
    views::Widget::ClosedReason reason) {}

void DownloadToolbarButtonView::OnDialogInteracted() {}

void DownloadToolbarButtonView::OnSecurityDialogButtonPress(
    const DownloadUIModel& model,
    DownloadCommands::Command command) {}

base::WeakPtr<DownloadBubbleNavigationHandler>
DownloadToolbarButtonView::GetWeakPtr() {}

void DownloadToolbarButtonView::OnBubbleClosing() {}

std::unique_ptr<DownloadBubbleNavigationHandler::CloseOnDeactivatePin>
DownloadToolbarButtonView::PreventDialogCloseOnDeactivate() {}

void DownloadToolbarButtonView::CreateBubbleDialogDelegate() {}

// If the browser was inactive when the bubble was shown, then the bubble would
// be inactive. This would prevent close-on-deactivate, making the bubble
// unclosable. To work around this, we activate the bubble when the current
// browser becomes active, so that clicking outside the bubble will deactivate
// and close it.
void DownloadToolbarButtonView::OnBrowserSetLastActive(Browser* browser) {}

void DownloadToolbarButtonView::OnBrowserNoLongerActive(Browser* browser) {}

DownloadToolbarButtonView::BubbleCloser::BubbleCloser(
    DownloadToolbarButtonView* toolbar_button)
    :{}

DownloadToolbarButtonView::BubbleCloser::~BubbleCloser() = default;

void DownloadToolbarButtonView::BubbleCloser::OnEvent(const ui::Event& event) {}

void DownloadToolbarButtonView::ShowIphPromo() {}

void DownloadToolbarButtonView::OnPartialViewClosed() {}

void DownloadToolbarButtonView::DeactivateAutoClose() {}

void DownloadToolbarButtonView::AutoClosePartialView() {}

// If the bubble delegate is set (either the main or the partial view), the
// button press is going to make the bubble lose focus, and will destroy
// the bubble.
// If the bubble delegate is not set, show the main view.
void DownloadToolbarButtonView::ButtonPressed() {}

void DownloadToolbarButtonView::ShowPendingDownloadStartedAnimation() {}

bool DownloadToolbarButtonView::ShouldShowBubbleAsInactive() const {}

void DownloadToolbarButtonView::CloseAutofillPopup() {}

SkColor DownloadToolbarButtonView::GetIconColor() const {}

SkColor DownloadToolbarButtonView::GetProgressColor(bool is_disabled,
                                                    bool is_active) const {}

void DownloadToolbarButtonView::UpdateIconDormant() {}

void DownloadToolbarButtonView::OnAnyRowRemoved() {}

void DownloadToolbarButtonView::DisableAutoCloseTimerForTesting() {}

void DownloadToolbarButtonView::DisableDownloadStartedAnimationForTesting() {}

DownloadDisplay::IconState DownloadToolbarButtonView::GetIconState() const {}

void DownloadToolbarButtonView::SetBubbleControllerForTesting(
    std::unique_ptr<DownloadBubbleUIController> bubble_controller) {}

BEGIN_METADATA()