0
Files
src/content/renderer/document_state.cc
Thomas Lukaszewicz af57eb3e1a [discard] Address same-document navigation crash during discard
This CL clones content::DocumentState / WebDocumentLoader::ExtraData
and passes it to document loaders of empty documents replacing
the current document as part of a discard operation or JavaScript URL
navigation.

DocumentState is cloned instead of extracted as the original document
state object may be needed to process operations in the replaced
document's unload handlers (such as same-site navigations, see linked
bug).

DocumentState::navigation_state_ is not cloned as this is specific to
the document being replaced and should not be moved to the new empty
document instance.

Bug: 361658816
Change-Id: I9d39867a1688e81b17e18e5f103f53d63aed96fc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5821193
Reviewed-by: Jeremy Roman <jbroman@chromium.org>
Commit-Queue: Thomas Lukaszewicz <tluk@chromium.org>
Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com>
Reviewed-by: Alexander Timin <altimin@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1348293}
2024-08-28 21:34:50 +00:00

32 lines
990 B
C++

// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "content/renderer/document_state.h"
#include "content/renderer/navigation_state.h"
namespace content {
DocumentState::DocumentState() {}
DocumentState::~DocumentState() {}
std::unique_ptr<blink::WebDocumentLoader::ExtraData> DocumentState::Clone() {
auto cloned_document_state = std::make_unique<DocumentState>();
cloned_document_state->set_was_load_data_with_base_url_request(
was_load_data_with_base_url_request_);
cloned_document_state->set_data_url(data_url_);
cloned_document_state->set_is_overriding_user_agent(
is_overriding_user_agent_);
cloned_document_state->set_request_id(request_id_);
return cloned_document_state;
}
void DocumentState::set_navigation_state(
std::unique_ptr<NavigationState> navigation_state) {
navigation_state_ = std::move(navigation_state);
}
} // namespace content