重新自行封装libcef

This commit is contained in:
JackLee 2025-03-22 14:37:03 +08:00
parent ee42bc59bc
commit 8fe459cd53
34 changed files with 1 additions and 4545 deletions

View File

@ -1,24 +0,0 @@
//
// CefVersion.h
// CefViewCore
//
// Created by Sheen Tian on 2025/1/19.
// This file was generated during CMake configuring.
// Do not edit this file directly by manual.
// Edit the CefVersion.h.in and then re-config project with CMake.
//
#ifndef CefVersion_h
#define CefVersion_h
#pragma once
// clang-format off
#define CEF_VERSION "134.3.5+g36934eb+chromium-134.0.6998.89"
#define CEF_VERSION_MAJOR 134
#define CEF_VERSION_MINOR 3
#define CEF_VERSION_PATCH 5
#define CEF_COMMIT_NUMBER 3154
#define CEF_COMMIT_HASH "36934ebbc5279631116b9e2b71d8b22acbcd1574"
// clang-format on
#endif // CefVersion

View File

@ -1,129 +0,0 @@
//
// CefViewBrowserApp.h
// CefViewCore
//
// Created by Sheen Tian on 2020/6/11.
//
#ifndef CefViewBrowserApp_h
#define CefViewBrowserApp_h
#pragma once
#pragma region stl_headers
#include <unordered_map>
#include <list>
#pragma endregion
#include <CefViewCoreGlobal.h>
#include <CefViewBrowserAppDelegate.h>
#include <CefViewBrowserClientDelegate.h>
struct FolderResourceMapping
{
CefString path;
CefString url;
int priority;
};
struct ArchiveResourceMapping
{
CefString path;
CefString url;
CefString password;
int priority;
};
class CefViewBrowserApp
: public CefApp
, public CefBrowserProcessHandler
{
IMPLEMENT_REFCOUNTING(CefViewBrowserApp);
private:
// The name of the bridge object
CefString builtin_scheme_name_;
CefString bridge_object_name_;
std::unordered_map<void*, CefViewBrowserClientDelegateInterface::WeakPtr> client_handler_map_;
// The app delegate
CefViewBrowserAppDelegateInterface::WeakPtr app_delegate_;
std::list<FolderResourceMapping> folderResourceMappingList_;
std::list<ArchiveResourceMapping> archiveResourceMappingList_;
public:
CefViewBrowserApp(const CefString& scheme_name,
const CefString& bridge_name,
CefViewBrowserAppDelegateInterface::RefPtr delegate);
~CefViewBrowserApp();
void CheckInClient(void* ctx, const CefViewBrowserClientDelegateInterface::RefPtr& handler);
void CheckOutClient(void* ctx);
CefViewBrowserClientDelegateInterface::RefPtr GetClientHandler(void* ctx);
void AddLocalFolderResource(const CefString& path, const CefString& url, int priority = 0);
const std::list<FolderResourceMapping>& FolderResourceMappingList();
void AddArchiveResource(const CefString& path,
const CefString& url,
const CefString& password = "",
int priority = 0);
const std::list<ArchiveResourceMapping>& ArchiveResourceMappingList();
bool AddGlobalCookie(const CefString& name,
const CefString& value,
const CefString& domain,
const CefString& url);
bool DeleteAllCookies();
bool AddCrossOriginWhitelistEntry(const CefString& sourceOrigin,
const CefString& targetSchema,
const CefString& targetDomain,
bool allowTargetSubdomains);
bool RemoveCrossOriginWhitelistEntry(const CefString& sourceOrigin,
const CefString& targetSchema,
const CefString& targetDomain,
bool allowTargetSubdomains);
bool ClearCrossOriginWhitelistEntry();
bool IsSafeToExit();
private:
#pragma region CefApp
//////////////////////////////////////////////////////////////////////////
// CefApp methods:
virtual void OnBeforeCommandLineProcessing(const CefString& process_type,
CefRefPtr<CefCommandLine> command_line) override;
virtual void OnRegisterCustomSchemes(CefRawPtr<CefSchemeRegistrar> registrar) override;
virtual CefRefPtr<CefResourceBundleHandler> GetResourceBundleHandler() override;
virtual CefRefPtr<CefBrowserProcessHandler> GetBrowserProcessHandler() override;
virtual CefRefPtr<CefRenderProcessHandler> GetRenderProcessHandler() override;
#pragma endregion
#pragma region CefBrowserProcessHandler
//////////////////////////////////////////////////////////////////////////
// CefBrowserProcessHandler methods:
virtual void OnContextInitialized() override;
virtual void OnBeforeChildProcessLaunch(CefRefPtr<CefCommandLine> command_line) override;
virtual void OnScheduleMessagePumpWork(int64_t delay_ms) override;
CefRefPtr<CefClient> GetDefaultClient() override;
#pragma endregion
};
#endif

View File

@ -1,59 +0,0 @@
//
// CefViewBrowserAppDelegate.h
// CefViewCore
//
// Created by Sheen Tian on 2020/6/11.
//
#ifndef CefViewBrowserAppDelegate_h
#define CefViewBrowserAppDelegate_h
#pragma once
#pragma region stl_headers
#include <memory>
#pragma endregion
#include <CefViewCoreGlobal.h>
/// <summary>
///
/// </summary>
class CefViewBrowserAppDelegateInterface
{
public:
/// <summary>
///
/// </summary>
typedef std::shared_ptr<CefViewBrowserAppDelegateInterface> RefPtr;
/// <summary>
///
/// </summary>
typedef std::weak_ptr<CefViewBrowserAppDelegateInterface> WeakPtr;
/// <summary>
///
/// </summary>
virtual ~CefViewBrowserAppDelegateInterface(){};
/// <summary>
///
/// </summary>
/// <param name="process_type"></param>
/// <param name="command_line"></param>
virtual void onBeforeCommandLineProcessing(const CefString& process_type, CefRefPtr<CefCommandLine> command_line) = 0;
/// <summary>
///
/// </summary>
/// <param name="command_line"></param>
virtual void onBeforeChildProcessLaunch(CefRefPtr<CefCommandLine> command_line) = 0;
/// <summary>
///
/// </summary>
/// <param name="delay_ms"></param>
virtual void onScheduleMessageLoopWork(int64_t delay_ms) = 0;
};
#endif

View File

@ -1,477 +0,0 @@
//
// CefViewBrowserClient.h
// CefViewCore
//
// Created by Sheen Tian on 2020/6/11.
//
#ifndef CefViewBrowserHandler_h
#define CefViewBrowserHandler_h
#pragma once
#pragma region stl_headers
#include <unordered_map>
#pragma endregion
#include <CefViewCoreGlobal.h>
#include <CefViewBrowserApp.h>
#include <CefViewBrowserClientDelegate.h>
#if CEF_VERSION_MAJOR < 122
#define CEFVIEW_MAIN_FRAME (0)
#define CEFVIEW_ALL_FRAMES (-1)
#else
#define CEFVIEW_MAIN_FRAME ("0")
#define CEFVIEW_ALL_FRAMES ("-1")
#endif
/// <summary>
/// Forward declaration
/// </summary>
class CefViewQueryHandler;
/// <summary>
///
/// </summary>
class CefViewBrowserClient
: public CefClient
, public CefContextMenuHandler
, public CefDialogHandler
, public CefDisplayHandler
, public CefDownloadHandler
, public CefDragHandler
, public CefFindHandler
, public CefFocusHandler
, public CefJSDialogHandler
, public CefKeyboardHandler
, public CefLifeSpanHandler
, public CefLoadHandler
, public CefRequestHandler
, public CefResourceRequestHandler
, public CefRenderHandler
{
IMPLEMENT_REFCOUNTING(CefViewBrowserClient);
private:
/// <summary>
///
/// </summary>
CefRefPtr<CefViewBrowserApp> app_;
/// <summary>
///
/// </summary>
CefViewBrowserClientDelegateInterface::WeakPtr client_delegate_;
// flags
bool is_closing_;
bool close_by_native_;
bool initial_navigation_;
// message router
CefMessageRouterConfig message_router_config_;
CefRefPtr<CefMessageRouterBrowserSide> message_router_;
CefRefPtr<CefViewQueryHandler> message_router_handler_;
// resource manager
CefRefPtr<CefResourceManager> resource_manager_;
// browser map
std::unordered_map<int, CefRefPtr<CefBrowser>> browser_map_;
public:
/// <summary>
///
/// </summary>
/// <param name="app_"></param>
/// <param name="delegate"></param>
CefViewBrowserClient(CefRefPtr<CefViewBrowserApp> app, CefViewBrowserClientDelegateInterface::RefPtr delegate);
/// <summary>
///
/// </summary>
~CefViewBrowserClient();
/// <summary>
///
/// </summary>
/// <returns></returns>
int GetBrowserCount() { return static_cast<int>(browser_map_.size()); }
/// <summary>
///
/// </summary>
void CloseAllBrowsers();
/// <summary>
///
/// </summary>
/// <param name="dir_path"></param>
/// <param name="url"></param>
/// <param name="priority"></param>
void AddLocalDirectoryResourceProvider(const CefString& dir_path, const CefString& url, int priority = 0);
/// <summary>
///
/// </summary>
/// <param name="archive_path"></param>
/// <param name="url"></param>
/// <param name="password"></param>
/// <param name="priority"></param>
void AddArchiveResourceProvider(const CefString& archive_path,
const CefString& url,
const CefString& password,
int priority = 0);
bool TriggerEvent(CefRefPtr<CefBrowser> browser, const CefFrameId& frame_id, const CefRefPtr<CefProcessMessage> msg);
/// <summary>
///
/// </summary>
/// <param name="query"></param>
/// <param name="success"></param>
/// <param name="response"></param>
/// <param name="error"></param>
/// <returns></returns>
bool ResponseQuery(const int64_t query, bool success, const CefString& response, int error);
/// <summary>
///
/// </summary>
/// <param name="browser"></param>
/// <param name="frame"></param>
/// <param name="code"></param>
/// <param name="url"></param>
/// <param name="context"></param>
/// <returns></returns>
bool AsyncExecuteJSCode(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
const CefString& code,
const CefString& url,
const CefString& context);
protected:
bool DispatchRenderMessage(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefProcessMessage> message);
bool OnRenderFocusedNodeChangedMessage(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefProcessMessage> message);
bool OnRenderInvokeMethodMessage(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefProcessMessage> message);
bool OnRenderReportJSResultMessage(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefProcessMessage> message);
// CefClient methods:
#pragma region CefContextMenuHandler
virtual bool OnProcessMessageReceived(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefProcessId source_process,
CefRefPtr<CefProcessMessage> message) override;
#pragma endregion
// CefContextMenuHandler methods
#pragma region CefContextMenuHandler
virtual CefRefPtr<CefContextMenuHandler> GetContextMenuHandler() override;
virtual void OnBeforeContextMenu(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefContextMenuParams> params,
CefRefPtr<CefMenuModel> model) override;
virtual bool RunContextMenu(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefContextMenuParams> params,
CefRefPtr<CefMenuModel> model,
CefRefPtr<CefRunContextMenuCallback> callback) override;
virtual bool OnContextMenuCommand(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefContextMenuParams> params,
int command_id,
EventFlags event_flags) override;
virtual void OnContextMenuDismissed(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame) override;
#pragma endregion
// CefDialogHandler
#pragma region CefDialogHandler
virtual CefRefPtr<CefDialogHandler> GetDialogHandler() override;
#if CEF_VERSION_MAJOR < 102
virtual bool OnFileDialog(CefRefPtr<CefBrowser> browser,
FileDialogMode mode,
const CefString& title,
const CefString& default_file_path,
const std::vector<CefString>& accept_filters,
int selected_accept_filter,
CefRefPtr<CefFileDialogCallback> callback) override;
#elif CEF_VERSION_MAJOR < 126
virtual bool OnFileDialog(CefRefPtr<CefBrowser> browser,
FileDialogMode mode,
const CefString& title,
const CefString& default_file_path,
const std::vector<CefString>& accept_filters,
CefRefPtr<CefFileDialogCallback> callback) override;
#else
virtual bool OnFileDialog(CefRefPtr<CefBrowser> browser,
FileDialogMode mode,
const CefString& title,
const CefString& default_file_path,
const std::vector<CefString>& accept_filters,
const std::vector<CefString>& accept_extensions,
const std::vector<CefString>& accept_descriptions,
CefRefPtr<CefFileDialogCallback> callback) override;
#endif
#pragma endregion
// CefDisplayHandler methods
#pragma region CefDisplayHandler
virtual CefRefPtr<CefDisplayHandler> GetDisplayHandler() override;
virtual void OnAddressChange(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, const CefString& url) override;
virtual void OnTitleChange(CefRefPtr<CefBrowser> browser, const CefString& title) override;
virtual void OnFaviconURLChange(CefRefPtr<CefBrowser> browser, const std::vector<CefString>& icon_urls) override;
virtual void OnFullscreenModeChange(CefRefPtr<CefBrowser> browser, bool fullscreen) override;
virtual bool OnTooltip(CefRefPtr<CefBrowser> browser, CefString& text) override;
virtual void OnStatusMessage(CefRefPtr<CefBrowser> browser, const CefString& value) override;
virtual bool OnConsoleMessage(CefRefPtr<CefBrowser> browser,
cef_log_severity_t level,
const CefString& message,
const CefString& source,
int line) override;
virtual bool OnAutoResize(CefRefPtr<CefBrowser> browser, const CefSize& new_size) override;
virtual void OnLoadingProgressChange(CefRefPtr<CefBrowser> browser, double progress) override;
virtual bool OnCursorChange(CefRefPtr<CefBrowser> browser,
CefCursorHandle cursor,
cef_cursor_type_t type,
const CefCursorInfo& custom_cursor_info) override;
#pragma endregion
// CefDownloadHandler
#pragma region CefDownloadHandler
virtual CefRefPtr<CefDownloadHandler> GetDownloadHandler() override;
#if CEF_VERSION_MAJOR < 125
virtual void OnBeforeDownload(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefDownloadItem> download_item,
const CefString& suggested_name,
CefRefPtr<CefBeforeDownloadCallback> callback) override;
#else
virtual bool OnBeforeDownload(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefDownloadItem> download_item,
const CefString& suggested_name,
CefRefPtr<CefBeforeDownloadCallback> callback) override;
#endif
void OnDownloadUpdated(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefDownloadItem> download_item,
CefRefPtr<CefDownloadItemCallback> callback) override;
#pragma endregion
// CefDragHandler methods
#pragma region CefDragHandler
virtual CefRefPtr<CefDragHandler> GetDragHandler() override;
virtual bool OnDragEnter(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefDragData> dragData,
CefDragHandler::DragOperationsMask mask) override;
virtual void OnDraggableRegionsChanged(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
const std::vector<CefDraggableRegion>& regions) override;
#pragma endregion
// CefFindHandler methods
#pragma region CefFindHandler
virtual CefRefPtr<CefFindHandler> GetFindHandler() override;
virtual void OnFindResult(CefRefPtr<CefBrowser> browser,
int identifier,
int count,
const CefRect& selectionRect,
int activeMatchOrdinal,
bool finalUpdate) override;
#pragma endregion
// CefFocusHandler methods
#pragma region CefFocusHandler
virtual CefRefPtr<CefFocusHandler> GetFocusHandler() override;
void OnTakeFocus(CefRefPtr<CefBrowser> browser, bool next) override;
bool OnSetFocus(CefRefPtr<CefBrowser> browser, FocusSource source) override;
void OnGotFocus(CefRefPtr<CefBrowser> browser) override;
#pragma endregion
// CefJSDialogHandler methods
#pragma region CefJSDialogHandler
virtual CefRefPtr<CefJSDialogHandler> GetJSDialogHandler() override;
virtual bool OnJSDialog(CefRefPtr<CefBrowser> browser,
const CefString& origin_url,
JSDialogType dialog_type,
const CefString& message_text,
const CefString& default_prompt_text,
CefRefPtr<CefJSDialogCallback> callback,
bool& suppress_message) override;
virtual bool OnBeforeUnloadDialog(CefRefPtr<CefBrowser> browser,
const CefString& message_text,
bool is_reload,
CefRefPtr<CefJSDialogCallback> callback) override;
virtual void OnResetDialogState(CefRefPtr<CefBrowser> browser) override;
virtual void OnDialogClosed(CefRefPtr<CefBrowser> browser) override;
#pragma endregion
// CefKeyboardHandler methods
#pragma region CefKeyboardHandler
virtual CefRefPtr<CefKeyboardHandler> GetKeyboardHandler() override;
virtual bool OnPreKeyEvent(CefRefPtr<CefBrowser> browser,
const CefKeyEvent& event,
CefEventHandle os_event,
bool* is_keyboard_shortcut) override;
virtual bool OnKeyEvent(CefRefPtr<CefBrowser> browser, const CefKeyEvent& event, CefEventHandle os_event) override;
#pragma endregion
// CefLifeSpanHandler methods:
#pragma region CefLifeSpanHandler
virtual CefRefPtr<CefLifeSpanHandler> GetLifeSpanHandler() override;
virtual bool OnBeforePopup(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
#if CEF_VERSION_MAJOR > 131
int popup_id,
#endif
const CefString& target_url,
const CefString& target_frame_name,
CefLifeSpanHandler::WindowOpenDisposition target_disposition,
bool user_gesture,
const CefPopupFeatures& popupFeatures,
CefWindowInfo& windowInfo,
CefRefPtr<CefClient>& client,
CefBrowserSettings& settings,
CefRefPtr<CefDictionaryValue>& extra_info,
bool* no_javascript_access) override;
virtual void OnAfterCreated(CefRefPtr<CefBrowser> browser) override;
virtual bool DoClose(CefRefPtr<CefBrowser> browser) override;
virtual void OnBeforeClose(CefRefPtr<CefBrowser> browser) override;
#pragma endregion
// CefLoadHandler methods
#pragma region CefLoadHandler
virtual CefRefPtr<CefLoadHandler> GetLoadHandler() override;
virtual void OnLoadingStateChange(CefRefPtr<CefBrowser> browser,
bool isLoading,
bool canGoBack,
bool canGoForward) override;
virtual void OnLoadStart(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
TransitionType transition_type) override;
virtual void OnLoadEnd(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, int httpStatusCode) override;
virtual void OnLoadError(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
ErrorCode errorCode,
const CefString& errorText,
const CefString& failedUrl) override;
#pragma endregion
// CefRenderHandler
#pragma region CefRenderHandler
virtual CefRefPtr<CefRenderHandler> GetRenderHandler() override;
virtual CefRefPtr<CefAccessibilityHandler> GetAccessibilityHandler() override;
virtual bool GetRootScreenRect(CefRefPtr<CefBrowser> browser, CefRect& rect) override;
virtual void GetViewRect(CefRefPtr<CefBrowser> browser, CefRect& rect) override;
virtual bool GetScreenPoint(CefRefPtr<CefBrowser> browser, int viewX, int viewY, int& screenX, int& screenY) override;
virtual bool GetScreenInfo(CefRefPtr<CefBrowser> browser, CefScreenInfo& screen_info) override;
virtual void OnPopupShow(CefRefPtr<CefBrowser> browser, bool show) override;
virtual void OnPopupSize(CefRefPtr<CefBrowser> browser, const CefRect& rect) override;
virtual void OnPaint(CefRefPtr<CefBrowser> browser,
PaintElementType type,
const RectList& dirtyRects,
const void* buffer,
int width,
int height) override;
#if CEF_VERSION_MAJOR < 124
virtual void OnAcceleratedPaint(CefRefPtr<CefBrowser> browser,
PaintElementType type,
const RectList& dirtyRects,
void* shared_handle) override;
#else
virtual void OnAcceleratedPaint(CefRefPtr<CefBrowser> browser,
PaintElementType type,
const RectList& dirtyRects,
const CefAcceleratedPaintInfo& info) override;
#endif
virtual bool StartDragging(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefDragData> drag_data,
CefRenderHandler::DragOperationsMask allowed_ops,
int x,
int y) override;
virtual void UpdateDragCursor(CefRefPtr<CefBrowser> browser, DragOperation operation) override;
virtual void OnScrollOffsetChanged(CefRefPtr<CefBrowser> browser, double x, double y) override;
virtual void OnImeCompositionRangeChanged(CefRefPtr<CefBrowser> browser,
const CefRange& selected_range,
const RectList& character_bounds) override;
virtual void OnTextSelectionChanged(CefRefPtr<CefBrowser> browser,
const CefString& selected_text,
const CefRange& selected_range) override;
virtual void OnVirtualKeyboardRequested(CefRefPtr<CefBrowser> browser, TextInputMode input_mode) override;
#pragma endregion
// CefRequestHandler methods
#pragma region CefRequestHandler
virtual CefRefPtr<CefRequestHandler> GetRequestHandler() override;
virtual bool OnBeforeBrowse(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefRequest> request,
bool user_gesture,
bool is_redirect) override;
virtual bool OnOpenURLFromTab(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
const CefString& target_url,
CefRequestHandler::WindowOpenDisposition target_disposition,
bool user_gesture) override;
#if CEF_VERSION_MAJOR > 91 && CEF_VERSION_MAJOR < 109
virtual bool OnQuotaRequest(CefRefPtr<CefBrowser> browser,
const CefString& origin_url,
int64 new_size,
CefRefPtr<CefCallback> callback) override;
#endif
#if CEF_VERSION_MAJOR < 124
virtual void OnRenderProcessTerminated(CefRefPtr<CefBrowser> browser, TerminationStatus status) override;
#else
virtual void OnRenderProcessTerminated(CefRefPtr<CefBrowser> browser,
TerminationStatus status,
int error_code,
const CefString& error_string) override;
#endif
#pragma endregion
// CefResourceRequestHandler
#pragma region CefResourceRequestHandler
virtual CefRefPtr<CefResourceRequestHandler> GetResourceRequestHandler(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefRequest> request,
bool is_navigation,
bool is_download,
const CefString& request_initiator,
bool& disable_default_handling) override;
virtual ReturnValue OnBeforeResourceLoad(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefRequest> request,
#if CEF_VERSION_MAJOR > 91
CefRefPtr<CefCallback> callback
#else
CefRefPtr<CefRequestCallback> callback
#endif
) override;
virtual CefRefPtr<CefResourceHandler> GetResourceHandler(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefRequest> request) override;
virtual void OnProtocolExecution(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefRequest> request,
bool& allow_os_execution) override;
#pragma endregion
};
#endif

View File

@ -1,311 +0,0 @@
//
// CefViewBrowserHandlerDelegate.h
// CefViewCore
//
// Created by Sheen Tian on 2020/6/11.
//
#ifndef CefViewBrowserHandlerDelegate_h
#define CefViewBrowserHandlerDelegate_h
#pragma once
#pragma region stl_headers
#include <memory>
#pragma endregion
#include <CefViewCoreGlobal.h>
/// <summary>
///
/// </summary>
class CefViewBrowserClientDelegateInterface
{
public:
/// <summary>
///
/// </summary>
typedef std::shared_ptr<CefViewBrowserClientDelegateInterface> RefPtr;
/// <summary>
///
/// </summary>
typedef std::weak_ptr<CefViewBrowserClientDelegateInterface> WeakPtr;
/// <summary>
///
/// </summary>
virtual ~CefViewBrowserClientDelegateInterface() {}
/// <summary>
///
/// </summary>
/// <param name="browser"></param>
/// <param name="frame"></param>
/// <param name="url"></param>
virtual void processUrlRequest(CefRefPtr<CefBrowser>& browser, CefRefPtr<CefFrame>& frame, const CefString& url) = 0;
/// <summary>
///
/// </summary>
/// <param name="browser"></param>
/// <param name="frame"></param>
/// <param name="query"></param>
/// <param name="query_id"></param>
virtual void processQueryRequest(CefRefPtr<CefBrowser>& browser,
CefRefPtr<CefFrame>& frame,
const CefString& query,
const int64_t query_id) = 0;
/// <summary>
///
/// </summary>
/// <param name="browser"></param>
/// <param name="frame"></param>
/// <param name="focusOnEditableNode"></param>
virtual void focusedEditableNodeChanged(CefRefPtr<CefBrowser>& browser,
CefRefPtr<CefFrame>& frame,
bool focusOnEditableNode) = 0;
/// <summary>
///
/// </summary>
/// <param name="browser"></param>
/// <param name="frame"></param>
/// <param name="method"></param>
/// <param name="arguments"></param>
virtual void invokeMethodNotify(CefRefPtr<CefBrowser>& browser,
CefRefPtr<CefFrame>& frame,
const CefString& method,
const CefRefPtr<CefListValue>& arguments) = 0;
/// <summary>
///
/// </summary>
/// <param name="browser"></param>
/// <param name="frame"></param>
/// <param name="context"></param>
/// <param name="result"></param>
virtual void reportJSResult(CefRefPtr<CefBrowser>& browser,
CefRefPtr<CefFrame>& frame,
const CefString& context,
const CefRefPtr<CefValue>& result) = 0;
// context menu handler
#pragma region ContextMenuHandler
virtual void onBeforeContextMenu(CefRefPtr<CefBrowser>& browser,
CefRefPtr<CefFrame>& frame,
CefRefPtr<CefContextMenuParams>& params,
CefRefPtr<CefMenuModel>& model) = 0;
virtual bool onRunContextMenu(CefRefPtr<CefBrowser>& browser,
CefRefPtr<CefFrame>& frame,
CefRefPtr<CefContextMenuParams>& params,
CefRefPtr<CefMenuModel>& model,
CefRefPtr<CefRunContextMenuCallback>& callback) = 0;
virtual bool onContextMenuCommand(CefRefPtr<CefBrowser>& browser,
CefRefPtr<CefFrame>& frame,
CefRefPtr<CefContextMenuParams>& params,
int command_id,
CefContextMenuHandler::EventFlags event_flags) = 0;
virtual void onContextMenuDismissed(CefRefPtr<CefBrowser>& browser, CefRefPtr<CefFrame>& frame) = 0;
#pragma endregion
// dialog handler
#pragma region DialogHandler
virtual bool onFileDialog(CefRefPtr<CefBrowser>& browser,
CefBrowserHost::FileDialogMode mode,
const CefString& title,
const CefString& default_file_path,
const std::vector<CefString>& accept_filters,
#if CEF_VERSION_MAJOR < 102
int selected_accept_filter,
#endif
CefRefPtr<CefFileDialogCallback>& callback)
{
return false;
};
#pragma endregion
// display handler
#pragma region DisplayHandler
virtual void addressChanged(CefRefPtr<CefBrowser>& browser, CefRefPtr<CefFrame>& frame, const CefString& url) = 0;
virtual void titleChanged(CefRefPtr<CefBrowser>& browser, const CefString& title) = 0;
virtual void faviconURLChanged(CefRefPtr<CefBrowser>& browser, const std::vector<CefString>& icon_urls) = 0;
virtual bool tooltipMessage(CefRefPtr<CefBrowser>& browser, const CefString& text) = 0;
virtual void fullscreenModeChanged(CefRefPtr<CefBrowser>& browser, bool fullscreen) = 0;
virtual void statusMessage(CefRefPtr<CefBrowser>& browser, const CefString& value) = 0;
virtual void loadingProgressChanged(CefRefPtr<CefBrowser>& browser, double progress) = 0;
virtual void consoleMessage(CefRefPtr<CefBrowser>& browser, const CefString& message, int level) = 0;
virtual bool cursorChanged(CefRefPtr<CefBrowser>& browser,
CefCursorHandle cursor,
cef_cursor_type_t type,
const CefCursorInfo& custom_cursor_info) = 0;
#pragma endregion
// download hander
#pragma region DownloadHandler
virtual void onBeforeDownload(CefRefPtr<CefBrowser>& browser,
CefRefPtr<CefDownloadItem>& download_item,
const CefString& suggested_name,
CefRefPtr<CefBeforeDownloadCallback>& callback) = 0;
virtual void onDownloadUpdated(CefRefPtr<CefBrowser>& browser,
CefRefPtr<CefDownloadItem>& download_item,
CefRefPtr<CefDownloadItemCallback>& callback) = 0;
#pragma endregion
// drag hander
#pragma region DragHandler
virtual bool onDragEnter(CefRefPtr<CefBrowser>& browser,
CefRefPtr<CefDragData>& dragData,
CefDragHandler::DragOperationsMask mask)
{
return true;
}
virtual void draggableRegionChanged(CefRefPtr<CefBrowser>& browser,
CefRefPtr<CefFrame>& frame,
const std::vector<CefDraggableRegion>& regions) = 0;
#pragma endregion
// focus handler
#pragma region FocusHandler
virtual void takeFocus(CefRefPtr<CefBrowser>& browser, bool next) = 0;
virtual bool setFocus(CefRefPtr<CefBrowser>& browser) = 0;
virtual void gotFocus(CefRefPtr<CefBrowser>& browser) = 0;
#pragma endregion
// JS dialog handler
#pragma region JSDialogHandler
virtual bool onJSDialog(CefRefPtr<CefBrowser>& browser,
const CefString& origin_url,
CefJSDialogHandler::JSDialogType dialog_type,
const CefString& message_text,
const CefString& default_prompt_text,
CefRefPtr<CefJSDialogCallback>& callback,
bool& suppress_message) = 0;
virtual bool onBeforeUnloadDialog(CefRefPtr<CefBrowser>& browser,
const CefString& message_text,
bool is_reload,
CefRefPtr<CefJSDialogCallback>& callback) = 0;
virtual void onResetDialogState(CefRefPtr<CefBrowser>& browser) = 0;
virtual void onDialogClosed(CefRefPtr<CefBrowser>& browser) = 0;
#pragma endregion
// keyboard handler
#pragma region KeyboardHandler
virtual bool onPreKeyEvent(CefRefPtr<CefBrowser>& browser,
const CefKeyEvent& event,
CefEventHandle os_event,
bool* is_keyboard_shortcut) = 0;
virtual bool onKeyEvent(CefRefPtr<CefBrowser>& browser, const CefKeyEvent& event, CefEventHandle os_event) = 0;
#pragma endregion
// life span handler
#pragma region LifeSpanHandler
virtual bool onBeforePopup(CefRefPtr<CefBrowser>& browser,
CefRefPtr<CefFrame>& frame,
const CefString& targetUrl,
const CefString& targetFrameName,
CefLifeSpanHandler::WindowOpenDisposition targetDisposition,
CefWindowInfo& windowInfo,
CefBrowserSettings& settings,
bool& DisableJavascriptAccess) = 0;
virtual void onAfterCreate(CefRefPtr<CefBrowser>& browser) = 0;
virtual bool doClose(CefRefPtr<CefBrowser>& browser) = 0;
virtual bool requestClose(CefRefPtr<CefBrowser>& browser) = 0;
virtual void onBeforeClose(CefRefPtr<CefBrowser>& browser) = 0;
#pragma endregion
// load handler
#pragma region LoadHandler
virtual void loadingStateChanged(CefRefPtr<CefBrowser>& browser,
bool isLoading,
bool canGoBack,
bool canGoForward) = 0;
virtual void loadStart(CefRefPtr<CefBrowser>& browser, CefRefPtr<CefFrame>& frame, int transition_type) = 0;
virtual void loadEnd(CefRefPtr<CefBrowser>& browser, CefRefPtr<CefFrame>& frame, int httpStatusCode) = 0;
virtual void loadError(CefRefPtr<CefBrowser>& browser,
CefRefPtr<CefFrame>& frame,
int errorCode,
const CefString& errorMsg,
const CefString& failedUrl,
bool& handled) = 0;
#pragma endregion
// Off screen rendering
#pragma region RenderHandler
virtual bool getRootScreenRect(CefRefPtr<CefBrowser>& browser, CefRect& rect) { return false; }
virtual void getViewRect(CefRefPtr<CefBrowser>& browser, CefRect& rect) {}
virtual bool getScreenPoint(CefRefPtr<CefBrowser>& browser, int viewX, int viewY, int& screenX, int& screenY)
{
return false;
}
virtual bool getScreenInfo(CefRefPtr<CefBrowser>& browser, CefScreenInfo& screen_info) { return false; }
virtual void onPopupShow(CefRefPtr<CefBrowser>& browser, bool show) {}
virtual void onPopupSize(CefRefPtr<CefBrowser>& browser, const CefRect& rect) {}
virtual void onPaint(CefRefPtr<CefBrowser>& browser,
CefRenderHandler::PaintElementType type,
const CefRenderHandler::RectList& dirtyRects,
const void* buffer,
int width,
int height)
{
}
#if CEF_VERSION_MAJOR < 124
virtual void onAcceleratedPaint(CefRefPtr<CefBrowser>& browser,
CefRenderHandler::PaintElementType type,
const CefRenderHandler::RectList& dirtyRects,
void* shared_handle)
{
}
#else
virtual void onAcceleratedPaint(CefRefPtr<CefBrowser>& browser,
CefRenderHandler::PaintElementType type,
const CefRenderHandler::RectList& dirtyRects,
const CefAcceleratedPaintInfo& info)
{
}
#endif
virtual bool startDragging(CefRefPtr<CefBrowser>& browser,
CefRefPtr<CefDragData>& drag_data,
CefRenderHandler::DragOperationsMask allowed_ops,
int x,
int y)
{
return false;
}
virtual void updateDragCursor(CefRefPtr<CefBrowser>& browser, CefRenderHandler::DragOperation operation) {}
virtual void onScrollOffsetChanged(CefRefPtr<CefBrowser>& browser, double x, double y) {}
virtual void onImeCompositionRangeChanged(CefRefPtr<CefBrowser>& browser,
const CefRange& selected_range,
const CefRenderHandler::RectList& character_bounds)
{
}
virtual void onTextSelectionChanged(CefRefPtr<CefBrowser>& browser,
const CefString& selected_text,
const CefRange& selected_range)
{
}
virtual void onVirtualKeyboardRequested(CefRefPtr<CefBrowser>& browser, CefRenderHandler::TextInputMode input_mode) {}
#pragma endregion
};
#endif

View File

@ -1,44 +0,0 @@
//
// CefViewCoreGlobal.h
// CefViewCore
//
// Created by Sheen Tian on 2023/5/30.
//
#ifndef CefViewCoreGlobal_h
#define CefViewCoreGlobal_h
#pragma once
#pragma region stl_headers
#include <string>
#include <type_traits>
#pragma endregion
#pragma region cef_headers
#include <include/cef_app.h>
#include <include/cef_client.h>
#include <include/cef_version.h>
#include <include/cef_parser.h>
#include <include/wrapper/cef_helpers.h>
#include <include/wrapper/cef_message_router.h>
#include <include/wrapper/cef_resource_manager.h>
#pragma endregion
#if CEF_VERSION_MAJOR < 122
using CefFrameId = int64_t;
#else
using CefFrameId = CefString;
template<>
struct std::hash<CefFrameId>
{
std::size_t operator()(const CefFrameId& k) const
{
using std::hash;
using std::string;
return std::hash<std::string>()(k.ToString());
}
};
#endif // CEF_VERSION_MAJOR < 122
#endif // CefViewCoreGlobal_h

View File

@ -1,135 +0,0 @@
//
// CefViewCoreProtocol.h
// CefViewCore
//
// Created by Sheen Tian on 2020/6/11.
// This file was generated during CMake configuring.
// Do not edit this file directly by manual.
// Edit the CefViewCoreProtocol.h.in and then re-config project with CMake.
//
#ifndef CefViewCoreProtocol_h
#define CefViewCoreProtocol_h
#pragma once
/// <summary>
/// CefView Helper Process Name
/// </summary>
#define kCefViewRenderProcessName "CefViewWing"
/// <summary>
///
/// </summary>
#define kCefViewQueryFuntionName "cefViewQuery"
/// <summary>
///
/// </summary>
#define kCefViewQueryCancelFunctionName "cefViewQueryCancel"
/// <summary>
///
/// </summary>
#define kCefViewBridgeObjectNameKey "bridge-obj-name"
/// <summary>
///
/// </summary>
#define kCefViewBuiltinSchemeNameKey "builtin-scheme-name"
/// <summary>
///
/// </summary>
#define kCefViewWindowsJobNameKey "windows-job-name"
/// <summary>
///
/// </summary>
#define kCefViewDefaultBridgeObjectName "CefViewClient"
/// <summary>
///
/// </summary>
#define kCefViewDefaultBuiltinSchemaName "CefView"
/// <summary>
/// CEFVIEWClient.invokeMethod("method_name", ...)
/// </summary>
#define kCefViewInvokeMethodFunctionName "invoke"
/// <summary>
/// CEFVIEWClient.addEventListener(type, listener)
/// </summary>
#define kCefViewAddEventListenerFunctionName "addEventListener"
/// <summary>
/// CEFVIEWClient.removeEventListener(type, listener)
/// </summary>
#define kCefViewRemoveEventListenerFunctionName "removeEventListener"
/// <summary>
/// this message is sent from render process to browser process
/// and is processed in the Qt UI thread
///
/// </summary>
#define kCefViewClientRenderFocusedNodeChangedMessage "CefViewClientRender.FocusedNodeChanged"
/// <summary>
/// this message is sent from render process to browser process
/// and is processed in the Qt UI thread
///
/// </summary>
#define kCefViewClientRenderReportJSResultMessage "CefViewClientRender.ReportJSResult"
/// <summary>
/// this message is sent from render process to browser process
/// and is processed in the Qt UI thread
///
/// format
/// msg.name
/// msg.arg[0]: function name
/// msg.arg[1~...]: function parameters
/// </summary>
#define kCefViewClientRenderInvokeMethodMessage "CefViewClientRender.InvokeMethod"
/// <summary>
/// this message is sent from browser process to render process
/// and is processed in the CefRenderer_Main thread
///
/// format:
/// msg.name:
/// msg.arg[0]: function name
/// msg.arg[1~...]: function parameters
/// </summary>
#define kCefViewClientBrowserTriggerEventMessage "CefViewClientBrowser.TriggerEvent"
/// <summary>
/// window.__cefview_report_js_result__(context, result)
/// context must be double
/// </summary>
#define kCefViewReportJSResultFunctionName "__cefview_report_js_result__"
/// <summary>
///
/// </summary>
#define kCefViewResourceDirectoryName "resources"
/// <summary>
///
/// </summary>
#define kCefViewLocalesDirectoryName "locales"
/// <summary>
///
/// </summary>
#if defined(OS_WINDOWS)
#define kCefViewDefaultUserAgent "CefView/1.0 (Windows; en-us)"
#elif defined(OS_MACOS)
#define kCefViewDefaultUserAgent "CefView/1.0 (macOS; en-us)"
#elif defined(OS_LINUX)
#define kCefViewDefaultUserAgent "CefView/1.0 (Linux; en-us)"
#else
#define kCefViewDefaultUserAgent "CefView/1.0 (Unknown; en-us)"
#endif
#endif

Binary file not shown.

View File

@ -1,24 +0,0 @@
//
// CefVersion.h
// CefViewCore
//
// Created by Sheen Tian on 2025/1/19.
// This file was generated during CMake configuring.
// Do not edit this file directly by manual.
// Edit the CefVersion.h.in and then re-config project with CMake.
//
#ifndef CefVersion_h
#define CefVersion_h
#pragma once
// clang-format off
#define CEF_VERSION "134.3.5+g36934eb+chromium-134.0.6998.89"
#define CEF_VERSION_MAJOR 134
#define CEF_VERSION_MINOR 3
#define CEF_VERSION_PATCH 5
#define CEF_COMMIT_NUMBER 3154
#define CEF_COMMIT_HASH "36934ebbc5279631116b9e2b71d8b22acbcd1574"
// clang-format on
#endif // CefVersion

View File

@ -1,320 +0,0 @@
/*
* File: QCefConfig.h
* Project: QCefView
* Created: 21nd January 2021
* Author: Sheen
* Source: https://github.com/cefview/qcefview
* Docs: https://cefview.github.io/QCefView/
*/
#ifndef QCEFCONFIG_H
#define QCEFCONFIG_H
#pragma once
#include <QCefView_global.h>
#pragma region qt_headers
#include <QColor>
#include <QScopedPointer>
#include <QString>
#include <QVariant>
#pragma endregion
class QCefConfigPrivate;
/// <summary>
/// Represents the CEF setting. For more details please refer to:
/// https://bitbucket.org/chromiumembedded/cef/wiki/GeneralUsage.md#markdown-header-cefsettings
/// </summary>
class QCEFVIEW_EXPORT QCefConfig
{
Q_DECLARE_PRIVATE(QCefConfig)
QScopedPointer<QCefConfigPrivate> d_ptr;
public:
/// <summary>
/// Represents the log severity
/// </summary>
enum LogLevel
{
/// Default logging (currently INFO logging)
LOGSEVERITY_DEFAULT,
/// Verbose logging
LOGSEVERITY_VERBOSE,
/// DEBUG logging
LOGSEVERITY_DEBUG,
/// INFO logging
LOGSEVERITY_INFO,
/// WARNING logging
LOGSEVERITY_WARNING,
/// ERROR logging
LOGSEVERITY_ERROR,
/// FATAL logging
LOGSEVERITY_FATAL,
/// Disable logging to file for all messages, and to stderr for messages with severity less than FATAL
LOGSEVERITY_DISABLE = 99
};
public:
/// <summary>
/// Constructs a CEF config instance
/// </summary>
QCefConfig();
/// <summary>
/// Constructs a CEF setting from existing one
/// </summary>
QCefConfig(const QCefConfig& other);
/// <summary>
/// Assigns an existing config to current
/// </summary>
QCefConfig& operator=(const QCefConfig& other);
/// <summary>
/// Destructs the config
/// </summary>
~QCefConfig();
/// <summary>
/// Adds a switch to the commandline args used to initialize the CEF
/// </summary>
/// <param name="smitch">The switch name</param>
void addCommandLineSwitch(const QString& smitch);
/// <summary>
/// Adds a switch with value to the commandline args used to initialize the CEF
/// </summary>
/// <param name="smitch">The swtich name</param>
/// <param name="v">The switch value</param>
void addCommandLineSwitchWithValue(const QString& smitch, const QString& v);
/// <summary>
/// Sets the flag to enable/disable OSR mode
/// </summary>
/// <param name="enabled">True to enable OSR mode, false to disable</param>
void setWindowlessRenderingEnabled(const bool enabled);
/// <summary>
/// Gets the OSR mode flag
/// </summary>
/// <returns>The flag indicates the enable/disable of OSR mode</returns>
const QVariant WindowlessRenderingEnabled() const;
#if !defined(Q_OS_MACOS)
/// <summary>
/// Sets the browser subprocess path
/// </summary>
/// <param name="path">The path to the sub process executable</param>
void setBrowserSubProcessPath(const QString& path);
/// <summary>
/// Gets the browser subprocess path
/// </summary>
const QString browserSubProcessPath() const;
/// <summary>
/// Sets the resource directory path
/// </summary>
/// <param name="path">The resource directory path</param>
void setResourceDirectoryPath(const QString& path);
/// <summary>
/// Gets the resource directory path
/// </summary>
const QString resourceDirectoryPath() const;
/// <summary>
/// Sets the locales directory path
/// </summary>
/// <param name="path">The locales directory path</param>
void setLocalesDirectoryPath(const QString& path);
/// <summary>
/// Gets the locales directory path
/// </summary>
const QString localesDirectoryPath() const;
#endif
/// <summary>
/// Sets the log level
/// </summary>
/// <param name="lvl"></param>
void setLogLevel(const LogLevel lvl);
/// <summary>
/// Gets the log level
/// </summary>
/// <returns>The current log level</returns>
const QCefConfig::LogLevel logLevel() const;
/// <summary>
/// Sets the locale
/// </summary>
/// <param name="locale">The locale to use. If empty the default locale of "en-US" will be used. This value is ignored
/// on Linux where locale is determined using environment variable parsing with the precedence order: LANGUAGE,
/// LC_ALL, LC_MESSAGES and LANG. Also configurable using the "lang" command-line switch.</param>
void setLocale(const QString& locale);
/// <summary>
/// Gets the locale
/// </summary>
const QString locale() const;
/// <summary>
/// Sets the user agent
/// </summary>
/// <param name="agent">The user agent</param>
void setUserAgent(const QString& agent);
/// <summary>
/// Gets the user agent
/// </summary>
const QString userAgent() const;
/// <summary>
/// Sets the cache directory path
/// </summary>
/// <param name="path">The cache path</param>
void setCachePath(const QString& path);
/// <summary>
/// Gets the cache directory path
/// </summary>
const QString cachePath() const;
#if CEF_VERSION_MAJOR < 115
/// <summary>
/// Sets the user data directory path
/// </summary>
/// <param name="path">The user data directory path</param>
void setUserDataPath(const QString& path);
/// <summary>
/// Gets the user data directory path
/// </summary>
const QString userDataPath() const;
#else
/// <summary>
/// Gets the root cache directory path
/// </summary>
const QString rootCachePath() const;
/// <summary>
/// Sets the root cache directory path
/// </summary>
/// <param name="path">The root cache directory path</param>
void setRootCachePath(const QString& path);
#endif
/// <summary>
/// Sets the bridge object name
/// </summary>
/// <param name="name">The bridge object name</param>
/// <remarks>
/// The bridge object represents a Javascript object which will be inserted
/// into all browser and frames. This object is designated for communicating
/// between Javascript in web content and native context(C/C++) code.
/// This object is set as an property of window object. That means it can be
/// obtained by calling window.bridgeObject in the Javascript code
/// </remarks>
void setBridgeObjectName(const QString& name);
/// <summary>
/// Gets the bridge object name
/// </summary>
const QString bridgeObjectName() const;
/// <summary>
/// Sets the built-in scheme name
/// </summary>
/// <param name="name">The scheme name</param>
/// <remarks>
/// The default value is CefView
/// </remarks>
void setBuiltinSchemeName(const QString& name);
/// <summary>
/// Gets the built-in scheme object name
/// </summary>
const QString builtinSchemeName() const;
/// <summary>
/// Sets the background color of the web page
/// </summary>
/// <param name="color">The color to be set</param>
/// <remarks>
/// This only works if the web page has no background color set. The alpha component value
/// will be adjusted to 0 or 255, it means if you pass a value with alpha value
/// in the range of [1, 255], it will be accepted as 255. The default value is qRgba(255, 255, 255, 255)
/// </remarks>
void setBackgroundColor(const QColor& color);
/// <summary>
/// Gets the background color
/// </summary>
const QVariant backgroundColor() const;
/// <summary>
/// Sets the acceptable language list
/// </summary>
/// <param name="languages">Comma delimited ordered list of language codes without any whitespace
/// that will be used in the "Accept-Language" HTTP header.</param>
void setAcceptLanguageList(const QString& languages);
/// <summary>
/// Get the acceptable language list
/// </summary>
const QString acceptLanguageList() const;
/// <summary>
/// Sets whether to persist session cookie
/// </summary>
/// <param name="enabled">True if to persist session cookie</param>
void setPersistSessionCookies(bool enabled);
/// <summary>
/// Gets whether to persist session cookie
/// </summary>
const QVariant persistSessionCookies() const;
#if CEF_VERSION_MAJOR < 128
/// <summary>
/// Sets whether to persist user preferences
/// </summary>
/// <param name="enabled">True if to persist user preferences</param>
void setPersistUserPreferences(bool enabled);
/// <summary>
/// Gets whether to persist user preferences
/// </summary>
const QVariant persistUserPreferences() const;
#endif
/// <summary>
/// Sets the remote debugging port
/// </summary>
/// <param name="port">The port to use</param>
/// <remarks>
/// CEF supports the remote debugging with Dev Tools in Chrome/Edge.
/// if this value is set then you can debug the web application by
/// accessing http://127.0.0.1:port from Chrome/Edge
/// </remarks>
void setRemoteDebuggingPort(short port);
/// <summary>
/// Gets the remote debugging port
/// </summary>
const QVariant remoteDebuggingPort() const;
};
Q_DECLARE_METATYPE(QCefConfig);
#endif

View File

@ -1,149 +0,0 @@
/*
* File: QCefContext.h
* Project: QCefView
* Created: 29th March 2016
* Author: Sheen
* Source: https://github.com/cefview/qcefview
* Docs: https://cefview.github.io/QCefView/
*/
#ifndef QCEFCONTEXT_H
#define QCEFCONTEXT_H
#pragma once
#include <QCefView_global.h>
#pragma region qt_headers
#include <QCoreApplication>
#include <QScopedPointer>
#pragma endregion
#include <QCefConfig.h>
class QCefContextPrivate;
/// <summary>
/// Represents the CEF context
/// </summary>
class QCEFVIEW_EXPORT QCefContext : public QObject
{
Q_OBJECT
Q_DECLARE_PRIVATE(QCefContext)
QScopedPointer<QCefContextPrivate> d_ptr;
friend class QCefView;
public:
/// <summary>
/// Constructs the CEF context
/// </summary>
/// <param name="app">The application</param>
/// <param name="argc">The argument count</param>
/// <param name="argv">The argument list pointer</param>
/// <param name="config">The <see cref="QCefConfig"/> instance</param>
QCefContext(QCoreApplication* app, int argc, char** argv, const QCefConfig* config);
/// <summary>
/// Gets the unique default instance
/// </summary>
/// <returns>The default instance</returns>
static QCefContext* instance();
/// <summary>
/// Destructs the CEF context
/// </summary>
~QCefContext();
/// <summary>
/// Adds a url mapping item with local web resource directory. This works for all <see ref="QCefView" /> instances
/// created subsequently
/// </summary>
/// <param name="path">The path to the local resource directory</param>
/// <param name="url">The url to be mapped to</param>
/// <param name="priority">The priority</param>
void addLocalFolderResource(const QString& path, const QString& url, int priority = 0);
/// <summary>
/// Adds a url mapping item with local archive (.zip) file which contains the web resource. This works for all <see
/// ref="QCefView" /> instances created subsequently
/// </summary>
/// <param name="path">The path to the local archive file</param>
/// <param name="url">The url to be mapped to</param>
/// <param name="password">The password of the archive</param>
/// <param name="priority">The priority</param>
void addArchiveResource(const QString& path, const QString& url, const QString& password = "", int priority = 0);
/// <summary>
/// Adds a cookie to the CEF context, this cookie is accessible from all browsers created with this context
/// </summary>
/// <param name="name">The cookie item name</param>
/// <param name="value">The cookie item value</param>
/// <param name="domain">The applicable domain name</param>
/// <param name="url">The applicable url</param>
/// <returns>True on success; otherwise false</returns>
bool addCookie(const QString& name, const QString& value, const QString& domain, const QString& url);
/// <summary>
/// Deletes all cookies from the CEF context
/// </summary>
/// <returns>True on success; otherwise false</returns>
bool deleteAllCookies();
/// <summary>
/// Adds an entry to the cross-origin access whitelist. For details please refer to:
/// https://github.com/chromiumembedded/cef/blob/605c2bac86415dcec1e2902cdc46dc11c1ad026a/include/cef_origin_whitelist.h#L81C23-L81C23
/// </summary>
/// <param name="sourceOrigin">The source origin</param>
/// <param name="targetSchema">The target schema</param>
/// <param name="targetDomain">The target domain</param>
/// <param name="allowTargetSubdomains">Whether to allow subdomain or not</param>
/// <returns>True on success; otherwise false</returns>
bool addCrossOriginWhitelistEntry(const QString& sourceOrigin,
const QString& targetSchema,
const QString& targetDomain,
bool allowTargetSubdomains);
/// <summary>
/// Removes an entry from the cross-origin access whitelist. For details please refer to:
/// https://github.com/chromiumembedded/cef/blob/605c2bac86415dcec1e2902cdc46dc11c1ad026a/include/cef_origin_whitelist.h#L91C12-L91C12
/// </summary>
/// <param name="sourceOrigin">The source origin</param>
/// <param name="targetSchema">The target schema</param>
/// <param name="targetDomain">The target domain</param>
/// <param name="allowTargetSubdomains">Whether to allow subdomain or not</param>
/// <returns>True on success; otherwise false</returns>
bool removeCrossOriginWhitelistEntry(const QString& sourceOrigin,
const QString& targetSchema,
const QString& targetDomain,
bool allowTargetSubdomains);
/// <summary>
/// Removes all entries from the cross-origin access whitelist.
/// </summary>
bool clearCrossOriginWhitelistEntry();
/// <summary>
/// Gets the QCefConfig
/// </summary>
/// <returns>The QCefConfig instance</returns>
const QCefConfig* cefConfig() const;
protected:
/// <summary>
/// Initialize the CEF context
/// </summary>
/// <param name="config">The <see cref="QCefConfig"/> instance</param>
/// <returns>True on success; otherwise false</returns>
bool init(const QCefConfig* config);
/// <summary>
/// Uninitialize the CEF context
/// </summary>
void uninit();
private:
/// <summary>
/// The default instance
/// </summary>
static QCefContext* s_self;
};
#endif // QCEFCONTEXT_H

View File

@ -1,177 +0,0 @@
/*
* File: QCefDownloadItem.h
* Project: QCefView
* Created: 13th July 2022
* Author: Sheen
* Source: https://github.com/cefview/qcefview
* Docs: https://cefview.github.io/QCefView/
*/
#ifndef QCEFDOWNLOADITEM_H
#define QCEFDOWNLOADITEM_H
#pragma once
#include <QCefView_global.h>
#pragma region qt_headers
#include <QDateTime>
#include <QScopedPointer>
#include <QString>
#pragma endregion
class QCefDownloadItemPrivate;
/// <summary>
/// Represents the download item
/// </summary>
class QCEFVIEW_EXPORT QCefDownloadItem
{
Q_DECLARE_PRIVATE(QCefDownloadItem)
QScopedPointer<QCefDownloadItemPrivate> d_ptr;
Q_DISABLE_COPY(QCefDownloadItem)
QCefDownloadItem(QCefDownloadItem&&) = delete;
QCefDownloadItem& operator=(QCefDownloadItem&&) = delete;
friend class QCefView;
/// <summary>
/// Constructs a download item instance
/// </summary>
QCefDownloadItem();
public:
/// <summary>
/// Destructs the download item instance
/// </summary>
~QCefDownloadItem();
/// <summary>
/// Starts to download the item.
/// </summary>
/// <param name="path">The full path name (must include file name) to save the downloaded item</param>
/// <param name="useDefaultDialog">Whether to use the default 'Save As...' dialog or not</param>
/// <remarks>
/// The 'path' parameter only works when 'useDefaultDialog' is set to false.
/// If you set 'useDefaultDialog' to true then you cannot control the initial
/// location of the opened 'Save As...' dialog, it is determined by CEF internal implementation.
/// </remarks>
void start(const QString& path, bool useDefaultDialog = true) const;
/// <summary>
/// Pauses the download
/// </summary>
void pause() const;
/// <summary>
/// Resume the download
/// </summary>
void resume() const;
/// <summary>
/// Cancels the download
/// </summary>
void cancel() const;
/// <summary>
/// Gets whether the download is started
/// </summary>
/// <returns></returns>
bool isStarted() const;
/// <summary>
/// Gets whether the download is in progress
/// </summary>
/// <returns>True if the download is in progress; otherwise false</returns>
bool isInProgress() const;
/// <summary>
/// Gets whether the download is complete
/// </summary>
/// <returns>True if the download is complete; otherwise false</returns>
bool isComplete() const;
/// <summary>
/// Gets whether the download has been canceled or interrupted
/// </summary>
/// <returns>True if the download has been canceled or interrupted; otherwise false</returns>
bool isCanceled() const;
/// <summary>
/// Gets current download speed
/// </summary>
/// <returns>A simple speed estimate in bytes/s</returns>
qint64 currentSpeed() const;
/// <summary>
/// Gets the completion percentage
/// </summary>
/// <returns>The rough percent complete or -1 if the receive total size is unknown</returns>
int percentComplete() const;
/// <summary>
/// Gets total number of bytes
/// </summary>
/// <returns>The total number of bytes</returns>
qint64 totalBytes() const;
/// <summary>
/// Gets number of received bytes
/// </summary>
/// <returns>The number of received bytes</returns>
qint64 receivedBytes() const;
/// <summary>
/// Gets the time that the download started
/// </summary>
/// <returns>The time that the download started</returns>
QDateTime startTime() const;
/// <summary>
/// Gets the time that the download ended
/// </summary>
/// <returns>The time that the download ended</returns>
QDateTime endTime() const;
/// <summary>
/// Gets the full path to the downloaded or downloading file
/// </summary>
/// <returns>The full path to the downloaded or downloading file</returns>
QString fullPath() const;
/// <summary>
/// Gets the unique identifier for this download
/// </summary>
/// <returns>The unique identifier for this download</returns>
quint32 id() const;
/// <summary>
/// Gets the URL
/// </summary>
/// <returns>The the URL</returns>
QString url() const;
/// <summary>
/// Gets the original URL before any redirections
/// </summary>
/// <returns>The original URL before any redirections</returns>
QString originalUrl() const;
/// <summary>
/// Gets the suggested file name
/// </summary>
/// <returns>The suggested file name</returns>
QString suggestedFileName() const;
/// <summary>
/// Gets the content disposition
/// </summary>
/// <returns>The the content disposition</returns>
QString contentDisposition() const;
/// <summary>
/// Gets the mime type
/// </summary>
/// <returns>The mime type</returns>
QString mimeType() const;
};
#endif /// QCEFDOWNLOADITEM_H

View File

@ -1,88 +0,0 @@
/*
* File: QCefEvent.h
* Project: QCefView
* Created: 29th March 2016
* Author: Sheen
* Source: https://github.com/cefview/qcefview
* Docs: https://cefview.github.io/QCefView/
*/
#ifndef QCEFEVENT_H
#define QCEFEVENT_H
#pragma once
#include <QCefView_global.h>
#pragma region qt_headers
#include <QScopedPointer>
#include <QString>
#include <QVariantList>
#pragma endregion
class QCefEventPrivate;
/// <summary>
/// Represents the event sent from native context(C/C++ code) to the web context(javascript)
/// </summary>
class QCEFVIEW_EXPORT QCefEvent
{
Q_DECLARE_PRIVATE(QCefEvent)
QScopedPointer<QCefEventPrivate> d_ptr;
friend class QCefView;
public:
/// <summary>
/// Constructs an event instance
/// </summary>
QCefEvent();
/// <summary>
/// Constructs an event instance with name
/// </summary>
/// <param name="name">The event name</param>
QCefEvent(const QString& name);
/// <summary>
/// Constructs an event instance from existing one
/// </summary>
/// <param name="other">The other event instance</param>
QCefEvent(const QCefEvent& other);
/// <summary>
/// Assigns an existing event instance to current
/// </summary>
/// <param name="other">The other event instance</param>
QCefEvent& operator=(const QCefEvent& other);
/// <summary>
/// Destructs the event instance
/// </summary>
~QCefEvent();
/// <summary>
/// Sets the event name
/// </summary>
/// <param name="name">The name to be set</param>
void setEventName(const QString& name);
/// <summary>
/// Gets the event name
/// </summary>
/// <returns>The event name</returns>
const QString eventName() const;
/// <summary>
/// Sets the argument list
/// </summary>
/// <param name="args">The argument list</param>
void setArguments(const QVariantList& args);
/// <summary>
/// Gets the argument list
/// </summary>
/// <returns>The argument list</returns>
QVariantList& arguments();
};
Q_DECLARE_METATYPE(QCefEvent);
#endif // QCEFEVENT_H

View File

@ -1,109 +0,0 @@
/*
* File: QCefQuery.h
* Project: QCefView
* Created: 29th March 2016
* Author: Sheen
* Source: https://github.com/cefview/qcefview
* Docs: https://cefview.github.io/QCefView/
*/
#ifndef QCEFQUERY_H
#define QCEFQUERY_H
#pragma once
#include <QCefView_global.h>
#pragma region stl_headers
#include <cstdint>
#pragma endregion
#pragma region qt_headers
#include <QSharedPointer>
#include <QString>
#pragma endregion
class QCefQueryPrivate;
class QCefViewPrivate;
/// <summary>
/// Represents the query request sent from the web content(Javascript)
/// </summary>
class QCEFVIEW_EXPORT QCefQuery
{
Q_DECLARE_PRIVATE(QCefQuery)
QSharedPointer<QCefQueryPrivate> d_ptr;
friend class QCefViewPrivate;
protected:
/// <summary>
/// Constructs a query instance with request context and query id
/// </summary>
/// <param name="source">The source CefView</param>
/// <param name="req">The request context</param>
/// <param name="query">The query id</param>
QCefQuery(QCefViewPrivate* source, const QString& req, const int64_t query);
/// <summary>
/// Marks the query as replied (for internal use only)
/// </summary>
void markAsReplied() const;
public:
/// <summary>
/// Constructs a query instance
/// </summary>
QCefQuery();
/// <summary>
/// Destructs a query instance
/// </summary>
~QCefQuery();
/// <summary>
/// Gets the query content
/// </summary>
/// <returns>The content string</returns>
const QString request() const;
/// <summary>
/// Gets the query id
/// </summary>
/// <returns>The query id</returns>
const qint64 id() const;
/// <summary>
/// Gets the response content string
/// </summary>
/// <returns>The response content string</returns>
const QString response() const;
/// <summary>
/// Gets the response result
/// </summary>
/// <returns>The respone result</returns>
const bool result() const;
/// <summary>
/// Gets the response error
/// </summary>
/// <returns>The response error</returns>
const int error() const;
/// <summary>
/// Sets the response
/// </summary>
/// <param name="success">True if the query is successful; otherwise false</param>
/// <param name="response">The response content string</param>
/// <param name="error">The response error</param>
void setResponseResult(bool success, const QString& response, int error = 0) const;
/// <summary>
/// Replies the query
/// </summary>
/// <param name="success">The result</param>
/// <param name="response">The response data</param>
/// <param name="error">The error code</param>
void reply(bool success, const QString& response, int error = 0) const;
};
Q_DECLARE_METATYPE(QCefQuery);
#endif // QCEFQUERY_H

View File

@ -1,419 +0,0 @@
/*
* File: QCefSetting.h
* Project: QCefView
* Created: 29th March 2016
* Author: Sheen
* Source: https://github.com/cefview/qcefview
* Docs: https://cefview.github.io/QCefView/
*/
#ifndef QCEFSETTING_H
#define QCEFSETTING_H
#pragma once
#include <QCefView_global.h>
#pragma region qt_headers
#include <QColor>
#include <QScopedPointer>
#include <QSize>
#include <QString>
#pragma endregion
class QCefSettingPrivate;
/// <summary>
/// Represents the settings for individual browser
/// </summary>
class QCEFVIEW_EXPORT QCefSetting
{
Q_DECLARE_PRIVATE(QCefSetting)
QScopedPointer<QCefSettingPrivate> d_ptr;
friend class QCefView;
public:
/// <summary>
/// Constructs the QCefSetting instance
/// </summary>
QCefSetting();
/// <summary>
/// Constructs the QCefSetting instance from existing one
/// </summary>
/// <param name="other">The existing QCefSetting instance</param>
QCefSetting(const QCefSetting& other);
/// <summary>
/// Assigns the existing QCefSetting instance to current
/// </summary>
/// <param name="other"></param>
QCefSetting& operator=(const QCefSetting& other);
/// <summary>
/// Destructs the instance
/// </summary>
~QCefSetting();
/// <summary>
/// Sets the initial size of the browser
/// </summary>
/// <param name="size">The initial size</param>
void setWindowInitialSize(const QSize& size);
/// <summary>
/// Gets the initial size of the browser
/// </summary>
/// <returns></returns>
const QSize windowInitialSize() const;
/// <summary>
/// Sets the standard font family
/// </summary>
/// <param name="value">The font family</param>
void setStandardFontFamily(const QString& value);
/// <summary>
/// Gets the standard font family
/// </summary>
/// <returns>The font family</returns>
const QString standardFontFamily() const;
/// <summary>
/// Sets the fixed font family
/// </summary>
/// <param name="value">The font family</param>
void setFixedFontFamily(const QString& value);
/// <summary>
/// Gets the fixed font family
/// </summary>
/// <returns>The font family</returns>
const QString fixedFontFamily() const;
/// <summary>
/// Sets the serif font family
/// </summary>
/// <param name="value">The font family</param>
void setSerifFontFamily(const QString& value);
/// <summary>
/// Gets the serif font family
/// </summary>
/// <returns>The font family</returns>
const QString serifFontFamily() const;
/// <summary>
/// Sets the sans serif font family
/// </summary>
/// <param name="value">The font family</param>
void setSansSerifFontFamily(const QString& value);
/// <summary>
/// Gets the sans serif font family
/// </summary>
/// <returns>The font family</returns>
const QString sansSerifFontFamily() const;
/// <summary>
/// Sets the cursive font family
/// </summary>
/// <param name="value">The font family</param>
void setCursiveFontFamily(const QString& value);
/// <summary>
/// Gets the cursive font family
/// </summary>
/// <returns>The font family</returns>
const QString cursiveFontFamily() const;
/// <summary>
/// Sets the fantasy font family
/// </summary>
/// <param name="value">The font family</param>
void setFantasyFontFamily(const QString& value);
/// <summary>
/// Gets the fantasy font family
/// </summary>
/// <returns>The font family</returns>
const QString fantasyFontFamily() const;
/// <summary>
/// Sets the default encoding
/// </summary>
/// <param name="value">The encoding name</param>
void setDefaultEncoding(const QString& value);
/// <summary>
/// Gets the default encoding
/// </summary>
/// <returns>The encoding name</returns>
const QString defaultEncoding() const;
#if CEF_VERSION_MAJOR < 118
/// <summary>
/// Sets the acceptable language list
/// </summary>
/// <param name="value">The acceptable languate list</param>
void setAcceptLanguageList(const QString& value);
/// <summary>
/// Gets the acceptable language list
/// </summary>
/// <returns>The acceptable languate list</returns>
const QString acceptLanguageList() const;
#endif
/// <summary>
/// Sets the frame rate in window less mode
/// </summary>
/// <param name="value">The frame rate</param>
void setWindowlessFrameRate(const int value);
/// <summary>
/// Gets the frame rate in window less mode
/// </summary>
/// <returns>The frame rate</returns>
const QVariant windowlessFrameRate() const;
/// <summary>
/// Sets the default font size
/// </summary>
/// <param name="value">The font size</param>
void setDefaultFontSize(const int value);
/// <summary>
/// Gets the default font size
/// </summary>
/// <returns>The font size</returns>
const QVariant defaultFontSize() const;
/// <summary>
/// Sets the default fixed font size
/// </summary>
/// <param name="value">The font size</param>
void setDefaultFixedFontSize(const int value);
/// <summary>
/// Gets the default fixed font size
/// </summary>
/// <returns>The font size</returns>
const QVariant defaultFixedFontSize() const;
/// <summary>
/// Sets the minimum font size
/// </summary>
/// <param name="value">The font size</param>
void setMinimumFontSize(const int value);
/// <summary>
/// Gets the minimum font size
/// </summary>
/// <returns>The font size</returns>
const QVariant minimumFontSize() const;
/// <summary>
/// Sets the minimum logical font size
/// </summary>
/// <param name="value">The font size</param>
void setMinimumLogicalFontSize(const int value);
/// <summary>
/// Gets the minimum logical font size
/// </summary>
/// <returns>The font size</returns>
const QVariant minimumLogicalFontSize() const;
/// <summary>
/// Sets to enable or disable remote fonts
/// </summary>
/// <param name="value">True to enable; false to disable</param>
void setRemoteFonts(const bool value);
/// <summary>
/// Gets whether to enable or disable the remote fonts
/// </summary>
/// <returns>True to enable; false to disable</returns>
const QVariant remoteFonts() const;
/// <summary>
/// Sets to enable or disable Javascript
/// </summary>
/// <param name="value">True to enable; false to disable</param>
void setJavascript(const bool value);
/// <summary>
/// Gets whether to enable or disable Javascript
/// </summary>
/// <returns>True to enable; false to disable</returns>
const QVariant javascript() const;
/// <summary>
/// Sets to enable or disable the permission of closing window from Javascript
/// </summary>
/// <param name="value">True to enable; false to disable</param>
void setJavascriptCloseWindows(const bool value);
/// <summary>
/// Gets whether to enable or disable the permission of closing window from Javascript
/// </summary>
/// <returns>True to enable; false to disable</returns>
const QVariant javascriptCloseWindows() const;
/// <summary>
/// Sets to enable or disable the permission of accessing clipboard from Javascript
/// </summary>
/// <param name="value">True to enable; false to disable</param>
void setJavascriptAccessClipboard(const bool value);
/// <summary>
/// Gets whether to enable or disable the permission of accessing clipboard from Javascript
/// </summary>
/// <returns>True to enable; false to disable</returns>
const QVariant javascriptAccessClipboard() const;
/// <summary>
/// Sets to enable or disable the permission of pasting DOM in Javascript
/// </summary>
/// <param name="value">True to enable; false to disable</param>
void setJavascriptDomPaste(const bool value);
/// <summary>
/// Gets whether to enable or disable the permission of pasting DOM in Javascript
/// </summary>
/// <returns>True to enable; false to disable</returns>
const QVariant javascriptDomPaste() const;
#if CEF_VERSION_MAJOR < 100
/// <summary>
/// Sets to enable or disable plugins
/// </summary>
/// <param name="value">True to enable; false to disable</param>
void setPlugins(const bool value);
/// <summary>
/// Gets whether to enable or disable plugins
/// </summary>
/// <returns>True to enable; false to disable</returns>
const QVariant plugins() const;
#endif
/// <summary>
/// Sets to enable or disable the permission of loading images
/// </summary>
/// <param name="value">True to enable; false to disable</param>
void setImageLoading(const bool value);
/// <summary>
/// Gets whether to enable or disable the permission of loading images
/// </summary>
/// <returns>True to enable; false to disable</returns>
const QVariant imageLoading() const;
/// <summary>
/// Sets to enable or disable the shrinking image standalone to fit
/// </summary>
/// <param name="value">True to enable; false to disable</param>
void setImageShrinkStandaloneToFit(const bool value);
/// <summary>
/// Gets whether to enable or disable the shrinking image standalone to fit
/// </summary>
/// <returns>True to enable; false to disable</returns>
const QVariant imageShrinkStandaloneToFit() const;
/// <summary>
/// Sets to enable or disable the resizing of text area
/// </summary>
/// <param name="value">True to enable; false to disable</param>
void setTextAreaResize(const bool value);
/// <summary>
/// Gets whether to enable or disable the resizing of text area
/// </summary>
/// <returns>True to enable; false to disable</returns>
const QVariant textAreaResize() const;
/// <summary>
/// Sets to enable or disable tab to links
/// </summary>
/// <param name="value">True to enable; false to disable</param>
void setTabToLinks(const bool value);
/// <summary>
/// Gets whether to enable or disable tab to links
/// </summary>
/// <returns>True to enable; false to disable</returns>
const QVariant tabToLinks() const;
/// <summary>
/// Sets to enable or disable local storage
/// </summary>
/// <param name="value">True to enable; false to disable</param>
void setLocalStorage(const bool value);
/// <summary>
/// Gets whether to enable or disable local storage
/// </summary>
/// <returns>True to enable; false to disable</returns>
const QVariant localStorage() const;
/// <summary>
/// Sets to enable or disable database
/// </summary>
/// <param name="value">True to enable; false to disable</param>
void setDatabases(const bool value);
/// <summary>
/// Gets whether to enable or disable database
/// </summary>
/// <returns>True to enable; false to disable</returns>
const QVariant databases() const;
/// <summary>
/// Sets to enable or disable webGL
/// </summary>
/// <param name="value">True to enable; false to disable</param>
void setWebGL(const bool value);
/// <summary>
/// Gets whether to enable or disable webGL
/// </summary>
/// <returns>True to enable; false to disable</returns>
const QVariant webGL() const;
/// <summary>
/// Sets the background color
/// </summary>
/// <param name="value">The color</param>
/// <remarks>
/// This only works if the web page has no background color set. The alpha component value
/// will be adjusted to 0 or 255, it means if you pass a value with alpha value
/// in the range of [1, 255], it will be accepted as 255. The default value is inherited from
/// <see cref="QCefConfig::backgroundColor()"/>
/// </remarks>
void setBackgroundColor(const QColor& value);
/// <summary>
/// Gets the background color
/// </summary>
/// <returns>The color</returns>
const QVariant backgroundColor() const;
#if CEF_VERSION_MAJOR >= 125
/// <summary>
///
/// </summary>
/// <param name="value"></param>
void setHardwareAcceleration(const bool value);
/// <summary>
///
/// </summary>
/// <returns></returns>
const bool hardwareAcceleration() const;
#endif
};
Q_DECLARE_METATYPE(QCefSetting);
#endif

View File

@ -1,604 +0,0 @@
/*
* File: QCefView.h
* Project: QCefView
* Created: 29th March 2016
* Author: Sheen
* Source: https://github.com/cefview/qcefview
* Docs: https://cefview.github.io/QCefView/
*/
#ifndef QCEFVIEW_H
#define QCEFVIEW_H
#pragma once
#include <QCefView_global.h>
#pragma region qt_headers
#include <QScopedPointer>
#include <QVariantList>
#include <QWidget>
#include <QWindow>
#pragma endregion
#include <QCefDownloadItem.h>
#include <QCefEvent.h>
#include <QCefQuery.h>
#include <QCefSetting.h>
/// <summary>
/// Type alias for CEF browser id
/// </summary>
#define QCefBrowserId int
/// <summary>
/// Type alias for CEF frame id
/// </summary>
#if CEF_VERSION_MAJOR < 122
#define QCefFrameId qint64
#else
#define QCefFrameId QString
#endif
/// <summary>
/// Private implementation
/// </summary>
class QCefViewPrivate;
/// <summary>
/// Represents the CEF browser view
/// </summary>
class QCEFVIEW_EXPORT QCefView : public QWidget
{
Q_OBJECT
Q_DECLARE_PRIVATE(QCefView)
Q_DISABLE_COPY(QCefView)
QScopedPointer<QCefViewPrivate> d_ptr;
public:
/// <summary>
/// The main frame identity
/// </summary>
static const QCefFrameId MainFrameID;
/// <summary>
/// The identifier for all frames
/// </summary>
static const QCefFrameId AllFrameID;
/// <summary>
/// Represents the CEF pop-up windows open disposition
/// </summary>
enum CefWindowOpenDisposition
{
CefWindowOpenDispositionUnknown,
CefWindowOpenDispositionCurrentTab,
CefWindowOpenDispositionSingletonTab,
CefWindowOpenDispositionNewForeGroundTab,
CefWindowOpenDispositionNewBackgroundTab,
CefWindowOpenDispositionNewPopup,
CefWindowOpenDispositionNewWindow,
CefWindowOpenDispositionSaveToDisk,
CefWindowOpenDispositionOffTheRecord,
CefWindowOpenDispositionIgnoreAction,
};
Q_ENUM(CefWindowOpenDisposition)
public:
/// <summary>
/// Constructs a QCefView instance
/// </summary>
/// <param name="url">The target url</param>
/// <param name="setting">The <see cref="QCefSetting"/> instance</param>
/// <param name="parent">The parent</param>
/// <param name="f">The Qt WindowFlags</param>
QCefView(const QString& url,
const QCefSetting* setting,
QWidget* parent = nullptr,
Qt::WindowFlags f = Qt::WindowFlags());
/// <summary>
/// Constructs a QCefView instance
/// </summary>
/// <param name="parent">The parent</param>
/// <param name="f">The Qt WindowFlags</param>
QCefView(QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
/// <summary>
/// Destructs the QCefView instance
/// </summary>
~QCefView();
/// <summary>
/// Adds a url mapping item with local web resource directory
/// </summary>
/// <param name="path">The path to the local resource directory</param>
/// <param name="url">The url to be mapped to</param>
/// <param name="priority">The priority</param>
void addLocalFolderResource(const QString& path, const QString& url, int priority = 0);
/// <summary>
/// Adds a url mapping item with local archive (.zip) file which contains the web resource
/// </summary>
/// <param name="path">The path to the local archive file</param>
/// <param name="url">The url to be mapped to</param>
/// <param name="password">The password of the archive</param>
/// <param name="priority">The priority</param>
void addArchiveResource(const QString& path, const QString& url, const QString& password = "", int priority = 0);
/// <summary>
/// Gets the browser id
/// </summary>
/// <returns>The browser id</returns>
QCefBrowserId browserId();
/// <summary>
/// Navigates to the content.
/// </summary>
/// <param name="content">The content</param>
void navigateToString(const QString& content);
/// <summary>
/// Navigates to the URL
/// </summary>
/// <param name="url">The url</param>
void navigateToUrl(const QString& url);
/// <summary>
/// Checks whether the browser can go back
/// </summary>
/// <returns>True if can; otherwise false</returns>
bool browserCanGoBack();
/// <summary>
/// Checks whether the browser can go forward
/// </summary>
/// <returns>True if can; otherwise false</returns>
bool browserCanGoForward();
/// <summary>
/// Requires the browser to go back
/// </summary>
void browserGoBack();
/// <summary>
/// Requires the browser to go forward
/// </summary>
void browserGoForward();
/// <summary>
/// Checks whether the browser is loading
/// </summary>
/// <returns>True if it is loading; otherwise false</returns>
bool browserIsLoading();
/// <summary>
/// Requires the browser to reload
/// </summary>
void browserReload();
/// <summary>
/// Requires the browser to stop load
/// </summary>
void browserStopLoad();
/// <summary>
/// Triggers the event for main frame
/// </summary>
/// <param name="event">The <see cref="QCefEvent"/> instance</param>
/// <returns>True on successful; otherwise false</returns>
bool triggerEvent(const QCefEvent& event);
/// <summary>
/// Triggers the event for specified frame
/// </summary>
/// <param name="event">The <see cref="QCefEvent"/> instance</param>
/// <param name="frameId">The frame id</param>
/// <returns>True on successful; otherwise false</returns>
bool triggerEvent(const QCefEvent& event, const QCefFrameId& frameId);
/// <summary>
/// Broad cast the event for all frames
/// </summary>
/// <param name="event">The <see cref="QCefEvent"/> instance</param>
/// <returns>True on successful; otherwise false</returns>
bool broadcastEvent(const QCefEvent& event);
/// <summary>
/// Response the <see cref="QCefQuery"/> request
/// </summary>
/// <param name="query">The query instance</param>
/// <returns>True on successful; otherwise false</returns>
bool responseQCefQuery(const QCefQuery& query);
/// <summary>
/// Executes javascript code in specified frame, this method does not report the result of the javascript.
/// To get the result of the javascript execution use <see cref="executeJavascriptWithResult"/>
/// </summary>
/// <param name="frameId">The frame id</param>
/// <param name="code">The javascript code</param>
/// <param name="url">
/// The URL where the script in question can be found, if any. The renderer may request this URL to show the developer
/// the source of the error
/// </param>
/// <returns>True on successful; otherwise false</returns>
bool executeJavascript(const QCefFrameId& frameId, const QString& code, const QString& url);
/// <summary>
/// Executes javascript code in specified frame and the result will be reported through <see
/// cref="reportJavascriptResult"/> signal
/// </summary>
/// <param name="frameId">The frame id</param>
/// <param name="code">The javascript code</param>
/// <param name="url">
/// The URL where the script in question can be found, if any. The renderer may request this URL to show the developer
/// the source of the error
/// </param>
/// <param name="context">The context used to identify the one execution</param>
/// <returns>True on successful; otherwise false</returns>
bool executeJavascriptWithResult(const QCefFrameId& frameId,
const QString& code,
const QString& url,
const QString& context);
/// <summary>
/// Sets the preference for this browser
/// </summary>
/// <param name="name">The preference name</param>
/// <param name="value">
/// The preference value, if this value is QVariant::UnknownType or QVariant::Invalid, the
/// preference will be restored to default value
/// </param>
/// <param name="error">The error message populated on failure</param>
/// <returns>True on successful; otherwise false</returns>
bool setPreference(const QString& name, const QVariant& value, const QString& error);
/// <summary>
/// Sets whether to disable the context menu for popup browser
/// </summary>
/// <param name="disable">True to disable; otherwise false</param>
void setDisablePopupContextMenu(bool disable);
/// <summary>
/// Gets whether to disable the context menu for popup browser
/// </summary>
/// <returns>True to disable; otherwise false</returns>
bool isPopupContextMenuDisabled();
/// <summary>
/// Detects whether this browser has a devtools opened
/// </summary>
/// <returns>True if opend already; otherwise false</returns>
bool hasDevTools();
/// <summary>
/// Opens the devtools dialog
/// </summary>
void showDevTools();
/// <summary>
/// Closes the devtools dialog
/// </summary>
void closeDevTools();
/// <summary>
/// Sets whether to enable drag and drop
/// </summary>
/// <param name="enable">True to enable; otherwise false</param>
/// <remarks>
/// This function does not work for OSR mode. There is a problem, when dragging a file to a non dragging area,
/// the content of the file will be displayed. You need to solve the problem yourself.
/// </remarks>
void setEnableDragAndDrop(bool enable);
/// <summary>
/// Gets whether to enable drag and drop
/// </summary>
/// <returns>True to enable; otherwise false</returns>
bool isDragAndDropEnabled() const;
signals:
/// <summary>
/// Gets called on loading state changed
/// </summary>
/// <param name="browserId">Indicates the browser id</param>
/// <param name="isLoading">Indicates the browser is loading</param>
/// <param name="canGoBack">Indicates the browser can go back</param>
/// <param name="canGoForward">Indicates the browser can go forward</param>
void loadingStateChanged(const QCefBrowserId& browserId, bool isLoading, bool canGoBack, bool canGoForward);
/// <summary>
/// Gets called on loading starts
/// </summary>
/// <param name="browserId">Indicates the browser id</param>
/// <param name="frameId">Indicates the frame id</param>
/// <param name="isMainFrame">Indicates the whether this is the main frame</param>
/// <param name="transitionType">transition type</param>
void loadStart(const QCefBrowserId& browserId, const QCefFrameId& frameId, bool isMainFrame, int transitionType);
/// <summary>
/// Gets called on loading ends
/// </summary>
/// <param name="browserId">Indicates the browser id</param>
/// <param name="frameId">Indicates the frame id</param>
/// <param name="isMainFrame">Indicates the whether this is the main frame</param>
/// <param name="httpStatusCode">The HTTP status code</param>
void loadEnd(const QCefBrowserId& browserId, const QCefFrameId& frameId, bool isMainFrame, int httpStatusCode);
/// <summary>
/// Gets called on loading failed due to error
/// </summary>
/// <param name="browserId">Indicates the browser id</param>
/// <param name="frameId">Indicates the frame id</param>
/// <param name="isMainFrame">Indicates the whether this is the main frame</param>
/// <param name="errorCode">The error code</param>
/// <param name="errorMsg">The error message</param>
/// <param name="failedUrl">The url caused the failure</param>
void loadError(const QCefBrowserId& browserId,
const QCefFrameId& frameId,
bool isMainFrame,
int errorCode,
const QString& errorMsg,
const QString& failedUrl);
/// <summary>
/// Gets called on draggable region changed
/// </summary>
/// <param name="draggableRegion">The new draggable region</param>
/// <param name="nonDraggableRegion">The new non-draggable region</param>
void draggableRegionChanged(const QRegion& draggableRegion, const QRegion& nonDraggableRegion);
/// <summary>
/// Gets called on the address changed
/// </summary>
/// <param name="frameId">The frame id</param>
/// <param name="url">The address</param>
void addressChanged(const QCefFrameId& frameId, const QString& url);
/// <summary>
/// Gets called on title changed
/// </summary>
/// <param name="title">The title</param>
void titleChanged(const QString& title);
/// <summary>
/// Gets called on favicon url changed
/// </summary>
/// <param name="urls">The urls</param>
void faviconURLChanged(const QStringList& urls);
/// <summary>
/// Gets called on fullscreen mode changed
/// </summary>
/// <param name="fullscreen">The current fullscreen mode</param>
void fullscreenModeChanged(bool fullscreen);
/// <summary>
/// Gets called on status message changed
/// </summary>
/// <param name="message">The status message</param>
void statusMessage(const QString& message);
/// <summary>
/// Gets called on console message from the web content
/// </summary>
/// <param name="message">The message</param>
/// <param name="level">The level</param>
void consoleMessage(const QString& message, int level);
/// <summary>
/// Gets called on loading progress changed
/// </summary>
/// <param name="progress">Current progress</param>
void loadingProgressChanged(double progress);
/// <summary>
/// Gets called on built-in scheme URL access
/// </summary>
/// <param name="browserId">The browser id</param>
/// <param name="frameId">The frame id</param>
/// <param name="query">The full url</param>
void cefUrlRequest(const QCefBrowserId& browserId, const QCefFrameId& frameId, const QString& url);
/// <summary>
/// Gets called on new <see cref="QCefQuery"/> request
/// </summary>
/// <param name="browserId">The browser id</param>
/// <param name="frameId">The frame id</param>
/// <param name="query">The query request</param>
void cefQueryRequest(const QCefBrowserId& browserId, const QCefFrameId& frameId, const QCefQuery& query);
/// <summary>
/// Gets called on invoking method request from web content(Javascript)
/// </summary>
/// <param name="browserId">The browser id</param>
/// <param name="frameId">The frame id</param>
/// <param name="method">The method name</param>
/// <param name="arguments">The arguments list</param>
void invokeMethod(const QCefBrowserId& browserId,
const QCefFrameId& frameId,
const QString& method,
const QVariantList& arguments);
/// <summary>
/// Gets called on the result of the javascript executed with <see cref="executeJavascriptWithResult"/> returned
/// </summary>
/// <param name="browserId">The browser id</param>
/// <param name="frameId">The frame id</param>
/// <param name="context">The context</param>
/// <param name="result">The result</param>
void reportJavascriptResult(const QCefBrowserId& browserId,
const QCefFrameId& frameId,
const QString& context,
const QVariant& result);
/// <summary>
/// Gets called after the native browser window created. This slot does not work for OSR mode.
/// </summary>
/// <param name="window">The native browser windows</param>
void nativeBrowserCreated(QWindow* window);
protected:
/// <summary>
/// Gets called before a new browser created (only for browser created by non-JavaScript)
/// </summary>
/// <param name="frameId">The source frame id</param>
/// <param name="url">The target URL</param>
/// <param name="name">The target name</param>
/// <param name="targetDisposition">Target window open method</param>
/// <param name="rect">Rect to be used for the popup</param>
/// <param name="settings">Settings to be used for the popup</param>
/// <returns>True to cancel the popup; false to allow</returns>
/// <returns></returns>
virtual QCefView* onNewBrowser(const QCefFrameId& sourceFrameId,
const QString& url,
const QString& name,
QCefView::CefWindowOpenDisposition targetDisposition,
QRect& rect,
QCefSetting& settings);
/// <summary>
/// Gets called before the popup browser created (only for browser created by JavaScript)
/// </summary>
/// <param name="frameId">The source frame id</param>
/// <param name="targetUrl">The target URL</param>
/// <param name="targetFrameName">The target name</param>
/// <param name="targetDisposition">Target window open method</param>
/// <param name="rect">Rect to be used for the popup</param>
/// <param name="settings">Settings to be used for the popup</param>
/// <returns>True to cancel the popup; false to allow</returns>
virtual bool onNewPopup(const QCefFrameId& frameId,
const QString& targetUrl,
QString& targetFrameName,
QCefView::CefWindowOpenDisposition targetDisposition,
QRect& rect,
QCefSetting& settings,
bool& disableJavascriptAccess);
/// <summary>
/// Gets called on new download item was required. Keep reference to the download item
/// and call <see cref="QCefDownloadItem::start"/> method to allow and start the download,
/// Ignore the download item to disallow the download
/// </summary>
/// <param name="item">The new download item</param>
/// <param name="suggestedName">The new suggested name</param>
virtual void onNewDownloadItem(const QSharedPointer<QCefDownloadItem>& item, const QString& suggestedName);
/// <summary>
/// Gets called on download item updated. To get this method called <see cref="QCefDownloadItem::start"/> method must
/// be called in <see cref="newDownloadItem"/> method
/// </summary>
/// <param name="item">The download item</param>
virtual void onUpdateDownloadItem(const QSharedPointer<QCefDownloadItem>& item);
/// <summary>
/// Gets called on close request from web
/// </summary>
/// <returns>True to allow the close, false to cancel the close</returns>
virtual bool onRequestCloseFromWeb();
#pragma region QWidget
public slots:
/// <summary>
///
/// </summary>
inline void setFocus() { setFocus(Qt::OtherFocusReason); }
public:
/// <summary>
/// Please refer to QWidget::setFocus
/// </summary>
void setFocus(Qt::FocusReason reason);
/// <summary>
/// Please refer to QWidget::inputMethodQuery
/// </summary>
QVariant inputMethodQuery(Qt::InputMethodQuery query) const override;
/// <summary>
/// Renders the view content to target painter
/// </summary>
/// <param name="painter">The target painter</param>
void render(QPainter* painter);
protected:
/// <summary>
/// Please refer to QWidget::paintEngine
/// </summary>
QPaintEngine* paintEngine() const override;
/// <summary>
/// Please refer to QWidget::paintEvent
/// </summary>
void paintEvent(QPaintEvent* event) override;
/// <summary>
/// Please refer to QWidget::inputMethodEvent
/// </summary>
void inputMethodEvent(QInputMethodEvent* event) override;
/// <summary>
/// Please refer to QWidget::showEvent
/// </summary>
void showEvent(QShowEvent* event) override;
/// <summary>
/// Please refer to QWidget::hideEvent
/// </summary>
void hideEvent(QHideEvent* event) override;
/// <summary>
/// Please refer to QWidget::focusInEvent
/// </summary>
void focusInEvent(QFocusEvent* event) override;
/// <summary>
/// Please refer to QWidget::focusOutEvent
/// </summary>
void focusOutEvent(QFocusEvent* event) override;
/// <summary>
/// Please refer to QWidget::resizeEvent
/// </summary>
void resizeEvent(QResizeEvent* event) override;
/// <summary>
/// Please refer to QWidget::keyPressEvent
/// </summary>
void keyPressEvent(QKeyEvent* event) override;
/// <summary>
/// Please refer to QWidget::keyReleaseEvent
/// </summary>
void keyReleaseEvent(QKeyEvent* event) override;
/// <summary>
/// Please refer to QWidget::mouseMoveEvent
/// </summary>
void mouseMoveEvent(QMouseEvent* event) override;
/// <summary>
/// Please refer to QWidget::mousePressEvent
/// </summary>
void mousePressEvent(QMouseEvent* event) override;
/// <summary>
/// Please refer to QWidget::mouseReleaseEvent
/// </summary>
void mouseReleaseEvent(QMouseEvent* event) override;
/// <summary>
/// Please refer to QWidget::wheelEvent
/// </summary>
void wheelEvent(QWheelEvent* event) override;
/// <summary>
/// Please refer to QWidget::leaveEvent
/// </summary>
void leaveEvent(QEvent* event) override;
/// <summary>
/// Please refer to QWidget::contextMenuEvent
/// </summary>
void contextMenuEvent(QContextMenuEvent* event) override;
#pragma endregion
};
#endif // QCEFVIEW_H

View File

@ -1,40 +0,0 @@
/*
* File: QCefView_global.h
* Project: QCefView
* Created: 29th March 2016
* Author: Sheen
* Source: https://github.com/cefview/qcefview
* Docs: https://cefview.github.io/QCefView/
*/
#ifndef QCEFEVIEW_GLOBAL_H
#define QCEFEVIEW_GLOBAL_H
#pragma once
// clang-format off
#pragma region qt_headers
#include <QtCore/qglobal.h>
#include <QMetaType>
#pragma endregion
#ifdef QCEFVIEW_STATIC
// Static library, no need export
#define QCEFVIEW_EXPORT
#else
// Dynamic library
#ifdef QCEFVIEW_LIB
// Build QCefView project, export API
#define QCEFVIEW_EXPORT Q_DECL_EXPORT
#else
// Referenced by other project, import API
#define QCEFVIEW_EXPORT Q_DECL_IMPORT
#if _WIN32
#pragma comment(lib, "QCefView.lib")
#endif
#endif
#endif
// clang-format on
// CEF version numbers
#include <CefVersion.h>
#endif // QCEFEVIEW_GLOBAL_H

Binary file not shown.

View File

@ -1,241 +0,0 @@
#
# The main config file for QCefView
#
cmake_minimum_required(VERSION 3.21)
project(QCefView)
set(CMAKE_FOLDER "QCefView")
# arguments:
# CEF_SDK_VERSION:
# - specify the CEF version to be used,
# - refer to: cmake\CefViewCoreConfig.cmake
#
# QT_SDK_DIR:
# - specify the Qt SDK path
# - refer to: cmake\QtConfig.cmake
#
SET(QT_SDK_DIR "D:/Dev/Qt/6.8.0/mingw1310_static_x64/lib/cmake")
#,
get_cmake_property(cache_vars CACHE_VARIABLES)
#
foreach(var IN LISTS cache_vars)
if(var MATCHES "^BUILD_")
unset(${var} CACHE)
endif()
if(var MATCHES "^STATIC_")
unset(${var} CACHE)
endif()
if(var MATCHES "^USE_")
unset(${var} CACHE)
endif()
endforeach()
# options
option(BUILD_DEMO "Build the demo" OFF)
option(BUILD_STATIC "Build QCefView as static library" ON)
option(STATIC_CRT "Use MultiThreaded linkage for MSVC" OFF)
option(USE_SANDBOX "Enable CEF Sandbox" OFF)
option(USE_WIN_DCOMPOSITION "Enabled Windows direct composition for hardware rendering, _WIN32_WINNT >= 0x602 (Windows 8) is required" ON)
# Only works for Windows & Linux, always enabled on macOS
# If enable then:
# CefSettings.multi_threaded_message_loop = false && CefSettings.external_message_pump = true
# else:
# CefSettings.multi_threaded_message_loop = true && CefSettings.external_message_pump = false
option(USE_QT_EVENT_LOOP "Enable the integration of CEF message loop thread into Qt event loop" ON)
# append cmake config module path
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
# Debug Release
set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "" FORCE)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose build type" FORCE)
endif()
# Use folders in the resulting project files.
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
# C standard
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_STANDARD 11)
# C++ standard
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD 17)
#
if(MSVC)
add_definitions(-D_SILENCE_CXX17_RESULT_OF_DEPRECATION_WARNING=1)
elseif(MINGW)
add_compile_options(-Wno-deprecated-declarations)
endif()
# Determine the project architecture.
if(CMAKE_SIZEOF_VOID_P MATCHES 8)
set(PROJECT_ARCH "x86_64")
else()
set(PROJECT_ARCH "x86")
endif()
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
set(OS_MACOS 1)
set(OS_POSIX 1)
add_definitions(
-DOS_MACOS=1
-DOS_POSIX=1
)
add_compile_options(
#"-g"
"$<$<CONFIG:DEBUG>:-O0>"
"$<$<CONFIG:RELEASE>:-O3>"
)
# Target architecture.
if(PROJECT_ARCH STREQUAL "x86_64")
set(CMAKE_OSX_ARCHITECTURES "x86_64")
elseif(PROJECT_ARCH STREQUAL "arm64")
set(CMAKE_OSX_ARCHITECTURES "arm64")
else()
set(CMAKE_OSX_ARCHITECTURES "i386")
endif()
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
set(OS_LINUX 1)
set(OS_POSIX 1)
add_definitions(-DOS_LINUX=1 -DOS_POSIX=1)
add_compile_options(
"-g"
"$<$<CONFIG:DEBUG>:-O0>"
"$<$<CONFIG:RELEASE>:-O3>"
)
if(PROJECT_ARCH STREQUAL "x86_64")
# x86 64-bit architecture.
add_compile_options(-m64 -march=x86-64)
add_link_options(-m64)
elseif(PROJECT_ARCH STREQUAL "x86")
# x86 32-bit architecture.
add_compile_options(-m32)
add_link_options(-m32)
endif()
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
if(MSVC)
set(OS_WINDOWS 1)
# Disable the sandbox on Windows, because the sandbox.lib is MT which is conflict with Qt
set(USE_SANDBOX OFF CACHE BOOL "Disable sandbox on Windows" FORCE)
add_definitions(
-DOS_WINDOWS=1
-D_WIN32_WINNT=0x0A00
)
if(USE_WIN_DCOMPOSITION)
add_definitions(
-DENABLE_WINDOWS_DIRECT_COMPOSITION=1
)
endif()
add_compile_options(
/W3
/WX
/M$<IF:$<BOOL:${STATIC_CRT}>,T,D>$<$<CONFIG:Debug>:d>
)
add_link_options(/DEBUG)
elseif(MINGW)
set(OS_WINDOWS 1)
add_definitions(
-DOS_WINDOWS=1
-D_WIN32_WINNT=0x0A00
)
if(USE_WIN_DCOMPOSITION)
add_definitions(
-DENABLE_WINDOWS_DIRECT_COMPOSITION=1
)
endif()
add_definitions(
-DOS_WINDOWS=1
-D_WIN32_WINNT=0x0A00
)
endif()
endif()
if(BUILD_STATIC)
set(QCEFVIEW_LIB_TYPE STATIC)
add_definitions(-DQCEFVIEW_STATIC=1)
else()
set(QCEFVIEW_LIB_TYPE SHARED)
endif()
# detect whether we are in sub folder
get_directory_property(QCefView_HAS_PARENT_DIRECTORY PARENT_DIRECTORY)
if(NOT QCefView_HAS_PARENT_DIRECTORY)
message(STATUS "QCefView is not in subdirectory, put all output together")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/output/$<CONFIG>/bin)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/output/$<CONFIG>/lib)
if(BUILD_STATIC)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/output/$<CONFIG>/lib)
else()
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/output/$<CONFIG>/bin)
endif()
endif()
message(STATUS "QCEFVIEW_RUNTIME_OUTPUT_DIRECTORY: ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
message(STATUS "QCEFVIEW_LIBRARY_OUTPUT_DIRECTORY: ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")
message(STATUS "QCEFVIEW_ARCHIVE_OUTPUT_DIRECTORY: ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}")
# Config the QT package
# ##############################################################
set(QT_SDK_DIR "" CACHE PATH "Qt build toolchain path")
include(QtConfig)
set(Qt_VERSION ${Qt${QT_VERSION_MAJOR}Core_VERSION})
# ##############################################################
# thirdparty CefViewCore
add_subdirectory(thirdparty)
if(OS_MACOS)
# detect minimum deployment target by Qt
if(${Qt_VERSION} VERSION_GREATER_EQUAL 6.5)
set(QT_MIN_DEPLOYMENT_TARGET 11.0)
elseif(${Qt_VERSION} VERSION_GREATER_EQUAL 6.2)
set(QT_MIN_DEPLOYMENT_TARGET 10.14)
elseif(${Qt_VERSION} VERSION_GREATER_EQUAL 5.14)
set(QT_MIN_DEPLOYMENT_TARGET 10.13)
elseif(${Qt_VERSION} VERSION_GREATER_EQUAL 5.13)
set(QT_MIN_DEPLOYMENT_TARGET 10.12)
elseif(${Qt_VERSION} VERSION_GREATER_EQUAL 5.10)
set(QT_MIN_DEPLOYMENT_TARGET 10.11)
else()
set(QT_MIN_DEPLOYMENT_TARGET 10.10)
endif()
# detect minimum deployment target by CEF
# plese refer to: https://bitbucket.org/chromiumembedded/cef/wiki/BranchesAndBuilding.md
if(${CEF_VERSION_MAJOR} VERSION_GREATER_EQUAL 117)
set(CEF_MIN_DEPLOYMENT_TARGET 10.15)
elseif(${CEF_VERSION_MAJOR} VERSION_GREATER_EQUAL 104)
set(CEF_MIN_DEPLOYMENT_TARGET 10.13)
else()
set(CEF_MIN_DEPLOYMENT_TARGET 10.11)
endif()
# use the greater one as the minimum deployment target
if(${QT_MIN_DEPLOYMENT_TARGET} VERSION_LESS ${CEF_MIN_DEPLOYMENT_TARGET})
set(CMAKE_OSX_DEPLOYMENT_TARGET ${CEF_MIN_DEPLOYMENT_TARGET})
else()
set(CMAKE_OSX_DEPLOYMENT_TARGET ${QT_MIN_DEPLOYMENT_TARGET})
endif()
endif()
# Config QCefView target
# ##############################################################
add_subdirectory(src)
# Config the Demo project
# ##############################################################
if(BUILD_DEMO)
add_subdirectory(example/QCefViewTest)
endif()
# ##############################################################

View File

@ -1,33 +0,0 @@
# ################################################################################
#
# The Qt SDK path
# You can set the environment variable via
# 1. command line
# Windows: SET QTDIR=PATH/TO/QT
# Non-Windows: export QTDIR=PATH/TO/QT
# 2. modifying the value below directly
#
# Qt build toolchain path not set or doesn't exist
# try to read from environment QTDIR
if(NOT EXISTS ${QT_SDK_DIR})
message(STATUS "QT_SDK_DIR not found, try to read from environment variable: QTDIR")
set(QT_SDK_DIR "$ENV{QTDIR}" CACHE STRING "QT_SDK_DIR read from environment variable: QTDIR" FORCE)
endif()
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!NOTE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# You must make sure the target platform and architecture
# of QT binaries math the ones of CEF binaries
# Qt linux-x86 + CEF linux-x86
# Qt linux-x86_64 + CEF linux-x86_64
# Qt windows-x86 + CEF windows-x86
# Qt windows-x86_64 + CEF windows-x86_64
# Qt macos-x86_64 + CEF macos-x86_64
# Qt macos-arm64 + CEF macos-arm64
#
# find required components
message(STATUS "Qt SDK dir: " ${QT_SDK_DIR})
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ${QT_SDK_DIR})
find_package(QT NAMES Qt6 Qt5 COMPONENTS Core Gui Widgets REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Gui Widgets REQUIRED)

View File

@ -1,253 +0,0 @@
# ## QCefView
# ###############################################################################################
set(CMAKE_GLOBAL_AUTOGEN_TARGET OFF)
set(CMAKE_AUTOMOC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
find_package(QT NAMES Qt6 Qt5 COMPONENTS Core Gui Widgets REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Gui Widgets REQUIRED)
file(GLOB_RECURSE QCefView_INCLUDE_FILES
"${CMAKE_CURRENT_SOURCE_DIR}/../include/*.h"
)
source_group(
TREE "${CMAKE_CURRENT_SOURCE_DIR}/../include"
PREFIX Include
FILES ${QCefView_INCLUDE_FILES}
)
file(GLOB QCefView_SRC_FILES
"${CMAKE_CURRENT_SOURCE_DIR}/*.h"
"${CMAKE_CURRENT_SOURCE_DIR}/*.cpp"
)
source_group(
TREE ${CMAKE_CURRENT_SOURCE_DIR}
PREFIX Source
FILES ${QCefView_SRC_FILES}
)
file(GLOB_RECURSE QCefView_details_SRC_FILES
"${CMAKE_CURRENT_SOURCE_DIR}/details/*.h"
"${CMAKE_CURRENT_SOURCE_DIR}/details/*.cpp"
)
source_group(
TREE ${CMAKE_CURRENT_SOURCE_DIR}
PREFIX Source
FILES ${QCefView_details_SRC_FILES}
)
if(USE_SANDBOX AND(OS_WINDOWS OR OS_MACOS))
add_definitions(-DCEF_USE_SANDBOX)
endif()
if(USE_QT_EVENT_LOOP)
add_definitions(-DCEF_USE_QT_EVENT_LOOP)
endif()
if(OS_WINDOWS)
file(GLOB_RECURSE QCefView_Windows_SRC_FILES
"${CMAKE_CURRENT_SOURCE_DIR}/win/*.h"
"${CMAKE_CURRENT_SOURCE_DIR}/win/*.cpp"
)
source_group(
TREE "${CMAKE_CURRENT_SOURCE_DIR}/win"
PREFIX Source
FILES ${QCefView_Windows_SRC_FILES}
)
add_library(QCefView ${QCEFVIEW_LIB_TYPE}
${QCefView_INCLUDE_FILES}
${QCefView_SRC_FILES}
${QCefView_details_SRC_FILES}
${QCefView_Windows_SRC_FILES}
)
target_compile_definitions(QCefView PRIVATE
UNICODE
_UNICODE
QCEFVIEW_LIB
)
target_link_options(QCefView PRIVATE
"/DELAYLOAD:libcef.dll"
)
target_link_libraries(QCefView
PRIVATE
d3d11
d3dcompiler
dcomp
)
# add_custom_command(TARGET QCefView
# PRE_BUILD
# # copy binary files of CefViewCore
# COMMAND ${CMAKE_COMMAND}
# -E copy_directory
# "$<TARGET_FILE_DIR:${CEFVIEW_WING_NAME}>"
# "$<TARGET_FILE_DIR:QCefView>/CefView"
# # gnerate a file contains timestamp
# COMMAND ${CMAKE_COMMAND}
# -E echo "/* Auto Build Trigger */" > "${CMAKE_BINARY_DIR}/auto_rebuild.cpp"
# )
endif() # OS_WINDOWS
if(OS_LINUX)
find_package(Qt${QT_VERSION_MAJOR}Gui ${QT_MIN_VERSION} CONFIG REQUIRED Private)
file(GLOB_RECURSE QCefView_Linux_SRC_FILES
"${CMAKE_CURRENT_SOURCE_DIR}/linux/*.h"
"${CMAKE_CURRENT_SOURCE_DIR}/linux/*.cpp"
)
source_group(
TREE "${CMAKE_CURRENT_SOURCE_DIR}/linux"
PREFIX Source
FILES ${QCefView_Linux_SRC_FILES}
)
add_library(QCefView ${QCEFVIEW_LIB_TYPE}
${QCefView_INCLUDE_FILES}
${QCefView_SRC_FILES}
${QCefView_details_SRC_FILES}
${QCefView_Linux_SRC_FILES}
)
target_compile_definitions(QCefView
PRIVATE
QCEFVIEW_LIB
)
set_target_properties(${PROJECT_NAME}
PROPERTIES
INSTALL_RPATH "$ORIGIN"
BUILD_WITH_INSTALL_RPATH TRUE
)
add_custom_command(TARGET QCefView
PRE_BUILD
# copy binary files of CefViewCore
COMMAND ${CMAKE_COMMAND}
-E copy_directory
"$<TARGET_FILE_DIR:${CEFVIEW_WING_NAME}>"
"$<TARGET_FILE_DIR:QCefView>"
)
endif() # OS_LINUX
if(OS_MACOS)
file(GLOB_RECURSE QCefView_INCLUDE_HEADERS
"${CMAKE_CURRENT_SOURCE_DIR}/../include/*.h"
)
source_group(
TREE "${CMAKE_CURRENT_SOURCE_DIR}/../include"
PREFIX Include
FILES ${QCefView_INCLUDE_HEADERS}
)
file(GLOB_RECURSE QCefView_macOS_SRC_FILES
"${CMAKE_CURRENT_SOURCE_DIR}/mac/*.h"
"${CMAKE_CURRENT_SOURCE_DIR}/mac/*.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/mac/*.mm"
)
source_group(
TREE "${CMAKE_CURRENT_SOURCE_DIR}/mac"
PREFIX Source
FILES ${QCefView_macOS_SRC_FILES}
)
set(QCefView_INFO_PLIST_FILE "${CMAKE_CURRENT_LIST_DIR}/mac/Info.plist")
add_library(QCefView ${QCEFVIEW_LIB_TYPE}
${QCefView_INCLUDE_FILES}
${QCefView_SRC_FILES}
${QCefView_details_SRC_FILES}
${QCefView_macOS_SRC_FILES}
${QCefView_INFO_PLIST_FILE}
)
find_library(METAL_FRAMEWORK Metal)
find_library(QUARTZCORE_FRAMEWORK QuartzCore)
target_link_libraries(QCefView
PRIVATE
${METAL_FRAMEWORK}
${QUARTZCORE_FRAMEWORK}
)
set_target_properties(QCefView
PROPERTIES
FRAMEWORK TRUE
# compiler settings
COMPILE_FLAGS "-fobjc-arc"
CLANG_ENABLE_OBJC_ARC "YES"
# xcode settings
PUBLIC_HEADER "${QCefView_INCLUDE_HEADERS}"
MACOSX_FRAMEWORK_INFO_PLIST "${QCefView_INFO_PLIST_FILE}"
XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER "com.cefview.qcefview"
XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "gnu++11" # -std=gnu++11
XCODE_ATTRIBUTE_CLANG_LINK_OBJC_RUNTIME "NO" # -fno-objc-link-runtime
XCODE_ATTRIBUTE_COPY_PHASE_STRIP "NO"
XCODE_ATTRIBUTE_DEAD_CODE_STRIPPING[variant=Release] "YES" # -Wl,-dead_strip
XCODE_ATTRIBUTE_GCC_C_LANGUAGE_STANDARD "c99" # -std=c99
XCODE_ATTRIBUTE_LD_RUNPATH_SEARCH_PATHS "@executable_path/../Frameworks @loader_path/Frameworks"
)
add_custom_command(TARGET QCefView
POST_BUILD
# create plugins directory
COMMAND mkdir -p
"$<TARGET_BUNDLE_DIR:QCefView>/Resources/PlugIns/"
# copy the CefViewCore binaries to resource directory
COMMAND cp -a
"$<TARGET_BUNDLE_DIR:CefViewWing>/../"
"$<TARGET_BUNDLE_DIR:QCefView>/Resources/PlugIns/"
# adjust file permission
COMMAND
cd "$<TARGET_BUNDLE_DIR:QCefView>/Resources/PlugIns/Chromium Embedded Framework.framework/Resources" && chmod +rw *.bin
# sign the cef framework
COMMAND codesign
--force
--sign -
"$<TARGET_BUNDLE_DIR:QCefView>/Resources/PlugIns/Chromium Embedded Framework.framework"
)
endif() # OS_MACOS
target_compile_definitions(QCefView PRIVATE NOMINMAX)
target_include_directories(QCefView
PUBLIC
"${CMAKE_CURRENT_SOURCE_DIR}/../include"
PRIVATE
${CefViewCore_EXPORT_INCLUDE_PATH}
)
add_dependencies(QCefView
CefViewCore::CefViewCore
)
target_link_libraries(QCefView
PUBLIC
Qt${QT_VERSION_MAJOR}::Gui
Qt${QT_VERSION_MAJOR}::Core
Qt${QT_VERSION_MAJOR}::Widgets
PRIVATE
CefViewCore::CefViewCore
)
# install QCefView files
install(
TARGETS QCefView
ARCHIVE DESTINATION "QCefView/lib$<$<CONFIG:Debug>:/Debug>"
LIBRARY DESTINATION "QCefView/bin$<$<CONFIG:Debug>:/Debug>"
FRAMEWORK DESTINATION "QCefView/lib$<$<CONFIG:Debug>:/Debug>"
)
if(NOT OS_MACOS)
install(DIRECTORY "${CMAKE_SOURCE_DIR}/include" DESTINATION "QCefView")
install(DIRECTORY "$<TARGET_FILE_DIR:QCefView>/" DESTINATION "QCefView/bin$<$<CONFIG:Debug>:/Debug>")
endif()

View File

@ -1,272 +0,0 @@
# ## QCefView
# ###############################################################################################
set(CMAKE_GLOBAL_AUTOGEN_TARGET OFF)
set(CMAKE_AUTOMOC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
find_package(QT NAMES Qt6 Qt5 COMPONENTS Core Gui Widgets REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Gui Widgets REQUIRED)
file(GLOB_RECURSE QCefView_INCLUDE_FILES
"${CMAKE_CURRENT_SOURCE_DIR}/../include/*.h"
)
source_group(
TREE "${CMAKE_CURRENT_SOURCE_DIR}/../include"
PREFIX Include
FILES ${QCefView_INCLUDE_FILES}
)
file(GLOB QCefView_SRC_FILES
"${CMAKE_CURRENT_SOURCE_DIR}/*.h"
"${CMAKE_CURRENT_SOURCE_DIR}/*.cpp"
)
source_group(
TREE ${CMAKE_CURRENT_SOURCE_DIR}
PREFIX Source
FILES ${QCefView_SRC_FILES}
)
file(GLOB_RECURSE QCefView_details_SRC_FILES
"${CMAKE_CURRENT_SOURCE_DIR}/details/*.h"
"${CMAKE_CURRENT_SOURCE_DIR}/details/*.cpp"
)
source_group(
TREE ${CMAKE_CURRENT_SOURCE_DIR}
PREFIX Source
FILES ${QCefView_details_SRC_FILES}
)
if(USE_SANDBOX AND(OS_WINDOWS OR OS_MACOS))
add_definitions(-DCEF_USE_SANDBOX)
endif()
if(USE_QT_EVENT_LOOP)
add_definitions(-DCEF_USE_QT_EVENT_LOOP)
endif()
if(OS_WINDOWS)
file(GLOB_RECURSE QCefView_Windows_SRC_FILES
"${CMAKE_CURRENT_SOURCE_DIR}/win/*.h"
"${CMAKE_CURRENT_SOURCE_DIR}/win/*.cpp"
)
source_group(
TREE "${CMAKE_CURRENT_SOURCE_DIR}/win"
PREFIX Source
FILES ${QCefView_Windows_SRC_FILES}
)
add_library(QCefView ${QCEFVIEW_LIB_TYPE}
${QCefView_INCLUDE_FILES}
${QCefView_SRC_FILES}
${QCefView_details_SRC_FILES}
${QCefView_Windows_SRC_FILES}
)
target_compile_definitions(QCefView PRIVATE
UNICODE
_UNICODE
QCEFVIEW_LIB
)
if(MSVC)
target_link_options(QCefView PRIVATE
"/DELAYLOAD:libcef.dll"
)
add_custom_command(TARGET QCefView
PRE_BUILD
# copy binary files of CefViewCore
COMMAND ${CMAKE_COMMAND}
-E copy_directory
"$<TARGET_FILE_DIR:CefViewCore>"
"$<TARGET_FILE_DIR:QCefView>/CefView"
# gnerate a file contains timestamp
COMMAND ${CMAKE_COMMAND}
-E echo "/* Auto Build Trigger */" > "${CMAKE_BINARY_DIR}/auto_rebuild.cpp"
)
elseif(MINGW)
target_link_options(QCefView PRIVATE
"-Wl,--enable-auto-import"
"-Wl,--as-needed"
"-lcef"
)
add_custom_command(TARGET QCefView
PRE_BUILD
# copy binary files of CefViewCore
COMMAND ${CMAKE_COMMAND}
-E copy_directory
"$<TARGET_FILE_DIR:CefViewCore>"
"$<TARGET_FILE_DIR:QCefView>/CefView"
# generate a file contains timestamp
COMMAND ${CMAKE_COMMAND}
-E echo "/* Auto Build Trigger */" > "${CMAKE_BINARY_DIR}/auto_rebuild.cpp"
)
endif()
target_link_libraries(QCefView
PRIVATE
d3d11
d3dcompiler
dcomp
)
endif() # OS_WINDOWS
if(OS_LINUX)
find_package(Qt${QT_VERSION_MAJOR}Gui ${QT_MIN_VERSION} CONFIG REQUIRED Private)
file(GLOB_RECURSE QCefView_Linux_SRC_FILES
"${CMAKE_CURRENT_SOURCE_DIR}/linux/*.h"
"${CMAKE_CURRENT_SOURCE_DIR}/linux/*.cpp"
)
source_group(
TREE "${CMAKE_CURRENT_SOURCE_DIR}/linux"
PREFIX Source
FILES ${QCefView_Linux_SRC_FILES}
)
add_library(QCefView ${QCEFVIEW_LIB_TYPE}
${QCefView_INCLUDE_FILES}
${QCefView_SRC_FILES}
${QCefView_details_SRC_FILES}
${QCefView_Linux_SRC_FILES}
)
target_compile_definitions(QCefView
PRIVATE
QCEFVIEW_LIB
)
set_target_properties(${PROJECT_NAME}
PROPERTIES
INSTALL_RPATH "$ORIGIN"
BUILD_WITH_INSTALL_RPATH TRUE
)
add_custom_command(TARGET QCefView
PRE_BUILD
# copy binary files of CefViewCore
COMMAND ${CMAKE_COMMAND}
-E copy_directory
"$<TARGET_FILE_DIR:${CEFVIEW_WING_NAME}>"
"$<TARGET_FILE_DIR:QCefView>"
)
endif() # OS_LINUX
if(OS_MACOS)
file(GLOB_RECURSE QCefView_INCLUDE_HEADERS
"${CMAKE_CURRENT_SOURCE_DIR}/../include/*.h"
)
source_group(
TREE "${CMAKE_CURRENT_SOURCE_DIR}/../include"
PREFIX Include
FILES ${QCefView_INCLUDE_HEADERS}
)
file(GLOB_RECURSE QCefView_macOS_SRC_FILES
"${CMAKE_CURRENT_SOURCE_DIR}/mac/*.h"
"${CMAKE_CURRENT_SOURCE_DIR}/mac/*.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/mac/*.mm"
)
source_group(
TREE "${CMAKE_CURRENT_SOURCE_DIR}/mac"
PREFIX Source
FILES ${QCefView_macOS_SRC_FILES}
)
set(QCefView_INFO_PLIST_FILE "${CMAKE_CURRENT_LIST_DIR}/mac/Info.plist")
add_library(QCefView ${QCEFVIEW_LIB_TYPE}
${QCefView_INCLUDE_FILES}
${QCefView_SRC_FILES}
${QCefView_details_SRC_FILES}
${QCefView_macOS_SRC_FILES}
${QCefView_INFO_PLIST_FILE}
)
find_library(METAL_FRAMEWORK Metal)
find_library(QUARTZCORE_FRAMEWORK QuartzCore)
target_link_libraries(QCefView
PRIVATE
${METAL_FRAMEWORK}
${QUARTZCORE_FRAMEWORK}
)
set_target_properties(QCefView
PROPERTIES
FRAMEWORK TRUE
# compiler settings
COMPILE_FLAGS "-fobjc-arc"
CLANG_ENABLE_OBJC_ARC "YES"
# xcode settings
PUBLIC_HEADER "${QCefView_INCLUDE_HEADERS}"
MACOSX_FRAMEWORK_INFO_PLIST "${QCefView_INFO_PLIST_FILE}"
XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER "com.cefview.qcefview"
XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "gnu++11" # -std=gnu++11
XCODE_ATTRIBUTE_CLANG_LINK_OBJC_RUNTIME "NO" # -fno-objc-link-runtime
XCODE_ATTRIBUTE_COPY_PHASE_STRIP "NO"
XCODE_ATTRIBUTE_DEAD_CODE_STRIPPING[variant=Release] "YES" # -Wl,-dead_strip
XCODE_ATTRIBUTE_GCC_C_LANGUAGE_STANDARD "c99" # -std=c99
XCODE_ATTRIBUTE_LD_RUNPATH_SEARCH_PATHS "@executable_path/../Frameworks @loader_path/Frameworks"
)
add_custom_command(TARGET QCefView
POST_BUILD
# create plugins directory
COMMAND mkdir -p
"$<TARGET_BUNDLE_DIR:QCefView>/Resources/PlugIns/"
# copy the CefViewCore binaries to resource directory
COMMAND cp -a
"$<TARGET_BUNDLE_DIR:CefViewWing>/../"
"$<TARGET_BUNDLE_DIR:QCefView>/Resources/PlugIns/"
# adjust file permission
COMMAND
cd "$<TARGET_BUNDLE_DIR:QCefView>/Resources/PlugIns/Chromium Embedded Framework.framework/Resources" && chmod +rw *.bin
# sign the cef framework
COMMAND codesign
--force
--sign -
"$<TARGET_BUNDLE_DIR:QCefView>/Resources/PlugIns/Chromium Embedded Framework.framework"
)
endif() # OS_MACOS
target_compile_definitions(QCefView PRIVATE NOMINMAX)
target_include_directories(QCefView
PUBLIC
"${CMAKE_CURRENT_SOURCE_DIR}/../include"
PRIVATE
${CefViewCore_EXPORT_INCLUDE_PATH}
)
message(STATUS "CefViewCore_EXPORT_INCLUDE_PATH: ${CefViewCore_EXPORT_INCLUDE_PATH}")
add_dependencies(QCefView
CefViewCore::CefViewCore
)
target_link_libraries(QCefView
PUBLIC
Qt${QT_VERSION_MAJOR}::Gui
Qt${QT_VERSION_MAJOR}::Core
Qt${QT_VERSION_MAJOR}::Widgets
CefViewCore::CefViewCore
)
# install QCefView files
install(
TARGETS QCefView
ARCHIVE DESTINATION "QCefView/lib$<$<CONFIG:Debug>:/Debug>"
LIBRARY DESTINATION "QCefView/bin$<$<CONFIG:Debug>:/Debug>"
FRAMEWORK DESTINATION "QCefView/lib$<$<CONFIG:Debug>:/Debug>"
)
if(NOT OS_MACOS)
install(DIRECTORY "${CMAKE_SOURCE_DIR}/include" DESTINATION "QCefView")
install(DIRECTORY "$<TARGET_FILE_DIR:QCefView>/" DESTINATION "QCefView/bin$<$<CONFIG:Debug>:/Debug>")
endif()

View File

@ -1,23 +0,0 @@
使用情况CMakelists.txt
add_definitions(-DQCEFVIEW_STATIC)
#libcef_dll_wrapper
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/libcef_dll_wrapper)
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/libcef_dll_wrapper/lib)
#QCefViewCore
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/CefViewCore/include)
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/CefViewCore/lib)
#QCefView
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/QCefView/include)
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/QCefView/lib)
target_link_libraries(${PROJECT_NAME} PRIVATE
-lQCefView
-lCefViewCore
-lcef_dll_wrapper
-lcef
d3d11
d3dcompiler
dcomp
)

View File

@ -77,13 +77,6 @@ add_definitions(-DCEF_USE_QT_EVENT_LOOP)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/libcef_dll_wrapper) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/libcef_dll_wrapper)
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/libcef_dll_wrapper/lib) link_directories(${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/libcef_dll_wrapper/lib)
#QCefViewCore
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/CefViewCore/include)
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/CefViewCore/lib)
#QCefView
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/QCefView/include)
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/QCefView/lib)
#QT #QT
FIND_PACKAGE(Qt6 REQUIRED Core Gui Widgets) FIND_PACKAGE(Qt6 REQUIRED Core Gui Widgets)
@ -165,8 +158,6 @@ target_link_libraries(${PROJECT_NAME} PRIVATE
LaTeX LaTeX
libcmark-gfm_static libcmark-gfm_static
libcmark-gfm-extensions_static libcmark-gfm-extensions_static
-lQCefView
-lCefViewCore
-lcef_dll_wrapper -lcef_dll_wrapper
-lcef -lcef
d3d11 d3d11

View File

@ -1,106 +0,0 @@
#include "CefViewWidget.h"
CefViewWidget::CefViewWidget(const QString url, const QCefSetting* setting, QWidget* parent /* = 0*/)
: QCefView(url, setting, parent)
{
// setStyleSheet("background: blue;");
connect(this, &CefViewWidget::draggableRegionChanged, this, &CefViewWidget::onDraggableRegionChanged);
connect(this, &CefViewWidget::nativeBrowserCreated, this, &CefViewWidget::onNativeBrowserWindowCreated);
}
CefViewWidget::~CefViewWidget() {}
void
CefViewWidget::onScreenChanged(QScreen* screen)
{
if (!m_pCefWindow)
return;
updateMask();
}
void
CefViewWidget::onNativeBrowserWindowCreated(QWindow* window)
{
m_pCefWindow = window;
if (!m_pCefWindow)
return;
connect(this->window()->windowHandle(), SIGNAL(screenChanged(QScreen*)), this, SLOT(onScreenChanged(QScreen*)));
updateMask();
}
void
CefViewWidget::onDraggableRegionChanged(const QRegion& draggableRegion, const QRegion& nonDraggableRegion)
{
m_draggableRegion = draggableRegion;
m_nonDraggableRegion = nonDraggableRegion;
}
bool
CefViewWidget::onNewPopup(const QCefFrameId& sourceFrameId,
const QString& targetUrl,
QString& targetFrameName,
QCefView::CefWindowOpenDisposition targetDisposition,
QRect& rect,
QCefSetting& settings,
bool& disableJavascriptAccess)
{
// create new QCefView as popup browser
// settings.setBackgroundColor(Qt::red);
return false;
}
void
CefViewWidget::onNewDownloadItem(const QSharedPointer<QCefDownloadItem>& item, const QString& suggestedName)
{
// keep the item into list or map, and call item->start() to allow the download
DownloadManager::getInstance().AddNewDownloadItem(item);
}
void
CefViewWidget::onUpdateDownloadItem(const QSharedPointer<QCefDownloadItem>& item)
{
// control the download by invoking item->pause(), item->resume(), item->cancel()
DownloadManager::getInstance().UpdateDownloadItem(item);
}
void
CefViewWidget::resizeEvent(QResizeEvent* event)
{
// update mask first, because the new mask will be
// used in the QCefView::resizeEvent
updateMask();
QCefView::resizeEvent(event);
}
void
CefViewWidget::mousePressEvent(QMouseEvent* event)
{
QCefView::mousePressEvent(event);
if (event->buttons().testFlag(Qt::LeftButton) && m_draggableRegion.contains(event->pos())) {
HWND hWnd = ::GetAncestor((HWND)(window()->windowHandle()->winId()), GA_ROOT);
POINT pt;
::GetCursorPos(&pt);
::ReleaseCapture();
::SendMessage(hWnd, WM_NCLBUTTONDOWN, HTCAPTION, POINTTOPOINTS(pt));
}
}
void
CefViewWidget::updateMask()
{
// create a rect with rounded corner (50px radius) as mask
QPainterPath path;
path.addRoundedRect(rect(), 0, 0);
QRegion mask = QRegion(path.toFillPolygon().toPolygon());
// apply the mask
setMask(mask);
}

View File

@ -1,65 +0,0 @@
#ifndef CUSTOMCEFVIEW_H
#define CUSTOMCEFVIEW_H
#include <QColor>
#include <QDebug>
#include <QScreen>
#include <QPainterPath>
#include <QRandomGenerator>
#include <QResizeEvent>
#include <QWindow>
#include <windows.h>
#include <QCefView.h>
#include "DownloadManager.h"
/// <summary>
/// Represents the customized QCefView
/// </summary>
class CefViewWidget : public QCefView
{
Q_OBJECT
public:
CefViewWidget(const QString url, const QCefSetting* setting, QWidget* parent = 0);
~CefViewWidget();
protected slots:
void onScreenChanged(QScreen* screen);
void onNativeBrowserWindowCreated(QWindow* window);
void onDraggableRegionChanged(const QRegion& draggableRegion, const QRegion& nonDraggableRegion);
protected:
bool onNewPopup(const QCefFrameId& sourceFrameId,
const QString& targetUrl,
QString& targetFrameName,
QCefView::CefWindowOpenDisposition targetDisposition,
QRect& rect,
QCefSetting& settings,
bool& disableJavascriptAccess) override;
void onNewDownloadItem(const QSharedPointer<QCefDownloadItem>& item, const QString& suggestedName) override;
void onUpdateDownloadItem(const QSharedPointer<QCefDownloadItem>& item) override;
protected:
void resizeEvent(QResizeEvent* event) override;
void mousePressEvent(QMouseEvent* event) override;
private:
void updateMask();
private:
QWindow* m_pCefWindow = nullptr;
int m_iCornerRadius = 50;
QRegion m_draggableRegion;
QRegion m_nonDraggableRegion;
};
#endif // CUSTOMCEFVIEW_H

View File

@ -1,214 +0,0 @@
#include "CefWidget.h"
#include <QCoreApplication>
#include <QDebug>
#include <QDir>
#include <QHBoxLayout>
#include <QJsonDocument>
#include <QJsonValue>
#include <QMessageBox>
#include <QRandomGenerator>
#include <QCefContext.h>
CefWidget::CefWidget(QWidget *parent)
: QWidget(parent /*, Qt::FramelessWindowHint*/)
{
m_Layout = new QVBoxLayout;
m_OptionsLayout = new QHBoxLayout;
m_BrowserLayout = new QHBoxLayout;
m_NewBrowser = new QPushButton(tr("New Browser"));
m_ExitAllBrowser = new QPushButton(tr("Exit ALL Browser"));
m_DevTools = new QPushButton(tr("DevTools"));
m_CallJSCode = new QPushButton(tr("Call JS Code"));
m_SetFocus = new QPushButton(tr("Set Focus"));
m_BtnToUrl = new QPushButton(tr("To Url"));
m_TextToUrl = new QLineEdit();
m_TextToUrl->setPlaceholderText(tr("输入前往url地址"));
m_OptionsLayout->addWidget(m_NewBrowser);
m_OptionsLayout->addWidget(m_TextToUrl);
m_OptionsLayout->addWidget(m_BtnToUrl);
m_OptionsLayout->addWidget(m_SetFocus);
m_OptionsLayout->addWidget(m_CallJSCode);
m_OptionsLayout->addWidget(m_DevTools);
m_OptionsLayout->addWidget(m_ExitAllBrowser);
m_OptionsLayout->setStretch(1,7);
m_Layout->addLayout(m_OptionsLayout);
m_Layout->addLayout(m_BrowserLayout);
m_Layout->setStretch(0,2);
m_Layout->setStretch(1,8);
setLayout(m_Layout);
connect(m_BtnToUrl, &QPushButton::clicked, this, &CefWidget::onBtnToUrl);
connect(m_DevTools, &QPushButton::clicked, this, &CefWidget::onBtnShowDevToolsClicked);
connect(m_SetFocus, &QPushButton::clicked, this, &CefWidget::onBtnSetFocusClicked);
connect(m_CallJSCode, &QPushButton::clicked, this, &CefWidget::onBtnCallJSCodeClicked);
connect(m_NewBrowser, &QPushButton::clicked, this, &CefWidget::onBtnNewBrowserClicked);
connect(m_ExitAllBrowser, &QPushButton::clicked, qApp, &QCoreApplication::quit);
setMinimumSize(1000, 800);
initBrowser();
}
CefWidget::~CefWidget() {}
void CefWidget::initBrowser()
{
if (m_CefWidget)
{
m_CefWidget->deleteLater();
m_CefWidget = nullptr;
}
setting.setHardwareAcceleration(true);
m_CefWidget = new CefViewWidget("https://www.bilibili.com/", &setting, this);
connect(m_CefWidget, &QCefView::invokeMethod, this, &CefWidget::onInvokeMethod);
connect(m_CefWidget, &QCefView::cefUrlRequest, this, &CefWidget::onQCefUrlRequest);
connect(m_CefWidget, &QCefView::cefQueryRequest, this, &CefWidget::onQCefQueryRequest);
connect(m_CefWidget, &QCefView::reportJavascriptResult, this, &CefWidget::onJavascriptResult);
connect(m_CefWidget, &QCefView::loadStart, this, &CefWidget::onLoadStart);
connect(m_CefWidget, &QCefView::loadEnd, this, &CefWidget::onLoadEnd);
connect(m_CefWidget, &QCefView::loadError, this, &CefWidget::onLoadError);
m_BrowserLayout->addWidget(m_CefWidget);
}
void CefWidget::onBtnToUrl()
{
if (!m_TextToUrl->text().isEmpty())
{
m_CefWidget->navigateToUrl(m_TextToUrl->text());
}
}
void CefWidget::onInvokeMethod(const QCefBrowserId &browserId,
const QCefFrameId &frameId,
const QString &method,
const QVariantList &arguments)
{
// extract the arguments and dispatch the invocation to corresponding handler
if (0 == method.compare("TestMethod"))
{
QString title("QCef InvokeMethod Notify");
QString text = QString("================== Current Thread: QT_UI ==================\r\n"
"Frame: %1\r\n"
"Method: %2\r\n"
"Arguments:\r\n")
.arg(frameId)
.arg(method);
for (int i = 0; i < arguments.size(); i++)
{
auto jv = QJsonValue::fromVariant(arguments[i]);
// clang-format off
text.append(
QString("%1 Type:%2, Value:%3\r\n")
.arg(i).arg(arguments[i].typeName()).arg(arguments[i].toString())
);
// clang-format on
}
auto jsonValue = QJsonDocument::fromVariant(arguments);
auto jsonString = QString(jsonValue.toJson());
text.append(QString("\r\nArguments List in JSON format:\r\n%1").arg(jsonString));
QMessageBox::information(this->window(), title, text);
}
else
{
}
}
void CefWidget::onQCefUrlRequest(const QCefBrowserId &browserId, const QCefFrameId &frameId, const QString &url)
{
QString title("QCef URL Request");
QString text = QString("Current Thread: QT_UI\r\n"
"URL: %1")
.arg(url);
QMessageBox::information(this->window(), title, text);
}
void CefWidget::onQCefQueryRequest(const QCefBrowserId &browserId, const QCefFrameId &frameId, const QCefQuery &query)
{
QString title("QCef Query Request");
QString text = QString("Current Thread: QT_UI\r\n"
"Query: %1")
.arg(query.request());
QMessageBox::information(this->window(), title, text);
QString response = query.request().toUpper();
query.setResponseResult(true, response);
m_CefWidget->responseQCefQuery(query);
}
void CefWidget::onJavascriptResult(const QCefBrowserId &browserId,
const QCefFrameId &frameId,
const QString &context,
const QVariant &result)
{
auto jsonValue = QJsonDocument::fromVariant(result);
auto jsonString = QString(jsonValue.toJson());
QString title("Javascript result notification");
QString text = QString("Context: %1\r\nResult in JSON format:\r\n%2").arg(context).arg(jsonString);
QMessageBox::information(this->window(), title, text);
}
void CefWidget::onLoadingStateChanged(const QCefBrowserId &browserId, bool isLoading, bool canGoBack, bool canGoForward)
{
qDebug() << "onLoadingStateChanged, browserId:" << browserId << ", isLoading:" << isLoading
<< ", canGoBack:" << canGoBack << ", canGoForward:" << canGoForward;
}
void CefWidget::onLoadStart(const QCefBrowserId &browserId,
const QCefFrameId &frameId,
bool isMainFrame,
int transitionType)
{
qDebug() << "onLoadStart, browserId:" << browserId << ", frameId:" << frameId << ", isMainFrame:" << isMainFrame
<< ", transitionType:" << transitionType;
}
void CefWidget::onLoadEnd(const QCefBrowserId &browserId, const QCefFrameId &frameId, bool isMainFrame, int httpStatusCode)
{
qDebug() << "onLoadEnd, browserId:" << browserId << ", frameId:" << frameId << ", isMainFrame:" << isMainFrame
<< ", httpStatusCode:" << httpStatusCode;
}
void CefWidget::onLoadError(const QCefBrowserId &browserId,
const QCefFrameId &frameId,
bool isMainFrame,
int errorCode,
const QString &errorMsg,
const QString &failedUrl)
{
qDebug() << "onLoadError, browserId:" << browserId << ", frameId:" << frameId << ", isMainFrame:" << isMainFrame
<< ", errorCode:" << errorCode;
}
void CefWidget::onBtnShowDevToolsClicked()
{
if (m_CefWidget)
{
m_CefWidget->showDevTools();
}
}
void CefWidget::onBtnCallJSCodeClicked()
{
QString context = "helloQCefView";
QString code = "alert('hello QCefView'); return {k1: 'str', k2: true, k3: 100};";
m_CefWidget->executeJavascriptWithResult(QCefView::MainFrameID, code, "", context);
}
void CefWidget::onBtnSetFocusClicked()
{
if (m_CefWidget)
{
m_CefWidget->setFocus();
}
}
void CefWidget::onBtnNewBrowserClicked()
{
}

View File

@ -1,69 +0,0 @@
#ifndef CEFWIDGET_H
#define CEFWIDGET_H
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QCloseEvent>
#include <QWidget>
#include <QLineEdit>
#include <QPushButton>
#include "CefViewWidget.h"
class CefWidget : public QWidget
{
Q_OBJECT
public:
CefWidget(QWidget* parent = 0);
~CefWidget();
private:
void initBrowser();
private:
QVBoxLayout* m_Layout={};
QHBoxLayout* m_OptionsLayout={};
QHBoxLayout* m_BrowserLayout={};
QPushButton* m_NewBrowser={};
QPushButton* m_ExitAllBrowser={};
QPushButton* m_DevTools={};
QPushButton* m_CallJSCode={};
QPushButton* m_SetFocus={};
QLineEdit* m_TextToUrl={};
QPushButton* m_BtnToUrl={};
QCefView* m_CefWidget ={};
QCefSetting setting;
protected:
void createLeftCefView();
// QCefView slots
protected slots:
void onInvokeMethod(const QCefBrowserId& browserId,
const QCefFrameId& frameId,
const QString& method,
const QVariantList& arguments);
void onQCefUrlRequest(const QCefBrowserId& browserId, const QCefFrameId& frameId, const QString& url);
void onQCefQueryRequest(const QCefBrowserId& browserId, const QCefFrameId& frameId, const QCefQuery& query);
void onJavascriptResult(const QCefBrowserId& browserId,
const QCefFrameId& frameId,
const QString& context,
const QVariant& result);
void onLoadingStateChanged(const QCefBrowserId& browserId, bool isLoading, bool canGoBack, bool canGoForward);
void onLoadStart(const QCefBrowserId& browserId, const QCefFrameId& frameId, bool isMainFrame, int transitionType);
void onLoadEnd(const QCefBrowserId& browserId, const QCefFrameId& frameId, bool isMainFrame, int httpStatusCode);
void onLoadError(const QCefBrowserId& browserId,
const QCefFrameId& frameId,
bool isMainFrame,
int errorCode,
const QString& errorMsg,
const QString& failedUrl);
//ui slots
protected slots:
void onBtnShowDevToolsClicked();
void onBtnSetFocusClicked();
void onBtnCallJSCodeClicked();
void onBtnNewBrowserClicked();
void onBtnToUrl();
};
#endif // QCEFVIEWTEST_H

View File

@ -1,52 +0,0 @@
#include "DownloadManager.h"
#include <QDebug>
DownloadManager&
DownloadManager::getInstance()
{
static DownloadManager s_instance;
return s_instance;
}
void
DownloadManager::AddNewDownloadItem(const QSharedPointer<QCefDownloadItem>& item)
{
qDebug() << "DownloadManager::AddNewDownloadItem:"
<< " id: " << item->id() << "\n"
<< " name: " << item->suggestedFileName() << "\n"
<< " path: " << item->fullPath() << "\n"
<< " percent: " << item->percentComplete() << "%, " << item->totalBytes() << "/" << item->receivedBytes()
<< "\n"
<< " canceled: " << item->isCanceled() << "\n"
<< " complete: " << item->isComplete();
m_mapDownloadingItem[item->id()] = item;
item->start("", true);
}
void
DownloadManager::UpdateDownloadItem(const QSharedPointer<QCefDownloadItem>& item)
{
qDebug() << "DownloadManager::UpdateDownloadItem:"
<< " id: " << item->id() << "\n"
<< " name: " << item->suggestedFileName() << "\n"
<< " path: " << item->fullPath() << "\n"
<< " percent: " << item->percentComplete() << "%, " << item->totalBytes() << "/" << item->receivedBytes()
<< "\n"
<< " canceled: " << item->isCanceled() << "\n"
<< " complete: " << item->isComplete();
if (item->isCanceled() || item->isComplete())
m_mapDownloadingItem.remove(item->id());
}
DownloadManager::DownloadManager() {}
DownloadManager::~DownloadManager()
{
for (auto& item : m_mapDownloadingItem) {
item->cancel();
}
m_mapDownloadingItem.clear();
}

View File

@ -1,26 +0,0 @@
#ifndef DOWNLOADMANAGER_H
#define DOWNLOADMANAGER_H
#pragma once
#include <QMap>
#include <QSharedPointer>
#include <QCefDownloadItem.h>
class DownloadManager
{
public:
static DownloadManager& getInstance();
void AddNewDownloadItem(const QSharedPointer<QCefDownloadItem>& item);
void UpdateDownloadItem(const QSharedPointer<QCefDownloadItem>& item);
private:
DownloadManager();
~DownloadManager();
QMap<qint32, QSharedPointer<QCefDownloadItem>> m_mapDownloadingItem;
};
#endif

View File

@ -1,20 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!--The ID below indicates application support for Windows Vista -->
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
<!--The ID below indicates application support for Windows 7 -->
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
<!--The ID below indicates application support for Windows 8 -->
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
<!--The ID below indicates application support for Windows 8.1 -->
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
<!--The ID below indicates application support for Windows 10 -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
<!-- This tag is required for XAML islands usage in the process for media scenarios. -->
<!-- This version corresponds to the Windows 10 May 2019 Update. -->
<maxversiontested Id="10.0.18362.0"/>
</application>
</compatibility>
</assembly>

View File

@ -1,20 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<!--The compatibility section will be merged from build/win/compatibility.manifest -->
<dependency>
<dependentAssembly>
<assemblyIdentity type="Win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*"></assemblyIdentity>
</dependentAssembly>
</dependency>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="asInvoker" />
</requestedPrivileges>
</security>
</trustInfo>
</assembly>

View File

@ -4,41 +4,10 @@
#include "sui_base_ex.h" #include "sui_base_ex.h"
#include "ctai.h" #include "ctai.h"
#include <QApplication> #include <QApplication>
#include <QCefContext.h>
#include "cef/CefWidget.h"
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
QString exeDir = QDir::currentPath();
QApplication a(argc, argv);
QCefConfig config;
config.setUserAgent("QCefViewTest");
config.setLogLevel(QCefConfig::LOGSEVERITY_VERBOSE);
config.setBridgeObjectName("CallBridge");
config.setBuiltinSchemeName("CefView");
config.setWindowlessRenderingEnabled(true);
config.addCommandLineSwitch("single-process");
config.addCommandLineSwitch("use-alloy-style");
config.addCommandLineSwitch("off-screen-rendering-enabled");
config.addCommandLineSwitch("multi-threaded-message-loop");
config.addCommandLineSwitch("external-message-pump");
config.addCommandLineSwitch("enable-chrome-runtime");
config.addCommandLineSwitch("enable-gpu");
config.addCommandLineSwitch("use-views");
config.addCommandLineSwitch("site-per-process");
config.addCommandLineSwitch("no-sandbox");
config.addCommandLineSwitch("in-process-gpu");
config.addCommandLineSwitch("use-mock-keychain");
config.addCommandLineSwitchWithValue("ignore-certificate-errors","true");
config.addCommandLineSwitchWithValue("enable-gpu-rasterizatio","true");
config.addCommandLineSwitchWithValue("enable-accelerated-video","true");
config.addCommandLineSwitchWithValue("use-fake-ui-for-media-stream","true");
config.addCommandLineSwitchWithValue("use-fake-device-for-media-stream","true");
config.addCommandLineSwitchWithValue("renderer-process-limit", "1");
config.addCommandLineSwitchWithValue("disable-features", "BlinkGenPropertyTrees,TranslateUI,site-per-process");
QCefContext cefContext(&a, argc, argv, &config);
CefWidget cw;
cw.show();
QApplication a(argc, argv);
qputenv("QT_QPA_PLATFORM", "windows:fontengine=freetype"); qputenv("QT_QPA_PLATFORM", "windows:fontengine=freetype");
// 加载语言包 // 加载语言包
QTranslator qtBaseTranslator; QTranslator qtBaseTranslator;

View File

@ -2,7 +2,6 @@
#define SUI_H #define SUI_H
#include "sui_title.h" #include "sui_title.h"
typedef enum { typedef enum {
UP=0, UP=0,
DOWN=1, DOWN=1,