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

Side by Side Diff: content/browser/frame_host/navigator_impl.cc

Issue 2499313003: Set user_gesture bit at NavigationHandle creation time. (Closed)
Patch Set: address comments Created 4 years, 1 month 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/frame_host/navigator_impl.h" 5 #include "content/browser/frame_host/navigator_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/metrics/histogram_macros.h" 10 #include "base/metrics/histogram_macros.h"
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 return delegate_; 136 return delegate_;
137 } 137 }
138 138
139 NavigationController* NavigatorImpl::GetController() { 139 NavigationController* NavigatorImpl::GetController() {
140 return controller_; 140 return controller_;
141 } 141 }
142 142
143 void NavigatorImpl::DidStartProvisionalLoad( 143 void NavigatorImpl::DidStartProvisionalLoad(
144 RenderFrameHostImpl* render_frame_host, 144 RenderFrameHostImpl* render_frame_host,
145 const GURL& url, 145 const GURL& url,
146 const base::TimeTicks& navigation_start) { 146 const base::TimeTicks& navigation_start,
147 NavigationGesture gesture) {
147 bool is_main_frame = render_frame_host->frame_tree_node()->IsMainFrame(); 148 bool is_main_frame = render_frame_host->frame_tree_node()->IsMainFrame();
148 bool is_error_page = (url.spec() == kUnreachableWebDataURL); 149 bool is_error_page = (url.spec() == kUnreachableWebDataURL);
149 bool is_iframe_srcdoc = (url.spec() == kAboutSrcDocURL); 150 bool is_iframe_srcdoc = (url.spec() == kAboutSrcDocURL);
150 GURL validated_url(url); 151 GURL validated_url(url);
151 RenderProcessHost* render_process_host = render_frame_host->GetProcess(); 152 RenderProcessHost* render_process_host = render_frame_host->GetProcess();
152 render_process_host->FilterURL(false, &validated_url); 153 render_process_host->FilterURL(false, &validated_url);
153 154
154 // Do not allow browser plugin guests to navigate to non-web URLs, since they 155 // Do not allow browser plugin guests to navigate to non-web URLs, since they
155 // cannot swap processes or grant bindings. 156 // cannot swap processes or grant bindings.
156 ChildProcessSecurityPolicyImpl* policy = 157 ChildProcessSecurityPolicyImpl* policy =
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 is_renderer_initiated = pending_entry->is_renderer_initiated(); 203 is_renderer_initiated = pending_entry->is_renderer_initiated();
203 pending_nav_entry_id = pending_entry->GetUniqueID(); 204 pending_nav_entry_id = pending_entry->GetUniqueID();
204 started_from_context_menu = pending_entry->has_started_from_context_menu(); 205 started_from_context_menu = pending_entry->has_started_from_context_menu();
205 } 206 }
206 207
207 render_frame_host->SetNavigationHandle(NavigationHandleImpl::Create( 208 render_frame_host->SetNavigationHandle(NavigationHandleImpl::Create(
208 validated_url, render_frame_host->frame_tree_node(), 209 validated_url, render_frame_host->frame_tree_node(),
209 is_renderer_initiated, 210 is_renderer_initiated,
210 false, // is_same_page 211 false, // is_same_page
211 is_iframe_srcdoc, // is_srcdoc 212 is_iframe_srcdoc, // is_srcdoc
212 navigation_start, pending_nav_entry_id, started_from_context_menu)); 213 navigation_start, pending_nav_entry_id, gesture,
214 started_from_context_menu));
213 } 215 }
214 216
215 void NavigatorImpl::DidFailProvisionalLoadWithError( 217 void NavigatorImpl::DidFailProvisionalLoadWithError(
216 RenderFrameHostImpl* render_frame_host, 218 RenderFrameHostImpl* render_frame_host,
217 const FrameHostMsg_DidFailProvisionalLoadWithError_Params& params) { 219 const FrameHostMsg_DidFailProvisionalLoadWithError_Params& params) {
218 VLOG(1) << "Failed Provisional Load: " << params.url.possibly_invalid_spec() 220 VLOG(1) << "Failed Provisional Load: " << params.url.possibly_invalid_spec()
219 << ", error_code: " << params.error_code 221 << ", error_code: " << params.error_code
220 << ", error_description: " << params.error_description 222 << ", error_description: " << params.error_description
221 << ", showing_repost_interstitial: " << 223 << ", showing_repost_interstitial: " <<
222 params.showing_repost_interstitial 224 params.showing_repost_interstitial
(...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after
960 DCHECK(frame_tree_node); 962 DCHECK(frame_tree_node);
961 963
962 NavigationRequest* ongoing_navigation_request = 964 NavigationRequest* ongoing_navigation_request =
963 frame_tree_node->navigation_request(); 965 frame_tree_node->navigation_request();
964 966
965 // The renderer-initiated navigation request is ignored iff a) there is an 967 // The renderer-initiated navigation request is ignored iff a) there is an
966 // ongoing request b) which is browser or user-initiated and c) the renderer 968 // ongoing request b) which is browser or user-initiated and c) the renderer
967 // request is not user-initiated. 969 // request is not user-initiated.
968 if (ongoing_navigation_request && 970 if (ongoing_navigation_request &&
969 (ongoing_navigation_request->browser_initiated() || 971 (ongoing_navigation_request->browser_initiated() ||
970 ongoing_navigation_request->begin_params().has_user_gesture) && 972 ongoing_navigation_request->common_params().gesture ==
971 !begin_params.has_user_gesture) { 973 NavigationGestureUser) &&
974 common_params.gesture != NavigationGestureUser) {
972 RenderFrameHost* current_frame_host = 975 RenderFrameHost* current_frame_host =
973 frame_tree_node->render_manager()->current_frame_host(); 976 frame_tree_node->render_manager()->current_frame_host();
974 current_frame_host->Send( 977 current_frame_host->Send(
975 new FrameMsg_Stop(current_frame_host->GetRoutingID())); 978 new FrameMsg_Stop(current_frame_host->GetRoutingID()));
976 return; 979 return;
977 } 980 }
978 981
979 // In all other cases the current navigation, if any, is canceled and a new 982 // In all other cases the current navigation, if any, is canceled and a new
980 // NavigationRequest is created for the node. 983 // NavigationRequest is created for the node.
981 frame_tree_node->CreatedNavigationRequest( 984 frame_tree_node->CreatedNavigationRequest(
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
1266 if (navigation_handle) 1269 if (navigation_handle)
1267 navigation_handle->update_entry_id_for_transfer(entry->GetUniqueID()); 1270 navigation_handle->update_entry_id_for_transfer(entry->GetUniqueID());
1268 1271
1269 controller_->SetPendingEntry(std::move(entry)); 1272 controller_->SetPendingEntry(std::move(entry));
1270 if (delegate_) 1273 if (delegate_)
1271 delegate_->NotifyChangedNavigationState(content::INVALIDATE_TYPE_URL); 1274 delegate_->NotifyChangedNavigationState(content::INVALIDATE_TYPE_URL);
1272 } 1275 }
1273 } 1276 }
1274 1277
1275 } // namespace content 1278 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698