#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "chrome/browser/media/webrtc/tab_desktop_media_list.h"
#include <utility>
#include "base/containers/adapters.h"
#include "base/functional/bind.h"
#include "base/hash/hash.h"
#include "base/task/bind_post_task.h"
#include "base/task/thread_pool.h"
#include "base/time/time.h"
#include "chrome/browser/browser_features.h"
#include "chrome/browser/media/webrtc/desktop_media_list_layout_config.h"
#include "chrome/browser/media/webrtc/desktop_media_picker_utils.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/web_applications/app_browser_controller.h"
#include "components/favicon/content/content_favicon_driver.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_widget_host_view.h"
#include "extensions/browser/app_window/app_window.h"
#include "extensions/browser/app_window/app_window_registry.h"
#include "media/base/video_util.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkImage.h"
#include "ui/gfx/favicon_size.h"
BrowserThread;
DesktopMediaID;
WebContents;
namespace {
gfx::ImageSkia CreateEnclosedFaviconImage(gfx::Size size,
const gfx::ImageSkia& favicon) { … }
const int kDefaultTabDesktopMediaListUpdatePeriod = …;
void HandleCapturedBitmap(
base::OnceCallback<void(uint32_t, const gfx::ImageSkia&)> reply,
std::optional<uint32_t> last_hash,
const SkBitmap& bitmap) { … }
}
TabDesktopMediaList::TabDesktopMediaList(
WebContents* web_contents,
DesktopMediaList::WebContentsFilter includable_web_contents_filter,
bool include_chrome_app_windows)
: … { … }
TabDesktopMediaList::~TabDesktopMediaList() { … }
void TabDesktopMediaList::CompleteRefreshAfterThumbnailProcessing() { … }
void TabDesktopMediaList::Refresh(bool update_thumnails) { … }
void TabDesktopMediaList::TriggerScreenshot(
int remaining_retries,
std::unique_ptr<TabDesktopMediaList::RefreshCompleter> refresh_completer) { … }
void TabDesktopMediaList::ScreenshotReceived(
int remaining_retries,
const content::DesktopMediaID& id,
std::unique_ptr<TabDesktopMediaList::RefreshCompleter> refresh_completer,
const SkBitmap& bitmap) { … }
void TabDesktopMediaList::OnPreviewCaptureHandled(
const content::DesktopMediaID& media_id,
std::unique_ptr<TabDesktopMediaList::RefreshCompleter> refresh_completer,
uint32_t new_hash,
const gfx::ImageSkia& image) { … }
void TabDesktopMediaList::SetPreviewedSource(
const std::optional<content::DesktopMediaID>& id) { … }
TabDesktopMediaList::RefreshCompleter::RefreshCompleter(
base::WeakPtr<TabDesktopMediaList> list)
: … { … }
TabDesktopMediaList::RefreshCompleter::~RefreshCompleter() { … }