Tab browser

broken image

WebContents derives from SupportsUserData, so that mechanism works for attaching objects to a WebContents, but the SupportsUserData mechanism is a bit low-level. There are three calls to attach and detach the data. The mechanism is simple: host objects derive from SupportsUserData, and owned objects derive from SupportsUserData::Data. There is a mechanism used in Chromium called SupportsUserData that allows attaching of arbitrary objects to an object. It is owned indirectly by the TabStripModel. Note that TabStripModel::WebContentsData object is not owned by the WebContents. That object overrides WebContentsDestroyed(), and when a WebContents gets destroyed, the callback is called and the object processes the message. So it creates a TabStripModel::WebContentsData. As an example, if we look at the TabStripModel, there are times when it need to watch out for WebContents being deleted. WebContentsObserver is a simple interface that allows an object to observe events in the life of a WebContents. What is a “tab helper”? It is a WebContentsObserver owned by the WebContents itself. Not every WebContents has every tab helper.

broken image

Reusing tab helpers with non-browser tab WebContentses.

broken image