Firefox/URL Bar Algorithm: Difference between revisions

From MozillaWiki
Jump to navigation Jump to search
Line 25: Line 25:
...
...


* If it looks like a search according to [http://mxr.mozilla.org/mozilla-central/source/docshell/base/nsDefaultURIFixup.cpp#804 this algorithm], insert it into the <tt>keyword.URL</tt> preference value to produce a search URL.
* If it looks like a search according to [http://mxr.mozilla.org/mozilla-central/source/docshell/base/nsDefaultURIFixup.cpp#804 this algorithm], insert it into the <tt>keyword.URL</tt> preference value to produce a search URL, since the <code>keyword.enabled</code> preference defaults to true in Firefox.
* The algorithm says it's a search if it contains a space or a quote before the first dot, colon or question mark, or if it starts with a question mark.
* The algorithm says it's a search if it contains a space or a quote before the first dot, colon or question mark, or if it starts with a question mark.


Line 31: Line 31:


* If we're looking at something that does not have a scheme specified, prepend either "ftp://" or "http://" depending on whether <code>nsDefaultURIFixup::IsLikelyFTP</code> returns true.
* If we're looking at something that does not have a scheme specified, prepend either "ftp://" or "http://" depending on whether <code>nsDefaultURIFixup::IsLikelyFTP</code> returns true.
* Try to construct an <code>nsIURI</code>.  If that fails, fall back on producing a search url from <tt>keyword.URL</tt>.
* Try to construct an <code>nsIURI</code>.  If that fails, fall back on producing a search url from <tt>keyword.URL</tt>, since again <code>keyword.enabled</code> defaults to true.
* Start the network load.
* Start the network load.



Revision as of 05:37, 29 October 2011

This page documents the steps Firefox takes as a user types some text into the URL bar, and when they press "Enter" or "Go".

While The User Is Typing

From the very first character typed, we dynamically search:

  • history titles and URLs
  • bookmark titles, URLs and tags
  • open tabs titles and URLs

with search results limited to some subset of those sources if requested, according to this algorithm.

When Enter Is Pressed

(Adding a Ctrl or Shift modifier changes the behaviour; the below is the unmodified algorithm.)

Before Network

Function getShortCutOrURI in browser.js.

  • If the string contains a space, split on the first space and examine the first token.
  • If it's a search engine keyword, expand using the relevant search URL.
  • If it's a user-defined keyword, expand that.

...

  • If it looks like a search according to this algorithm, insert it into the keyword.URL preference value to produce a search URL, since the keyword.enabled preference defaults to true in Firefox.
  • The algorithm says it's a search if it contains a space or a quote before the first dot, colon or question mark, or if it starts with a question mark.

...

  • If we're looking at something that does not have a scheme specified, prepend either "ftp://" or "http://" depending on whether nsDefaultURIFixup::IsLikelyFTP returns true.
  • Try to construct an nsIURI. If that fails, fall back on producing a search url from keyword.URL, since again keyword.enabled defaults to true.
  • Start the network load.

Network

...