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

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

Issue 2309083002: PlzNavigate: Fix history navigation for error pages. (Closed)
Patch Set: . Created 4 years, 3 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 2257 matching lines...) Expand 10 before | Expand all | Expand 10 after
2268 if (file_chooser_completions_.size() == 1) { 2268 if (file_chooser_completions_.size() == 1) {
2269 // Actually show the browse dialog when this is the first request. 2269 // Actually show the browse dialog when this is the first request.
2270 Send(new FrameHostMsg_RunFileChooser(routing_id_, params)); 2270 Send(new FrameHostMsg_RunFileChooser(routing_id_, params));
2271 } 2271 }
2272 return true; 2272 return true;
2273 } 2273 }
2274 2274
2275 void RenderFrameImpl::LoadNavigationErrorPage( 2275 void RenderFrameImpl::LoadNavigationErrorPage(
2276 const WebURLRequest& failed_request, 2276 const WebURLRequest& failed_request,
2277 const WebURLError& error, 2277 const WebURLError& error,
2278 bool replace) { 2278 bool replace,
2279 HistoryEntry* entry) {
2279 std::string error_html; 2280 std::string error_html;
2280 GetContentClient()->renderer()->GetNavigationErrorStrings( 2281 GetContentClient()->renderer()->GetNavigationErrorStrings(
2281 this, failed_request, error, &error_html, nullptr); 2282 this, failed_request, error, &error_html, nullptr);
2282 2283
2283 frame_->loadHTMLString(error_html, 2284 blink::WebFrameLoadType frame_load_type =
2284 GURL(kUnreachableWebDataURL), 2285 entry ? blink::WebFrameLoadType::BackForward
2285 error.unreachableURL, 2286 : blink::WebFrameLoadType::Standard;
2286 replace); 2287 const blink::WebHistoryItem& history_item =
2288 entry ? entry->root() : blink::WebHistoryItem();
2289
2290 frame_->loadData(error_html, WebString::fromUTF8("text/html"),
2291 WebString::fromUTF8("UTF-8"), GURL(kUnreachableWebDataURL),
2292 error.unreachableURL, replace, frame_load_type, history_item,
2293 blink::WebHistoryDifferentDocumentLoad, false);
2287 } 2294 }
2288 2295
2289 void RenderFrameImpl::DidMeaningfulLayout( 2296 void RenderFrameImpl::DidMeaningfulLayout(
2290 blink::WebMeaningfulLayout layout_type) { 2297 blink::WebMeaningfulLayout layout_type) {
2291 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, 2298 FOR_EACH_OBSERVER(RenderFrameObserver, observers_,
2292 DidMeaningfulLayout(layout_type)); 2299 DidMeaningfulLayout(layout_type));
2293 } 2300 }
2294 2301
2295 void RenderFrameImpl::DidCommitCompositorFrame() { 2302 void RenderFrameImpl::DidCommitCompositorFrame() {
2296 if (BrowserPluginManager::Get()) 2303 if (BrowserPluginManager::Get())
(...skipping 994 matching lines...) Expand 10 before | Expand all | Expand 10 after
3291 // page load is regarded as the same browser initiated request. 3298 // page load is regarded as the same browser initiated request.
3292 if (!navigation_state->IsContentInitiated()) { 3299 if (!navigation_state->IsContentInitiated()) {
3293 pending_navigation_params_.reset(new NavigationParams( 3300 pending_navigation_params_.reset(new NavigationParams(
3294 navigation_state->common_params(), navigation_state->start_params(), 3301 navigation_state->common_params(), navigation_state->start_params(),
3295 navigation_state->request_params())); 3302 navigation_state->request_params()));
3296 pending_navigation_params_->request_params.request_time = 3303 pending_navigation_params_->request_params.request_time =
3297 document_state->request_time(); 3304 document_state->request_time();
3298 } 3305 }
3299 3306
3300 // Load an error page. 3307 // Load an error page.
3301 LoadNavigationErrorPage(failed_request, error, replace); 3308 LoadNavigationErrorPage(failed_request, error, replace, nullptr);
3302 } 3309 }
3303 3310
3304 void RenderFrameImpl::didCommitProvisionalLoad( 3311 void RenderFrameImpl::didCommitProvisionalLoad(
3305 blink::WebLocalFrame* frame, 3312 blink::WebLocalFrame* frame,
3306 const blink::WebHistoryItem& item, 3313 const blink::WebHistoryItem& item,
3307 blink::WebHistoryCommitType commit_type) { 3314 blink::WebHistoryCommitType commit_type) {
3308 TRACE_EVENT2("navigation,rail", "RenderFrameImpl::didCommitProvisionalLoad", 3315 TRACE_EVENT2("navigation,rail", "RenderFrameImpl::didCommitProvisionalLoad",
3309 "id", routing_id_, 3316 "id", routing_id_,
3310 "url", GetLoadingUrl().possibly_invalid_spec()); 3317 "url", GetLoadingUrl().possibly_invalid_spec());
3311 DCHECK_EQ(frame_, frame); 3318 DCHECK_EQ(frame_, frame);
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
3642 InternalDocumentStateData* internal_data = 3649 InternalDocumentStateData* internal_data =
3643 InternalDocumentStateData::FromDataSource(frame->dataSource()); 3650 InternalDocumentStateData::FromDataSource(frame->dataSource());
3644 int http_status_code = internal_data->http_status_code(); 3651 int http_status_code = internal_data->http_status_code();
3645 if (GetContentClient()->renderer()->HasErrorPage(http_status_code, 3652 if (GetContentClient()->renderer()->HasErrorPage(http_status_code,
3646 &error_domain)) { 3653 &error_domain)) {
3647 WebURLError error; 3654 WebURLError error;
3648 error.unreachableURL = frame->document().url(); 3655 error.unreachableURL = frame->document().url();
3649 error.domain = WebString::fromUTF8(error_domain); 3656 error.domain = WebString::fromUTF8(error_domain);
3650 error.reason = http_status_code; 3657 error.reason = http_status_code;
3651 // This call may run scripts, e.g. via the beforeunload event. 3658 // This call may run scripts, e.g. via the beforeunload event.
3652 LoadNavigationErrorPage(frame->dataSource()->request(), error, true); 3659 LoadNavigationErrorPage(frame->dataSource()->request(), error, true,
3660 nullptr);
3653 } 3661 }
3654 // Do not use |this| or |frame| here without checking |weak_self|. 3662 // Do not use |this| or |frame| here without checking |weak_self|.
3655 } 3663 }
3656 3664
3657 void RenderFrameImpl::didHandleOnloadEvents(blink::WebLocalFrame* frame) { 3665 void RenderFrameImpl::didHandleOnloadEvents(blink::WebLocalFrame* frame) {
3658 DCHECK_EQ(frame_, frame); 3666 DCHECK_EQ(frame_, frame);
3659 if (!frame->parent()) { 3667 if (!frame->parent()) {
3660 FrameMsg_UILoadMetricsReportType::Value report_type = 3668 FrameMsg_UILoadMetricsReportType::Value report_type =
3661 static_cast<FrameMsg_UILoadMetricsReportType::Value>( 3669 static_cast<FrameMsg_UILoadMetricsReportType::Value>(
3662 frame->dataSource()->request().inputPerfMetricReportPolicy()); 3670 frame->dataSource()->request().inputPerfMetricReportPolicy());
(...skipping 1226 matching lines...) Expand 10 before | Expand all | Expand 10 after
4889 frame_->enableViewSourceMode(false); 4897 frame_->enableViewSourceMode(false);
4890 4898
4891 // Replace the current history entry in reloads, and loads of the same url. 4899 // Replace the current history entry in reloads, and loads of the same url.
4892 // This corresponds to Blink's notion of a standard commit. 4900 // This corresponds to Blink's notion of a standard commit.
4893 // Also replace the current history entry if the browser asked for it 4901 // Also replace the current history entry if the browser asked for it
4894 // specifically. 4902 // specifically.
4895 // TODO(clamy): see if initial commits in subframes should be handled 4903 // TODO(clamy): see if initial commits in subframes should be handled
4896 // separately. 4904 // separately.
4897 bool replace = is_reload || common_params.url == GetLoadingUrl() || 4905 bool replace = is_reload || common_params.url == GetLoadingUrl() ||
4898 common_params.should_replace_current_entry; 4906 common_params.should_replace_current_entry;
4899 LoadNavigationErrorPage(failed_request, error, replace); 4907 std::unique_ptr<HistoryEntry> history_entry;
4908 if (request_params.page_state.IsValid())
4909 history_entry = PageStateToHistoryEntry(request_params.page_state);
4910 LoadNavigationErrorPage(failed_request, error, replace, history_entry.get());
4900 } 4911 }
4901 4912
4902 WebNavigationPolicy RenderFrameImpl::decidePolicyForNavigation( 4913 WebNavigationPolicy RenderFrameImpl::decidePolicyForNavigation(
4903 const NavigationPolicyInfo& info) { 4914 const NavigationPolicyInfo& info) {
4904 // A content initiated navigation may have originated from a link-click, 4915 // A content initiated navigation may have originated from a link-click,
4905 // script, drag-n-drop operation, etc. 4916 // script, drag-n-drop operation, etc.
4906 // info.extraData is only non-null if this is a redirect. Use the extraData 4917 // info.extraData is only non-null if this is a redirect. Use the extraData
4907 // initiation information for redirects, and check pending_navigation_params_ 4918 // initiation information for redirects, and check pending_navigation_params_
4908 // otherwise. 4919 // otherwise.
4909 bool is_content_initiated = 4920 bool is_content_initiated =
(...skipping 1438 matching lines...) Expand 10 before | Expand all | Expand 10 after
6348 // event target. Potentially a Pepper plugin will receive the event. 6359 // event target. Potentially a Pepper plugin will receive the event.
6349 // In order to tell whether a plugin gets the last mouse event and which it 6360 // In order to tell whether a plugin gets the last mouse event and which it
6350 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets 6361 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets
6351 // the event, it will notify us via DidReceiveMouseEvent() and set itself as 6362 // the event, it will notify us via DidReceiveMouseEvent() and set itself as
6352 // |pepper_last_mouse_event_target_|. 6363 // |pepper_last_mouse_event_target_|.
6353 pepper_last_mouse_event_target_ = nullptr; 6364 pepper_last_mouse_event_target_ = nullptr;
6354 #endif 6365 #endif
6355 } 6366 }
6356 6367
6357 } // namespace content 6368 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_frame_impl.h ('k') | testing/buildbot/filters/browser-side-navigation.linux.browser_tests.filter » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698