Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 | 9 |
| 10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
| (...skipping 1073 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1084 bool ignore_cache = (common_params.navigation_type == | 1084 bool ignore_cache = (common_params.navigation_type == |
| 1085 FrameMsg_Navigate_Type::RELOAD_IGNORING_CACHE); | 1085 FrameMsg_Navigate_Type::RELOAD_IGNORING_CACHE); |
| 1086 | 1086 |
| 1087 if (reload_original_url) | 1087 if (reload_original_url) |
| 1088 frame->reloadWithOverrideURL(common_params.url, true); | 1088 frame->reloadWithOverrideURL(common_params.url, true); |
| 1089 else | 1089 else |
| 1090 frame->reload(ignore_cache); | 1090 frame->reload(ignore_cache); |
| 1091 } else if (is_history_navigation) { | 1091 } else if (is_history_navigation) { |
| 1092 // We must know the page ID of the page we are navigating back to. | 1092 // We must know the page ID of the page we are navigating back to. |
| 1093 DCHECK_NE(history_params.page_id, -1); | 1093 DCHECK_NE(history_params.page_id, -1); |
| 1094 // We must know the nav entry ID of the page we are navigating back to, | |
| 1095 // which should be the case because history navigations are browser- | |
| 1096 // initiated. | |
| 1097 DCHECK_NE(0, history_params.nav_entry_id); | |
| 1094 scoped_ptr<HistoryEntry> entry = | 1098 scoped_ptr<HistoryEntry> entry = |
| 1095 PageStateToHistoryEntry(history_params.page_state); | 1099 PageStateToHistoryEntry(history_params.page_state); |
| 1096 if (entry) { | 1100 if (entry) { |
| 1097 // Ensure we didn't save the swapped out URL in UpdateState, since the | 1101 // Ensure we didn't save the swapped out URL in UpdateState, since the |
| 1098 // browser should never be telling us to navigate to swappedout://. | 1102 // browser should never be telling us to navigate to swappedout://. |
| 1099 CHECK(entry->root().urlString() != WebString::fromUTF8(kSwappedOutURL)); | 1103 CHECK(entry->root().urlString() != WebString::fromUTF8(kSwappedOutURL)); |
| 1100 render_view_->history_controller()->GoToEntry(entry.Pass(), cache_policy); | 1104 render_view_->history_controller()->GoToEntry(entry.Pass(), cache_policy); |
| 1101 } | 1105 } |
| 1102 } else if (!common_params.base_url_for_data_url.is_empty()) { | 1106 } else if (!common_params.base_url_for_data_url.is_empty()) { |
| 1103 LoadDataURL(common_params, frame); | 1107 LoadDataURL(common_params, frame); |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 1128 data = reinterpret_cast<const char*>( | 1132 data = reinterpret_cast<const char*>( |
| 1129 &start_params.browser_initiated_post_data.front()); | 1133 &start_params.browser_initiated_post_data.front()); |
| 1130 } | 1134 } |
| 1131 http_body.appendData( | 1135 http_body.appendData( |
| 1132 WebData(data, start_params.browser_initiated_post_data.size())); | 1136 WebData(data, start_params.browser_initiated_post_data.size())); |
| 1133 request.setHTTPBody(http_body); | 1137 request.setHTTPBody(http_body); |
| 1134 } | 1138 } |
| 1135 | 1139 |
| 1136 // A session history navigation should have been accompanied by state. | 1140 // A session history navigation should have been accompanied by state. |
| 1137 CHECK_EQ(history_params.page_id, -1); | 1141 CHECK_EQ(history_params.page_id, -1); |
| 1142 // FYIREMOVEME(avi): Page id being -1 will happen with browser-initiated new | |
| 1143 // (non-history) navigations, and that's the test here. Nav entry unique | |
| 1144 // ids, however, are always provided with browser-initiated navigations, | |
| 1145 // history or new, so this test isn't valid for nav entry unique ids. | |
| 1138 | 1146 |
| 1139 // Record this before starting the load, we need a lower bound of this time | 1147 // Record this before starting the load, we need a lower bound of this time |
| 1140 // to sanitize the navigationStart override set below. | 1148 // to sanitize the navigationStart override set below. |
| 1141 base::TimeTicks renderer_navigation_start = base::TimeTicks::Now(); | 1149 base::TimeTicks renderer_navigation_start = base::TimeTicks::Now(); |
| 1142 frame->loadRequest(request); | 1150 frame->loadRequest(request); |
| 1143 | 1151 |
| 1144 UpdateFrameNavigationTiming(frame, commit_params.browser_navigation_start, | 1152 UpdateFrameNavigationTiming(frame, commit_params.browser_navigation_start, |
| 1145 renderer_navigation_start); | 1153 renderer_navigation_start); |
| 1146 } | 1154 } |
| 1147 | 1155 |
| (...skipping 1281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2429 // If this is a failed back/forward/reload navigation, then we need to do a | 2437 // If this is a failed back/forward/reload navigation, then we need to do a |
| 2430 // 'replace' load. This is necessary to avoid messing up session history. | 2438 // 'replace' load. This is necessary to avoid messing up session history. |
| 2431 // Otherwise, we do a normal load, which simulates a 'go' navigation as far | 2439 // Otherwise, we do a normal load, which simulates a 'go' navigation as far |
| 2432 // as session history is concerned. | 2440 // as session history is concerned. |
| 2433 // | 2441 // |
| 2434 // AUTO_SUBFRAME loads should always be treated as loads that do not advance | 2442 // AUTO_SUBFRAME loads should always be treated as loads that do not advance |
| 2435 // the page id. | 2443 // the page id. |
| 2436 // | 2444 // |
| 2437 // TODO(davidben): This should also take the failed navigation's replacement | 2445 // TODO(davidben): This should also take the failed navigation's replacement |
| 2438 // state into account, if a location.replace() failed. | 2446 // state into account, if a location.replace() failed. |
| 2447 ui::PageTransition transition = navigation_state->transition_type(); | |
| 2439 bool replace = | 2448 bool replace = |
| 2440 navigation_state->pending_page_id() != -1 || | 2449 navigation_state->pending_page_id() != -1 || |
| 2441 ui::PageTransitionCoreTypeIs(navigation_state->transition_type(), | 2450 ui::PageTransitionCoreTypeIs(transition, |
| 2442 ui::PAGE_TRANSITION_AUTO_SUBFRAME); | 2451 ui::PAGE_TRANSITION_AUTO_SUBFRAME); |
| 2452 bool replace2 = | |
| 2453 ui::PageTransitionCoreTypeIs(transition, ui::PAGE_TRANSITION_RELOAD) || | |
| 2454 transition & ui::PAGE_TRANSITION_FORWARD_BACK || | |
| 2455 ui::PageTransitionCoreTypeIs(transition, | |
| 2456 ui::PAGE_TRANSITION_AUTO_SUBFRAME); | |
| 2457 DCHECK_EQ(replace, replace2); | |
| 2443 | 2458 |
| 2444 // If we failed on a browser initiated request, then make sure that our error | 2459 // If we failed on a browser initiated request, then make sure that our error |
| 2445 // page load is regarded as the same browser initiated request. | 2460 // page load is regarded as the same browser initiated request. |
| 2446 if (!navigation_state->is_content_initiated()) { | 2461 if (!navigation_state->is_content_initiated()) { |
| 2447 render_view_->pending_navigation_params_.reset(new NavigationParams( | 2462 render_view_->pending_navigation_params_.reset(new NavigationParams( |
| 2448 CommonNavigationParams( | 2463 CommonNavigationParams( |
| 2449 error.unreachableURL, Referrer(), | 2464 error.unreachableURL, Referrer(), |
| 2450 navigation_state->transition_type(), FrameMsg_Navigate_Type::NORMAL, | 2465 navigation_state->transition_type(), FrameMsg_Navigate_Type::NORMAL, |
| 2451 true, base::TimeTicks(), | 2466 true, base::TimeTicks(), |
| 2452 FrameMsg_UILoadMetricsReportType::NO_REPORT, GURL(), GURL()), | 2467 FrameMsg_UILoadMetricsReportType::NO_REPORT, GURL(), GURL()), |
| 2453 StartNavigationParams(false, std::string(), | 2468 StartNavigationParams(false, std::string(), |
| 2454 std::vector<unsigned char>(), replace, -1, -1), | 2469 std::vector<unsigned char>(), replace, -1, -1), |
| 2455 CommitNavigationParams(false, base::TimeTicks(), std::vector<GURL>(), | 2470 CommitNavigationParams(false, base::TimeTicks(), std::vector<GURL>(), |
| 2456 false, std::string(), | 2471 false, std::string(), |
| 2457 document_state->request_time()), | 2472 document_state->request_time()), |
| 2458 HistoryNavigationParams( | 2473 HistoryNavigationParams( |
| 2459 PageState(), navigation_state->pending_page_id(), | 2474 PageState(), navigation_state->pending_page_id(), |
| 2475 navigation_state->pending_nav_entry_id(), | |
| 2460 navigation_state->pending_history_list_offset(), -1, 0, | 2476 navigation_state->pending_history_list_offset(), -1, 0, |
| 2461 navigation_state->history_list_was_cleared()))); | 2477 navigation_state->history_list_was_cleared()))); |
| 2462 } | 2478 } |
| 2463 | 2479 |
| 2464 // Load an error page. | 2480 // Load an error page. |
| 2465 LoadNavigationErrorPage(failed_request, error, replace); | 2481 LoadNavigationErrorPage(failed_request, error, replace); |
| 2466 } | 2482 } |
| 2467 | 2483 |
| 2468 void RenderFrameImpl::didCommitProvisionalLoad( | 2484 void RenderFrameImpl::didCommitProvisionalLoad( |
| 2469 blink::WebLocalFrame* frame, | 2485 blink::WebLocalFrame* frame, |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 2498 | 2514 |
| 2499 if (document_state->commit_load_time().is_null()) | 2515 if (document_state->commit_load_time().is_null()) |
| 2500 document_state->set_commit_load_time(Time::Now()); | 2516 document_state->set_commit_load_time(Time::Now()); |
| 2501 | 2517 |
| 2502 if (internal_data->must_reset_scroll_and_scale_state()) { | 2518 if (internal_data->must_reset_scroll_and_scale_state()) { |
| 2503 render_view_->webview()->resetScrollAndScaleState(); | 2519 render_view_->webview()->resetScrollAndScaleState(); |
| 2504 internal_data->set_must_reset_scroll_and_scale_state(false); | 2520 internal_data->set_must_reset_scroll_and_scale_state(false); |
| 2505 } | 2521 } |
| 2506 internal_data->set_use_error_page(false); | 2522 internal_data->set_use_error_page(false); |
| 2507 | 2523 |
| 2524 bool successful_history_nav = false; | |
| 2508 bool is_new_navigation = commit_type == blink::WebStandardCommit; | 2525 bool is_new_navigation = commit_type == blink::WebStandardCommit; |
| 2509 if (is_new_navigation) { | 2526 if (is_new_navigation) { |
| 2510 // We bump our Page ID to correspond with the new session history entry. | 2527 // We bump our Page ID to correspond with the new session history entry. |
| 2511 render_view_->page_id_ = render_view_->next_page_id_++; | 2528 render_view_->page_id_ = render_view_->next_page_id_++; |
| 2512 | 2529 |
| 2513 // Don't update history list values for kSwappedOutURL, since | 2530 // Don't update history list values for kSwappedOutURL, since |
| 2514 // we don't want to forget the entry that was there, and since we will | 2531 // we don't want to forget the entry that was there, and since we will |
| 2515 // never come back to kSwappedOutURL. Note that we have to call | 2532 // never come back to kSwappedOutURL. Note that we have to call |
| 2516 // UpdateSessionHistory and update page_id_ even in this case, so that | 2533 // UpdateSessionHistory and update page_id_ even in this case, so that |
| 2517 // the current entry gets a state update and so that we don't send a | 2534 // the current entry gets a state update and so that we don't send a |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 2535 // history, the first committed frame suffices. We keep track of whether | 2552 // history, the first committed frame suffices. We keep track of whether |
| 2536 // we've seen this commit before so that only capture session history once | 2553 // we've seen this commit before so that only capture session history once |
| 2537 // per navigation. | 2554 // per navigation. |
| 2538 // | 2555 // |
| 2539 // Note that we need to check if the page ID changed. In the case of a | 2556 // Note that we need to check if the page ID changed. In the case of a |
| 2540 // reload, the page ID doesn't change, and UpdateSessionHistory gets the | 2557 // reload, the page ID doesn't change, and UpdateSessionHistory gets the |
| 2541 // previous URL and the current page ID, which would be wrong. | 2558 // previous URL and the current page ID, which would be wrong. |
| 2542 if (navigation_state->pending_page_id() != -1 && | 2559 if (navigation_state->pending_page_id() != -1 && |
| 2543 navigation_state->pending_page_id() != render_view_->page_id_ && | 2560 navigation_state->pending_page_id() != render_view_->page_id_ && |
| 2544 !navigation_state->request_committed()) { | 2561 !navigation_state->request_committed()) { |
| 2562 successful_history_nav = true; | |
|
Charlie Reis
2015/03/12 18:28:17
nit: Put below the following comment.
Avi (use Gerrit)
2015/03/12 19:21:18
Done.
| |
| 2545 // This is a successful session history navigation! | 2563 // This is a successful session history navigation! |
| 2546 render_view_->page_id_ = navigation_state->pending_page_id(); | 2564 render_view_->page_id_ = navigation_state->pending_page_id(); |
| 2547 | 2565 |
| 2548 render_view_->history_list_offset_ = | 2566 render_view_->history_list_offset_ = |
| 2549 navigation_state->pending_history_list_offset(); | 2567 navigation_state->pending_history_list_offset(); |
| 2550 } | 2568 } |
| 2551 } | 2569 } |
| 2552 | 2570 |
| 2571 if (commit_type == blink::WebBackForwardCommit) { | |
| 2572 // Checking the commit type is planned to be the replacement for the if() | |
| 2573 // block containing the comment "This is a successful session history | |
| 2574 // navigation!" Make sure that it fires correspondingly. | |
| 2575 DCHECK(successful_history_nav); | |
| 2576 } | |
| 2577 | |
| 2553 bool sent = Send( | 2578 bool sent = Send( |
| 2554 new FrameHostMsg_DidAssignPageId(routing_id_, render_view_->page_id_)); | 2579 new FrameHostMsg_DidAssignPageId(routing_id_, render_view_->page_id_)); |
| 2555 CHECK(sent); // http://crbug.com/407376 | 2580 CHECK(sent); // http://crbug.com/407376 |
| 2556 | 2581 |
| 2557 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers_, | 2582 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers_, |
| 2558 DidCommitProvisionalLoad(frame, is_new_navigation)); | 2583 DidCommitProvisionalLoad(frame, is_new_navigation)); |
| 2559 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, | 2584 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, |
| 2560 DidCommitProvisionalLoad( | 2585 DidCommitProvisionalLoad( |
| 2561 is_new_navigation, | 2586 is_new_navigation, |
| 2562 navigation_state->was_within_same_page())); | 2587 navigation_state->was_within_same_page())); |
| (...skipping 1126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3689 | 3714 |
| 3690 DocumentState* document_state = DocumentState::FromDataSource(ds); | 3715 DocumentState* document_state = DocumentState::FromDataSource(ds); |
| 3691 NavigationState* navigation_state = document_state->navigation_state(); | 3716 NavigationState* navigation_state = document_state->navigation_state(); |
| 3692 InternalDocumentStateData* internal_data = | 3717 InternalDocumentStateData* internal_data = |
| 3693 InternalDocumentStateData::FromDocumentState(document_state); | 3718 InternalDocumentStateData::FromDocumentState(document_state); |
| 3694 | 3719 |
| 3695 FrameHostMsg_DidCommitProvisionalLoad_Params params; | 3720 FrameHostMsg_DidCommitProvisionalLoad_Params params; |
| 3696 params.http_status_code = response.httpStatusCode(); | 3721 params.http_status_code = response.httpStatusCode(); |
| 3697 params.url_is_unreachable = ds->hasUnreachableURL(); | 3722 params.url_is_unreachable = ds->hasUnreachableURL(); |
| 3698 params.is_post = false; | 3723 params.is_post = false; |
| 3724 params.commit_type = commit_type; | |
|
Charlie Reis
2015/03/12 18:28:17
I'd like to avoid exposing this directly if possib
Avi (use Gerrit)
2015/03/12 19:21:17
Let me hack on getting the tests to pass, but I'm
| |
| 3699 params.post_id = -1; | 3725 params.post_id = -1; |
| 3700 params.page_id = render_view_->page_id_; | 3726 params.page_id = render_view_->page_id_; |
| 3727 params.nav_entry_id = navigation_state->pending_nav_entry_id(); | |
| 3701 // We need to track the RenderViewHost routing_id because of downstream | 3728 // We need to track the RenderViewHost routing_id because of downstream |
| 3702 // dependencies (crbug.com/392171 DownloadRequestHandle, SaveFileManager, | 3729 // dependencies (crbug.com/392171 DownloadRequestHandle, SaveFileManager, |
| 3703 // ResourceDispatcherHostImpl, MediaStreamUIProxy, | 3730 // ResourceDispatcherHostImpl, MediaStreamUIProxy, |
| 3704 // SpeechRecognitionDispatcherHost and possibly others). They look up the view | 3731 // SpeechRecognitionDispatcherHost and possibly others). They look up the view |
| 3705 // based on the ID stored in the resource requests. Once those dependencies | 3732 // based on the ID stored in the resource requests. Once those dependencies |
| 3706 // are unwound or moved to RenderFrameHost (crbug.com/304341) we can move the | 3733 // are unwound or moved to RenderFrameHost (crbug.com/304341) we can move the |
| 3707 // client to be based on the routing_id of the RenderFrameHost. | 3734 // client to be based on the routing_id of the RenderFrameHost. |
| 3708 params.render_view_routing_id = render_view_->routing_id(); | 3735 params.render_view_routing_id = render_view_->routing_id(); |
| 3709 params.socket_address.set_host(response.remoteIPAddress().utf8()); | 3736 params.socket_address.set_host(response.remoteIPAddress().utf8()); |
| 3710 params.socket_address.set_port(response.remotePort()); | 3737 params.socket_address.set_port(response.remotePort()); |
| (...skipping 804 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4515 | 4542 |
| 4516 #if defined(ENABLE_BROWSER_CDMS) | 4543 #if defined(ENABLE_BROWSER_CDMS) |
| 4517 RendererCdmManager* RenderFrameImpl::GetCdmManager() { | 4544 RendererCdmManager* RenderFrameImpl::GetCdmManager() { |
| 4518 if (!cdm_manager_) | 4545 if (!cdm_manager_) |
| 4519 cdm_manager_ = new RendererCdmManager(this); | 4546 cdm_manager_ = new RendererCdmManager(this); |
| 4520 return cdm_manager_; | 4547 return cdm_manager_; |
| 4521 } | 4548 } |
| 4522 #endif // defined(ENABLE_BROWSER_CDMS) | 4549 #endif // defined(ENABLE_BROWSER_CDMS) |
| 4523 | 4550 |
| 4524 } // namespace content | 4551 } // namespace content |
| OLD | NEW |