CEF + t.me + whatsapp.com

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

CEF + t.me + whatsapp.com

Postby chuah » Fri Dec 23, 2022 5:49 am

Good time of the day.
Has anyone encountered such a problem? I go to https://t.me/some_name or https://api.whatsapp.com/send?phone=66666666 , the first second it works fine, and then a white screen with an error:

Page failed to load.
URL: tg://resolve?domain=some_name
Error: ERR_UNKNOWN_URL_SCHEME (-302)
ERR_UNKNOWN_URL_SCHEME

Рas anyone overcome this error?
chuah
Newbie
 
Posts: 4
Joined: Fri Aug 05, 2022 2:44 am

Re: CEF + t.me + whatsapp.com

Postby amaitland » Fri Dec 23, 2022 2:31 pm

Cancel the navigation in CefRequestHandler::OnBeforeBrowse (return true to cancel navigation).
Maintainer of the CefSharp project.
amaitland
Virtuoso
 
Posts: 1290
Joined: Wed Jan 14, 2015 2:35 am

Re: CEF + t.me + whatsapp.com

Postby chuah » Tue Jan 10, 2023 6:02 am

Found and replaced return with true in the cef_request_handler.h file. Rebuilt a clean project for Windows. But the error didn't go away.
chuah
Newbie
 
Posts: 4
Joined: Fri Aug 05, 2022 2:44 am

Re: CEF + t.me + whatsapp.com

Postby ndesktop » Tue Jan 10, 2023 2:44 pm

Run cefclient (or whatever is the test application) with --enable-logging --v=1.
But I think tg:// will not go thru OnBeforeBrowse, but rather thru CefResourceRequestHandler::OnProtocolExecution.
(Other methods of CefResourceRequestHandler, such as OnBeforeResourceLoad might be involved as well).
ndesktop
Master
 
Posts: 750
Joined: Thu Dec 03, 2015 10:10 am

Re: CEF + t.me + whatsapp.com

Postby amaitland » Tue Jan 10, 2023 3:41 pm

OnProtocolExecution ends up as a blank page as per https://bitbucket.org/chromiumembedded/ ... lank-after

CefResourceRequestHandler::OnProtocolExecution also happens after OnBeforeBrowse

OnBeforeBrowse is currently the only way to handle an unknown scheme (unless you want to register the scheme and provide some sort of response).

Related discussion https://github.com/cefsharp/CefSharp/discussions/4232
Maintainer of the CefSharp project.
amaitland
Virtuoso
 
Posts: 1290
Joined: Wed Jan 14, 2015 2:35 am

Re: CEF + t.me + whatsapp.com

Postby ndesktop » Wed Jan 11, 2023 9:02 am

amaitland wrote:OnProtocolExecution ends up as a blank page as per https://bitbucket.org/chromiumembedded/ ... lank-after

CefResourceRequestHandler::OnProtocolExecution also happens after OnBeforeBrowse

OnBeforeBrowse is currently the only way to handle an unknown scheme (unless you want to register the scheme and provide some sort of response).

Related discussion https://github.com/cefsharp/CefSharp/discussions/4232

True. I managed to handle this, but not without patching CEF.
ndesktop
Master
 
Posts: 750
Joined: Thu Dec 03, 2015 10:10 am

Re: CEF + t.me + whatsapp.com

Postby chuah » Tue Feb 07, 2023 3:55 am

I am new to CEF.
I took a clean project, assembled it according to the instructions https://bitbucket.org/chromiumembedded/ ... ckStart.md.
I got an error when going to the https://api.whatsapp.com/send?phone=66666666 site

Found cef_request_handler.h file, changed OnBeforeBrowse method response to ture
Code: Select all
  virtual bool OnBeforeBrowse(CefRefPtr<CefBrowser> browser,
                              CefRefPtr<CefFrame> frame,
                              CefRefPtr<CefRequest> request,
                              bool user_gesture,
                              bool is_redirect) {
    return true;
  }

Rebuilt the project, the error remained

Found cef_extension_handler.h file, changed OnBeforeBrowse method
Code: Select all
  virtual bool OnBeforeBrowser(CefRefPtr<CefExtension> extension,
                               CefRefPtr<CefBrowser> browser,
                               CefRefPtr<CefBrowser> active_browser,
                               int index,
                               const CefString& url,
                               bool active,
                               CefWindowInfo& windowInfo,
                               CefRefPtr<CefClient>& client,
                               CefBrowserSettings& settings) {
    if (request.Url.StartsWith("whatsapp:"))
    {
      return true;
    }
    return base.OnBeforeBrowse(chromiumWebBrowser, browser, frame, request, userGesture, isRedirect);
  }

Rebuilt the project, the error remained

What am I doing wrong ?
chuah
Newbie
 
Posts: 4
Joined: Fri Aug 05, 2022 2:44 am

Re: CEF + t.me + whatsapp.com

Postby ndesktop » Tue Feb 07, 2023 4:09 am

You do not change directly cef_request_handler.h. You need to implement in your client the request handler interface (GetRequestHandler + derive from CefRequestHandler), and implement your OnBeforeBrowse.
That would provide the entrypoint for your specific implementation.
ndesktop
Master
 
Posts: 750
Joined: Thu Dec 03, 2015 10:10 am


Return to Support Forum

Who is online

Users browsing this forum: No registered users and 36 guests