#pragma once
#include <iostream>
#include "external_pump.h"
#include "include/cef_app.h"
#include "include/wrapper/cef_message_router.h"
#include "utils.h"
class WefApp : public CefApp, public CefBrowserProcessHandler {
IMPLEMENT_REFCOUNTING(WefApp);
private:
std::unique_ptr<ExternalPump> external_pump_;
public:
WefApp() : external_pump_(ExternalPump::Create()) {}
virtual void OnBeforeCommandLineProcessing(
const CefString& process_type,
CefRefPtr<CefCommandLine> command_line) override {
if (process_type.empty()) {
command_line->AppendSwitch("disable-gpu");
command_line->AppendSwitch("disable-gpu-compositing");
}
#ifdef __APPLE__
command_line->AppendSwitch("use-mock-keychain");
#endif
}
CefRefPtr<CefBrowserProcessHandler> GetBrowserProcessHandler() override {
return this;
}
bool OnAlreadyRunningAppRelaunch(
CefRefPtr<CefCommandLine> command_line,
const CefString& current_directory) override {
return true;
}
void OnScheduleMessagePumpWork(int64_t delay_ms) override {
external_pump_->OnScheduleMessagePumpWork(delay_ms);
}
};