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

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

Issue 2657323003: Convert HistoryTabHelper to use the new navigation callbacks. (Closed)
Patch Set: better fix to send this data from the renderer initially Created 3 years, 11 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 fd595cf16216f28e9e72351f1e0307b5b2120af3..62a0eaf355623f60911cc3e72200f69be3d9d838 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_;
+}
+
void NavigationHandleImpl::Resume() {
if (state_ != DEFERRING_START && state_ != DEFERRING_REDIRECT &&
state_ != DEFERRING_RESPONSE) {
@@ -464,9 +480,16 @@ 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;
+ if (transition_ & ui::PAGE_TRANSITION_CLIENT_REDIRECT) {
jam 2017/01/31 20:24:23 this mirrors the logic in RenderFrameImpl::SendDid
+ // If the page contained a client redirect (meta refresh, document.loc...),
nasko 2017/02/06 19:07:52 nit: Don't use ..., spell out the whole word.
+ // 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;
@@ -497,8 +520,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;
@@ -570,15 +598,17 @@ void NavigationHandleImpl::ReadyToCommitNavigation(
void NavigationHandleImpl::DidCommitNavigation(
const FrameHostMsg_DidCommitProvisionalLoad_Params& params,
- bool same_page,
+ bool did_replace_entry,
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;
// If an error page reloads, net_error_code might be 200 but we still want to
« 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