Multisession Architecture

To support multiple simultaneous browsing sessions the architecture of Focus has been refactored to strictly separate sessions (and associated data) from the UI that displays this data.

Sessions are managed by a global SessionManager instance. UI components display data hold by Session objects.

The new multisession architecture makes use of Android’s Architecture Components. The list of sessions in the SessionManager and the data inside a Session is returned as LiveData objects. UI components can observe those LiveData objects for changes and update the UI state if needed.

  • BrowserFragment is the fragment that displays the browser chrome and web content. A BrowserFragment is always connected to a Session (1:1).

  • IWebView is a generic interface for the view that renders web content. At runtime it’s implemented by either WebView or GeckoView. State changes will be reported to a class that implements IWebView.Callback.

  • With the multisession architecture IWebView.Callback is implemented by SessionCallbackProxy. The purpose of this class is to update the Session object for this browsing session. Currently SessionCallbackProxy will still delegate some callback methods to the BrowserFragment. This is expected to be removed in a follow-up refactoring eventually.

  • BrowserFragment displays data hold by the Session object. Data that changes periodically (e.g. URL, progress, ..) are represented as LiveData objects and can be observed so that the UI can be updated whenever the state changes.

  • Sessions are switched by displaying a new BrowserFragment for a different Session object.