#ifndef CHROME_BROWSER_UI_THUMBNAILS_THUMBNAIL_TRACKER_H_
#define CHROME_BROWSER_UI_THUMBNAILS_THUMBNAIL_TRACKER_H_
#include <memory>
#include "base/containers/flat_map.h"
#include "base/memory/scoped_refptr.h"
#include "chrome/browser/ui/thumbnails/thumbnail_image.h"
namespace content {
class WebContents;
}
class ThumbnailTracker {
public:
using CompressedThumbnailData = ThumbnailImage::CompressedThumbnailData;
using GetThumbnailCallback =
base::RepeatingCallback<scoped_refptr<ThumbnailImage>(
content::WebContents*)>;
using ThumbnailUpdatedCallback =
base::RepeatingCallback<void(content::WebContents*,
CompressedThumbnailData)>;
explicit ThumbnailTracker(ThumbnailUpdatedCallback callback);
ThumbnailTracker(ThumbnailUpdatedCallback callback,
GetThumbnailCallback thumbnail_getter);
~ThumbnailTracker();
void AddTab(content::WebContents* contents);
void RemoveTab(content::WebContents* contents);
private:
void ThumbnailUpdated(content::WebContents* contents,
CompressedThumbnailData image);
void ContentsClosed(content::WebContents* contents);
static scoped_refptr<ThumbnailImage> GetThumbnailFromTabHelper(
content::WebContents* contents);
GetThumbnailCallback thumbnail_getter_;
ThumbnailUpdatedCallback callback_;
class ContentsData;
base::flat_map<content::WebContents*, std::unique_ptr<ContentsData>>
contents_data_;
};
#endif