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:
If you then open the file /opensearch.xml you can see the following:
Stack Overflow
Search Stack Overflow: Q&A for professional and enthusiast programmers
UTF-8
http://sstatic.net/stackoverflow/img/favicon.ico
The most important part is the line that specifies the search term string in line 7.