Walk FrameTrees to register origins in all frames.

In addition to doing a global walk of the session history to find
existing instances of an origin that is opting in to isolation (see
https://chromium-review.googlesource.com/c/chromium/src/+/2018252), we
must also look for that origin in the FrameTreeNodes. This looks at
committed origins as well as navigations that are pending commit.

The FrameTree walk is necessary since some frames may be missing
FrameNavigationEntries, and also since pending navigations will contain
information not yet in the session history.

Bug: 1042415, 1062719
Change-Id: I802c1f391037471a698e7eb7795a367bd0604f5b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2136703
Reviewed-by: Charlie Reis <[email protected]>
Reviewed-by: Alex Moshchuk <[email protected]>
Commit-Queue: James MacLean <[email protected]>
Cr-Commit-Position: refs/heads/master@{#764730}
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index 9512a13..9e45d85 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -6194,13 +6194,19 @@
 }
 
 void WebContentsImpl::RegisterExistingOriginToPreventOptInIsolation(
-    const url::Origin& origin) {
+    const url::Origin& origin,
+    NavigationRequest* navigation_request_to_exclude) {
   // Note: This function can be made static if we ever need call it without
   // a WebContentsImpl instance, in which case we can use a wrapper to
   // implement the override from NavigatorDelegate.
   for (WebContentsImpl* web_contents : GetAllWebContents()) {
     web_contents->controller_.RegisterExistingOriginToPreventOptInIsolation(
         origin);
+    // Walk the frame tree to pick up any frames without FrameNavigationEntries.
+    // * Some frames won't have FrameNavigationEntries (Issues 524208, 608402).
+    // * Some pending navigations won't have NavigationEntries.
+    web_contents->GetFrameTree()->RegisterExistingOriginToPreventOptInIsolation(
+        origin, navigation_request_to_exclude);
   }
 }