// 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 class SimpleHandler : public CefClient, public CefDisplayHandler, public CefLifeSpanHandler, public CefLoadHandler { public: SimpleHandler(); ~SimpleHandler(); // Provide access to the single global instance of this object. static SimpleHandler* GetInstance(); // CefClient methods: virtual CefRefPtr GetDisplayHandler() override { return this; } virtual CefRefPtr GetLifeSpanHandler() override { return this; } virtual CefRefPtr GetLoadHandler() override { return this; } // CefDisplayHandler methods: virtual void OnTitleChange(CefRefPtr browser, const CefString& title) override; // CefLifeSpanHandler methods: virtual void OnAfterCreated(CefRefPtr browser) override; virtual bool DoClose(CefRefPtr browser) override; virtual void OnBeforeClose(CefRefPtr browser) override; // CefLoadHandler methods: virtual void OnLoadError(CefRefPtr browser, CefRefPtr frame, ErrorCode errorCode, const CefString& errorText, const CefString& failedUrl) override; void ShowMainWindow(); // Request that all existing browser windows close. void CloseAllBrowsers(bool force_close); bool IsClosing() const { return is_closing_; } // Returns true if the Chrome runtime is enabled. static bool IsChromeRuntimeEnabled(); private: // Platform-specific implementation. void PlatformTitleChange(CefRefPtr browser, const CefString& title); void PlatformShowWindow(CefRefPtr browser); // List of existing browser windows. Only accessed on the CEF UI thread. typedef std::list> BrowserList; BrowserList browser_list_; bool is_closing_ = false; // Include the default reference counting implementation. IMPLEMENT_REFCOUNTING(SimpleHandler); }; #endif // CEF_TESTS_CEFSIMPLE_SIMPLE_HANDLER_H_