Handling custom url protocols

828 views
Skip to first unread message

Paul. F

unread,
Jun 15, 2013, 12:19:53 PM6/15/13
to cef...@googlegroups.com
Hi guys, I would like to know if it is possible to handle a custom url protocol using CefGlue the way I would do normally using Windows, where I insert into it's Registry some keys and all browsers installed (IE, Firefox, Chrome) will know what to do when I click on a link that uses this custom protocol, I ran the cefclient demo app and upon clicking on my custom url I get the following message "Failed to load URL vsp:New Session with error (-302), where "vsp" happens to be the custom protocol that I registered which launches an external app installed on the computer.
Can such behavior be achieved on the cefclient app that doesn't require C++ expertise since I don't have it?
Thank you.
Paul

Sample registry keys that I use to register my custom "vsp" url protocol on Windows, works on all browsers installed:
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\vsp]
"URL Protocol"=""

[HKEY_CLASSES_ROOT\vsp\DefaultIcon]
@="\"C:\\MyApp\MyApp.exe,1\""

[HKEY_CLASSES_ROOT\vsp\shell]

[HKEY_CLASSES_ROOT\vsp\shell\open]

[HKEY_CLASSES_ROOT\vsp\shell\open\command]
@="\"C:\\MyApp\MyApp.exe\" \"%1\""

Dmitry Azaraev

unread,
Jun 16, 2013, 7:12:23 AM6/16/13
to cef...@googlegroups.com
Hi.

Try implement CefRequestHandler and override OnProtocolExecution method (by default os execution is disabled and you must enable it).





--
You received this message because you are subscribed to the Google Groups "CefGlue" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cefglue+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Best regards,
   Dmitry

Paul. F

unread,
Jun 17, 2013, 10:37:15 AM6/17/13
to cef...@googlegroups.com, dmitry....@gmail.com
Thanks Dmitry, that worked. The only problem that I'm having now is that upon clicking the custom url handler and the external app launches the website will go to a blank page whereas on Chrome, IE and Firefox it stops the execution, any idea about that?
Paul


I'm posting here the changes I've made:

  1. client_handler.cpp :: 423
    1. if (urlStr.find("spotify:") == 0 || urlStr.find("vsp:") == 0) //Added || urlStr.find("vsp:") == 0
  2. client_handler.app :: 496
    1. if (urlStr.find("spotify:") == 0 || urlStr.find("vsp:") == 0) //Added || urlStr.find("vsp:") == 0

Paul. F

unread,
Jun 17, 2013, 10:42:16 AM6/17/13
to cef...@googlegroups.com, dmitry....@gmail.com
Fixed the problem with the blank page displaying after clicking on the custom handler link, line 490:

void ClientHandler::OnProtocolExecution(CefRefPtr<CefBrowser> browser,
                                        const CefString& url,
                                        bool& allow_os_execution) {
  std::string urlStr = url;
  // Allow OS execution of Spotify URIs.
  if (urlStr.find("spotify:") == 0 || urlStr.find("vsp:") == 0)
  {
    allow_os_execution = true;
browser->StopLoad();
  }
}

Dmitry Azaraev

unread,
Jun 17, 2013, 11:05:46 AM6/17/13
to cef...@googlegroups.com
Please report to CEF forum / issue tracker. This is strange.


--
You received this message because you are subscribed to the Google Groups "CefGlue" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cefglue+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Best regards,
   Dmitry
Message has been deleted

Paul. F

unread,
Jun 17, 2013, 12:06:53 PM6/17/13
to cef...@googlegroups.com, dmitry....@gmail.com
Posted to the CEF forum, thank you.
Reply all
Reply to author
Forward
0 new messages