Skip to content

Commit

Permalink
App history API to navigation API rename (4/n)
Browse files Browse the repository at this point in the history
See WICG/navigation-api#83 and
WICG/navigation-api#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 <alexmos@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Nate Chapin <japhet@chromium.org>
Commit-Queue: Domenic Denicola <domenic@chromium.org>
Cr-Commit-Position: refs/heads/main@{#981872}
NOKEYCHECK=True
GitOrigin-RevId: cd30f5f8cd986ed1d95f12af2004b19f749eadb4
  • Loading branch information
domenic authored and Copybara-Service committed Mar 16, 2022
1 parent e1c7835 commit 70c3b7e
Show file tree
Hide file tree
Showing 12 changed files with 46 additions and 44 deletions.
3 changes: 2 additions & 1 deletion blink/common/navigation/navigation_params.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ mojom::CommitNavigationParamsPtr CreateCommitNavigationParams() {
auto commit_params = mojom::CommitNavigationParams::New();
commit_params->navigation_token = base::UnguessableToken::Create();
commit_params->navigation_timing = mojom::NavigationTiming::New();
commit_params->app_history_entry_arrays = mojom::AppHistoryEntryArrays::New();
commit_params->navigation_api_history_entry_arrays =
mojom::NavigationApiHistoryEntryArrays::New();

return commit_params;
}
Expand Down
2 changes: 1 addition & 1 deletion blink/public/mojom/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ mojom("mojom_platform") {
"mediastream/media_stream.mojom",
"mime/mime_registry.mojom",
"native_io/native_io.mojom",
"navigation/app_history_entry_arrays.mojom",
"navigation/navigation_api_history_entry_arrays.mojom",
"navigation/navigation_policy.mojom",
"navigation/prefetched_signed_exchange_info.mojom",
"navigation/renderer_eviction_reason.mojom",
Expand Down
10 changes: 5 additions & 5 deletions blink/public/mojom/frame/frame.mojom
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ import "third_party/blink/public/mojom/frame/user_activation_update_types.mojom"
import "third_party/blink/public/mojom/frame/viewport_intersection_state.mojom";
import "third_party/blink/public/mojom/input/focus_type.mojom";
import "third_party/blink/public/mojom/input/scroll_direction.mojom";
import "third_party/blink/public/mojom/navigation/app_history_entry_arrays.mojom";
import "third_party/blink/public/mojom/navigation/navigation_api_history_entry_arrays.mojom";
import "third_party/blink/public/mojom/navigation/navigation_policy.mojom";
import "third_party/blink/public/mojom/loader/referrer.mojom";
import "third_party/blink/public/mojom/widget/platform_widget.mojom";
Expand Down Expand Up @@ -839,12 +839,12 @@ interface LocalFrame {
// the document of this frame doesn't have the HTMLLinkElement.
GetCanonicalUrlForSharing() => (url.mojom.Url? canonical_url);

// Updates appHistory.entries() when restoring from bfcache.
// appHistory.entries() represents a subset of the back/forward list visible
// Updates navigation.entries() when restoring from bfcache.
// navigation.entries() represents a subset of the back/forward list visible
// to this frame, and that subset may have changed while the page was in
// bfcache.
SetAppHistoryEntriesForRestore(
AppHistoryEntryArrays app_history_entry_arrays);
SetNavigationApiHistoryEntriesForRestore(
NavigationApiHistoryEntryArrays entry_arrays);
};

// Also implemented in Blink, this interface defines frame-specific methods
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ module blink.mojom;

import "mojo/public/mojom/base/string16.mojom";

// AppHistoryEntry contains a subset of a session history item that is used by
// the appHistory API to represent a non-current history entry. The browser
// ensures that an AppHistoryEntry is only sent to the renderer if its |url| is
// same-origin to the navigation being committed.
struct AppHistoryEntry {
// The NavigationApiHistoryEntry contains a subset of a session history item
// that is used by the window.navigation API to represent a non-current history
// entry. The browser ensures that a NavigationApiHistoryEntry is only sent to
// the renderer if its |url| is same-origin to the navigation being committed.
struct NavigationApiHistoryEntry {
mojo_base.mojom.String16 key;
mojo_base.mojom.String16 id;
// |url| is represented as a string rather than a url.mojom.Url in keeping
Expand All @@ -21,9 +21,9 @@ struct AppHistoryEntry {
mojo_base.mojom.String16 state;
};

// A same-origin subset of the back/forward list exposed by the appHistory
// API.
struct AppHistoryEntryArrays {
array<AppHistoryEntry> back_entries;
array<AppHistoryEntry> forward_entries;
// A same-origin subset of the back/forward list exposed by the
// window.navigation API.
struct NavigationApiHistoryEntryArrays {
array<NavigationApiHistoryEntry> back_entries;
array<NavigationApiHistoryEntry> forward_entries;
};
8 changes: 4 additions & 4 deletions blink/public/mojom/navigation/navigation_params.mojom
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import "third_party/blink/public/mojom/fetch/fetch_api_request.mojom";
import "third_party/blink/public/mojom/frame/frame_policy.mojom";
import "third_party/blink/public/mojom/loader/mixed_content.mojom";
import "third_party/blink/public/mojom/loader/referrer.mojom";
import "third_party/blink/public/mojom/navigation/app_history_entry_arrays.mojom";
import "third_party/blink/public/mojom/navigation/navigation_api_history_entry_arrays.mojom";
import "third_party/blink/public/mojom/navigation/navigation_policy.mojom";
import "third_party/blink/public/mojom/navigation/prefetched_signed_exchange_info.mojom";
import "third_party/blink/public/mojom/navigation/was_activated_option.mojom";
Expand Down Expand Up @@ -458,9 +458,9 @@ struct CommitNavigationParams {
// received response headers.
int32 http_response_code = -1;

// A same-origin subset of the back/forward list exposed by the appHistory
// API.
AppHistoryEntryArrays app_history_entry_arrays;
// A same-origin subset of the back/forward list exposed by the
// window.navigation API.
NavigationApiHistoryEntryArrays navigation_api_history_entry_arrays;

array<url.mojom.Url> early_hints_preloaded_resources;

Expand Down
8 changes: 4 additions & 4 deletions blink/public/web/web_navigation_params.h
Original file line number Diff line number Diff line change
Expand Up @@ -431,10 +431,10 @@ struct BLINK_EXPORT WebNavigationParams {
std::unique_ptr<WebPolicyContainer> policy_container;

// These are used to construct a subset of the back/forward list for the
// appHistory API. They only have the attributes that are needed for
// appHistory.
WebVector<WebHistoryItem> app_history_back_entries;
WebVector<WebHistoryItem> app_history_forward_entries;
// window.navigation API. They only have the attributes that are needed for
// that API.
WebVector<WebHistoryItem> navigation_api_back_entries;
WebVector<WebHistoryItem> navigation_api_forward_entries;

// List of URLs which are preloaded by HTTP Early Hints.
WebVector<WebURL> early_hints_preloaded_resources;
Expand Down
4 changes: 2 additions & 2 deletions blink/renderer/core/frame/local_frame_mojo_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1149,8 +1149,8 @@ void LocalFrameMojoHandler::GetCanonicalUrlForSharing(
#endif
}

void LocalFrameMojoHandler::SetAppHistoryEntriesForRestore(
mojom::blink::AppHistoryEntryArraysPtr entry_arrays) {
void LocalFrameMojoHandler::SetNavigationApiHistoryEntriesForRestore(
mojom::blink::NavigationApiHistoryEntryArraysPtr entry_arrays) {
if (NavigationApi* navigation_api =
NavigationApi::navigation(*frame_->DomWindow()))
navigation_api->SetEntriesForRestore(entry_arrays);
Expand Down
4 changes: 2 additions & 2 deletions blink/renderer/core/frame/local_frame_mojo_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@ class LocalFrameMojoHandler
void GetCanonicalUrlForSharing(
GetCanonicalUrlForSharingCallback callback) final;

void SetAppHistoryEntriesForRestore(
mojom::blink::AppHistoryEntryArraysPtr) final;
void SetNavigationApiHistoryEntriesForRestore(
mojom::blink::NavigationApiHistoryEntryArraysPtr) final;

// blink::mojom::LocalMainFrame overrides:
void AnimateDoubleTapZoom(const gfx::Point& point,
Expand Down
16 changes: 8 additions & 8 deletions blink/renderer/core/loader/document_loader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,8 @@ struct SameSizeAsDocumentLoader
bool origin_agent_cluster;
bool origin_agent_cluster_left_as_default;
bool is_cross_site_cross_browsing_context_group;
WebVector<WebHistoryItem> app_history_back_entries;
WebVector<WebHistoryItem> app_history_forward_entries;
WebVector<WebHistoryItem> navigation_api_back_entries;
WebVector<WebHistoryItem> navigation_api_forward_entries;
std::unique_ptr<CodeCacheHost> code_cache_host;
HashSet<KURL> early_hints_preloaded_resources;
absl::optional<Vector<KURL>> ad_auction_components;
Expand Down Expand Up @@ -414,8 +414,8 @@ DocumentLoader::DocumentLoader(
params_->origin_agent_cluster_left_as_default),
is_cross_site_cross_browsing_context_group_(
params_->is_cross_site_cross_browsing_context_group),
app_history_back_entries_(params_->app_history_back_entries),
app_history_forward_entries_(params_->app_history_forward_entries),
navigation_api_back_entries_(params_->navigation_api_back_entries),
navigation_api_forward_entries_(params_->navigation_api_forward_entries),
anonymous_(params_->anonymous) {
DCHECK(frame_);

Expand Down Expand Up @@ -2404,12 +2404,12 @@ void DocumentLoader::CommitNavigation() {
NavigationApi::From(*frame_->DomWindow())
->InitializeForNewWindow(*history_item_, load_type_, commit_reason_,
NavigationApi::navigation(*previous_window),
app_history_back_entries_,
app_history_forward_entries_);
navigation_api_back_entries_,
navigation_api_forward_entries_);
// Now that the navigation API's entries array is initialized, we don't need
// to retain the state from which it was initialized.
app_history_back_entries_.Clear();
app_history_forward_entries_.Clear();
navigation_api_back_entries_.Clear();
navigation_api_forward_entries_.Clear();
}

if (commit_reason_ == CommitReason::kXSLT)
Expand Down
4 changes: 2 additions & 2 deletions blink/renderer/core/loader/document_loader.h
Original file line number Diff line number Diff line change
Expand Up @@ -638,8 +638,8 @@ class CORE_EXPORT DocumentLoader : public GarbageCollected<DocumentLoader>,
// BrowsingContextGroup.
bool is_cross_site_cross_browsing_context_group_ = false;

WebVector<WebHistoryItem> app_history_back_entries_;
WebVector<WebHistoryItem> app_history_forward_entries_;
WebVector<WebHistoryItem> navigation_api_back_entries_;
WebVector<WebHistoryItem> navigation_api_forward_entries_;

// This is the interface that handles generated code cache
// requests to fetch code cache when loading resources.
Expand Down
4 changes: 2 additions & 2 deletions blink/renderer/core/navigation_api/navigation_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ void NavigationApi::UpdateForNavigation(HistoryItem& item,
}

NavigationHistoryEntry* NavigationApi::GetEntryForRestore(
const mojom::blink::AppHistoryEntryPtr& entry) {
const mojom::blink::NavigationApiHistoryEntryPtr& entry) {
const auto& it = keys_to_indices_.find(entry->key);
if (it != keys_to_indices_.end()) {
NavigationHistoryEntry* existing_entry = entries_[it->value];
Expand Down Expand Up @@ -376,7 +376,7 @@ void FireDisposeEventsAsync(
}

void NavigationApi::SetEntriesForRestore(
const mojom::blink::AppHistoryEntryArraysPtr& entry_arrays) {
const mojom::blink::NavigationApiHistoryEntryArraysPtr& entry_arrays) {
// If this window HasEntriesAndEventsDisabled(), we shouldn't attempt to
// restore anything.
if (HasEntriesAndEventsDisabled())
Expand Down
7 changes: 4 additions & 3 deletions blink/renderer/core/navigation_api/navigation_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#define THIRD_PARTY_BLINK_RENDERER_CORE_NAVIGATION_API_NAVIGATION_API_H_

#include "base/memory/scoped_refptr.h"
#include "third_party/blink/public/mojom/navigation/app_history_entry_arrays.mojom-blink.h"
#include "third_party/blink/public/mojom/navigation/navigation_api_history_entry_arrays.mojom-blink.h"
#include "third_party/blink/public/web/web_frame_load_type.h"
#include "third_party/blink/public/web/web_history_item.h"
#include "third_party/blink/renderer/core/core_export.h"
Expand Down Expand Up @@ -62,7 +62,8 @@ class CORE_EXPORT NavigationApi final : public EventTargetWithInlineData,
const WebVector<WebHistoryItem>& back_entries,
const WebVector<WebHistoryItem>& forward_entries);
void UpdateForNavigation(HistoryItem&, WebFrameLoadType);
void SetEntriesForRestore(const mojom::blink::AppHistoryEntryArraysPtr&);
void SetEntriesForRestore(
const mojom::blink::NavigationApiHistoryEntryArraysPtr&);

bool HasOngoingNavigation() const { return ongoing_navigation_signal_; }

Expand Down Expand Up @@ -125,7 +126,7 @@ class CORE_EXPORT NavigationApi final : public EventTargetWithInlineData,
friend class NavigationApiNavigation;
void CloneFromPrevious(NavigationApi&);
NavigationHistoryEntry* GetEntryForRestore(
const mojom::blink::AppHistoryEntryPtr&);
const mojom::blink::NavigationApiHistoryEntryPtr&);
void PopulateKeySet();
void FinalizeWithAbortedNavigationError(ScriptState*,
NavigationApiNavigation*);
Expand Down

0 comments on commit 70c3b7e

Please sign in to comment.