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

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

Issue 2465813002: Fix content script injection for cancelled loads with PlzNavigate. (Closed)
Patch Set: 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/navigation_request.h" 5 #include "content/browser/frame_host/navigation_request.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "content/browser/child_process_security_policy_impl.h" 9 #include "content/browser/child_process_security_policy_impl.h"
10 #include "content/browser/devtools/render_frame_devtools_agent_host.h" 10 #include "content/browser/devtools/render_frame_devtools_agent_host.h"
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 } 361 }
362 362
363 void NavigationRequest::OnResponseStarted( 363 void NavigationRequest::OnResponseStarted(
364 const scoped_refptr<ResourceResponse>& response, 364 const scoped_refptr<ResourceResponse>& response,
365 std::unique_ptr<StreamHandle> body, 365 std::unique_ptr<StreamHandle> body,
366 const SSLStatus& ssl_status, 366 const SSLStatus& ssl_status,
367 std::unique_ptr<NavigationData> navigation_data) { 367 std::unique_ptr<NavigationData> navigation_data) {
368 DCHECK(state_ == STARTED); 368 DCHECK(state_ == STARTED);
369 state_ = RESPONSE_STARTED; 369 state_ = RESPONSE_STARTED;
370 370
371 RenderFrameHostImpl* render_frame_host =
372 frame_tree_node_->render_manager()->GetFrameHostForNavigation(*this);
373
371 // HTTP 204 (No Content) and HTTP 205 (Reset Content) responses should not 374 // HTTP 204 (No Content) and HTTP 205 (Reset Content) responses should not
372 // commit; they leave the frame showing the previous page. 375 // commit; they leave the frame showing the previous page.
373 DCHECK(response); 376 DCHECK(response);
374 if (response->head.headers.get() && 377 if (response->head.headers.get() &&
375 (response->head.headers->response_code() == 204 || 378 (response->head.headers->response_code() == 204 ||
376 response->head.headers->response_code() == 205)) { 379 response->head.headers->response_code() == 205)) {
377 frame_tree_node_->navigator()->DiscardPendingEntryIfNeeded( 380 frame_tree_node_->navigator()->DiscardPendingEntryIfNeeded(
378 navigation_handle_.get()); 381 navigation_handle_.get());
382 navigation_handle_->AbortCommit(render_frame_host,
383 response->head.headers);
379 frame_tree_node_->ResetNavigationRequest(false); 384 frame_tree_node_->ResetNavigationRequest(false);
380 return; 385 return;
381 } 386 }
382 387
383 // Update the service worker params of the request params. 388 // Update the service worker params of the request params.
384 bool did_create_service_worker_host = 389 bool did_create_service_worker_host =
385 navigation_handle_->service_worker_handle() && 390 navigation_handle_->service_worker_handle() &&
386 navigation_handle_->service_worker_handle() 391 navigation_handle_->service_worker_handle()
387 ->service_worker_provider_host_id() != 392 ->service_worker_provider_host_id() !=
388 kInvalidServiceWorkerProviderId; 393 kInvalidServiceWorkerProviderId;
389 request_params_.service_worker_provider_id = 394 request_params_.service_worker_provider_id =
390 did_create_service_worker_host 395 did_create_service_worker_host
391 ? navigation_handle_->service_worker_handle() 396 ? navigation_handle_->service_worker_handle()
392 ->service_worker_provider_host_id() 397 ->service_worker_provider_host_id()
393 : kInvalidServiceWorkerProviderId; 398 : kInvalidServiceWorkerProviderId;
394 399
395 // Update the lofi state of the request. 400 // Update the lofi state of the request.
396 if (response->head.is_using_lofi) 401 if (response->head.is_using_lofi)
397 common_params_.lofi_state = LOFI_ON; 402 common_params_.lofi_state = LOFI_ON;
398 else 403 else
399 common_params_.lofi_state = LOFI_OFF; 404 common_params_.lofi_state = LOFI_OFF;
400 405
401 // Select an appropriate renderer to commit the navigation. 406 // Select an appropriate renderer to commit the navigation.
402 RenderFrameHostImpl* render_frame_host =
403 frame_tree_node_->render_manager()->GetFrameHostForNavigation(*this);
404 NavigatorImpl::CheckWebUIRendererDoesNotDisplayNormalURL(render_frame_host, 407 NavigatorImpl::CheckWebUIRendererDoesNotDisplayNormalURL(render_frame_host,
405 common_params_.url); 408 common_params_.url);
406 409
407 // For renderer-initiated navigations that are set to commit in a different 410 // For renderer-initiated navigations that are set to commit in a different
408 // renderer, allow the embedder to cancel the transfer. 411 // renderer, allow the embedder to cancel the transfer.
409 if (!browser_initiated_ && 412 if (!browser_initiated_ &&
410 render_frame_host != frame_tree_node_->current_frame_host() && 413 render_frame_host != frame_tree_node_->current_frame_host() &&
411 !frame_tree_node_->navigator()->GetDelegate()->ShouldTransferNavigation( 414 !frame_tree_node_->navigator()->GetDelegate()->ShouldTransferNavigation(
412 frame_tree_node_->IsMainFrame())) { 415 frame_tree_node_->IsMainFrame())) {
413 frame_tree_node_->ResetNavigationRequest(false); 416 frame_tree_node_->ResetNavigationRequest(false);
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 DCHECK_EQ(request_params_.has_user_gesture, begin_params_.has_user_gesture); 592 DCHECK_EQ(request_params_.has_user_gesture, begin_params_.has_user_gesture);
590 593
591 render_frame_host->CommitNavigation(response_.get(), std::move(body_), 594 render_frame_host->CommitNavigation(response_.get(), std::move(body_),
592 common_params_, request_params_, 595 common_params_, request_params_,
593 is_view_source_); 596 is_view_source_);
594 597
595 frame_tree_node_->ResetNavigationRequest(true); 598 frame_tree_node_->ResetNavigationRequest(true);
596 } 599 }
597 600
598 } // namespace content 601 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698