-
Notifications
You must be signed in to change notification settings - Fork 15
Custom schema, onBeforeBrowse, expose "callEvent" to cef #198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -250,4 +250,9 @@ namespace Framework::GUI { | |
| } | ||
| return nullptr; | ||
| } | ||
|
|
||
| void Manager::RegisterSchemeHandlerFactory(const std::string &schema, const std::string &domain, Framework::GUI::CEF::SchemaHandlerFactoryCallback callback) { | ||
| _cefApp->RegisterSchemeHandlerFactory(schema, domain, callback); | ||
| CefRegisterSchemeHandlerFactory(schema, domain, _cefApp); | ||
| } | ||
|
Comment on lines
+254
to
+257
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
# Locate and print the relevant region around the flagged lines
FILE="code/framework/src/gui/manager.cpp"
# Show method and nearby members/flags
echo "=== Context around RegisterSchemeHandlerFactory ==="
nl -ba "$FILE" | sed -n '220,320p'
echo
echo "=== Search for CEF init guards / flags in this file ==="
rg -n "_cefInitialized|_cefApp|Init\(|RegisterSchemeHandlerFactory" "$FILE"
echo
echo "=== Find definitions/usage of _cefApp and CEF init state ==="
rg -n "CefRegisterSchemeHandlerFactory" "$FILE"
rg -n "RegisterSchemeHandlerFactory\(" "$FILE"
echo
echo "=== Find other call sites for RegisterSchemeHandlerFactory in repo ==="
rg -n "RegisterSchemeHandlerFactory\s*\(" -S code | head -n 50
echo
echo "=== Check how _cefInitialized is set / what _cefInitialized means ==="
rg -n "_cefInitialized\s*=" -S code/framework/src/gui/manager.cppRepository: MafiaHub/Framework Length of output: 175 🏁 Script executed: #!/bin/bash
set -euo pipefail
FILE="code/framework/src/gui/manager.cpp"
echo "=== Verify file exists ==="
ls -la "$FILE" || true
echo
echo "=== Context around RegisterSchemeHandlerFactory (lines 240-290) ==="
awk 'NR>=240 && NR<=290 {printf "%d:%s\n", NR, $0}' "$FILE" || true
echo
echo "=== Search for init guard / members in this file ==="
rg -n "_cefInitialized|_cefApp|Init\(|RegisterSchemeHandlerFactory" "$FILE" || true
echo
echo "=== Find usages of CEF registration return value ==="
rg -n "CefRegisterSchemeHandlerFactory" "$FILE" || true
echo
echo "=== Search for other call sites in repo ==="
rg -n "RegisterSchemeHandlerFactory\s*\(" -S code | head -n 50 || true
echo
echo "=== Where is _cefInitialized defined/set in this file ==="
rg -n "_cefInitialized" "$FILE" || trueRepository: MafiaHub/Framework Length of output: 3392 🏁 Script executed: #!/bin/bash
set -euo pipefail
# Inspect Manager ctor/dtor and Init logic
FILE="code/framework/src/gui/manager.cpp"
echo "=== Manager.cpp: lines 1-120 ==="
awk 'NR>=1 && NR<=120 {printf "%d:%s\n", NR, $0}' "$FILE"
echo
echo "=== Manager.cpp: lines 120-220 ==="
awk 'NR>=120 && NR<=220 {printf "%d:%s\n", NR, $0}' "$FILE"
echo
echo "=== Inspect Manager header for members (_cefApp, _cefInitialized) ==="
HFILE="code/framework/src/gui/manager.h"
nl -ba "$HFILE" | sed -n '1,140p'
echo
echo "=== Inspect CEF app wrapper header ==="
AHD="code/framework/src/gui/cef/app.h"
nl -ba "$AHD" | sed -n '1,140p'
echo
echo "=== Inspect CEF app wrapper impl around RegisterSchemeHandlerFactory ==="
ACI="code/framework/src/gui/cef/app.cpp"
awk 'NR>=1 && NR<=120 {printf "%d:%s\n", NR, $0}' "$ACI"
echo
echo "=== Inspect CEF app wrapper impl further (around line 55 from rg output) ==="
awk 'NR>=40 && NR<=110 {printf "%d:%s\n", NR, $0}' "$ACI"Repository: MafiaHub/Framework Length of output: 7782 🏁 Script executed: #!/bin/bash
set -euo pipefail
MFILE="code/framework/src/gui/manager.cpp"
HFILE="code/framework/src/gui/manager.h"
AHD="code/framework/src/gui/cef/app.h"
ACI="code/framework/src/gui/cef/app.cpp"
echo "=== Search for IsInitialized() ==="
rg -n "IsInitialized\s*\(" "$MFILE" "$HFILE"
echo
echo "=== Show Manager header member declarations (look for _cefApp/_cefInitialized) ==="
awk 'NR>=1 && NR<=140 {print NR ":" $0}' "$HFILE" | rg -n "_cefApp|_cefInitialized|_initialized|IsInitialized" || true
echo
echo "=== Show Manager header around those member declarations (wider context) ==="
rg -n "_cefApp|_cefInitialized|_initialized" "$HFILE" || true
LINE=$(rg -n "_cefApp|_cefInitialized|_initialized" "$HFILE" | head -n1 | cut -d: -f1)
START=$((LINE-20)); END=$((LINE+60))
awk -v s=$START -v e=$END 'NR>=s && NR<=e {print NR ":" $0}' "$HFILE" || true
echo
echo "=== Inspect CEF app wrapper declarations ==="
awk 'NR>=1 && NR<=140 {print NR ":" $0}' "$AHD" | rg -n "RegisterSchemeHandlerFactory|class App|_cefApp|CefRegisterSchemeHandlerFactory" || true
echo
echo "=== Inspect CEF app wrapper implementation around RegisterSchemeHandlerFactory ==="
rg -n "RegisterSchemeHandlerFactory" "$ACI"
MATCH_LINE=$(rg -n "RegisterSchemeHandlerFactory" "$ACI" | head -n1 | cut -d: -f1)
START=$((MATCH_LINE-20)); END=$((MATCH_LINE+60))
awk -v s=$START -v e=$END 'NR>=s && NR<=e {print NR ":" $0}' "$ACI"Repository: MafiaHub/Framework Length of output: 4601 🏁 Script executed: #!/bin/bash
set -euo pipefail
# Search for declaration/signature of CefRegisterSchemeHandlerFactory in repo headers (if vendored)
rg -n "CefRegisterSchemeHandlerFactory\s*\(" code/framework/src/gui -S || true
rg -n "CefRegisterSchemeHandlerFactory\s*\(" code -S || true
# Try to find CEF headers under include/ or third_party if present
fd -i "cef*.h" code | head -n 50
# Search likely header files for the signature (heuristic)
for f in $(fd -i "cef*.h" code 2>/dev/null | head -n 200); do
if rg -n "CefRegisterSchemeHandlerFactory" "$f" >/dev/null 2>&1; then
echo "=== Found in $f ==="
rg -n "CefRegisterSchemeHandlerFactory" "$f" | head -n 20
fi
doneRepository: MafiaHub/Framework Length of output: 421 🏁 Script executed: #!/bin/bash
set -euo pipefail
# Find call sites for Manager::RegisterSchemeHandlerFactory
rg -n "RegisterSchemeHandlerFactory\s*\(" code -S
# Narrow to likely member call syntax
rg -n "\.RegisterSchemeHandlerFactory\s*\(" code -S || true
rg -n "Manager::RegisterSchemeHandlerFactory\s*\(" code -S || true
# Also search for IsInitialized checks near potential calls
rg -n "IsInitialized\s*\(|_cefInitialized\s*|GUI_CEF_INIT_FAILED" code -S | head -n 200Repository: MafiaHub/Framework Length of output: 4640 🏁 Script executed: #!/bin/bash
set -euo pipefail
HFILE="code/framework/src/gui/cef/app.h"
echo "=== CEF App class declaration (search for CefSchemeHandlerFactory / inheritance) ==="
rg -n "class App|CefSchemeHandlerFactory|SchemeHandlerFactory|RegisterSchemeHandlerFactory" "$HFILE"
echo
echo "=== Show app.h around class App definition ==="
LINE=$(rg -n "class App" "$HFILE" | head -n1 | cut -d: -f1)
START=$((LINE-40)); END=$((LINE+120))
awk -v s=$START -v e=$END 'NR>=s && NR<=e {print NR ":" $0}' "$HFILE"Repository: MafiaHub/Framework Length of output: 2858 🌐 Web query:
💡 Result: The CefRegisterSchemeHandlerFactory function in the Chromium Embedded Framework (CEF) has a return type of bool [1][2]. It returns true if the scheme handler factory is successfully registered, and false if an error occurs [3][1]. This function is used to register a scheme handler factory with the global request context [1][4]. Key implementation details include: - Function Signature: In C++, it is defined as: bool CefRegisterSchemeHandlerFactory(const CefString& scheme_name, const CefString& domain_name, CefRefPtr factory) [1][2]. - Behavior: - An empty domain_name value for a standard scheme causes the factory to match all domain names [1][2]. - For non-standard schemes, the domain_name parameter is ignored [1][2]. - If the scheme_name is a custom scheme, you must also implement the CefApp::OnRegisterCustomSchemes method in all processes [1][2]. - The function may be called multiple times to change or remove a previously registered factory [1][2]. - It can be called on any thread in the browser process [1][2]. In CefSharp, the equivalent method RequestContext.RegisterSchemeHandlerFactory also returns a boolean value, indicating success or failure [5][6]. Citations:
Guard CEF scheme handler registration and handle failures explicitly.
Suggested fix void Manager::RegisterSchemeHandlerFactory(const std::string &schema, const std::string &domain, Framework::GUI::CEF::SchemaHandlerFactoryCallback callback) {
+ if (!_cefInitialized || !_cefApp) {
+ Framework::Logging::GetLogger("Web")->error("Cannot register scheme handler factory before CEF initialization");
+ return;
+ }
_cefApp->RegisterSchemeHandlerFactory(schema, domain, callback);
- CefRegisterSchemeHandlerFactory(schema, domain, _cefApp);
+ if (!CefRegisterSchemeHandlerFactory(schema, domain, _cefApp)) {
+ Framework::Logging::GetLogger("Web")->error("CefRegisterSchemeHandlerFactory failed for schema='{}' domain='{}'", schema, domain);
+ }
}🤖 Prompt for AI Agents |
||
| } // namespace Framework::GUI | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -185,5 +185,9 @@ namespace Framework::GUI { | |
| inline void SetOnWindowObjectReadyCallback(OnWindowObjectReadyCallback proc) { | ||
| _onWindowObjectReadyCallback = std::move(proc); | ||
| } | ||
|
|
||
| inline void SetOnBeforeBrowseCallback(CEF::OnBeforeBrowseCallback cb) { | ||
| _lifeSpanHandler->SetOnBeforeBrowseCallback(std::move(cb)); | ||
| } | ||
|
Comment on lines
+189
to
+191
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Verify where _lifeSpanHandler is initialized relative to SetOnBeforeBrowseCallback call sites.
rg -n "View::View\\(|_lifeSpanHandler\\s*=|SetOnBeforeBrowseCallback\\(" code/framework/src/gui -g '*.{h,hpp,hxx,cpp,cc,cxx}'Repository: MafiaHub/Framework Length of output: 604 Guard
🤖 Prompt for AI Agents |
||
| }; | ||
| } // namespace Framework::GUI | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Protect
_handlerswith synchronization (read/write race).Create()reads_handlerswhileRegisterSchemeHandlerFactory()mutates it with no lock. If registration can happen after CEF starts handling requests, this is a data race onstd::unordered_map(undefined behavior).Suggested fix
Also applies to: 55-57
🤖 Prompt for AI Agents