#include "headless/lib/browser/protocol/headless_handler.h"
#include <memory>
#include "base/base_switches.h"
#include "base/command_line.h"
#include "base/functional/bind.h"
#include "base/time/time.h"
#include "base/trace_event/trace_event.h"
#include "cc/base/switches.h"
#include "components/viz/common/frame_sinks/begin_frame_args.h"
#include "components/viz/common/switches.h"
#include "content/public/common/content_switches.h"
#include "headless/lib/browser/headless_browser_impl.h"
#include "headless/lib/browser/headless_web_contents_impl.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/codec/jpeg_codec.h"
#include "ui/gfx/codec/png_codec.h"
#include "ui/gfx/codec/webp_codec.h"
#include "ui/gfx/image/image.h"
namespace headless {
namespace protocol {
ScreenshotParams;
namespace {
constexpr int kDefaultScreenshotQuality = …;
BitmapEncoder;
bool EncodeBitmapAsPngSlow(const SkBitmap& bitmap,
std::vector<uint8_t>& output) { … }
bool EncodeBitmapAsPngFast(const SkBitmap& bitmap,
std::vector<uint8_t>& output) { … }
bool EncodeBitmapAsJpeg(int quality,
const SkBitmap& bitmap,
std::vector<uint8_t>& output) { … }
bool EncodeBitmapAsWebp(int quality,
const SkBitmap& bitmap,
std::vector<uint8_t>& output) { … }
absl::variant<protocol::Response, BitmapEncoder>
GetEncoder(const std::string& format, int quality, bool optimize_for_speed) { … }
void OnBeginFrameFinished(
BitmapEncoder encoder,
std::unique_ptr<HeadlessHandler::BeginFrameCallback> callback,
bool has_damage,
std::unique_ptr<SkBitmap> bitmap,
std::string error_message) { … }
}
HeadlessHandler::HeadlessHandler(HeadlessBrowserImpl* browser,
content::WebContents* web_contents)
: … { … }
HeadlessHandler::~HeadlessHandler() { … }
void HeadlessHandler::Wire(UberDispatcher* dispatcher) { … }
Response HeadlessHandler::Enable() { … }
Response HeadlessHandler::Disable() { … }
void HeadlessHandler::BeginFrame(Maybe<double> in_frame_time_ticks,
Maybe<double> in_interval,
Maybe<bool> in_no_display_updates,
Maybe<ScreenshotParams> screenshot,
std::unique_ptr<BeginFrameCallback> callback) { … }
}
}