Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1141)

Unified Diff: content/browser/frame_host/navigation_handle_impl.cc

Issue 2657323003: Convert HistoryTabHelper to use the new navigation callbacks. (Closed)
Patch Set: nit Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/frame_host/navigation_handle_impl.cc
diff --git a/content/browser/frame_host/navigation_handle_impl.cc b/content/browser/frame_host/navigation_handle_impl.cc
index cefb752a34332d98d623227b998de6af4e3540df..ce49e6c1b9f6dfc1063480e1c11cabd6b261a137 100644
--- a/content/browser/frame_host/navigation_handle_impl.cc
+++ b/content/browser/frame_host/navigation_handle_impl.cc
@@ -59,6 +59,7 @@ void NotifyAbandonedTransferNavigation(const GlobalRequestID& id) {
// static
std::unique_ptr<NavigationHandleImpl> NavigationHandleImpl::Create(
const GURL& url,
+ const std::vector<GURL>& redirect_chain,
FrameTreeNode* frame_tree_node,
bool is_renderer_initiated,
bool is_same_page,
@@ -66,13 +67,14 @@ std::unique_ptr<NavigationHandleImpl> NavigationHandleImpl::Create(
int pending_nav_entry_id,
bool started_from_context_menu) {
return std::unique_ptr<NavigationHandleImpl>(new NavigationHandleImpl(
- url, frame_tree_node, is_renderer_initiated, is_same_page,
+ url, redirect_chain, frame_tree_node, is_renderer_initiated, is_same_page,
navigation_start, pending_nav_entry_id,
started_from_context_menu));
}
NavigationHandleImpl::NavigationHandleImpl(
const GURL& url,
+ const std::vector<GURL>& redirect_chain,
FrameTreeNode* frame_tree_node,
bool is_renderer_initiated,
bool is_same_page,
@@ -88,6 +90,8 @@ NavigationHandleImpl::NavigationHandleImpl(
is_renderer_initiated_(is_renderer_initiated),
is_same_page_(is_same_page),
was_redirected_(false),
+ did_replace_entry_(false),
+ should_update_history_(false),
connection_info_(net::HttpResponseInfo::CONNECTION_INFO_UNKNOWN),
original_url_(url),
state_(INITIAL),
@@ -99,13 +103,15 @@ NavigationHandleImpl::NavigationHandleImpl(
request_context_type_(REQUEST_CONTEXT_TYPE_UNSPECIFIED),
mixed_content_context_type_(blink::WebMixedContentContextType::Blockable),
should_replace_current_entry_(false),
+ redirect_chain_(redirect_chain),
is_download_(false),
is_stream_(false),
started_from_context_menu_(started_from_context_menu),
reload_type_(ReloadType::NONE),
weak_factory_(this) {
DCHECK(!navigation_start.is_null());
- redirect_chain_.push_back(url);
+ if (redirect_chain_.empty())
+ redirect_chain_.push_back(url);
starting_site_instance_ =
frame_tree_node_->current_frame_host()->GetSiteInstance();
@@ -277,6 +283,16 @@ bool NavigationHandleImpl::IsErrorPage() {
return state_ == DID_COMMIT_ERROR_PAGE;
}
+bool NavigationHandleImpl::DidReplaceEntry() {
+ DCHECK(state_ == DID_COMMIT || state_ == DID_COMMIT_ERROR_PAGE);
+ return did_replace_entry_;
+}
+
+bool NavigationHandleImpl::ShouldUpdateHistory() {
+ DCHECK(state_ == DID_COMMIT || state_ == DID_COMMIT_ERROR_PAGE);
+ return should_update_history_;
+}
+
const GURL& NavigationHandleImpl::GetPreviousURL() {
DCHECK(state_ == DID_COMMIT || state_ == DID_COMMIT_ERROR_PAGE);
return previous_url_;
@@ -474,9 +490,17 @@ void NavigationHandleImpl::WillStartRequest(
method_ = method;
if (method_ == "POST")
resource_request_body_ = resource_request_body;
- sanitized_referrer_ = sanitized_referrer;
has_user_gesture_ = has_user_gesture;
transition_ = transition;
+ // Mirrors the logic in RenderFrameImpl::SendDidCommitProvisionalLoad.
+ if (transition_ & ui::PAGE_TRANSITION_CLIENT_REDIRECT) {
+ // If the page contained a client redirect (meta refresh,
+ // document.location), set the referrer appropriately.
+ sanitized_referrer_ =
+ Referrer(redirect_chain_[0], sanitized_referrer.policy);
+ } else {
+ sanitized_referrer_ = sanitized_referrer;
+ }
is_external_protocol_ = is_external_protocol;
request_context_type_ = request_context_type;
mixed_content_context_type_ = mixed_content_context_type;
@@ -507,8 +531,13 @@ void NavigationHandleImpl::WillRedirectRequest(
// Update the navigation parameters.
url_ = new_url;
method_ = new_method;
- sanitized_referrer_.url = new_referrer_url;
- sanitized_referrer_ = Referrer::SanitizeForRequest(url_, sanitized_referrer_);
+
+ if (!(transition_ & ui::PAGE_TRANSITION_CLIENT_REDIRECT)) {
+ sanitized_referrer_.url = new_referrer_url;
+ sanitized_referrer_ =
+ Referrer::SanitizeForRequest(url_, sanitized_referrer_);
+ }
+
is_external_protocol_ = new_is_external_protocol;
response_headers_ = response_headers;
connection_info_ = connection_info;
@@ -580,16 +609,18 @@ void NavigationHandleImpl::ReadyToCommitNavigation(
void NavigationHandleImpl::DidCommitNavigation(
const FrameHostMsg_DidCommitProvisionalLoad_Params& params,
- bool same_page,
+ bool did_replace_entry,
const GURL& previous_url,
RenderFrameHostImpl* render_frame_host) {
DCHECK(!render_frame_host_ || render_frame_host_ == render_frame_host);
DCHECK_EQ(frame_tree_node_, render_frame_host->frame_tree_node());
CHECK_EQ(url_, params.url);
+ did_replace_entry_ = did_replace_entry;
method_ = params.method;
has_user_gesture_ = (params.gesture == NavigationGestureUser);
transition_ = params.transition;
+ should_update_history_ = params.should_update_history;
render_frame_host_ = render_frame_host;
previous_url_ = previous_url;
base_url_ = params.base_url;
« no previous file with comments | « content/browser/frame_host/navigation_handle_impl.h ('k') | content/browser/frame_host/navigation_handle_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698