#ifndef CEF_TESTS_CEFCLIENT_BROWSER_BROWSER_WINDOW_H_
#define CEF_TESTS_CEFCLIENT_BROWSER_BROWSER_WINDOW_H_
#pragma once
#include <memory>
#include "include/cef_browser.h"
#include "tests/cefclient/browser/client_handler.h"
#include "tests/cefclient/browser/client_types.h"
namespace client {
class BrowserWindow : public ClientHandler::Delegate {
public:
class Delegate {
public:
virtual void OnBrowserCreated(CefRefPtr<CefBrowser> browser) = 0;
virtual void OnBrowserWindowClosing() {}
virtual void OnBrowserWindowDestroyed() = 0;
virtual void OnSetAddress(const std::string& url) = 0;
virtual void OnSetTitle(const std::string& title) = 0;
virtual void OnSetFullscreen(bool fullscreen) = 0;
virtual void OnAutoResize(const CefSize& new_size) = 0;
virtual void OnSetLoadingState(bool isLoading,
bool canGoBack,
bool canGoForward) = 0;
virtual void OnSetDraggableRegions(
const std::vector<CefDraggableRegion>& regions) = 0;
protected:
virtual ~Delegate() {}
};
virtual void CreateBrowser(ClientWindowHandle parent_handle,
const CefRect& rect,
const CefBrowserSettings& settings,
CefRefPtr<CefDictionaryValue> extra_info,
CefRefPtr<CefRequestContext> request_context) = 0;
virtual void GetPopupConfig(CefWindowHandle temp_handle,
CefWindowInfo& windowInfo,
CefRefPtr<CefClient>& client,
CefBrowserSettings& settings) = 0;
virtual void ShowPopup(ClientWindowHandle parent_handle,
int x,
int y,
size_t width,
size_t height) = 0;
virtual void Show() = 0;
virtual void Hide() = 0;
virtual void SetBounds(int x, int y, size_t width, size_t height) = 0;
virtual void SetFocus(bool focus) = 0;
virtual void SetDeviceScaleFactor(float device_scale_factor);
virtual float GetDeviceScaleFactor() const;
virtual ClientWindowHandle GetWindowHandle() const = 0;
CefRefPtr<CefBrowser> GetBrowser() const;
bool IsClosing() const;
protected:
friend std::default_delete<BrowserWindow>;
explicit BrowserWindow(Delegate* delegate);
void OnBrowserCreated(CefRefPtr<CefBrowser> browser) override;
void OnBrowserClosing(CefRefPtr<CefBrowser> browser) override;
void OnBrowserClosed(CefRefPtr<CefBrowser> browser) override;
void OnSetAddress(const std::string& url) override;
void OnSetTitle(const std::string& title) override;
void OnSetFullscreen(bool fullscreen) override;
void OnAutoResize(const CefSize& new_size) override;
void OnSetLoadingState(bool isLoading,
bool canGoBack,
bool canGoForward) override;
void OnSetDraggableRegions(
const std::vector<CefDraggableRegion>& regions) override;
Delegate* delegate_;
CefRefPtr<CefBrowser> browser_;
CefRefPtr<ClientHandler> client_handler_;
bool is_closing_;
private:
DISALLOW_COPY_AND_ASSIGN(BrowserWindow);
};
}
#endif