App history API to navigation API rename (4/n)
See https://github.com/WICG/navigation-api/issues/83 and
https://github.com/WICG/navigation-api/pull/203 for context.
This CL renames various "AppHistoryEntry" data structures and fields to
"NavigationApiHistoryEntry". This crosses the Blink/browser boundary.
Bug: 1300246
Change-Id: I878affd6c1ca2660b5d574bab8582467c9b51293
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3523006
Reviewed-by: Alex Moshchuk <[email protected]>
Reviewed-by: Daniel Cheng <[email protected]>
Reviewed-by: Nate Chapin <[email protected]>
Commit-Queue: Domenic Denicola <[email protected]>
Cr-Commit-Position: refs/heads/main@{#981872}
diff --git a/content/browser/renderer_host/navigation_controller_impl.cc b/content/browser/renderer_host/navigation_controller_impl.cc
index 45121da..317ac39 100644
--- a/content/browser/renderer_host/navigation_controller_impl.cc
+++ b/content/browser/renderer_host/navigation_controller_impl.cc
@@ -3722,7 +3722,7 @@
network::mojom::WebClientHintsType>() /* enabled_client_hints */,
false /* is_cross_browsing_instance */, nullptr /* old_page_info */,
-1 /* http_response_code */,
- blink::mojom::AppHistoryEntryArrays::New(),
+ blink::mojom::NavigationApiHistoryEntryArrays::New(),
std::vector<GURL>() /* early_hints_preloaded_resources */,
absl::nullopt /* ad_auction_components */,
// This timestamp will be populated when the commit IPC is sent.
@@ -4308,8 +4308,8 @@
NotifyEntryChanged(entry);
}
-std::vector<blink::mojom::AppHistoryEntryPtr>
-NavigationControllerImpl::PopulateSingleAppHistoryEntryVector(
+std::vector<blink::mojom::NavigationApiHistoryEntryPtr>
+NavigationControllerImpl::PopulateSingleNavigationApiHistoryEntryVector(
Direction direction,
int entry_index,
const url::Origin& pending_origin,
@@ -4317,7 +4317,7 @@
SiteInstance* site_instance,
int64_t pending_item_sequence_number,
int64_t pending_document_sequence_number) {
- std::vector<blink::mojom::AppHistoryEntryPtr> entries;
+ std::vector<blink::mojom::NavigationApiHistoryEntryPtr> entries;
if (GetLastCommittedEntry() && GetLastCommittedEntry()->IsInitialEntry()) {
// Don't process the initial entry.
DCHECK_EQ(GetEntryCount(), 1);
@@ -4330,9 +4330,10 @@
FrameNavigationEntry* frame_entry = GetEntryAtIndex(i)->GetFrameEntry(node);
if (!frame_entry)
break;
- // An entry should only appear in appHistory entries if it is for the same
- // origin as the document being committed. Check the committed origin, or if
- // that is not available (during restore), check against the FNE's url.
+ // An entry should only appear in the navigation API entries if it is for
+ // the same origin as the document being committed. Check the committed
+ // origin, or if that is not available (during restore), check against the
+ // FNE's url.
url::Origin frame_entry_origin =
frame_entry->committed_origin().value_or(url::Origin::Resolve(
frame_entry->url(),
@@ -4348,7 +4349,7 @@
// If the document represented by this FNE hid its full url from appearing
// in a referrer via a "no-referrer" or "origin" referrer policy, censor
- // the url in appHistory as well (unless we're navigating to that
+ // the url in the navigation API as well (unless we're navigating to that
// document).
std::u16string url;
if (pending_document_sequence_number ==
@@ -4357,8 +4358,8 @@
url = frame_state.url_string.value_or(std::u16string());
}
- blink::mojom::AppHistoryEntryPtr entry =
- blink::mojom::AppHistoryEntry::New(
+ blink::mojom::NavigationApiHistoryEntryPtr entry =
+ blink::mojom::NavigationApiHistoryEntry::New(
frame_state.app_history_key.value_or(std::u16string()),
frame_state.app_history_id.value_or(std::u16string()), url,
frame_state.item_sequence_number,
@@ -4379,8 +4380,8 @@
return entries;
}
-blink::mojom::AppHistoryEntryArraysPtr
-NavigationControllerImpl::GetAppHistoryEntryVectors(
+blink::mojom::NavigationApiHistoryEntryArraysPtr
+NavigationControllerImpl::GetNavigationApiHistoryEntryVectors(
FrameTreeNode* node,
NavigationRequest* request) {
url::Origin pending_origin =
@@ -4418,17 +4419,18 @@
}
}
- auto entry_arrays = blink::mojom::AppHistoryEntryArrays::New();
- entry_arrays->back_entries = PopulateSingleAppHistoryEntryVector(
+ auto entry_arrays = blink::mojom::NavigationApiHistoryEntryArrays::New();
+ entry_arrays->back_entries = PopulateSingleNavigationApiHistoryEntryVector(
Direction::kBack, entry_index, pending_origin, node, site_instance.get(),
pending_item_sequence_number, pending_document_sequence_number);
// Don't populate forward entries if they will be truncated by a new entry.
if (!will_create_new_entry) {
- entry_arrays->forward_entries = PopulateSingleAppHistoryEntryVector(
- Direction::kForward, entry_index, pending_origin, node,
- site_instance.get(), pending_item_sequence_number,
- pending_document_sequence_number);
+ entry_arrays->forward_entries =
+ PopulateSingleNavigationApiHistoryEntryVector(
+ Direction::kForward, entry_index, pending_origin, node,
+ site_instance.get(), pending_item_sequence_number,
+ pending_document_sequence_number);
}
return entry_arrays;
}
diff --git a/content/browser/renderer_host/navigation_controller_impl.h b/content/browser/renderer_host/navigation_controller_impl.h
index cfcee8e3f1..16b8c9b 100644
--- a/content/browser/renderer_host/navigation_controller_impl.h
+++ b/content/browser/renderer_host/navigation_controller_impl.h
@@ -32,7 +32,7 @@
#include "services/network/public/mojom/source_location.mojom-forward.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
#include "third_party/blink/public/common/tokens/tokens.h"
-#include "third_party/blink/public/mojom/navigation/app_history_entry_arrays.mojom-forward.h"
+#include "third_party/blink/public/mojom/navigation/navigation_api_history_entry_arrays.mojom-forward.h"
#include "third_party/blink/public/mojom/navigation/navigation_params.mojom-forward.h"
namespace blink {
@@ -398,9 +398,9 @@
// |request| may be nullptr when getting entries for an iframe that is being
// restored for back/forward cache (in that case, the iframe itself is not
// navigated, so there is no NavigationRequest).
- blink::mojom::AppHistoryEntryArraysPtr GetAppHistoryEntryVectors(
- FrameTreeNode* node,
- NavigationRequest* request);
+ blink::mojom::NavigationApiHistoryEntryArraysPtr
+ GetNavigationApiHistoryEntryVectors(FrameTreeNode* node,
+ NavigationRequest* request);
// The appHistory API exposes the urls of some non-current same-origin
// FrameNavigationEntries to the renderer. This helper checks whether the
@@ -729,16 +729,18 @@
// GetLastCommittedEntryIndex() and length is GetEntryCount().
void BroadcastHistoryOffsetAndLength();
- // Used by PopulateAppHistoryEntryVectors to initialize a single vector.
+ // Used by PopulateNavigationApiHistoryEntryVectors to initialize a single
+ // vector.
enum class Direction { kForward, kBack };
- std::vector<blink::mojom::AppHistoryEntryPtr>
- PopulateSingleAppHistoryEntryVector(Direction direction,
- int entry_index,
- const url::Origin& pending_origin,
- FrameTreeNode* node,
- SiteInstance* site_instance,
- int64_t pending_item_sequence_number,
- int64_t pending_document_sequence_number);
+ std::vector<blink::mojom::NavigationApiHistoryEntryPtr>
+ PopulateSingleNavigationApiHistoryEntryVector(
+ Direction direction,
+ int entry_index,
+ const url::Origin& pending_origin,
+ FrameTreeNode* node,
+ SiteInstance* site_instance,
+ int64_t pending_item_sequence_number,
+ int64_t pending_document_sequence_number);
// Helper for NavigateToAppHistoryKey(). Ensures that we only navigate to
// |target_entry| if it matches |current_entry|'s origin and site instance, as
// well as having |app_history_key| as its key.
diff --git a/content/browser/renderer_host/navigation_entry_impl.cc b/content/browser/renderer_host/navigation_entry_impl.cc
index a4aaa62..0ed0f7c 100644
--- a/content/browser/renderer_host/navigation_entry_impl.cc
+++ b/content/browser/renderer_host/navigation_entry_impl.cc
@@ -924,7 +924,7 @@
network::mojom::WebClientHintsType>() /* enabled_client_hints */,
false /* is_cross_browsing_instance */, nullptr /* old_page_info */,
-1 /* http_response_code */,
- blink::mojom::AppHistoryEntryArrays::New(),
+ blink::mojom::NavigationApiHistoryEntryArrays::New(),
std::vector<GURL>() /* early_hints_preloaded_resources */,
absl::nullopt /* ad_auction_components */,
// This timestamp will be populated when the commit IPC is sent.
diff --git a/content/browser/renderer_host/navigation_request.cc b/content/browser/renderer_host/navigation_request.cc
index 6b502c76..65e021d 100644
--- a/content/browser/renderer_host/navigation_request.cc
+++ b/content/browser/renderer_host/navigation_request.cc
@@ -1166,7 +1166,7 @@
std::vector<network::mojom::WebClientHintsType>(),
/*is_cross_browsing_instance=*/false,
/*old_page_info=*/nullptr, /*http_response_code=*/-1,
- blink::mojom::AppHistoryEntryArrays::New(),
+ blink::mojom::NavigationApiHistoryEntryArrays::New(),
/*early_hints_preloaded_resources=*/
std::vector<GURL>(), absl::nullopt /* ad_auction_components */,
// This timestamp will be populated when the commit IPC is sent.
@@ -1289,7 +1289,8 @@
std::vector<
network::mojom::WebClientHintsType>() /* enabled_client_hints */,
false /* is_cross_browsing_instance */, nullptr /* old_page_info */,
- http_response_code, blink::mojom::AppHistoryEntryArrays::New(),
+ http_response_code,
+ blink::mojom::NavigationApiHistoryEntryArrays::New(),
std::vector<GURL>() /* early_hints_preloaded_resources */,
absl::nullopt /* ad_auction_components */,
// This timestamp will be populated when the commit IPC is sent.
@@ -4601,9 +4602,9 @@
}
if (!IsSameDocument()) {
- commit_params_->app_history_entry_arrays =
- GetNavigationController()->GetAppHistoryEntryVectors(frame_tree_node_,
- this);
+ commit_params_->navigation_api_history_entry_arrays =
+ GetNavigationController()->GetNavigationApiHistoryEntryVectors(
+ frame_tree_node_, this);
}
if (early_hints_manager_) {
@@ -4672,10 +4673,10 @@
if (!activated_entry)
return;
- // Restore appHistory entries, since they will probably have changed since
- // the page entered bfcache. We must update all frames, not just the top
- // frame, because it is possible (though unlikely) that an iframe's entries
- // have changed, too.
+ // Restore navigation API entries, since they will probably have changed
+ // since the page entered bfcache. We must update all frames, not just the
+ // top frame, because it is possible (though unlikely) that an iframe's
+ // entries have changed, too.
activated_entry->render_frame_host()->ForEachRenderFrameHost(
base::BindRepeating(
[](content::RenderFrameHost* navigating_rfh,
@@ -4683,14 +4684,17 @@
RenderFrameHostImpl* rfhi =
static_cast<RenderFrameHostImpl*>(rfh);
// |request| is given as a parameter to
- // GetAppHistoryEntryVectors() only for the frame being committed
- // (i.e., the top frame).
+ // GetNavigationApiHistoryEntryVectors() only for the frame being
+ // committed (i.e., the top frame).
auto entry_arrays =
- rfhi->frame_tree()->controller().GetAppHistoryEntryVectors(
- rfhi->frame_tree_node(),
- navigating_rfh == rfh ? request : nullptr);
- rfhi->GetAssociatedLocalFrame()->SetAppHistoryEntriesForRestore(
- std::move(entry_arrays));
+ rfhi->frame_tree()
+ ->controller()
+ .GetNavigationApiHistoryEntryVectors(
+ rfhi->frame_tree_node(),
+ navigating_rfh == rfh ? request : nullptr);
+ rfhi->GetAssociatedLocalFrame()
+ ->SetNavigationApiHistoryEntriesForRestore(
+ std::move(entry_arrays));
return content::RenderFrameHost::FrameIterationAction::kContinue;
},
activated_entry->render_frame_host(), this));