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

Side by Side Diff: content/renderer/render_frame_impl.cc

Issue 2687593002: PlzNavigate: Invoke didFailProvisionalLoad() in the renderer when a navigation request is cancelled… (Closed)
Patch Set: We may not have a provisional data source at all times 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 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/renderer/render_frame_impl.h" 5 #include "content/renderer/render_frame_impl.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 1573 matching lines...) Expand 10 before | Expand all | Expand 10 after
1584 OnGetSerializedHtmlWithLocalLinks) 1584 OnGetSerializedHtmlWithLocalLinks)
1585 IPC_MESSAGE_HANDLER(FrameMsg_SerializeAsMHTML, OnSerializeAsMHTML) 1585 IPC_MESSAGE_HANDLER(FrameMsg_SerializeAsMHTML, OnSerializeAsMHTML)
1586 IPC_MESSAGE_HANDLER(FrameMsg_Find, OnFind) 1586 IPC_MESSAGE_HANDLER(FrameMsg_Find, OnFind)
1587 IPC_MESSAGE_HANDLER(FrameMsg_ClearActiveFindMatch, OnClearActiveFindMatch) 1587 IPC_MESSAGE_HANDLER(FrameMsg_ClearActiveFindMatch, OnClearActiveFindMatch)
1588 IPC_MESSAGE_HANDLER(FrameMsg_StopFinding, OnStopFinding) 1588 IPC_MESSAGE_HANDLER(FrameMsg_StopFinding, OnStopFinding)
1589 IPC_MESSAGE_HANDLER(FrameMsg_EnableViewSourceMode, OnEnableViewSourceMode) 1589 IPC_MESSAGE_HANDLER(FrameMsg_EnableViewSourceMode, OnEnableViewSourceMode)
1590 IPC_MESSAGE_HANDLER(FrameMsg_SuppressFurtherDialogs, 1590 IPC_MESSAGE_HANDLER(FrameMsg_SuppressFurtherDialogs,
1591 OnSuppressFurtherDialogs) 1591 OnSuppressFurtherDialogs)
1592 IPC_MESSAGE_HANDLER(FrameMsg_RunFileChooserResponse, OnFileChooserResponse) 1592 IPC_MESSAGE_HANDLER(FrameMsg_RunFileChooserResponse, OnFileChooserResponse)
1593 IPC_MESSAGE_HANDLER(FrameMsg_ClearFocusedElement, OnClearFocusedElement) 1593 IPC_MESSAGE_HANDLER(FrameMsg_ClearFocusedElement, OnClearFocusedElement)
1594 IPC_MESSAGE_HANDLER(FrameMsg_AbortNavigationRequest,
1595 OnAbortNavigationRequest)
1594 #if defined(OS_ANDROID) 1596 #if defined(OS_ANDROID)
1595 IPC_MESSAGE_HANDLER(FrameMsg_ActivateNearestFindResult, 1597 IPC_MESSAGE_HANDLER(FrameMsg_ActivateNearestFindResult,
1596 OnActivateNearestFindResult) 1598 OnActivateNearestFindResult)
1597 IPC_MESSAGE_HANDLER(FrameMsg_GetNearestFindResult, 1599 IPC_MESSAGE_HANDLER(FrameMsg_GetNearestFindResult,
1598 OnGetNearestFindResult) 1600 OnGetNearestFindResult)
1599 IPC_MESSAGE_HANDLER(FrameMsg_FindMatchRects, OnFindMatchRects) 1601 IPC_MESSAGE_HANDLER(FrameMsg_FindMatchRects, OnFindMatchRects)
1600 #endif 1602 #endif
1601 1603
1602 #if defined(USE_EXTERNAL_POPUP_MENU) 1604 #if defined(USE_EXTERNAL_POPUP_MENU)
1603 #if defined(OS_MACOSX) 1605 #if defined(OS_MACOSX)
(...skipping 1894 matching lines...) Expand 10 before | Expand all | Expand 10 after
3498 // local state here to fix https://crbug.com/671276. 3500 // local state here to fix https://crbug.com/671276.
3499 } 3501 }
3500 3502
3501 void RenderFrameImpl::didFailProvisionalLoad( 3503 void RenderFrameImpl::didFailProvisionalLoad(
3502 blink::WebLocalFrame* frame, 3504 blink::WebLocalFrame* frame,
3503 const blink::WebURLError& error, 3505 const blink::WebURLError& error,
3504 blink::WebHistoryCommitType commit_type) { 3506 blink::WebHistoryCommitType commit_type) {
3505 TRACE_EVENT1("navigation,benchmark,rail", 3507 TRACE_EVENT1("navigation,benchmark,rail",
3506 "RenderFrameImpl::didFailProvisionalLoad", "id", routing_id_); 3508 "RenderFrameImpl::didFailProvisionalLoad", "id", routing_id_);
3507 DCHECK_EQ(frame_, frame); 3509 DCHECK_EQ(frame_, frame);
3508 WebDataSource* ds = frame->provisionalDataSource();
3509 DCHECK(ds);
3510
3511 const WebURLRequest& failed_request = ds->getRequest();
3512
3513 // Notify the browser that we failed a provisional load with an error.
3514 // 3510 //
3515 // Note: It is important this notification occur before DidStopLoading so the 3511 // Note: It is important this notification occur before DidStopLoading so the
3516 // SSL manager can react to the provisional load failure before being 3512 // SSL manager can react to the provisional load failure before being
3517 // notified the load stopped. 3513 // notified the load stopped.
3518 // 3514 //
3519 for (auto& observer : render_view_->observers()) 3515 for (auto& observer : render_view_->observers())
3520 observer.DidFailProvisionalLoad(frame, error); 3516 observer.DidFailProvisionalLoad(frame, error);
3521 for (auto& observer : observers_) 3517 for (auto& observer : observers_)
3522 observer.DidFailProvisionalLoad(error); 3518 observer.DidFailProvisionalLoad(error);
3523 3519
3520 WebDataSource* ds = frame->provisionalDataSource();
3521 if (!ds)
3522 return;
3523
3524 const WebURLRequest& failed_request = ds->getRequest();
3525
3526 // Notify the browser that we failed a provisional load with an error.
3524 SendFailedProvisionalLoad(failed_request, error, frame); 3527 SendFailedProvisionalLoad(failed_request, error, frame);
3525 3528
3526 if (!ShouldDisplayErrorPageForFailedLoad(error.reason, error.unreachableURL)) 3529 if (!ShouldDisplayErrorPageForFailedLoad(error.reason, error.unreachableURL))
3527 return; 3530 return;
3528 3531
3529 // Make sure we never show errors in view source mode. 3532 // Make sure we never show errors in view source mode.
3530 frame->enableViewSourceMode(false); 3533 frame->enableViewSourceMode(false);
3531 3534
3532 DocumentState* document_state = DocumentState::FromDataSource(ds); 3535 DocumentState* document_state = DocumentState::FromDataSource(ds);
3533 NavigationStateImpl* navigation_state = 3536 NavigationStateImpl* navigation_state =
(...skipping 1682 matching lines...) Expand 10 before | Expand all | Expand 10 after
5216 // This corresponds to Blink's notion of a standard commit. 5219 // This corresponds to Blink's notion of a standard commit.
5217 // Also replace the current history entry if the browser asked for it 5220 // Also replace the current history entry if the browser asked for it
5218 // specifically. 5221 // specifically.
5219 // TODO(clamy): see if initial commits in subframes should be handled 5222 // TODO(clamy): see if initial commits in subframes should be handled
5220 // separately. 5223 // separately.
5221 bool replace = is_reload || common_params.url == GetLoadingUrl() || 5224 bool replace = is_reload || common_params.url == GetLoadingUrl() ||
5222 common_params.should_replace_current_entry; 5225 common_params.should_replace_current_entry;
5223 std::unique_ptr<HistoryEntry> history_entry; 5226 std::unique_ptr<HistoryEntry> history_entry;
5224 if (request_params.page_state.IsValid()) 5227 if (request_params.page_state.IsValid())
5225 history_entry = PageStateToHistoryEntry(request_params.page_state); 5228 history_entry = PageStateToHistoryEntry(request_params.page_state);
5229 didFailProvisionalLoad(frame_, error, blink::WebStandardCommit);
5226 LoadNavigationErrorPage(failed_request, error, replace, history_entry.get()); 5230 LoadNavigationErrorPage(failed_request, error, replace, history_entry.get());
5227 browser_side_navigation_pending_ = false; 5231 browser_side_navigation_pending_ = false;
5228 } 5232 }
5229 5233
5230 WebNavigationPolicy RenderFrameImpl::decidePolicyForNavigation( 5234 WebNavigationPolicy RenderFrameImpl::decidePolicyForNavigation(
5231 const NavigationPolicyInfo& info) { 5235 const NavigationPolicyInfo& info) {
5232 // A content initiated navigation may have originated from a link-click, 5236 // A content initiated navigation may have originated from a link-click,
5233 // script, drag-n-drop operation, etc. 5237 // script, drag-n-drop operation, etc.
5234 // info.extraData is only non-null if this is a redirect. Use the extraData 5238 // info.extraData is only non-null if this is a redirect. Use the extraData
5235 // initiation information for redirects, and check pending_navigation_params_ 5239 // initiation information for redirects, and check pending_navigation_params_
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after
5689 } 5693 }
5690 } 5694 }
5691 5695
5692 void RenderFrameImpl::OnClearFocusedElement() { 5696 void RenderFrameImpl::OnClearFocusedElement() {
5693 // TODO(ekaramad): Should we add a method to WebLocalFrame instead and avoid 5697 // TODO(ekaramad): Should we add a method to WebLocalFrame instead and avoid
5694 // calling this on the WebView? 5698 // calling this on the WebView?
5695 if (auto* webview = render_view_->GetWebView()) 5699 if (auto* webview = render_view_->GetWebView())
5696 webview->clearFocusedElement(); 5700 webview->clearFocusedElement();
5697 } 5701 }
5698 5702
5703 void RenderFrameImpl::OnAbortNavigationRequest(const GURL& url,
5704 int error_code) {
5705 // Send the provisional load failure.
5706 blink::WebURLError error = CreateWebURLError(url, false, error_code);
5707 didFailProvisionalLoad(frame_, error, blink::WebStandardCommit);
5708 }
5709
5699 #if defined(OS_ANDROID) 5710 #if defined(OS_ANDROID)
5700 void RenderFrameImpl::OnActivateNearestFindResult(int request_id, 5711 void RenderFrameImpl::OnActivateNearestFindResult(int request_id,
5701 float x, 5712 float x,
5702 float y) { 5713 float y) {
5703 WebRect selection_rect; 5714 WebRect selection_rect;
5704 int ordinal = 5715 int ordinal =
5705 frame_->selectNearestFindMatch(WebFloatPoint(x, y), &selection_rect); 5716 frame_->selectNearestFindMatch(WebFloatPoint(x, y), &selection_rect);
5706 if (ordinal == -1) { 5717 if (ordinal == -1) {
5707 // Something went wrong, so send a no-op reply (force the frame to report 5718 // Something went wrong, so send a no-op reply (force the frame to report
5708 // the current match count) in case the host is waiting for a response due 5719 // the current match count) in case the host is waiting for a response due
(...skipping 1105 matching lines...) Expand 10 before | Expand all | Expand 10 after
6814 // event target. Potentially a Pepper plugin will receive the event. 6825 // event target. Potentially a Pepper plugin will receive the event.
6815 // In order to tell whether a plugin gets the last mouse event and which it 6826 // In order to tell whether a plugin gets the last mouse event and which it
6816 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets 6827 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets
6817 // the event, it will notify us via DidReceiveMouseEvent() and set itself as 6828 // the event, it will notify us via DidReceiveMouseEvent() and set itself as
6818 // |pepper_last_mouse_event_target_|. 6829 // |pepper_last_mouse_event_target_|.
6819 pepper_last_mouse_event_target_ = nullptr; 6830 pepper_last_mouse_event_target_ = nullptr;
6820 #endif 6831 #endif
6821 } 6832 }
6822 6833
6823 } // namespace content 6834 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698