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 <list>
|
|
|
|
|
2024-04-30 17:45:07 +02:00
|
|
|
#include "include/cef_client.h"
|
|
|
|
|
2013-11-26 23:02:14 +01:00
|
|
|
class SimpleHandler : public CefClient,
|
|
|
|
public CefDisplayHandler,
|
|
|
|
public CefLifeSpanHandler,
|
|
|
|
public CefLoadHandler {
|
|
|
|
public:
|
2024-04-17 18:01:26 +02:00
|
|
|
explicit SimpleHandler(bool is_alloy_style);
|
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_; }
|
|
|
|
|
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
|
|
|
|
2024-04-17 18:01:26 +02:00
|
|
|
// True if this client is Alloy style, otherwise Chrome style.
|
|
|
|
const bool is_alloy_style_;
|
|
|
|
|
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_
|