Skip to content

Commit

Permalink
feat: reform core project
Browse files Browse the repository at this point in the history
1. unify string type in core delegates
2. export public includ dirs
3. remove redundant log from cmake
  • Loading branch information
tishion committed Dec 14, 2024
1 parent 070672c commit ca26251
Show file tree
Hide file tree
Showing 9 changed files with 174 additions and 156 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ dep/*.bz2
dep/cef_binary_*
.build
include/CefViewWingProcessName.h
include/CefViewCoreProtocol.h
include/CefViewCoreProtocol.h
2 changes: 0 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ if(OS_WINDOWS)
add_compile_options("/MT$<$<CONFIG:Debug>:d>")
else()
# either MT or MD is supported
message(STATUS "===== " ${STATIC_CRT})
set(CEF_RUNTIME_LIBRARY_FLAG "/M$<IF:$<BOOL:${STATIC_CRT}>,T,D>" CACHE STRING "Use static runtime" FORCE)
add_compile_options("/M$<IF:$<BOOL:${STATIC_CRT}>,T,D>$<$<CONFIG:Debug>:d>")
endif()
Expand Down Expand Up @@ -195,7 +194,6 @@ set(CMAKE_SUPPRESS_REGENERATION TRUE)
# ##############################################################
set(CefViewCore_INCLUDE_PATH
"${CEF_INCLUDE_PATH}"
"${CMAKE_CURRENT_SOURCE_DIR}/src/Shared"
"${CMAKE_CURRENT_SOURCE_DIR}/include"
)

Expand Down
48 changes: 48 additions & 0 deletions include/CefViewBrowserApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,28 @@
#pragma region stl_headers
#include <string>
#include <unordered_map>
#include <list>
#pragma endregion

#include <CefViewCoreGlobal.h>
#include <CefViewBrowserAppDelegate.h>
#include <CefViewBrowserClientDelegate.h>

struct FolderResourceMapping
{
std::string path;
std::string url;
int priority;
};

struct ArchiveResourceMapping
{
std::string path;
std::string url;
std::string password;
int priority;
};

class CefViewBrowserApp
: public CefApp
, public CefBrowserProcessHandler
Expand All @@ -33,6 +49,10 @@ class CefViewBrowserApp
// The app delegate
CefViewBrowserAppDelegateInterface::WeakPtr app_delegate_;

std::list<FolderResourceMapping> folderResourceMappingList_;

std::list<ArchiveResourceMapping> archiveResourceMappingList_;

public:
CefViewBrowserApp(const std::string& scheme_name,
const std::string& bridge_name,
Expand All @@ -46,6 +66,34 @@ class CefViewBrowserApp

CefViewBrowserClientDelegateInterface::RefPtr GetClientHandler(void* ctx);

void AddLocalFolderResource(const std::string& path, const std::string& url, int priority = 0);
const std::list<FolderResourceMapping>& FolderResourceMappingList();

void AddArchiveResource(const std::string& path,
const std::string& url,
const std::string& password = "",
int priority = 0);
const std::list<ArchiveResourceMapping>& ArchiveResourceMappingList();

bool AddGlobalCookie(const std::string& name,
const std::string& value,
const std::string& domain,
const std::string& url);

bool DeleteAllCookies();

bool AddCrossOriginWhitelistEntry(const std::string& sourceOrigin,
const std::string& targetSchema,
const std::string& targetDomain,
bool allowTargetSubdomains);

bool RemoveCrossOriginWhitelistEntry(const std::string& sourceOrigin,
const std::string& targetSchema,
const std::string& targetDomain,
bool allowTargetSubdomains);

bool ClearCrossOriginWhitelistEntry();

bool IsSafeToExit();

private:
Expand Down
2 changes: 1 addition & 1 deletion include/CefViewBrowserAppDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class CefViewBrowserAppDelegateInterface
///
/// </summary>
/// <param name="command_line"></param>
virtual void OnBeforeChildProcessLaunch(CefRefPtr<CefCommandLine> command_line) = 0;
virtual void onBeforeChildProcessLaunch(CefRefPtr<CefCommandLine> command_line) = 0;

/// <summary>
///
Expand Down
26 changes: 13 additions & 13 deletions include/CefViewBrowserClientDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class CefViewBrowserClientDelegateInterface
/// <param name="browser"></param>
/// <param name="frameId"></param>
/// <param name="url"></param>
virtual void processUrlRequest(CefRefPtr<CefBrowser>& browser, const CefFrameId& frameId, const std::string& url) = 0;
virtual void processUrlRequest(CefRefPtr<CefBrowser>& browser, const CefFrameId& frameId, const CefString& url) = 0;

/// <summary>
///
Expand All @@ -54,7 +54,7 @@ class CefViewBrowserClientDelegateInterface
/// <param name="query_id"></param>
virtual void processQueryRequest(CefRefPtr<CefBrowser>& browser,
const CefFrameId& frameId,
const std::string& query,
const CefString& query,
const int64_t query_id) = 0;

/// <summary>
Expand All @@ -76,7 +76,7 @@ class CefViewBrowserClientDelegateInterface
/// <param name="arguments"></param>
virtual void invokeMethodNotify(CefRefPtr<CefBrowser>& browser,
const CefFrameId& frameId,
const std::string& method,
const CefString& method,
const CefRefPtr<CefListValue>& arguments) = 0;

/// <summary>
Expand All @@ -88,7 +88,7 @@ class CefViewBrowserClientDelegateInterface
/// <param name="result"></param>
virtual void reportJSResult(CefRefPtr<CefBrowser>& browser,
const CefFrameId& frameId,
const std::string& context,
const CefString& context,
const CefRefPtr<CefValue>& result) = 0;

// context menu handler
Expand Down Expand Up @@ -128,21 +128,21 @@ class CefViewBrowserClientDelegateInterface

// display handler
#pragma region DisplayHandler
virtual void addressChanged(CefRefPtr<CefBrowser>& browser, const CefFrameId& frameId, const std::string& url) = 0;
virtual void addressChanged(CefRefPtr<CefBrowser>& browser, const CefFrameId& frameId, const CefString& url) = 0;

virtual void titleChanged(CefRefPtr<CefBrowser>& browser, const std::string& title) = 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 std::string& text) = 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 std::string& value) = 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 std::string& message, int level) = 0;
virtual void consoleMessage(CefRefPtr<CefBrowser>& browser, const CefString& message, int level) = 0;

virtual bool cursorChanged(CefRefPtr<CefBrowser> browser,
CefCursorHandle cursor,
Expand Down Expand Up @@ -179,8 +179,8 @@ class CefViewBrowserClientDelegateInterface
#pragma region LifeSpanHandler
virtual bool onBeforePopup(CefRefPtr<CefBrowser>& browser,
const CefFrameId& frameId,
const std::string& targetUrl,
const std::string& targetFrameName,
const CefString& targetUrl,
const CefString& targetFrameName,
CefLifeSpanHandler::WindowOpenDisposition targetDisposition,
CefWindowInfo& windowInfo,
CefBrowserSettings& settings,
Expand Down Expand Up @@ -217,8 +217,8 @@ class CefViewBrowserClientDelegateInterface
virtual void loadError(CefRefPtr<CefBrowser>& browser,
CefRefPtr<CefFrame>& frame,
int errorCode,
const std::string& errorMsg,
const std::string& failedUrl,
const CefString& errorMsg,
const CefString& failedUrl,
bool& handled) = 0;
#pragma endregion

Expand Down
135 changes: 0 additions & 135 deletions include/CefViewCoreProtocol.h

This file was deleted.

24 changes: 20 additions & 4 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@ add_library(CefViewCore STATIC
${CefViewCore_SRC_FILES}
)

target_include_directories(CefViewCore PRIVATE
target_include_directories(CefViewCore
PUBLIC
${CefViewCore_INCLUDE_PATH}
PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/Shared"
)

# ADD_LOGICAL_TARGET(libcef_lib
Expand Down Expand Up @@ -142,6 +145,8 @@ if(OS_MACOS)
)
endif() # OS_MACOS

add_library(CefViewCore::CefViewCore ALIAS CefViewCore)

# ## CefViewWing
# ###############################################################################################
# soruce code for all platforms
Expand Down Expand Up @@ -202,8 +207,10 @@ if(OS_WINDOWS)
)

target_include_directories(${CEFVIEW_WING_NAME}
PRIVATE
PUBLIC
${CefViewCore_INCLUDE_PATH}
PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/Shared"
)

add_dependencies(${CEFVIEW_WING_NAME}
Expand Down Expand Up @@ -281,8 +288,11 @@ if(OS_LINUX)
BUILD_WITH_INSTALL_RPATH TRUE
)

target_include_directories(${CEFVIEW_WING_NAME} PRIVATE
target_include_directories(${CEFVIEW_WING_NAME}
PUBLIC
${CefViewCore_INCLUDE_PATH}
PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/Shared"
)

add_dependencies(${CEFVIEW_WING_NAME}
Expand Down Expand Up @@ -378,8 +388,11 @@ if(OS_MACOS)
XCODE_ATTRIBUTE_CODE_SIGN_ENTITLEMENTS "${CMAKE_CURRENT_SOURCE_DIR}/CefWing/mac/CefViewWing.entitlements"
)

target_include_directories(${_helper_target} PRIVATE
target_include_directories(${_helper_target}
PUBLIC
${CefViewCore_INCLUDE_PATH}
PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/Shared"
)

add_dependencies(${_helper_target}
Expand All @@ -405,3 +418,6 @@ if(OS_MACOS)
VERBATIM
)
endif() # OS_MACOS

# add alias for heper process target
add_executable(CefViewCore::CefViewWing ALIAS ${CEFVIEW_WING_NAME})
Loading

0 comments on commit ca26251

Please sign in to comment.