chromium/chrome/browser/ui/views/desktop_capture/share_this_tab_source_view.cc

// Copyright 2023 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/desktop_capture/share_this_tab_source_view.h"

#include "base/task/bind_post_task.h"
#include "base/task/thread_pool.h"
#include "chrome/browser/favicon/favicon_utils.h"
#include "chrome/browser/media/webrtc/desktop_media_picker_utils.h"
#include "chrome/browser/ui/views/desktop_capture/rounded_corner_image_view.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_widget_host_view.h"
#include "media/base/video_util.h"
#include "ui/base/metadata/metadata_impl_macros.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/geometry/skia_conversions.h"
#include "ui/gfx/image/image_skia_operations.h"
#include "ui/gfx/text_constants.h"
#include "ui/views/layout/box_layout.h"

namespace {

// Base UI measurements
constexpr int kPreviewWidth =;
constexpr int kPreviewHeight =;
constexpr int kPadding =;
constexpr int kFaviconWidth =;
constexpr int kFaviconTabTitleRowHeight =;

// Derived UI measurements
constexpr gfx::Rect kPreviewRect(kPadding,
                                 kPadding,
                                 kPreviewWidth,
                                 kPreviewHeight);
// TODO(crbug.com/40268977): Align favicon height properly with label.
constexpr gfx::Rect kFaviconRect(kPadding,
                                 kPreviewRect.bottom() + kPadding,
                                 kFaviconWidth,
                                 kFaviconTabTitleRowHeight);
constexpr gfx::Rect kTabTitleMaxRect(kFaviconRect.right() + kPadding,
                                     kPreviewRect.bottom() + kPadding,
                                     kPreviewWidth - kFaviconWidth - kPadding,
                                     kFaviconTabTitleRowHeight);

constexpr base::TimeDelta kUpdatePeriodMs =;

void HandleCapturedBitmap(
    base::OnceCallback<void(uint32_t, const std::optional<gfx::ImageSkia>&)>
        reply,
    std::optional<uint32_t> last_hash,
    gfx::Size thumbnail_size,
    const SkBitmap& bitmap) {}

}  // namespace

ShareThisTabSourceView::ShareThisTabSourceView(
    base::WeakPtr<content::WebContents> web_contents)
    :{}

ShareThisTabSourceView::~ShareThisTabSourceView() = default;

void ShareThisTabSourceView::Activate() {}

void ShareThisTabSourceView::StopRefreshing() {}

gfx::Size ShareThisTabSourceView::CalculatePreferredSize(
    const views::SizeBounds& /*available_size*/) const {}

void ShareThisTabSourceView::UpdateFaviconAndTabTitle() {}

void ShareThisTabSourceView::Refresh() {}

void ShareThisTabSourceView::OnCaptureHandled(
    uint32_t hash,
    const std::optional<gfx::ImageSkia>& image) {}

BEGIN_METADATA()