tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

0006-search-defaults.md (8377B)



layout: page title: Determining the set of default search engines permalink: /rfc/0006-search-defaults


Summary

Determining the set of default search engines based on the user's home region.

Motivation

Our configuration of default search engines (list.json) is based on the region and language or locale of the user.

To provide our users with the best choice of search engines and to satisfy the needs of our partnerships, we want to determine (and recognize changes of) the user's region as accurately as possible.

The scope of this document is limited to the resolving and caching of the user's region and using it to determine the default search engines.

Problems and constraints

Guide-level explanation

Determining the region

While there are many available sources for determining the region of the user, we will focus on using the Mozilla Location Service (MLS) as the primary source for now. MLS can determine the region of the user by doing a GeoIP lookup. Additionally it supports determining the location based on Bluetooth, cell tower and WiFI access point data. However so far on mobile we have only been using the GeoIP lookup and have not sent any data to MLS.

Fallback

Other than previously in Fenix we are not using the locale as a fallback provider for the region. Instead we will fallback to use the default from the configuration (e.g. default in list.json).

Validation

The region returned by MLS may be skewed obscured by proxies, VPNs or inaccuracies in the geo IP databases. To accommodate for this, we want to perform additional validation to verify if the provided region is plausible.

The first validator that we want to ship uses the timezone of the user. Similar to the implementation in the desktop version of Firefox ([[1]](https://searchfox.org/mozilla-central/rev/f82d5c549f046cb64ce5602bfd894b7ae807c8f8/toolkit/modules/Region.jsm#213-224), [[2]](https://searchfox.org/mozilla-central/rev/f82d5c549f046cb64ce5602bfd894b7ae807c8f8/toolkit/modules/Region.jsm#763-779)) users with a US region and not a US timezone will not get US assigned as current or home region.

Home region and updates

We will use a similar mechanism to track and update the home region of a user as the desktop version of Firefox does.

We will determine between a home region and the current region. Eventually the current region may become the home region of the user. Only the home region will be used for determining the default search engines.

* If the result matches the home region then no further action is needed. * If the result different than the current region then we save the new value as the current region along with the current timestamp. * If the result matches the current region and the timestamp of the current region is older than 2 weeks (meaning the current region has not changed in two weeks) then we set the result as the new home region.

With a new home region the user may get a different set of default search engines.

The default search engine of the user will be determined by:

Tests

Like for our other components, we want to have a high test coverage for this critical implementation. For the search engine defaults we want to cover some partnership requirements as unit tests to avoid regressions in the affected areas.

Reference-level explanation

Region

We will introduce a new (internal) RegionManager class that will take care of tracking and updating the current and home region of the user. A RegionMiddleware will listen to the InitAction of the BrowserStore and dispatch an action to add a RegionState to the BrowserState, as well as asking the RegionManager to check whether a region change has happened (by internally querying MLS).

The new SearchMiddleware (see RFC 2 about the new search architecture) will listen to the RegionState update, load the matching default search engines using the search storage, and dispatch an action updating the SearchState.

Rationale and alternatives

Prior art

Unresolved questions