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

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

Issue 1001043002: Refactor NavigationState to use NavigationParams (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments Created 5 years, 9 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
« no previous file with comments | « content/renderer/navigation_state_impl.cc ('k') | content/renderer/render_view_browsertest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 #include "content/renderer/media/crypto/render_cdm_factory.h" 77 #include "content/renderer/media/crypto/render_cdm_factory.h"
78 #include "content/renderer/media/media_permission_dispatcher.h" 78 #include "content/renderer/media/media_permission_dispatcher.h"
79 #include "content/renderer/media/media_stream_dispatcher.h" 79 #include "content/renderer/media/media_stream_dispatcher.h"
80 #include "content/renderer/media/media_stream_renderer_factory.h" 80 #include "content/renderer/media/media_stream_renderer_factory.h"
81 #include "content/renderer/media/midi_dispatcher.h" 81 #include "content/renderer/media/midi_dispatcher.h"
82 #include "content/renderer/media/render_media_log.h" 82 #include "content/renderer/media/render_media_log.h"
83 #include "content/renderer/media/user_media_client_impl.h" 83 #include "content/renderer/media/user_media_client_impl.h"
84 #include "content/renderer/media/webmediaplayer_ms.h" 84 #include "content/renderer/media/webmediaplayer_ms.h"
85 #include "content/renderer/memory_benchmarking_extension.h" 85 #include "content/renderer/memory_benchmarking_extension.h"
86 #include "content/renderer/mojo/service_registry_js_wrapper.h" 86 #include "content/renderer/mojo/service_registry_js_wrapper.h"
87 #include "content/renderer/navigation_state_impl.h"
87 #include "content/renderer/notification_permission_dispatcher.h" 88 #include "content/renderer/notification_permission_dispatcher.h"
88 #include "content/renderer/npapi/plugin_channel_host.h" 89 #include "content/renderer/npapi/plugin_channel_host.h"
89 #include "content/renderer/pepper/plugin_instance_throttler_impl.h" 90 #include "content/renderer/pepper/plugin_instance_throttler_impl.h"
90 #include "content/renderer/presentation/presentation_dispatcher.h" 91 #include "content/renderer/presentation/presentation_dispatcher.h"
91 #include "content/renderer/push_messaging/push_messaging_dispatcher.h" 92 #include "content/renderer/push_messaging/push_messaging_dispatcher.h"
92 #include "content/renderer/render_frame_proxy.h" 93 #include "content/renderer/render_frame_proxy.h"
93 #include "content/renderer/render_process.h" 94 #include "content/renderer/render_process.h"
94 #include "content/renderer/render_thread_impl.h" 95 #include "content/renderer/render_thread_impl.h"
95 #include "content/renderer/render_view_impl.h" 96 #include "content/renderer/render_view_impl.h"
96 #include "content/renderer/render_widget_fullscreen_pepper.h" 97 #include "content/renderer/render_widget_fullscreen_pepper.h"
(...skipping 1938 matching lines...) Expand 10 before | Expand all | Expand 10 after
2035 } 2036 }
2036 2037
2037 void RenderFrameImpl::didAccessInitialDocument(blink::WebLocalFrame* frame) { 2038 void RenderFrameImpl::didAccessInitialDocument(blink::WebLocalFrame* frame) {
2038 DCHECK(!frame_ || frame_ == frame); 2039 DCHECK(!frame_ || frame_ == frame);
2039 // If the request hasn't yet committed, notify the browser process that it is 2040 // If the request hasn't yet committed, notify the browser process that it is
2040 // no longer safe to show the pending URL of the main frame, since a URL spoof 2041 // no longer safe to show the pending URL of the main frame, since a URL spoof
2041 // is now possible. (If the request has committed, the browser already knows.) 2042 // is now possible. (If the request has committed, the browser already knows.)
2042 if (!frame->parent()) { 2043 if (!frame->parent()) {
2043 DocumentState* document_state = 2044 DocumentState* document_state =
2044 DocumentState::FromDataSource(frame->dataSource()); 2045 DocumentState::FromDataSource(frame->dataSource());
2045 NavigationState* navigation_state = document_state->navigation_state(); 2046 NavigationStateImpl* navigation_state =
2047 static_cast<NavigationStateImpl*>(document_state->navigation_state());
2046 2048
2047 if (!navigation_state->request_committed()) { 2049 if (!navigation_state->request_committed()) {
2048 Send(new FrameHostMsg_DidAccessInitialDocument(routing_id_)); 2050 Send(new FrameHostMsg_DidAccessInitialDocument(routing_id_));
2049 } 2051 }
2050 } 2052 }
2051 } 2053 }
2052 2054
2053 blink::WebFrame* RenderFrameImpl::createChildFrame( 2055 blink::WebFrame* RenderFrameImpl::createChildFrame(
2054 blink::WebLocalFrame* parent, 2056 blink::WebLocalFrame* parent,
2055 const blink::WebString& name, 2057 const blink::WebString& name,
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
2277 DCHECK(!frame_ || frame_ == frame); 2279 DCHECK(!frame_ || frame_ == frame);
2278 2280
2279 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, WillSendSubmitEvent(form)); 2281 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, WillSendSubmitEvent(form));
2280 } 2282 }
2281 2283
2282 void RenderFrameImpl::willSubmitForm(blink::WebLocalFrame* frame, 2284 void RenderFrameImpl::willSubmitForm(blink::WebLocalFrame* frame,
2283 const blink::WebFormElement& form) { 2285 const blink::WebFormElement& form) {
2284 DCHECK(!frame_ || frame_ == frame); 2286 DCHECK(!frame_ || frame_ == frame);
2285 DocumentState* document_state = 2287 DocumentState* document_state =
2286 DocumentState::FromDataSource(frame->provisionalDataSource()); 2288 DocumentState::FromDataSource(frame->provisionalDataSource());
2287 NavigationState* navigation_state = document_state->navigation_state(); 2289 NavigationStateImpl* navigation_state =
2290 static_cast<NavigationStateImpl*>(document_state->navigation_state());
2288 InternalDocumentStateData* internal_data = 2291 InternalDocumentStateData* internal_data =
2289 InternalDocumentStateData::FromDocumentState(document_state); 2292 InternalDocumentStateData::FromDocumentState(document_state);
2290 2293
2291 if (ui::PageTransitionCoreTypeIs(navigation_state->transition_type(), 2294 if (ui::PageTransitionCoreTypeIs(navigation_state->GetTransitionType(),
2292 ui::PAGE_TRANSITION_LINK)) { 2295 ui::PAGE_TRANSITION_LINK)) {
2293 navigation_state->set_transition_type(ui::PAGE_TRANSITION_FORM_SUBMIT); 2296 navigation_state->set_transition_type(ui::PAGE_TRANSITION_FORM_SUBMIT);
2294 } 2297 }
2295 2298
2296 // Save these to be processed when the ensuing navigation is committed. 2299 // Save these to be processed when the ensuing navigation is committed.
2297 WebSearchableFormData web_searchable_form_data(form); 2300 WebSearchableFormData web_searchable_form_data(form);
2298 internal_data->set_searchable_form_url(web_searchable_form_data.url()); 2301 internal_data->set_searchable_form_url(web_searchable_form_data.url());
2299 internal_data->set_searchable_form_encoding( 2302 internal_data->set_searchable_form_encoding(
2300 web_searchable_form_data.encoding().utf8()); 2303 web_searchable_form_data.encoding().utf8());
2301 2304
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
2359 2362
2360 bool is_top_most = !frame->parent(); 2363 bool is_top_most = !frame->parent();
2361 if (is_top_most) { 2364 if (is_top_most) {
2362 render_view_->set_navigation_gesture( 2365 render_view_->set_navigation_gesture(
2363 WebUserGestureIndicator::isProcessingUserGesture() ? 2366 WebUserGestureIndicator::isProcessingUserGesture() ?
2364 NavigationGestureUser : NavigationGestureAuto); 2367 NavigationGestureUser : NavigationGestureAuto);
2365 } else if (ds->replacesCurrentHistoryItem()) { 2368 } else if (ds->replacesCurrentHistoryItem()) {
2366 // Subframe navigations that don't add session history items must be 2369 // Subframe navigations that don't add session history items must be
2367 // marked with AUTO_SUBFRAME. See also didFailProvisionalLoad for how we 2370 // marked with AUTO_SUBFRAME. See also didFailProvisionalLoad for how we
2368 // handle loading of error pages. 2371 // handle loading of error pages.
2369 document_state->navigation_state()->set_transition_type( 2372 static_cast<NavigationStateImpl*>(document_state->navigation_state())
2370 ui::PAGE_TRANSITION_AUTO_SUBFRAME); 2373 ->set_transition_type(ui::PAGE_TRANSITION_AUTO_SUBFRAME);
2371 } 2374 }
2372 2375
2373 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(), 2376 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(),
2374 DidStartProvisionalLoad(frame)); 2377 DidStartProvisionalLoad(frame));
2375 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, DidStartProvisionalLoad()); 2378 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, DidStartProvisionalLoad());
2376 2379
2377 Send(new FrameHostMsg_DidStartProvisionalLoadForFrame( 2380 Send(new FrameHostMsg_DidStartProvisionalLoadForFrame(
2378 routing_id_, ds->request().url(), is_transition_navigation)); 2381 routing_id_, ds->request().url(), is_transition_navigation));
2379 } 2382 }
2380 2383
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
2442 2445
2443 if (RenderThreadImpl::current() && 2446 if (RenderThreadImpl::current() &&
2444 RenderThreadImpl::current()->layout_test_mode()) { 2447 RenderThreadImpl::current()->layout_test_mode()) {
2445 return; 2448 return;
2446 } 2449 }
2447 2450
2448 // Make sure we never show errors in view source mode. 2451 // Make sure we never show errors in view source mode.
2449 frame->enableViewSourceMode(false); 2452 frame->enableViewSourceMode(false);
2450 2453
2451 DocumentState* document_state = DocumentState::FromDataSource(ds); 2454 DocumentState* document_state = DocumentState::FromDataSource(ds);
2452 NavigationState* navigation_state = document_state->navigation_state(); 2455 NavigationStateImpl* navigation_state =
2456 static_cast<NavigationStateImpl*>(document_state->navigation_state());
2453 2457
2454 // If this is a failed back/forward/reload navigation, then we need to do a 2458 // If this is a failed back/forward/reload navigation, then we need to do a
2455 // 'replace' load. This is necessary to avoid messing up session history. 2459 // 'replace' load. This is necessary to avoid messing up session history.
2456 // Otherwise, we do a normal load, which simulates a 'go' navigation as far 2460 // Otherwise, we do a normal load, which simulates a 'go' navigation as far
2457 // as session history is concerned. 2461 // as session history is concerned.
2458 // 2462 //
2459 // AUTO_SUBFRAME loads should always be treated as loads that do not advance 2463 // AUTO_SUBFRAME loads should always be treated as loads that do not advance
2460 // the page id. 2464 // the page id.
2461 // 2465 //
2462 // TODO(davidben): This should also take the failed navigation's replacement 2466 // TODO(davidben): This should also take the failed navigation's replacement
2463 // state into account, if a location.replace() failed. 2467 // state into account, if a location.replace() failed.
2464 bool replace = 2468 bool replace =
2465 navigation_state->pending_page_id() != -1 || 2469 navigation_state->history_params().page_id != -1 ||
2466 ui::PageTransitionCoreTypeIs(navigation_state->transition_type(), 2470 ui::PageTransitionCoreTypeIs(navigation_state->GetTransitionType(),
2467 ui::PAGE_TRANSITION_AUTO_SUBFRAME); 2471 ui::PAGE_TRANSITION_AUTO_SUBFRAME);
2468 2472
2469 // If we failed on a browser initiated request, then make sure that our error 2473 // If we failed on a browser initiated request, then make sure that our error
2470 // page load is regarded as the same browser initiated request. 2474 // page load is regarded as the same browser initiated request.
2471 if (!navigation_state->is_content_initiated()) { 2475 if (!navigation_state->IsContentInitiated()) {
2472 render_view_->pending_navigation_params_.reset(new NavigationParams( 2476 render_view_->pending_navigation_params_.reset(new NavigationParams(
2473 CommonNavigationParams( 2477 navigation_state->common_params(), navigation_state->start_params(),
2474 error.unreachableURL, Referrer(),
2475 navigation_state->transition_type(), FrameMsg_Navigate_Type::NORMAL,
2476 true, base::TimeTicks(),
2477 FrameMsg_UILoadMetricsReportType::NO_REPORT, GURL(), GURL()),
2478 StartNavigationParams(false, std::string(),
2479 std::vector<unsigned char>(), replace, -1, -1),
2480 CommitNavigationParams(false, base::TimeTicks(), std::vector<GURL>(), 2478 CommitNavigationParams(false, base::TimeTicks(), std::vector<GURL>(),
2481 false, std::string(), 2479 false, std::string(),
2482 document_state->request_time()), 2480 document_state->request_time()),
2483 HistoryNavigationParams( 2481 navigation_state->history_params()));
2484 PageState(), navigation_state->pending_page_id(),
2485 navigation_state->pending_history_list_offset(), -1, 0,
2486 navigation_state->history_list_was_cleared())));
2487 } 2482 }
2488 2483
2489 // Load an error page. 2484 // Load an error page.
2490 LoadNavigationErrorPage(failed_request, error, replace); 2485 LoadNavigationErrorPage(failed_request, error, replace);
2491 } 2486 }
2492 2487
2493 void RenderFrameImpl::didCommitProvisionalLoad( 2488 void RenderFrameImpl::didCommitProvisionalLoad(
2494 blink::WebLocalFrame* frame, 2489 blink::WebLocalFrame* frame,
2495 const blink::WebHistoryItem& item, 2490 const blink::WebHistoryItem& item,
2496 blink::WebHistoryCommitType commit_type) { 2491 blink::WebHistoryCommitType commit_type) {
2497 TRACE_EVENT2("navigation", "RenderFrameImpl::didCommitProvisionalLoad", 2492 TRACE_EVENT2("navigation", "RenderFrameImpl::didCommitProvisionalLoad",
2498 "id", routing_id_, 2493 "id", routing_id_,
2499 "url", GetLoadingUrl().possibly_invalid_spec()); 2494 "url", GetLoadingUrl().possibly_invalid_spec());
2500 DCHECK(!frame_ || frame_ == frame); 2495 DCHECK(!frame_ || frame_ == frame);
2501 DocumentState* document_state = 2496 DocumentState* document_state =
2502 DocumentState::FromDataSource(frame->dataSource()); 2497 DocumentState::FromDataSource(frame->dataSource());
2503 NavigationState* navigation_state = document_state->navigation_state(); 2498 NavigationStateImpl* navigation_state =
2499 static_cast<NavigationStateImpl*>(document_state->navigation_state());
2504 2500
2505 if (proxy_routing_id_ != MSG_ROUTING_NONE) { 2501 if (proxy_routing_id_ != MSG_ROUTING_NONE) {
2506 RenderFrameProxy* proxy = 2502 RenderFrameProxy* proxy =
2507 RenderFrameProxy::FromRoutingID(proxy_routing_id_); 2503 RenderFrameProxy::FromRoutingID(proxy_routing_id_);
2508 CHECK(proxy); 2504 CHECK(proxy);
2509 proxy->web_frame()->swap(frame_); 2505 proxy->web_frame()->swap(frame_);
2510 proxy_routing_id_ = MSG_ROUTING_NONE; 2506 proxy_routing_id_ = MSG_ROUTING_NONE;
2511 } 2507 }
2512 2508
2513 // When we perform a new navigation, we need to update the last committed 2509 // When we perform a new navigation, we need to update the last committed
2514 // session history entry with state for the page we are leaving. Do this 2510 // session history entry with state for the page we are leaving. Do this
2515 // before updating the HistoryController state. 2511 // before updating the HistoryController state.
2516 render_view_->UpdateSessionHistory(frame); 2512 render_view_->UpdateSessionHistory(frame);
2517 2513
2518 render_view_->history_controller()->UpdateForCommit(this, item, commit_type, 2514 render_view_->history_controller()->UpdateForCommit(
2519 navigation_state->was_within_same_page()); 2515 this, item, commit_type, navigation_state->WasWithinSamePage());
2520 2516
2521 InternalDocumentStateData* internal_data = 2517 InternalDocumentStateData* internal_data =
2522 InternalDocumentStateData::FromDocumentState(document_state); 2518 InternalDocumentStateData::FromDocumentState(document_state);
2523 2519
2524 if (document_state->commit_load_time().is_null()) 2520 if (document_state->commit_load_time().is_null())
2525 document_state->set_commit_load_time(Time::Now()); 2521 document_state->set_commit_load_time(Time::Now());
2526 2522
2527 if (internal_data->must_reset_scroll_and_scale_state()) { 2523 if (internal_data->must_reset_scroll_and_scale_state()) {
2528 render_view_->webview()->resetScrollAndScaleState(); 2524 render_view_->webview()->resetScrollAndScaleState();
2529 internal_data->set_must_reset_scroll_and_scale_state(false); 2525 internal_data->set_must_reset_scroll_and_scale_state(false);
2530 } 2526 }
2531 internal_data->set_use_error_page(false); 2527 internal_data->set_use_error_page(false);
2532 2528
2533 bool is_new_navigation = commit_type == blink::WebStandardCommit; 2529 bool is_new_navigation = commit_type == blink::WebStandardCommit;
2534 if (is_new_navigation) { 2530 if (is_new_navigation) {
2535 // We bump our Page ID to correspond with the new session history entry. 2531 // We bump our Page ID to correspond with the new session history entry.
2536 render_view_->page_id_ = render_view_->next_page_id_++; 2532 render_view_->page_id_ = render_view_->next_page_id_++;
2537 2533
2538 // Don't update history list values for kSwappedOutURL, since 2534 // Don't update history list values for kSwappedOutURL, since
2539 // we don't want to forget the entry that was there, and since we will 2535 // we don't want to forget the entry that was there, and since we will
2540 // never come back to kSwappedOutURL. Note that we have to call 2536 // never come back to kSwappedOutURL. Note that we have to call
2541 // UpdateSessionHistory and update page_id_ even in this case, so that 2537 // UpdateSessionHistory and update page_id_ even in this case, so that
2542 // the current entry gets a state update and so that we don't send a 2538 // the current entry gets a state update and so that we don't send a
2543 // state update to the wrong entry when we swap back in. 2539 // state update to the wrong entry when we swap back in.
2544 DCHECK_IMPLIES(navigation_state->should_replace_current_entry(), 2540 DCHECK_IMPLIES(
2545 render_view_->history_list_length_ > 0); 2541 navigation_state->start_params().should_replace_current_entry,
2542 render_view_->history_list_length_ > 0);
2546 if (GetLoadingUrl() != GURL(kSwappedOutURL) && 2543 if (GetLoadingUrl() != GURL(kSwappedOutURL) &&
2547 !navigation_state->should_replace_current_entry()) { 2544 !navigation_state->start_params().should_replace_current_entry) {
2548 // Advance our offset in session history, applying the length limit. 2545 // Advance our offset in session history, applying the length limit.
2549 // There is now no forward history. 2546 // There is now no forward history.
2550 render_view_->history_list_offset_++; 2547 render_view_->history_list_offset_++;
2551 if (render_view_->history_list_offset_ >= kMaxSessionHistoryEntries) 2548 if (render_view_->history_list_offset_ >= kMaxSessionHistoryEntries)
2552 render_view_->history_list_offset_ = kMaxSessionHistoryEntries - 1; 2549 render_view_->history_list_offset_ = kMaxSessionHistoryEntries - 1;
2553 render_view_->history_list_length_ = 2550 render_view_->history_list_length_ =
2554 render_view_->history_list_offset_ + 1; 2551 render_view_->history_list_offset_ + 1;
2555 } 2552 }
2556 } else { 2553 } else {
2557 // Inspect the navigation_state on this frame to see if the navigation 2554 // Inspect the navigation_state on this frame to see if the navigation
2558 // corresponds to a session history navigation... Note: |frame| may or 2555 // corresponds to a session history navigation... Note: |frame| may or
2559 // may not be the toplevel frame, but for the case of capturing session 2556 // may not be the toplevel frame, but for the case of capturing session
2560 // history, the first committed frame suffices. We keep track of whether 2557 // history, the first committed frame suffices. We keep track of whether
2561 // we've seen this commit before so that only capture session history once 2558 // we've seen this commit before so that only capture session history once
2562 // per navigation. 2559 // per navigation.
2563 // 2560 //
2564 // Note that we need to check if the page ID changed. In the case of a 2561 // Note that we need to check if the page ID changed. In the case of a
2565 // reload, the page ID doesn't change, and UpdateSessionHistory gets the 2562 // reload, the page ID doesn't change, and UpdateSessionHistory gets the
2566 // previous URL and the current page ID, which would be wrong. 2563 // previous URL and the current page ID, which would be wrong.
2567 if (navigation_state->pending_page_id() != -1 && 2564 if (navigation_state->history_params().page_id != -1 &&
2568 navigation_state->pending_page_id() != render_view_->page_id_ && 2565 navigation_state->history_params().page_id != render_view_->page_id_ &&
2569 !navigation_state->request_committed()) { 2566 !navigation_state->request_committed()) {
2570 // This is a successful session history navigation! 2567 // This is a successful session history navigation!
2571 render_view_->page_id_ = navigation_state->pending_page_id(); 2568 render_view_->page_id_ = navigation_state->history_params().page_id;
2572 2569
2573 render_view_->history_list_offset_ = 2570 render_view_->history_list_offset_ =
2574 navigation_state->pending_history_list_offset(); 2571 navigation_state->history_params().pending_history_list_offset;
2575 } 2572 }
2576 } 2573 }
2577 2574
2578 bool sent = Send( 2575 bool sent = Send(
2579 new FrameHostMsg_DidAssignPageId(routing_id_, render_view_->page_id_)); 2576 new FrameHostMsg_DidAssignPageId(routing_id_, render_view_->page_id_));
2580 CHECK(sent); // http://crbug.com/407376 2577 CHECK(sent); // http://crbug.com/407376
2581 2578
2582 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers_, 2579 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers_,
2583 DidCommitProvisionalLoad(frame, is_new_navigation)); 2580 DidCommitProvisionalLoad(frame, is_new_navigation));
2584 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, 2581 FOR_EACH_OBSERVER(
2585 DidCommitProvisionalLoad( 2582 RenderFrameObserver, observers_,
2586 is_new_navigation, 2583 DidCommitProvisionalLoad(is_new_navigation,
2587 navigation_state->was_within_same_page())); 2584 navigation_state->WasWithinSamePage()));
2588 2585
2589 if (!frame->parent()) { // Only for top frames. 2586 if (!frame->parent()) { // Only for top frames.
2590 RenderThreadImpl* render_thread_impl = RenderThreadImpl::current(); 2587 RenderThreadImpl* render_thread_impl = RenderThreadImpl::current();
2591 if (render_thread_impl) { // Can be NULL in tests. 2588 if (render_thread_impl) { // Can be NULL in tests.
2592 render_thread_impl->histogram_customizer()-> 2589 render_thread_impl->histogram_customizer()->
2593 RenderViewNavigatedToHost(GURL(GetLoadingUrl()).host(), 2590 RenderViewNavigatedToHost(GURL(GetLoadingUrl()).host(),
2594 RenderViewImpl::GetRenderViewCount()); 2591 RenderViewImpl::GetRenderViewCount());
2595 } 2592 }
2596 } 2593 }
2597 2594
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
2791 // could end up having a non-null pending navigation params. We just need to 2788 // could end up having a non-null pending navigation params. We just need to
2792 // update the ExtraData on the datasource so that others who read the 2789 // update the ExtraData on the datasource so that others who read the
2793 // ExtraData will get the new NavigationState. Similarly, if we did not 2790 // ExtraData will get the new NavigationState. Similarly, if we did not
2794 // initiate this navigation, then we need to take care to reset any pre- 2791 // initiate this navigation, then we need to take care to reset any pre-
2795 // existing navigation state to a content-initiated navigation state. 2792 // existing navigation state to a content-initiated navigation state.
2796 // DidCreateDataSource conveniently takes care of this for us. 2793 // DidCreateDataSource conveniently takes care of this for us.
2797 didCreateDataSource(frame, frame->dataSource()); 2794 didCreateDataSource(frame, frame->dataSource());
2798 2795
2799 DocumentState* document_state = 2796 DocumentState* document_state =
2800 DocumentState::FromDataSource(frame->dataSource()); 2797 DocumentState::FromDataSource(frame->dataSource());
2801 NavigationState* new_state = document_state->navigation_state(); 2798 static_cast<NavigationStateImpl*>(document_state->navigation_state())
2802 new_state->set_was_within_same_page(true); 2799 ->set_was_within_same_page(true);
2803 2800
2804 didCommitProvisionalLoad(frame, item, commit_type); 2801 didCommitProvisionalLoad(frame, item, commit_type);
2805 } 2802 }
2806 2803
2807 void RenderFrameImpl::didUpdateCurrentHistoryItem(blink::WebLocalFrame* frame) { 2804 void RenderFrameImpl::didUpdateCurrentHistoryItem(blink::WebLocalFrame* frame) {
2808 DCHECK(!frame_ || frame_ == frame); 2805 DCHECK(!frame_ || frame_ == frame);
2809 // TODO(nasko): Move implementation here. Needed methods: 2806 // TODO(nasko): Move implementation here. Needed methods:
2810 // * StartNavStateSyncTimerIfNecessary 2807 // * StartNavStateSyncTimerIfNecessary
2811 render_view_->didUpdateCurrentHistoryItem(frame); 2808 render_view_->didUpdateCurrentHistoryItem(frame);
2812 } 2809 }
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
3008 top_frame = frame; 3005 top_frame = frame;
3009 WebDataSource* provisional_data_source = top_frame->provisionalDataSource(); 3006 WebDataSource* provisional_data_source = top_frame->provisionalDataSource();
3010 WebDataSource* top_data_source = top_frame->dataSource(); 3007 WebDataSource* top_data_source = top_frame->dataSource();
3011 WebDataSource* data_source = 3008 WebDataSource* data_source =
3012 provisional_data_source ? provisional_data_source : top_data_source; 3009 provisional_data_source ? provisional_data_source : top_data_source;
3013 3010
3014 DocumentState* document_state = DocumentState::FromDataSource(data_source); 3011 DocumentState* document_state = DocumentState::FromDataSource(data_source);
3015 DCHECK(document_state); 3012 DCHECK(document_state);
3016 InternalDocumentStateData* internal_data = 3013 InternalDocumentStateData* internal_data =
3017 InternalDocumentStateData::FromDocumentState(document_state); 3014 InternalDocumentStateData::FromDocumentState(document_state);
3018 NavigationState* navigation_state = document_state->navigation_state(); 3015 NavigationStateImpl* navigation_state =
3019 ui::PageTransition transition_type = navigation_state->transition_type(); 3016 static_cast<NavigationStateImpl*>(document_state->navigation_state());
3017 ui::PageTransition transition_type = navigation_state->GetTransitionType();
3020 WebDataSource* frame_ds = frame->provisionalDataSource(); 3018 WebDataSource* frame_ds = frame->provisionalDataSource();
3021 if (frame_ds && frame_ds->isClientRedirect()) { 3019 if (frame_ds && frame_ds->isClientRedirect()) {
3022 transition_type = ui::PageTransitionFromInt( 3020 transition_type = ui::PageTransitionFromInt(
3023 transition_type | ui::PAGE_TRANSITION_CLIENT_REDIRECT); 3021 transition_type | ui::PAGE_TRANSITION_CLIENT_REDIRECT);
3024 } 3022 }
3025 3023
3026 GURL request_url(request.url()); 3024 GURL request_url(request.url());
3027 GURL new_url; 3025 GURL new_url;
3028 if (GetContentClient()->renderer()->WillSendRequest( 3026 if (GetContentClient()->renderer()->WillSendRequest(
3029 frame, 3027 frame,
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
3078 } 3076 }
3079 3077
3080 // Add an empty HTTP origin header for non GET methods if none is currently 3078 // Add an empty HTTP origin header for non GET methods if none is currently
3081 // present. 3079 // present.
3082 request.addHTTPOriginIfNeeded(WebString()); 3080 request.addHTTPOriginIfNeeded(WebString());
3083 3081
3084 // Attach |should_replace_current_entry| state to requests so that, should 3082 // Attach |should_replace_current_entry| state to requests so that, should
3085 // this navigation later require a request transfer, all state is preserved 3083 // this navigation later require a request transfer, all state is preserved
3086 // when it is re-created in the new process. 3084 // when it is re-created in the new process.
3087 bool should_replace_current_entry = false; 3085 bool should_replace_current_entry = false;
3088 if (navigation_state->is_content_initiated()) { 3086 if (navigation_state->IsContentInitiated()) {
3089 should_replace_current_entry = data_source->replacesCurrentHistoryItem(); 3087 should_replace_current_entry = data_source->replacesCurrentHistoryItem();
3090 } else { 3088 } else {
3091 // If the navigation is browser-initiated, the NavigationState contains the 3089 // If the navigation is browser-initiated, the NavigationState contains the
3092 // correct value instead of the WebDataSource. 3090 // correct value instead of the WebDataSource.
3093 // 3091 //
3094 // TODO(davidben): Avoid this awkward duplication of state. See comment on 3092 // TODO(davidben): Avoid this awkward duplication of state. See comment on
3095 // NavigationState::should_replace_current_entry(). 3093 // NavigationState::should_replace_current_entry().
3096 should_replace_current_entry = 3094 should_replace_current_entry =
3097 navigation_state->should_replace_current_entry(); 3095 navigation_state->start_params().should_replace_current_entry;
3098 } 3096 }
3099 3097
3100 int provider_id = kInvalidServiceWorkerProviderId; 3098 int provider_id = kInvalidServiceWorkerProviderId;
3101 if (request.frameType() == blink::WebURLRequest::FrameTypeTopLevel || 3099 if (request.frameType() == blink::WebURLRequest::FrameTypeTopLevel ||
3102 request.frameType() == blink::WebURLRequest::FrameTypeNested) { 3100 request.frameType() == blink::WebURLRequest::FrameTypeNested) {
3103 // |provisionalDataSource| may be null in some content::ResourceFetcher 3101 // |provisionalDataSource| may be null in some content::ResourceFetcher
3104 // use cases, we don't hook those requests. 3102 // use cases, we don't hook those requests.
3105 if (frame->provisionalDataSource()) { 3103 if (frame->provisionalDataSource()) {
3106 ServiceWorkerNetworkProvider* provider = 3104 ServiceWorkerNetworkProvider* provider =
3107 ServiceWorkerNetworkProvider::FromDocumentState( 3105 ServiceWorkerNetworkProvider::FromDocumentState(
(...skipping 20 matching lines...) Expand all
3128 RequestExtraData* extra_data = new RequestExtraData(); 3126 RequestExtraData* extra_data = new RequestExtraData();
3129 extra_data->set_visibility_state(render_view_->visibilityState()); 3127 extra_data->set_visibility_state(render_view_->visibilityState());
3130 extra_data->set_custom_user_agent(custom_user_agent); 3128 extra_data->set_custom_user_agent(custom_user_agent);
3131 extra_data->set_requested_with(requested_with); 3129 extra_data->set_requested_with(requested_with);
3132 extra_data->set_render_frame_id(routing_id_); 3130 extra_data->set_render_frame_id(routing_id_);
3133 extra_data->set_is_main_frame(!parent); 3131 extra_data->set_is_main_frame(!parent);
3134 extra_data->set_frame_origin( 3132 extra_data->set_frame_origin(
3135 GURL(frame->document().securityOrigin().toString())); 3133 GURL(frame->document().securityOrigin().toString()));
3136 extra_data->set_parent_is_main_frame(parent && !parent->parent()); 3134 extra_data->set_parent_is_main_frame(parent && !parent->parent());
3137 extra_data->set_parent_render_frame_id(parent_routing_id); 3135 extra_data->set_parent_render_frame_id(parent_routing_id);
3138 extra_data->set_allow_download(navigation_state->allow_download()); 3136 extra_data->set_allow_download(
3137 navigation_state->common_params().allow_download);
3139 extra_data->set_transition_type(transition_type); 3138 extra_data->set_transition_type(transition_type);
3140 extra_data->set_should_replace_current_entry(should_replace_current_entry); 3139 extra_data->set_should_replace_current_entry(should_replace_current_entry);
3141 extra_data->set_transferred_request_child_id( 3140 extra_data->set_transferred_request_child_id(
3142 navigation_state->transferred_request_child_id()); 3141 navigation_state->start_params().transferred_request_child_id);
3143 extra_data->set_transferred_request_request_id( 3142 extra_data->set_transferred_request_request_id(
3144 navigation_state->transferred_request_request_id()); 3143 navigation_state->start_params().transferred_request_request_id);
3145 extra_data->set_service_worker_provider_id(provider_id); 3144 extra_data->set_service_worker_provider_id(provider_id);
3146 extra_data->set_stream_override(stream_override.Pass()); 3145 extra_data->set_stream_override(stream_override.Pass());
3147 request.setExtraData(extra_data); 3146 request.setExtraData(extra_data);
3148 3147
3149 DocumentState* top_document_state = 3148 DocumentState* top_document_state =
3150 DocumentState::FromDataSource(top_data_source); 3149 DocumentState::FromDataSource(top_data_source);
3151 if (top_document_state) { 3150 if (top_document_state) {
3152 // TODO(gavinp): separate out prefetching and prerender field trials 3151 // TODO(gavinp): separate out prefetching and prerender field trials
3153 // if the rel=prerender rel type is sticking around. 3152 // if the rel=prerender rel type is sticking around.
3154 if (request.requestContext() == WebURLRequest::RequestContextPrefetch) 3153 if (request.requestContext() == WebURLRequest::RequestContextPrefetch)
3155 top_document_state->set_was_prefetcher(true); 3154 top_document_state->set_was_prefetcher(true);
3156 } 3155 }
3157 3156
3158 // This is an instance where we embed a copy of the routing id 3157 // This is an instance where we embed a copy of the routing id
3159 // into the data portion of the message. This can cause problems if we 3158 // into the data portion of the message. This can cause problems if we
3160 // don't register this id on the browser side, since the download manager 3159 // don't register this id on the browser side, since the download manager
3161 // expects to find a RenderViewHost based off the id. 3160 // expects to find a RenderViewHost based off the id.
3162 request.setRequestorID(render_view_->GetRoutingID()); 3161 request.setRequestorID(render_view_->GetRoutingID());
3163 request.setHasUserGesture(WebUserGestureIndicator::isProcessingUserGesture()); 3162 request.setHasUserGesture(WebUserGestureIndicator::isProcessingUserGesture());
3164 3163
3165 if (!navigation_state->extra_headers().empty()) { 3164 if (!navigation_state->start_params().extra_headers.empty()) {
3166 for (net::HttpUtil::HeadersIterator i( 3165 for (net::HttpUtil::HeadersIterator i(
3167 navigation_state->extra_headers().begin(), 3166 navigation_state->start_params().extra_headers.begin(),
3168 navigation_state->extra_headers().end(), "\n"); 3167 navigation_state->start_params().extra_headers.end(), "\n");
3169 i.GetNext(); ) { 3168 i.GetNext();) {
3170 if (LowerCaseEqualsASCII(i.name(), "referer")) { 3169 if (LowerCaseEqualsASCII(i.name(), "referer")) {
3171 WebString referrer = WebSecurityPolicy::generateReferrerHeader( 3170 WebString referrer = WebSecurityPolicy::generateReferrerHeader(
3172 blink::WebReferrerPolicyDefault, 3171 blink::WebReferrerPolicyDefault,
3173 request.url(), 3172 request.url(),
3174 WebString::fromUTF8(i.values())); 3173 WebString::fromUTF8(i.values()));
3175 request.setHTTPReferrer(referrer, blink::WebReferrerPolicyDefault); 3174 request.setHTTPReferrer(referrer, blink::WebReferrerPolicyDefault);
3176 } else { 3175 } else {
3177 request.setHTTPHeaderField(WebString::fromUTF8(i.name()), 3176 request.setHTTPHeaderField(WebString::fromUTF8(i.name()),
3178 WebString::fromUTF8(i.values())); 3177 WebString::fromUTF8(i.values()));
3179 } 3178 }
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after
3714 blink::WebFrame* frame, 3713 blink::WebFrame* frame,
3715 blink::WebHistoryCommitType commit_type) { 3714 blink::WebHistoryCommitType commit_type) {
3716 DCHECK(!frame_ || frame_ == frame); 3715 DCHECK(!frame_ || frame_ == frame);
3717 WebDataSource* ds = frame->dataSource(); 3716 WebDataSource* ds = frame->dataSource();
3718 DCHECK(ds); 3717 DCHECK(ds);
3719 3718
3720 const WebURLRequest& request = ds->request(); 3719 const WebURLRequest& request = ds->request();
3721 const WebURLResponse& response = ds->response(); 3720 const WebURLResponse& response = ds->response();
3722 3721
3723 DocumentState* document_state = DocumentState::FromDataSource(ds); 3722 DocumentState* document_state = DocumentState::FromDataSource(ds);
3724 NavigationState* navigation_state = document_state->navigation_state(); 3723 NavigationStateImpl* navigation_state =
3724 static_cast<NavigationStateImpl*>(document_state->navigation_state());
3725 InternalDocumentStateData* internal_data = 3725 InternalDocumentStateData* internal_data =
3726 InternalDocumentStateData::FromDocumentState(document_state); 3726 InternalDocumentStateData::FromDocumentState(document_state);
3727 3727
3728 FrameHostMsg_DidCommitProvisionalLoad_Params params; 3728 FrameHostMsg_DidCommitProvisionalLoad_Params params;
3729 params.http_status_code = response.httpStatusCode(); 3729 params.http_status_code = response.httpStatusCode();
3730 params.url_is_unreachable = ds->hasUnreachableURL(); 3730 params.url_is_unreachable = ds->hasUnreachableURL();
3731 params.is_post = false; 3731 params.is_post = false;
3732 params.post_id = -1; 3732 params.post_id = -1;
3733 params.page_id = render_view_->page_id_; 3733 params.page_id = render_view_->page_id_;
3734 // We need to track the RenderViewHost routing_id because of downstream 3734 // We need to track the RenderViewHost routing_id because of downstream
3735 // dependencies (crbug.com/392171 DownloadRequestHandle, SaveFileManager, 3735 // dependencies (crbug.com/392171 DownloadRequestHandle, SaveFileManager,
3736 // ResourceDispatcherHostImpl, MediaStreamUIProxy, 3736 // ResourceDispatcherHostImpl, MediaStreamUIProxy,
3737 // SpeechRecognitionDispatcherHost and possibly others). They look up the view 3737 // SpeechRecognitionDispatcherHost and possibly others). They look up the view
3738 // based on the ID stored in the resource requests. Once those dependencies 3738 // based on the ID stored in the resource requests. Once those dependencies
3739 // are unwound or moved to RenderFrameHost (crbug.com/304341) we can move the 3739 // are unwound or moved to RenderFrameHost (crbug.com/304341) we can move the
3740 // client to be based on the routing_id of the RenderFrameHost. 3740 // client to be based on the routing_id of the RenderFrameHost.
3741 params.render_view_routing_id = render_view_->routing_id(); 3741 params.render_view_routing_id = render_view_->routing_id();
3742 params.socket_address.set_host(response.remoteIPAddress().utf8()); 3742 params.socket_address.set_host(response.remoteIPAddress().utf8());
3743 params.socket_address.set_port(response.remotePort()); 3743 params.socket_address.set_port(response.remotePort());
3744 WebURLResponseExtraDataImpl* extra_data = GetExtraDataFromResponse(response); 3744 WebURLResponseExtraDataImpl* extra_data = GetExtraDataFromResponse(response);
3745 if (extra_data) 3745 if (extra_data)
3746 params.was_fetched_via_proxy = extra_data->was_fetched_via_proxy(); 3746 params.was_fetched_via_proxy = extra_data->was_fetched_via_proxy();
3747 params.was_within_same_page = navigation_state->was_within_same_page(); 3747 params.was_within_same_page = navigation_state->WasWithinSamePage();
3748 params.security_info = response.securityInfo(); 3748 params.security_info = response.securityInfo();
3749 3749
3750 // Set the URL to be displayed in the browser UI to the user. 3750 // Set the URL to be displayed in the browser UI to the user.
3751 params.url = GetLoadingUrl(); 3751 params.url = GetLoadingUrl();
3752 DCHECK(!is_swapped_out_ || params.url == GURL(kSwappedOutURL)); 3752 DCHECK(!is_swapped_out_ || params.url == GURL(kSwappedOutURL));
3753 3753
3754 // Set the origin of the frame. This will be replicated to the corresponding 3754 // Set the origin of the frame. This will be replicated to the corresponding
3755 // RenderFrameProxies in other processes. 3755 // RenderFrameProxies in other processes.
3756 // TODO(alexmos): Origins for URLs with non-standard schemes are excluded due 3756 // TODO(alexmos): Origins for URLs with non-standard schemes are excluded due
3757 // to https://crbug.com/439608 and will be replicated as unique origins. 3757 // to https://crbug.com/439608 and will be replicated as unique origins.
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
3809 if (host_zoom != render_view_->host_zoom_levels_.end()) { 3809 if (host_zoom != render_view_->host_zoom_levels_.end()) {
3810 // This zoom level was merely recorded transiently for this load. We can 3810 // This zoom level was merely recorded transiently for this load. We can
3811 // erase it now. If at some point we reload this page, the browser will 3811 // erase it now. If at some point we reload this page, the browser will
3812 // send us a new, up-to-date zoom level. 3812 // send us a new, up-to-date zoom level.
3813 render_view_->host_zoom_levels_.erase(host_zoom); 3813 render_view_->host_zoom_levels_.erase(host_zoom);
3814 } 3814 }
3815 3815
3816 // Update contents MIME type for main frame. 3816 // Update contents MIME type for main frame.
3817 params.contents_mime_type = ds->response().mimeType().utf8(); 3817 params.contents_mime_type = ds->response().mimeType().utf8();
3818 3818
3819 params.transition = navigation_state->transition_type(); 3819 params.transition = navigation_state->GetTransitionType();
3820 if (!ui::PageTransitionIsMainFrame(params.transition)) { 3820 if (!ui::PageTransitionIsMainFrame(params.transition)) {
3821 // If the main frame does a load, it should not be reported as a subframe 3821 // If the main frame does a load, it should not be reported as a subframe
3822 // navigation. This can occur in the following case: 3822 // navigation. This can occur in the following case:
3823 // 1. You're on a site with frames. 3823 // 1. You're on a site with frames.
3824 // 2. You do a subframe navigation. This is stored with transition type 3824 // 2. You do a subframe navigation. This is stored with transition type
3825 // MANUAL_SUBFRAME. 3825 // MANUAL_SUBFRAME.
3826 // 3. You navigate to some non-frame site, say, google.com. 3826 // 3. You navigate to some non-frame site, say, google.com.
3827 // 4. You navigate back to the page from step 2. Since it was initially 3827 // 4. You navigate back to the page from step 2. Since it was initially
3828 // MANUAL_SUBFRAME, it will be that same transition type here. 3828 // MANUAL_SUBFRAME, it will be that same transition type here.
3829 // We don't want that, because any navigation that changes the toplevel 3829 // We don't want that, because any navigation that changes the toplevel
(...skipping 22 matching lines...) Expand all
3852 3852
3853 // Send the user agent override back. 3853 // Send the user agent override back.
3854 params.is_overriding_user_agent = internal_data->is_overriding_user_agent(); 3854 params.is_overriding_user_agent = internal_data->is_overriding_user_agent();
3855 3855
3856 // Track the URL of the original request. We use the first entry of the 3856 // Track the URL of the original request. We use the first entry of the
3857 // redirect chain if it exists because the chain may have started in another 3857 // redirect chain if it exists because the chain may have started in another
3858 // process. 3858 // process.
3859 params.original_request_url = GetOriginalRequestURL(ds); 3859 params.original_request_url = GetOriginalRequestURL(ds);
3860 3860
3861 params.history_list_was_cleared = 3861 params.history_list_was_cleared =
3862 navigation_state->history_list_was_cleared(); 3862 navigation_state->history_params().should_clear_history_list;
3863 3863
3864 params.report_type = static_cast<FrameMsg_UILoadMetricsReportType::Value>( 3864 params.report_type = static_cast<FrameMsg_UILoadMetricsReportType::Value>(
3865 frame->dataSource()->request().inputPerfMetricReportPolicy()); 3865 frame->dataSource()->request().inputPerfMetricReportPolicy());
3866 params.ui_timestamp = base::TimeTicks() + base::TimeDelta::FromSecondsD( 3866 params.ui_timestamp = base::TimeTicks() + base::TimeDelta::FromSecondsD(
3867 frame->dataSource()->request().uiStartTime()); 3867 frame->dataSource()->request().uiStartTime());
3868 3868
3869 // Save some histogram data so we can compute the average memory used per 3869 // Save some histogram data so we can compute the average memory used per
3870 // page load of the glyphs. 3870 // page load of the glyphs.
3871 UMA_HISTOGRAM_COUNTS_10000("Memory.GlyphPagesPerLoad", 3871 UMA_HISTOGRAM_COUNTS_10000("Memory.GlyphPagesPerLoad",
3872 blink::WebGlyphCache::pageCount()); 3872 blink::WebGlyphCache::pageCount());
3873 3873
3874 // This message needs to be sent before any of allowScripts(), 3874 // This message needs to be sent before any of allowScripts(),
3875 // allowImages(), allowPlugins() is called for the new page, so that when 3875 // allowImages(), allowPlugins() is called for the new page, so that when
3876 // these functions send a ViewHostMsg_ContentBlocked message, it arrives 3876 // these functions send a ViewHostMsg_ContentBlocked message, it arrives
3877 // after the FrameHostMsg_DidCommitProvisionalLoad message. 3877 // after the FrameHostMsg_DidCommitProvisionalLoad message.
3878 Send(new FrameHostMsg_DidCommitProvisionalLoad(routing_id_, params)); 3878 Send(new FrameHostMsg_DidCommitProvisionalLoad(routing_id_, params));
3879 } else { 3879 } else {
3880 // Subframe navigation: the type depends on whether this navigation 3880 // Subframe navigation: the type depends on whether this navigation
3881 // generated a new session history entry. When they do generate a session 3881 // generated a new session history entry. When they do generate a session
3882 // history entry, it means the user initiated the navigation and we should 3882 // history entry, it means the user initiated the navigation and we should
3883 // mark it as such. 3883 // mark it as such.
3884 if (commit_type == blink::WebStandardCommit) 3884 if (commit_type == blink::WebStandardCommit)
3885 params.transition = ui::PAGE_TRANSITION_MANUAL_SUBFRAME; 3885 params.transition = ui::PAGE_TRANSITION_MANUAL_SUBFRAME;
3886 else 3886 else
3887 params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME; 3887 params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME;
3888 3888
3889 DCHECK(!navigation_state->history_list_was_cleared()); 3889 DCHECK(!navigation_state->history_params().should_clear_history_list);
3890 params.history_list_was_cleared = false; 3890 params.history_list_was_cleared = false;
3891 params.report_type = FrameMsg_UILoadMetricsReportType::NO_REPORT; 3891 params.report_type = FrameMsg_UILoadMetricsReportType::NO_REPORT;
3892 3892
3893 // Don't send this message while the subframe is swapped out. 3893 // Don't send this message while the subframe is swapped out.
3894 if (!is_swapped_out()) 3894 if (!is_swapped_out())
3895 Send(new FrameHostMsg_DidCommitProvisionalLoad(routing_id_, params)); 3895 Send(new FrameHostMsg_DidCommitProvisionalLoad(routing_id_, params));
3896 } 3896 }
3897 3897
3898 // If we end up reusing this WebRequest (for example, due to a #ref click), 3898 // If we end up reusing this WebRequest (for example, due to a #ref click),
3899 // we don't want the transition type to persist. Just clear it. 3899 // we don't want the transition type to persist. Just clear it.
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
4045 } 4045 }
4046 } 4046 }
4047 4047
4048 // Webkit is asking whether to navigate to a new URL. 4048 // Webkit is asking whether to navigate to a new URL.
4049 // This is fine normally, except if we're showing UI from one security 4049 // This is fine normally, except if we're showing UI from one security
4050 // context and they're trying to navigate to a different context. 4050 // context and they're trying to navigate to a different context.
4051 const GURL& url = info.urlRequest.url(); 4051 const GURL& url = info.urlRequest.url();
4052 4052
4053 // A content initiated navigation may have originated from a link-click, 4053 // A content initiated navigation may have originated from a link-click,
4054 // script, drag-n-drop operation, etc. 4054 // script, drag-n-drop operation, etc.
4055 bool is_content_initiated = static_cast<DocumentState*>(info.extraData)-> 4055 DocumentState* document_state = static_cast<DocumentState*>(info.extraData);
4056 navigation_state()->is_content_initiated(); 4056 bool is_content_initiated =
4057 document_state->navigation_state()->IsContentInitiated();
4057 4058
4058 // Experimental: 4059 // Experimental:
4059 // If --enable-strict-site-isolation is enabled, send all top-level 4060 // If --enable-strict-site-isolation is enabled, send all top-level
4060 // navigations to the browser to let it swap processes when crossing site 4061 // navigations to the browser to let it swap processes when crossing site
4061 // boundaries. This is currently expected to break some script calls and 4062 // boundaries. This is currently expected to break some script calls and
4062 // navigations, such as form submissions. 4063 // navigations, such as form submissions.
4063 bool force_swap_due_to_flag = 4064 bool force_swap_due_to_flag =
4064 command_line.HasSwitch(switches::kEnableStrictSiteIsolation); 4065 command_line.HasSwitch(switches::kEnableStrictSiteIsolation);
4065 if (force_swap_due_to_flag && 4066 if (force_swap_due_to_flag &&
4066 !info.frame->parent() && (is_content_initiated || info.isRedirect)) { 4067 !info.frame->parent() && (is_content_initiated || info.isRedirect)) {
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
4226 WebNavigationPolicy policy) { 4227 WebNavigationPolicy policy) {
4227 DCHECK_EQ(frame_, frame); 4228 DCHECK_EQ(frame_, frame);
4228 4229
4229 FrameHostMsg_OpenURL_Params params; 4230 FrameHostMsg_OpenURL_Params params;
4230 params.url = url; 4231 params.url = url;
4231 params.referrer = referrer; 4232 params.referrer = referrer;
4232 params.disposition = RenderViewImpl::NavigationPolicyToDisposition(policy); 4233 params.disposition = RenderViewImpl::NavigationPolicyToDisposition(policy);
4233 WebDataSource* ds = frame->provisionalDataSource(); 4234 WebDataSource* ds = frame->provisionalDataSource();
4234 if (ds) { 4235 if (ds) {
4235 DocumentState* document_state = DocumentState::FromDataSource(ds); 4236 DocumentState* document_state = DocumentState::FromDataSource(ds);
4236 NavigationState* navigation_state = document_state->navigation_state(); 4237 NavigationStateImpl* navigation_state =
4237 if (navigation_state->is_content_initiated()) { 4238 static_cast<NavigationStateImpl*>(document_state->navigation_state());
4239 if (navigation_state->IsContentInitiated()) {
4238 params.should_replace_current_entry = 4240 params.should_replace_current_entry =
4239 ds->replacesCurrentHistoryItem() && 4241 ds->replacesCurrentHistoryItem() &&
4240 render_view_->history_list_length_; 4242 render_view_->history_list_length_;
4241 } else { 4243 } else {
4242 // This is necessary to preserve the should_replace_current_entry value on 4244 // This is necessary to preserve the should_replace_current_entry value on
4243 // cross-process redirects, in the event it was set by a previous process. 4245 // cross-process redirects, in the event it was set by a previous process.
4244 // 4246 //
4245 // TODO(davidben): Avoid this awkward duplication of state. See comment on 4247 // TODO(davidben): Avoid this awkward duplication of state. See comment on
4246 // NavigationState::should_replace_current_entry(). 4248 // NavigationState::should_replace_current_entry().
4247 params.should_replace_current_entry = 4249 params.should_replace_current_entry =
4248 navigation_state->should_replace_current_entry(); 4250 navigation_state->start_params().should_replace_current_entry;
4249 } 4251 }
4250 } else { 4252 } else {
4251 params.should_replace_current_entry = false; 4253 params.should_replace_current_entry = false;
4252 } 4254 }
4253 params.user_gesture = WebUserGestureIndicator::isProcessingUserGesture(); 4255 params.user_gesture = WebUserGestureIndicator::isProcessingUserGesture();
4254 if (GetContentClient()->renderer()->AllowPopup()) 4256 if (GetContentClient()->renderer()->AllowPopup())
4255 params.user_gesture = true; 4257 params.user_gesture = true;
4256 4258
4257 if (policy == blink::WebNavigationPolicyNewBackgroundTab || 4259 if (policy == blink::WebNavigationPolicyNewBackgroundTab ||
4258 policy == blink::WebNavigationPolicyNewForegroundTab || 4260 policy == blink::WebNavigationPolicyNewForegroundTab ||
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
4548 4550
4549 #if defined(ENABLE_BROWSER_CDMS) 4551 #if defined(ENABLE_BROWSER_CDMS)
4550 RendererCdmManager* RenderFrameImpl::GetCdmManager() { 4552 RendererCdmManager* RenderFrameImpl::GetCdmManager() {
4551 if (!cdm_manager_) 4553 if (!cdm_manager_)
4552 cdm_manager_ = new RendererCdmManager(this); 4554 cdm_manager_ = new RendererCdmManager(this);
4553 return cdm_manager_; 4555 return cdm_manager_;
4554 } 4556 }
4555 #endif // defined(ENABLE_BROWSER_CDMS) 4557 #endif // defined(ENABLE_BROWSER_CDMS)
4556 4558
4557 } // namespace content 4559 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/navigation_state_impl.cc ('k') | content/renderer/render_view_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698