Files
brave-core/browser/web_discovery
Mario Sanchez Prada c22ae2f4b4 Adapt to removal of |enable_extension_apis| from |WebUIBubbleManagerT|
We need to manually add a ChromeExtensionWebContentsObserver to the
WebView's WebContents now that the |enable_extension_apis| parameter
is gone from the constructor, which we used to set to |true| causing
the BubbleContentsWrapper to do it for us.

Chromium change:

https://github.com/chromium/chromium/commit/183029096a06ae326108700c8f6272c6cec9b174

commit 183029096a06ae326108700c8f6272c6cec9b174
Author: Lukasz Anforowicz <lukasza@chromium.org>
Date:   Tue Nov 16 19:45:05 2021 +0000

    Introduce ContentBrowserClient::AttachUniversalWebContentsObservers.

    Problem description
    ===================

    Before this CL, there was a discrepancy in how Chrome Extensions were
    handled in the Browser process VS the Renderer processes:

    1. Code in a Renderer process ensures that content scripts are injected
       into *all* elligible documents (ones with URLs that match patterns
       requested by an extension).  This Renderer-side code is agnostic to
       whether the document is in a browser tab or in a different flavor of
       WebContents.

       This universal applicability of content scripts is desirable - if a
       user installs an extension to modify certain documents (e.g. change
       the behavior of https://example.com) then such user intent should be
       respected in all WebContents hosting such documents.

    2. Code in the Browser process would create ExtensionWebContentsObserver
       (EWCO) only for some, but not for all WebContents.  This was because
       when creating a new flavour of WebContents it was possible to miss
       the responsibility to construct EWCO - we've identified multiple
       WebContents flavours were EWCO was missing.

    The discrepancy between the Browser and the Rednderer processes would
    mean that some content scripts are injected but:

    A. They cannot talk to extensions::mojom::LocalFrameHost (which is
       bound by EWCO::BindLocalFrameHost) and therefore extension API calls
       do not work

    B. They are not recognized by ContentScriptTracker (which relies on
       notifications like EWCO::ReadyToCommitNavigation).  This was
       responsible for majority of DumpWithoutCrashing reports tracked in
       https://crbug.com/1212918.

    Changes in this CL
    ==================

    This CL adds a new method to ContentBrowserClient -
    AttachUniversalWebContentsObservers (which gets called by the //content
    layer for every WebContents after it gets created and initialized).
    Implementation of the new method in ChromeContentBrowserClient
    constructs ChromeExtensionWebContentsObserver for each WebContents.

    For more background (and discussion of alternative approaches for
    addressing the problem) please see the document here:
    https://docs.google.com/document/d/1zITHyso0axNdAZV3qySgsoWW-p6jOEKbWqoVJbOW92c/edit?usp=sharing

    Bug: 1212918
2022-01-24 15:33:54 -05:00
..