2013-11-26 23:02:14 +01:00
|
|
|
// Copyright (c) 2013 The Chromium Embedded Framework Authors. All rights
|
|
|
|
// reserved. Use of this source code is governed by a BSD-style license that
|
|
|
|
// can be found in the LICENSE file.
|
|
|
|
|
|
|
|
#ifndef CEF_TESTS_CEFSIMPLE_SIMPLE_HANDLER_H_
|
|
|
|
#define CEF_TESTS_CEFSIMPLE_SIMPLE_HANDLER_H_
|
|
|
|
|
|
|
|
#include "include/cef_client.h"
|
|
|
|
|
|
|
|
#include <list>
|
|
|
|
|
|
|
|
class SimpleHandler : public CefClient,
|
|
|
|
public CefDisplayHandler,
|
|
|
|
public CefLifeSpanHandler,
|
|
|
|
public CefLoadHandler {
|
|
|
|
public:
|
2024-01-29 19:38:25 +01:00
|
|
|
SimpleHandler();
|
2024-01-20 03:22:56 +01:00
|
|
|
~SimpleHandler() override;
|
2013-11-26 23:02:14 +01:00
|
|
|
|
|
|
|
// Provide access to the single global instance of this object.
|
|
|
|
static SimpleHandler* GetInstance();
|
|
|
|
|
|
|
|
// CefClient methods:
|
2024-01-20 03:22:56 +01:00
|
|
|
CefRefPtr<CefDisplayHandler> GetDisplayHandler() override { return this; }
|
|
|
|
CefRefPtr<CefLifeSpanHandler> GetLifeSpanHandler() override { return this; }
|
|
|
|
CefRefPtr<CefLoadHandler> GetLoadHandler() override { return this; }
|
2013-11-26 23:02:14 +01:00
|
|
|
|
|
|
|
// CefDisplayHandler methods:
|
2024-01-20 03:22:56 +01:00
|
|
|
void OnTitleChange(CefRefPtr<CefBrowser> browser,
|
|
|
|
const CefString& title) override;
|
2013-11-26 23:02:14 +01:00
|
|
|
|
|
|
|
// CefLifeSpanHandler methods:
|
2024-01-20 03:22:56 +01:00
|
|
|
void OnAfterCreated(CefRefPtr<CefBrowser> browser) override;
|
|
|
|
bool DoClose(CefRefPtr<CefBrowser> browser) override;
|
|
|
|
void OnBeforeClose(CefRefPtr<CefBrowser> browser) override;
|
2013-11-26 23:02:14 +01:00
|
|
|
|
|
|
|
// CefLoadHandler methods:
|
2024-01-20 03:22:56 +01:00
|
|
|
void OnLoadError(CefRefPtr<CefBrowser> browser,
|
|
|
|
CefRefPtr<CefFrame> frame,
|
|
|
|
ErrorCode errorCode,
|
|
|
|
const CefString& errorText,
|
|
|
|
const CefString& failedUrl) override;
|
2013-11-26 23:02:14 +01:00
|
|
|
|
2024-01-29 19:38:25 +01:00
|
|
|
void ShowMainWindow();
|
|
|
|
|
2013-11-26 23:02:14 +01:00
|
|
|
// Request that all existing browser windows close.
|
|
|
|
void CloseAllBrowsers(bool force_close);
|
|
|
|
|
2014-04-09 20:29:51 +02:00
|
|
|
bool IsClosing() const { return is_closing_; }
|
|
|
|
|
2021-02-15 22:40:07 +01:00
|
|
|
// Returns true if the Chrome runtime is enabled.
|
|
|
|
static bool IsChromeRuntimeEnabled();
|
|
|
|
|
2013-11-26 23:02:14 +01:00
|
|
|
private:
|
2016-01-19 21:09:01 +01:00
|
|
|
// Platform-specific implementation.
|
|
|
|
void PlatformTitleChange(CefRefPtr<CefBrowser> browser,
|
|
|
|
const CefString& title);
|
2024-01-29 19:38:25 +01:00
|
|
|
void PlatformShowWindow(CefRefPtr<CefBrowser> browser);
|
2016-01-19 21:09:01 +01:00
|
|
|
|
2013-11-26 23:02:14 +01:00
|
|
|
// List of existing browser windows. Only accessed on the CEF UI thread.
|
2017-05-17 11:29:28 +02:00
|
|
|
typedef std::list<CefRefPtr<CefBrowser>> BrowserList;
|
2013-11-26 23:02:14 +01:00
|
|
|
BrowserList browser_list_;
|
|
|
|
|
2024-01-20 03:22:56 +01:00
|
|
|
bool is_closing_ = false;
|
2014-04-09 20:29:51 +02:00
|
|
|
|
2013-11-26 23:02:14 +01:00
|
|
|
// Include the default reference counting implementation.
|
|
|
|
IMPLEMENT_REFCOUNTING(SimpleHandler);
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // CEF_TESTS_CEFSIMPLE_SIMPLE_HANDLER_H_
|