Create a ChromeBrowserHostImpl for every Chrome tab (see issue #2969)

The Browser object represents the top-level Chrome browser window. One or more
tabs (WebContents) are then owned by the Browser object via TabStripModel. A
new Browser object can be created programmatically using "new Browser" or
Browser::Create, or as a result of user action such as dragging a tab out of an
existing window. New or existing tabs can also be added to an already existing
Browser object.

The Browser object acts as the WebContentsDelegate for all attached tabs. CEF
integration requires WebContentsDelegate callbacks and notification of tab
attach/detach. To support this integration we add a cef::BrowserDelegate
(ChromeBrowserDelegate) member that is created in the Browser constructor and
receives delegation for the Browser callbacks. ChromeBrowserDelegate creates a
new ChromeBrowserHostImpl when a tab is added to a Browser for the first time,
and that ChromeBrowserHostImpl continues to exist until the tab's WebContents
is destroyed. The associated WebContents object does not change, but the
Browser object will change when the tab is dragged between windows.

CEF callback logic is shared between the chrome and alloy runtimes where
possible. This shared logic has been extracted from CefBrowserHostImpl to
create new CefBrowserHostBase and CefBrowserContentsDelegate classes. The
CefBrowserHostImpl class is now only used with the alloy runtime and will be
renamed to AlloyBrowserHostImpl in a future commit.
This commit is contained in:
Marshall Greenblatt
2020-09-17 18:24:08 -04:00
parent 7ca9e9c54b
commit 38d8acfa18
52 changed files with 3138 additions and 1603 deletions

View File

@@ -37,6 +37,8 @@ namespace IPC {
class Message;
}
class CefBrowserHostBase;
class CefBrowserHostImpl;
class CefBrowserPlatformDelegate;
// Singleton object for managing BrowserInfo instances.
@@ -48,7 +50,8 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
// Returns this singleton instance of this class.
static CefBrowserInfoManager* GetInstance();
// Called from CefBrowserHostImpl::Create when a new browser is being created
// Called from CefBrowserHostImpl::Create or
// ChromeBrowserDelegate::SetAsDelegate when a new browser is being created
// directly. In this case |is_popup| will be true only for DevTools browsers.
scoped_refptr<CefBrowserInfo> CreateBrowserInfo(
bool is_popup,
@@ -107,7 +110,7 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
int render_routing_id,
IPC::Message* reply_msg);
// Called from CefBrowserHostImpl::DestroyBrowser() when a browser is
// Called from CefBrowserHostBase::DestroyBrowser() when a browser is
// destroyed.
void RemoveBrowserInfo(scoped_refptr<CefBrowserInfo> browser_info);
@@ -116,7 +119,7 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
// Returns the CefBrowserInfo matching the specified IDs or nullptr if no
// match is found. It is allowed to add new callers of this method but
// consider using CefBrowserHostImpl::GetBrowserForFrameRoute() or
// consider using CefBrowserHostBase::GetBrowserForFrameRoute() or
// extensions::GetOwnerBrowserForFrameRoute() instead. If |is_guest_view| is
// non-nullptr it will be set to true if the IDs match a guest view associated
// with the returned browser info instead of the browser itself.
@@ -127,7 +130,7 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
// Returns the CefBrowserInfo matching the specified ID or nullptr if no match
// is found. It is allowed to add new callers of this method but consider
// using CefBrowserHostImpl::GetBrowserForFrameTreeNode() instead. If
// using CefBrowserHostBase::GetBrowserForFrameTreeNode() instead. If
// |is_guest_view| is non-nullptr it will be set to true if the IDs match a
// guest view associated with the returned browser info instead of the browser
// itself.