chromium/chrome/browser/ui/views/status_bubble_views.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.

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/40285824): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

#include "chrome/browser/ui/views/status_bubble_views.h"

#include <algorithm>
#include <utility>

#include "base/functional/bind.h"
#include "base/i18n/rtl.h"
#include "base/location.h"
#include "base/memory/raw_ptr.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task/single_thread_task_runner.h"
#include "base/timer/timer.h"
#include "base/types/cxx23_to_underlying.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "cc/paint/paint_flags.h"
#include "chrome/browser/ui/color/chrome_color_id.h"
#include "chrome/browser/ui/views/chrome_widget_sublevel.h"
#include "components/url_formatter/elide_url.h"
#include "components/url_formatter/url_formatter.h"
#include "third_party/skia/include/core/SkPath.h"
#include "third_party/skia/include/pathops/SkPathOps.h"
#include "ui/base/metadata/metadata_header_macros.h"
#include "ui/base/metadata/metadata_impl_macros.h"
#include "ui/display/display.h"
#include "ui/display/screen.h"
#include "ui/gfx/animation/linear_animation.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/font_list.h"
#include "ui/gfx/geometry/point.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/rrect_f.h"
#include "ui/gfx/geometry/skia_conversions.h"
#include "ui/gfx/scoped_canvas.h"
#include "ui/gfx/text_elider.h"
#include "ui/gfx/text_utils.h"
#include "ui/native_theme/native_theme.h"
#include "ui/views/animation/animation_delegate_views.h"
#include "ui/views/controls/label.h"
#include "ui/views/controls/scrollbar/scroll_bar_views.h"
#include "ui/views/layout/fill_layout.h"
#include "ui/views/style/typography.h"
#include "ui/views/style/typography_provider.h"
#include "ui/views/widget/root_view.h"
#include "ui/views/widget/widget.h"
#include "url/gurl.h"

#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "ash/public/cpp/window_properties.h"
#include "ui/aura/window.h"
#endif

namespace {

// The roundedness of the edges of our bubble.
constexpr int kBubbleCornerRadius =;

// How close the mouse can get to the infobubble before it starts sliding
// off-screen.
constexpr int kMousePadding =;

// The minimum horizontal space between the edges of the text and the edges of
// the status bubble, not including the outer shadow ring.
constexpr int kTextHorizPadding =;

// Delays before we start hiding or showing the bubble after we receive a
// show or hide request.
constexpr auto kShowDelay =;
constexpr auto kHideDelay =;

// How long each fade should last for.
constexpr auto kShowFadeDuration =;
constexpr auto kHideFadeDuration =;
constexpr int kFramerate =;

// How long each expansion step should take.
constexpr auto kMinExpansionStepDuration =;
constexpr auto kMaxExpansionStepDuration =;

// How long to delay before destroying an unused status bubble widget.
constexpr auto kDestroyPopupDelay =;

const gfx::FontList& GetFont() {}

}  // namespace

// StatusBubbleViews::StatusViewAnimation --------------------------------------
class StatusBubbleViews::StatusViewAnimation
    : public gfx::LinearAnimation,
      public views::AnimationDelegateViews {};

// StatusBubbleViews::StatusView -----------------------------------------------
//
// StatusView manages the display of the bubble, applying text changes and
// fading in or out the bubble as required.
class StatusBubbleViews::StatusView : public views::View {};
StatusView;

StatusView::StatusView(StatusBubbleViews* status_bubble)
    :{}

StatusView::~StatusView() {}

gfx::Insets StatusView::GetInsets() const {}

const std::u16string& StatusView::GetText() const {}

void StatusView::SetText(const std::u16string& text) {}

void StatusView::AnimateForText(const std::u16string& text) {}

void StatusView::SetStyle(BubbleStyle style) {}

void StatusView::ShowInstantly() {}

void StatusView::HideInstantly() {}

void StatusView::ResetTimer() {}

void StatusView::SetOpacity(float opacity) {}

void StatusView::OnAnimationEnded() {}

bool StatusView::IsDestroyPopupTimerRunning() const {}

void StatusView::OnThemeChanged() {}

void StatusView::StartTimer(base::TimeDelta time) {}

void StatusView::OnTimer() {}

void StatusView::CancelTimer() {}

void StatusView::RestartTimer(base::TimeDelta delay) {}

void StatusView::StartFade(float start, float end, base::TimeDelta duration) {}

void StatusView::StartHiding() {}

void StatusView::StartShowing() {}

void StatusView::SetTextLabelColors(views::Label* text) {}

void StatusView::OnPaint(gfx::Canvas* canvas) {}

DEFINE_ENUM_CONVERTERS()

DEFINE_ENUM_CONVERTERS()

BEGIN_METADATA()

// StatusBubbleViews::StatusViewAnimation --------------------------------------

StatusBubbleViews::StatusViewAnimation::StatusViewAnimation(
    StatusView* status_view,
    float opacity_start,
    float opacity_end)
    :{}

StatusBubbleViews::StatusViewAnimation::~StatusViewAnimation() {}

float StatusBubbleViews::StatusViewAnimation::GetCurrentOpacity() {}

void StatusBubbleViews::StatusViewAnimation::AnimateToState(double state) {}

void StatusBubbleViews::StatusViewAnimation::AnimationEnded(
    const gfx::Animation* animation) {}

// StatusBubbleViews::StatusViewExpander ---------------------------------------
//
// Manages the expansion and contraction of the status bubble as it accommodates
// URLs too long to fit in the standard bubble. Changes are passed through the
// StatusView to paint.
class StatusBubbleViews::StatusViewExpander
    : public gfx::LinearAnimation,
      public views::AnimationDelegateViews {};

void StatusBubbleViews::StatusViewExpander::AnimateToState(double state) {}

void StatusBubbleViews::StatusViewExpander::AnimationEnded(
    const gfx::Animation* animation) {}

void StatusBubbleViews::StatusViewExpander::StartExpansion(
    const std::u16string& expanded_text,
    int expansion_start,
    int expansion_end) {}

int StatusBubbleViews::StatusViewExpander::GetCurrentBubbleWidth() {}

void StatusBubbleViews::StatusViewExpander::SetBubbleWidth(int width) {}


// StatusBubbleViews -----------------------------------------------------------

const int StatusBubbleViews::kShadowThickness =;

StatusBubbleViews::StatusBubbleViews(views::View* base_view)
    :{}

StatusBubbleViews::~StatusBubbleViews() {}

void StatusBubbleViews::InitPopup() {}

void StatusBubbleViews::DestroyPopup() {}

void StatusBubbleViews::Reposition() {}

void StatusBubbleViews::RepositionPopup() {}

int StatusBubbleViews::GetPreferredHeight() {}

void StatusBubbleViews::SetBounds(int x, int y, int w, int h) {}

int StatusBubbleViews::GetWidthForURL(const std::u16string& url_string) {}

void StatusBubbleViews::SetStatus(const std::u16string& status_text) {}

void StatusBubbleViews::SetURL(const GURL& url) {}

void StatusBubbleViews::Hide() {}

void StatusBubbleViews::MouseMoved(bool left_content) {}

void StatusBubbleViews::MouseMovedAt(const gfx::Point& location,
                                     bool left_content) {}

void StatusBubbleViews::UpdateDownloadShelfVisibility(bool visible) {}

void StatusBubbleViews::AvoidMouse(const gfx::Point& location) {}

bool StatusBubbleViews::IsFrameVisible() {}

bool StatusBubbleViews::IsFrameMaximized() {}

void StatusBubbleViews::ExpandBubble() {}

int StatusBubbleViews::GetStandardStatusBubbleWidth() {}

int StatusBubbleViews::GetMaxStatusBubbleWidth() {}

void StatusBubbleViews::SetBubbleWidth(int width) {}

void StatusBubbleViews::CancelExpandTimer() {}

gfx::Animation* StatusBubbleViews::GetShowHideAnimationForTest() {}

bool StatusBubbleViews::IsDestroyPopupTimerRunningForTest() {}