I am wondering what algorithm does google use to make chrome browser\'s address bar to act as a default search bar for many websites like SO, Quroa etc. but not for facebook, me
This feature is powered by what is known as OpenSearch. It allows you to specify how queries are supposed to be formed when searching a website. You can read the documentation here: http://www.opensearch.org/Home
For example, StackOverflow has the following in their HTML source code:
<link rel="search" type="application/opensearchdescription+xml" title="Stack Overflow" href="/opensearch.xml">
If you then open the file /opensearch.xml you can see the following:
<?xml version="1.0" encoding="UTF-8" ?>
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/" xmlns:moz="http://www.mozilla.org/2006/browser/search/">
<ShortName>Stack Overflow</ShortName>
<Description>Search Stack Overflow: Q&A for professional and enthusiast programmers</Description>
<InputEncoding>UTF-8</InputEncoding>
<Image width="16" height="16" type="image/x-icon">http://sstatic.net/stackoverflow/img/favicon.ico</Image>
<Url type="text/html" method="get" template="http://stackoverflow.com/search?q={searchTerms}"></Url>
</OpenSearchDescription>
The most important part is the line that specifies the search term string in line 7.
Chrome uses search engines mechanism. It is described here how to use it http://support.google.com/chrome/bin/answer.py?hl=en&answer=95653&topic=14676&ctx=topic
Chrome automatically identifies search boxes and adds corresponding rules to search engines list. Maybe it's engine relies on document parsing. Hense a particular site may be added or not because of it's search box markup. https://superuser.com/questions/276069/google-chrome-automatically-adding-websites-to-my-list-of-search-engines
If you want to know about parsing algorithm, the only way i see is to dig through chrome sources
Also, you can edit search engine list manually.
PS: And it's not only chrome's feature, other browsers have similar things. Opera as an example http://tech.gaeatimes.com/index.php/archive/how-to-easily-use-manage-your-search-engines-in-opera-browser/