Skip to content

Commit

Permalink
feat: reform
Browse files Browse the repository at this point in the history
  • Loading branch information
tishion committed Oct 9, 2024
1 parent 6bb08e7 commit 5794ef6
Show file tree
Hide file tree
Showing 69 changed files with 1,386 additions and 1,279 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ if(NOT CEFVIEW_WING_NAME)
endif()

configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/include/CefViewWingProcessName.h.in"
"${CMAKE_CURRENT_SOURCE_DIR}/include/CefViewWingProcessName.h"
"${CMAKE_CURRENT_SOURCE_DIR}/include/CefViewCoreProtocol.h.in"
"${CMAKE_CURRENT_SOURCE_DIR}/include/CefViewCoreProtocol.h"
@ONLY
)

Expand Down
130 changes: 130 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
{
"version": 6,
"cmakeMinimumRequired": {
"major": 3,
"minor": 20,
"patch": 0
},
"include": [],
"configurePresets": [
{
"name": "default",
"hidden": true
},
{
"name": "win",
"hidden": true,
"inherits": "default"
},
{
"name": "win-x86",
"inherits": "win",
"displayName": "Windows x86 (Debug & Release)",
"binaryDir": "${sourceDir}/.build/win.x86",
"architecture": "Win32",
"cacheVariables": {
"PROJECT_ARCH": "x86",
"USE_SANDBOX": "ON"
}
},
{
"name": "win-x64",
"inherits": "win",
"displayName": "Windows x64 (Debug & Release)",
"binaryDir": "${sourceDir}/.build/win.x64",
"architecture": "x64",
"cacheVariables": {
"PROJECT_ARCH": "x86_64",
"USE_SANDBOX": "ON"
}
},
{
"name": "win-arm64",
"inherits": "win",
"displayName": "Windows arm64 (Debug & Release)",
"binaryDir": "${sourceDir}/.build/win.arm64",
"architecture": "ARM64",
"cacheVariables": {
"PROJECT_ARCH": "arm64",
"USE_SANDBOX": "ON"
}
},
{
"name": "osx",
"hidden": true,
"generator": "Xcode",
"inherits": "default"
},
{
"name": "osx-x64",
"inherits": "osx",
"displayName": "macOS x64 (Debug & Release)",
"binaryDir": "${sourceDir}/.build/osx.x64",
"architecture": "x64",
"cacheVariables": {
"PROJECT_ARCH": "x86_64",
"USE_SANDBOX": "ON"
}
},
{
"name": "osx-arm64",
"inherits": "osx",
"displayName": "macOS arm64 (Debug & Release)",
"binaryDir": "${sourceDir}/.build/osx.arm64",
"architecture": "arm64",
"cacheVariables": {
"PROJECT_ARCH": "arm64",
"USE_SANDBOX": "ON"
}
},
{
"name": "linux",
"hidden": true,
"inherits": "default"
},
{
"name": "linux-x64",
"inherits": "linux",
"displayName": "Linux x64",
"binaryDir": "${sourceDir}/.build/linux.x64",
"architecture": "x64",
"cacheVariables": {
"PROJECT_ARCH": "x86_64",
"USE_SANDBOX": "ON"
}
},
{
"name": "linux-arm64",
"inherits": "linux",
"displayName": "Linux arm64",
"binaryDir": "${sourceDir}/.build/linux.arm64",
"architecture": "arm64",
"cacheVariables": {
"PROJECT_ARCH": "arm64",
"USE_SANDBOX": "ON"
}
},
{
"name": "linux-x86",
"inherits": "linux",
"displayName": "Linux x86",
"binaryDir": "${sourceDir}/.build/linux.x86",
"architecture": "x86",
"cacheVariables": {
"PROJECT_ARCH": "x86",
"USE_SANDBOX": "ON"
}
},
{
"name": "linux-arm",
"inherits": "linux",
"displayName": "Linux arm",
"binaryDir": "${sourceDir}/.build/linux.arm",
"architecture": "arm",
"cacheVariables": {
"PROJECT_ARCH": "arm",
"USE_SANDBOX": "ON"
}
}
]
}
1 change: 1 addition & 0 deletions gen-linux-arm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cmake --preset=linux-arm %*
1 change: 1 addition & 0 deletions gen-linux-arm64.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cmake --preset=linux-arm64 %*
1 change: 1 addition & 0 deletions gen-linux-x64.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cmake --preset=linux-x64 %*
1 change: 1 addition & 0 deletions gen-linux-x86.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cmake --preset=linux-x86 %*
1 change: 1 addition & 0 deletions gen-mac-arm64.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cmake --preset=osx-arm64 %*
1 change: 1 addition & 0 deletions gen-mac-x64.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cmake --preset=osx-x64 %*
1 change: 1 addition & 0 deletions gen-win-arm64.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cmake --preset=win-arm64 %*
1 change: 1 addition & 0 deletions gen-win-x64.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cmake --preset=win-x64 %*
1 change: 1 addition & 0 deletions gen-win-x86.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cmake --preset=win-x86 %*
45 changes: 23 additions & 22 deletions include/CefViewBrowserApp.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// CefViewBrowserApp.h
// CefView
// CefViewCore
//
// Created by Sheen Tian on 2020/6/11.
//
Expand All @@ -9,17 +9,14 @@
#define CefViewBrowserApp_h
#pragma once

#pragma region std_headers
#include <set>
#pragma region stl_headers
#include <string>
#include <unordered_set>
#pragma endregion std_headers

#pragma region cef_headers
#include <include/cef_app.h>
#pragma endregion cef_headers
#include <unordered_map>
#pragma endregion

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

class CefViewBrowserApp
: public CefApp
Expand All @@ -29,53 +26,57 @@ class CefViewBrowserApp

private:
// The name of the bridge object
std::string builtin_scheme_name_;
std::string bridge_object_name_;
std::unordered_set<void*> client_set_;
std::unordered_map<void*, CefViewBrowserClientDelegateInterface::WeakPtr> client_handler_map_;

// The app delegate
CefViewBrowserAppDelegateInterface::WeakPtr app_delegate_;

public:
CefViewBrowserApp(const std::string& bridge_name, CefViewBrowserAppDelegateInterface::RefPtr delegate);
CefViewBrowserApp(const std::string& scheme_name,
const std::string& bridge_name,
CefViewBrowserAppDelegateInterface::RefPtr delegate);

~CefViewBrowserApp();

void CheckInClient(void* ctx);
void CheckInClient(void* ctx, const CefViewBrowserClientDelegateInterface::RefPtr& handler);

void CheckOutClient(void* ctx);

CefViewBrowserClientDelegateInterface::RefPtr GetClientHandler(void* ctx);

bool IsSafeToExit();

private:
// Registers custom schemes handler factories
static void RegisterCustomSchemesHandlerFactories();

// Registers custom schemes. Implemented in client_app_delegates.
static void RegisterCustomSchemes(CefRawPtr<CefSchemeRegistrar> registrar);

#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;

#pragma endregion CefApp
virtual CefRefPtr<CefRenderProcessHandler> GetRenderProcessHandler() override;

#pragma region CefBrowserProcessHandler
#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;

#pragma endregion CefBrowserProcessHandler
CefRefPtr<CefClient> GetDefaultClient() override;

#pragma endregion
};

#endif
6 changes: 4 additions & 2 deletions include/CefViewBrowserAppDelegate.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// CefViewBrowserAppDelegate.h
// CefView
// CefViewCore
//
// Created by Sheen Tian on 2020/6/11.
//
Expand All @@ -9,10 +9,12 @@
#define CefViewBrowserAppDelegate_h
#pragma once

#pragma region stl_headers
#include <memory>
#include <string>
#pragma endregion

#include <include/cef_app.h>
#include <CefViewCoreGlobal.h>

/// <summary>
///
Expand Down
Loading

0 comments on commit 5794ef6

Please sign in to comment.