views:

526

answers:

2

I have protocol (like http) with scheme managed with 3rd party App registered in Mac OS X. I.e, x-someapp://someaction or something like that.

How can I open this URL with Google Chrome? By default, Chrome starts searching in Google engine instead launching App and passing URL handling to it...

Safari launches some registered App. And it is right thing.

Firefox and Opera asks what to do... and I can launch App also.

But Chrome... Doesn't ask.

I even tried to write some HTML page with JavaScript inside to send XHttpRequest:

function _httpExecuteCallback()
{
 if (httpRequestCallbackFunction != null) {
  if (httpRequest.readyState == 4) {
   if (httpRequest.status == 200) {
    httpRequestCallbackFunction();
    httpRequestCallbackFunction = null;
   }   
  }
 }
}

function _httpGet(url, callbackFunction)
{
 httpRequest = false;
 httpRequestCallbackFunction = callbackFunction;
 httpRequest = new XMLHttpRequest();
 httpRequest.onreadystatechange = _httpExecuteCallback;
 httpRequest.open('GET', url, true);
 httpRequest.send(null);
}


_httpGet('x-someapp://test',function(){})

No results also...

+1  A: 

If Chrome does not recognize the URL scheme, it defaults to a search.

This is what I see in Safari: alt text

and in Firefox:

alt text

I believe the reason why Chrome defaults to search is that there are special google searches that use the colon.

E.g:

  • define: dictionary
  • filetype:pdf google chromium

This is one of the annoyances I have with Firefox, I have to jump to the "search box" rather than the address bar to execute these types of searches. Since Chrome does not have a separate search box like Firefox, IE and Safari have, this functionality is required.

Ajax requests won't get you around this.

Pierre-Antoine LaFayette
I dunno how it works on Windows, I tagged this question as Mac OS X.So, in the Mac OS X World, any App can register its own internet scheme right inside Info.plist file (which contains in the App Bundle).So, Safari will always know about 3rd party protocols, as only new App was installed, even Firefox and Opera will know, but Chrome seems doesn't read this information from the System.For example, if I have SpamSieve installed, I can open x-spamsieve protocol right from the Safari and register the software...Safari may just redirect this URL-scheme query to the NSWorkspace...
UncleMiF
Additionally, I successfully used AJAX from Firefox (see the code example inside my question) on Mac OS X to request 3rd party protocols (not http/ftp).
UncleMiF
Here is additional exampleshttp://mac.gettranslateit.com/integrationFireFox.shtmlandhttp://mac.gettranslateit.com/integrationOpera.shtmlI just wanna write Chrome extension, and generally I did it except sandbox restrictions - now I need to call 3rd party protocol (my own), but I can't.
UncleMiF
Chrome should recognize the protocol if it is registered with the OS. I believe this may be a Mac specific bug. Please file this as a Mac OS X bug at http://crbug.com. Thanks.
Pierre-Antoine LaFayette
A: 

I found the solution that works with Chrome. I use the IFRAME-way.

Example (with JQuery):

$("body").append('<span id="__protoProxy"></span>');

function queryWord(aWord)
{
 var protoProxy = document.getElementById('__protoProxy');
 if (protoProxy)
 {   
  var word = aWord.replace('"','\"');
  protoProxy.innerHTML = '<div style="display:none;"><iframe src="x-myproto://query?' + word + '"></iframe></div>';
 }
}

queryWord('hello');
UncleMiF