Add OnProtocolExecution callback to CefRequestHandler (issue #582).

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@711 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt
2012-06-25 21:21:27 +00:00
parent 89c70a8b11
commit d13cc9de1c
18 changed files with 253 additions and 0 deletions

View File

@ -275,6 +275,14 @@ void ClientHandler::OnLoadError(CefRefPtr<CefBrowser> browser,
if (errorCode == ERR_ABORTED)
return;
// Don't display an error for external protocols that we allow the OS to
// handle. See OnProtocolExecution().
if (errorCode == ERR_UNKNOWN_URL_SCHEME) {
std::string urlStr = frame->GetURL();
if (urlStr.find("spotify:") == 0)
return;
}
// Display a load error message.
std::stringstream ss;
ss << "<html><body><h2>Failed to load URL " << std::string(failedUrl) <<
@ -346,6 +354,16 @@ CefRefPtr<CefResourceHandler> ClientHandler::GetResourceHandler(
return handler;
}
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)
allow_os_execution = true;
}
void ClientHandler::SetMainHwnd(CefWindowHandle hwnd) {
AutoLock lock_scope(this);
m_MainHwnd = hwnd;