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

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: 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
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 1914 matching lines...) Expand 10 before | Expand all | Expand 10 after
2011 } 2012 }
2012 2013
2013 void RenderFrameImpl::didAccessInitialDocument(blink::WebLocalFrame* frame) { 2014 void RenderFrameImpl::didAccessInitialDocument(blink::WebLocalFrame* frame) {
2014 DCHECK(!frame_ || frame_ == frame); 2015 DCHECK(!frame_ || frame_ == frame);
2015 // If the request hasn't yet committed, notify the browser process that it is 2016 // If the request hasn't yet committed, notify the browser process that it is
2016 // no longer safe to show the pending URL of the main frame, since a URL spoof 2017 // no longer safe to show the pending URL of the main frame, since a URL spoof
2017 // is now possible. (If the request has committed, the browser already knows.) 2018 // is now possible. (If the request has committed, the browser already knows.)
2018 if (!frame->parent()) { 2019 if (!frame->parent()) {
2019 DocumentState* document_state = 2020 DocumentState* document_state =
2020 DocumentState::FromDataSource(frame->dataSource()); 2021 DocumentState::FromDataSource(frame->dataSource());
2021 NavigationState* navigation_state = document_state->navigation_state(); 2022 NavigationStateImpl* navigation_state =
2023 static_cast<NavigationStateImpl*>(document_state->navigation_state());
2022 2024
2023 if (!navigation_state->request_committed()) { 2025 if (!navigation_state->request_committed()) {
2024 Send(new FrameHostMsg_DidAccessInitialDocument(routing_id_)); 2026 Send(new FrameHostMsg_DidAccessInitialDocument(routing_id_));
2025 } 2027 }
2026 } 2028 }
2027 } 2029 }
2028 2030
2029 blink::WebFrame* RenderFrameImpl::createChildFrame( 2031 blink::WebFrame* RenderFrameImpl::createChildFrame(
2030 blink::WebLocalFrame* parent, 2032 blink::WebLocalFrame* parent,
2031 const blink::WebString& name, 2033 const blink::WebString& name,
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
2252 DCHECK(!frame_ || frame_ == frame); 2254 DCHECK(!frame_ || frame_ == frame);
2253 2255
2254 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, WillSendSubmitEvent(form)); 2256 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, WillSendSubmitEvent(form));
2255 } 2257 }
2256 2258
2257 void RenderFrameImpl::willSubmitForm(blink::WebLocalFrame* frame, 2259 void RenderFrameImpl::willSubmitForm(blink::WebLocalFrame* frame,
2258 const blink::WebFormElement& form) { 2260 const blink::WebFormElement& form) {
2259 DCHECK(!frame_ || frame_ == frame); 2261 DCHECK(!frame_ || frame_ == frame);
2260 DocumentState* document_state = 2262 DocumentState* document_state =
2261 DocumentState::FromDataSource(frame->provisionalDataSource()); 2263 DocumentState::FromDataSource(frame->provisionalDataSource());
2262 NavigationState* navigation_state = document_state->navigation_state(); 2264 NavigationStateImpl* navigation_state =
2265 static_cast<NavigationStateImpl*>(document_state->navigation_state());
2263 InternalDocumentStateData* internal_data = 2266 InternalDocumentStateData* internal_data =
2264 InternalDocumentStateData::FromDocumentState(document_state); 2267 InternalDocumentStateData::FromDocumentState(document_state);
2265 2268
2266 if (ui::PageTransitionCoreTypeIs(navigation_state->transition_type(), 2269 if (ui::PageTransitionCoreTypeIs(navigation_state->common_params().transition,
Charlie Reis 2015/03/17 03:26:31 Why not navigation_state->GetTransitionType()?
clamy 2015/03/17 16:08:18 Done.
2267 ui::PAGE_TRANSITION_LINK)) { 2270 ui::PAGE_TRANSITION_LINK)) {
2268 navigation_state->set_transition_type(ui::PAGE_TRANSITION_FORM_SUBMIT); 2271 navigation_state->common_params().transition =
Charlie Reis 2015/03/17 03:26:31 Should use a setter for this. Same below.
clamy 2015/03/17 16:08:18 Done.
2272 ui::PAGE_TRANSITION_FORM_SUBMIT;
2269 } 2273 }
2270 2274
2271 // Save these to be processed when the ensuing navigation is committed. 2275 // Save these to be processed when the ensuing navigation is committed.
2272 WebSearchableFormData web_searchable_form_data(form); 2276 WebSearchableFormData web_searchable_form_data(form);
2273 internal_data->set_searchable_form_url(web_searchable_form_data.url()); 2277 internal_data->set_searchable_form_url(web_searchable_form_data.url());
2274 internal_data->set_searchable_form_encoding( 2278 internal_data->set_searchable_form_encoding(
2275 web_searchable_form_data.encoding().utf8()); 2279 web_searchable_form_data.encoding().utf8());
2276 2280
2277 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, WillSubmitForm(form)); 2281 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, WillSubmitForm(form));
2278 } 2282 }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
2334 2338
2335 bool is_top_most = !frame->parent(); 2339 bool is_top_most = !frame->parent();
2336 if (is_top_most) { 2340 if (is_top_most) {
2337 render_view_->set_navigation_gesture( 2341 render_view_->set_navigation_gesture(
2338 WebUserGestureIndicator::isProcessingUserGesture() ? 2342 WebUserGestureIndicator::isProcessingUserGesture() ?
2339 NavigationGestureUser : NavigationGestureAuto); 2343 NavigationGestureUser : NavigationGestureAuto);
2340 } else if (ds->replacesCurrentHistoryItem()) { 2344 } else if (ds->replacesCurrentHistoryItem()) {
2341 // Subframe navigations that don't add session history items must be 2345 // Subframe navigations that don't add session history items must be
2342 // marked with AUTO_SUBFRAME. See also didFailProvisionalLoad for how we 2346 // marked with AUTO_SUBFRAME. See also didFailProvisionalLoad for how we
2343 // handle loading of error pages. 2347 // handle loading of error pages.
2344 document_state->navigation_state()->set_transition_type( 2348 static_cast<NavigationStateImpl*>(document_state->navigation_state())
2345 ui::PAGE_TRANSITION_AUTO_SUBFRAME); 2349 ->common_params()
2350 .transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME;
2346 } 2351 }
2347 2352
2348 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(), 2353 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(),
2349 DidStartProvisionalLoad(frame)); 2354 DidStartProvisionalLoad(frame));
2350 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, DidStartProvisionalLoad()); 2355 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, DidStartProvisionalLoad());
2351 2356
2352 Send(new FrameHostMsg_DidStartProvisionalLoadForFrame( 2357 Send(new FrameHostMsg_DidStartProvisionalLoadForFrame(
2353 routing_id_, ds->request().url(), is_transition_navigation)); 2358 routing_id_, ds->request().url(), is_transition_navigation));
2354 } 2359 }
2355 2360
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
2417 2422
2418 if (RenderThreadImpl::current() && 2423 if (RenderThreadImpl::current() &&
2419 RenderThreadImpl::current()->layout_test_mode()) { 2424 RenderThreadImpl::current()->layout_test_mode()) {
2420 return; 2425 return;
2421 } 2426 }
2422 2427
2423 // Make sure we never show errors in view source mode. 2428 // Make sure we never show errors in view source mode.
2424 frame->enableViewSourceMode(false); 2429 frame->enableViewSourceMode(false);
2425 2430
2426 DocumentState* document_state = DocumentState::FromDataSource(ds); 2431 DocumentState* document_state = DocumentState::FromDataSource(ds);
2427 NavigationState* navigation_state = document_state->navigation_state(); 2432 NavigationStateImpl* navigation_state =
2433 static_cast<NavigationStateImpl*>(document_state->navigation_state());
2428 2434
2429 // If this is a failed back/forward/reload navigation, then we need to do a 2435 // 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. 2436 // '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 2437 // Otherwise, we do a normal load, which simulates a 'go' navigation as far
2432 // as session history is concerned. 2438 // as session history is concerned.
2433 // 2439 //
2434 // AUTO_SUBFRAME loads should always be treated as loads that do not advance 2440 // AUTO_SUBFRAME loads should always be treated as loads that do not advance
2435 // the page id. 2441 // the page id.
2436 // 2442 //
2437 // TODO(davidben): This should also take the failed navigation's replacement 2443 // TODO(davidben): This should also take the failed navigation's replacement
2438 // state into account, if a location.replace() failed. 2444 // state into account, if a location.replace() failed.
2439 bool replace = 2445 bool replace =
2440 navigation_state->pending_page_id() != -1 || 2446 navigation_state->history_params().page_id != -1 ||
2441 ui::PageTransitionCoreTypeIs(navigation_state->transition_type(), 2447 ui::PageTransitionCoreTypeIs(navigation_state->common_params().transition,
2442 ui::PAGE_TRANSITION_AUTO_SUBFRAME); 2448 ui::PAGE_TRANSITION_AUTO_SUBFRAME);
2443 2449
2444 // If we failed on a browser initiated request, then make sure that our error 2450 // 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. 2451 // page load is regarded as the same browser initiated request.
2446 if (!navigation_state->is_content_initiated()) { 2452 if (!navigation_state->IsContentInitiated()) {
2447 render_view_->pending_navigation_params_.reset(new NavigationParams( 2453 render_view_->pending_navigation_params_.reset(new NavigationParams(
2448 CommonNavigationParams( 2454 navigation_state->common_params(), navigation_state->start_params(),
2449 error.unreachableURL, Referrer(),
Charlie Reis 2015/03/17 03:26:31 I don't understand how the new code is equivalent
clamy 2015/03/17 16:08:18 Well until https://codereview.chromium.org/9716530
Charlie Reis 2015/03/17 16:29:06 Oh I see-- it's from a recent change. Ok, I'll de
2450 navigation_state->transition_type(), FrameMsg_Navigate_Type::NORMAL,
2451 true, base::TimeTicks(),
2452 FrameMsg_UILoadMetricsReportType::NO_REPORT, GURL(), GURL()),
2453 StartNavigationParams(false, std::string(),
2454 std::vector<unsigned char>(), replace, -1, -1),
2455 CommitNavigationParams(false, base::TimeTicks(), std::vector<GURL>(), 2455 CommitNavigationParams(false, base::TimeTicks(), std::vector<GURL>(),
2456 false, std::string(), 2456 false, std::string(),
2457 document_state->request_time()), 2457 document_state->request_time()),
2458 HistoryNavigationParams( 2458 navigation_state->history_params()));
2459 PageState(), navigation_state->pending_page_id(),
2460 navigation_state->pending_history_list_offset(), -1, 0,
2461 navigation_state->history_list_was_cleared())));
2462 } 2459 }
2463 2460
2464 // Load an error page. 2461 // Load an error page.
2465 LoadNavigationErrorPage(failed_request, error, replace); 2462 LoadNavigationErrorPage(failed_request, error, replace);
2466 } 2463 }
2467 2464
2468 void RenderFrameImpl::didCommitProvisionalLoad( 2465 void RenderFrameImpl::didCommitProvisionalLoad(
2469 blink::WebLocalFrame* frame, 2466 blink::WebLocalFrame* frame,
2470 const blink::WebHistoryItem& item, 2467 const blink::WebHistoryItem& item,
2471 blink::WebHistoryCommitType commit_type) { 2468 blink::WebHistoryCommitType commit_type) {
2472 TRACE_EVENT2("navigation", "RenderFrameImpl::didCommitProvisionalLoad", 2469 TRACE_EVENT2("navigation", "RenderFrameImpl::didCommitProvisionalLoad",
2473 "id", routing_id_, 2470 "id", routing_id_,
2474 "url", GetLoadingUrl().possibly_invalid_spec()); 2471 "url", GetLoadingUrl().possibly_invalid_spec());
2475 DCHECK(!frame_ || frame_ == frame); 2472 DCHECK(!frame_ || frame_ == frame);
2476 DocumentState* document_state = 2473 DocumentState* document_state =
2477 DocumentState::FromDataSource(frame->dataSource()); 2474 DocumentState::FromDataSource(frame->dataSource());
2478 NavigationState* navigation_state = document_state->navigation_state(); 2475 NavigationStateImpl* navigation_state =
2476 static_cast<NavigationStateImpl*>(document_state->navigation_state());
2479 2477
2480 if (proxy_routing_id_ != MSG_ROUTING_NONE) { 2478 if (proxy_routing_id_ != MSG_ROUTING_NONE) {
2481 RenderFrameProxy* proxy = 2479 RenderFrameProxy* proxy =
2482 RenderFrameProxy::FromRoutingID(proxy_routing_id_); 2480 RenderFrameProxy::FromRoutingID(proxy_routing_id_);
2483 CHECK(proxy); 2481 CHECK(proxy);
2484 proxy->web_frame()->swap(frame_); 2482 proxy->web_frame()->swap(frame_);
2485 proxy_routing_id_ = MSG_ROUTING_NONE; 2483 proxy_routing_id_ = MSG_ROUTING_NONE;
2486 } 2484 }
2487 2485
2488 // When we perform a new navigation, we need to update the last committed 2486 // When we perform a new navigation, we need to update the last committed
2489 // session history entry with state for the page we are leaving. Do this 2487 // session history entry with state for the page we are leaving. Do this
2490 // before updating the HistoryController state. 2488 // before updating the HistoryController state.
2491 render_view_->UpdateSessionHistory(frame); 2489 render_view_->UpdateSessionHistory(frame);
2492 2490
2493 render_view_->history_controller()->UpdateForCommit(this, item, commit_type, 2491 render_view_->history_controller()->UpdateForCommit(
2494 navigation_state->was_within_same_page()); 2492 this, item, commit_type, navigation_state->GetWasWithinSamePage());
2495 2493
2496 InternalDocumentStateData* internal_data = 2494 InternalDocumentStateData* internal_data =
2497 InternalDocumentStateData::FromDocumentState(document_state); 2495 InternalDocumentStateData::FromDocumentState(document_state);
2498 2496
2499 if (document_state->commit_load_time().is_null()) 2497 if (document_state->commit_load_time().is_null())
2500 document_state->set_commit_load_time(Time::Now()); 2498 document_state->set_commit_load_time(Time::Now());
2501 2499
2502 if (internal_data->must_reset_scroll_and_scale_state()) { 2500 if (internal_data->must_reset_scroll_and_scale_state()) {
2503 render_view_->webview()->resetScrollAndScaleState(); 2501 render_view_->webview()->resetScrollAndScaleState();
2504 internal_data->set_must_reset_scroll_and_scale_state(false); 2502 internal_data->set_must_reset_scroll_and_scale_state(false);
2505 } 2503 }
2506 internal_data->set_use_error_page(false); 2504 internal_data->set_use_error_page(false);
2507 2505
2508 bool is_new_navigation = commit_type == blink::WebStandardCommit; 2506 bool is_new_navigation = commit_type == blink::WebStandardCommit;
2509 if (is_new_navigation) { 2507 if (is_new_navigation) {
2510 // We bump our Page ID to correspond with the new session history entry. 2508 // We bump our Page ID to correspond with the new session history entry.
2511 render_view_->page_id_ = render_view_->next_page_id_++; 2509 render_view_->page_id_ = render_view_->next_page_id_++;
2512 2510
2513 // Don't update history list values for kSwappedOutURL, since 2511 // 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 2512 // 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 2513 // never come back to kSwappedOutURL. Note that we have to call
2516 // UpdateSessionHistory and update page_id_ even in this case, so that 2514 // 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 2515 // the current entry gets a state update and so that we don't send a
2518 // state update to the wrong entry when we swap back in. 2516 // state update to the wrong entry when we swap back in.
2519 DCHECK_IMPLIES(navigation_state->should_replace_current_entry(), 2517 DCHECK_IMPLIES(
2520 render_view_->history_list_length_ > 0); 2518 navigation_state->start_params().should_replace_current_entry,
2519 render_view_->history_list_length_ > 0);
2521 if (GetLoadingUrl() != GURL(kSwappedOutURL) && 2520 if (GetLoadingUrl() != GURL(kSwappedOutURL) &&
2522 !navigation_state->should_replace_current_entry()) { 2521 !navigation_state->start_params().should_replace_current_entry) {
2523 // Advance our offset in session history, applying the length limit. 2522 // Advance our offset in session history, applying the length limit.
2524 // There is now no forward history. 2523 // There is now no forward history.
2525 render_view_->history_list_offset_++; 2524 render_view_->history_list_offset_++;
2526 if (render_view_->history_list_offset_ >= kMaxSessionHistoryEntries) 2525 if (render_view_->history_list_offset_ >= kMaxSessionHistoryEntries)
2527 render_view_->history_list_offset_ = kMaxSessionHistoryEntries - 1; 2526 render_view_->history_list_offset_ = kMaxSessionHistoryEntries - 1;
2528 render_view_->history_list_length_ = 2527 render_view_->history_list_length_ =
2529 render_view_->history_list_offset_ + 1; 2528 render_view_->history_list_offset_ + 1;
2530 } 2529 }
2531 } else { 2530 } else {
2532 // Inspect the navigation_state on this frame to see if the navigation 2531 // Inspect the navigation_state on this frame to see if the navigation
2533 // corresponds to a session history navigation... Note: |frame| may or 2532 // corresponds to a session history navigation... Note: |frame| may or
2534 // may not be the toplevel frame, but for the case of capturing session 2533 // may not be the toplevel frame, but for the case of capturing session
2535 // history, the first committed frame suffices. We keep track of whether 2534 // 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 2535 // we've seen this commit before so that only capture session history once
2537 // per navigation. 2536 // per navigation.
2538 // 2537 //
2539 // Note that we need to check if the page ID changed. In the case of a 2538 // 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 2539 // reload, the page ID doesn't change, and UpdateSessionHistory gets the
2541 // previous URL and the current page ID, which would be wrong. 2540 // previous URL and the current page ID, which would be wrong.
2542 if (navigation_state->pending_page_id() != -1 && 2541 if (navigation_state->history_params().page_id != -1 &&
2543 navigation_state->pending_page_id() != render_view_->page_id_ && 2542 navigation_state->history_params().page_id != render_view_->page_id_ &&
2544 !navigation_state->request_committed()) { 2543 !navigation_state->request_committed()) {
2545 // This is a successful session history navigation! 2544 // This is a successful session history navigation!
2546 render_view_->page_id_ = navigation_state->pending_page_id(); 2545 render_view_->page_id_ = navigation_state->history_params().page_id;
2547 2546
2548 render_view_->history_list_offset_ = 2547 render_view_->history_list_offset_ =
2549 navigation_state->pending_history_list_offset(); 2548 navigation_state->history_params().pending_history_list_offset;
2550 } 2549 }
2551 } 2550 }
2552 2551
2553 bool sent = Send( 2552 bool sent = Send(
2554 new FrameHostMsg_DidAssignPageId(routing_id_, render_view_->page_id_)); 2553 new FrameHostMsg_DidAssignPageId(routing_id_, render_view_->page_id_));
2555 CHECK(sent); // http://crbug.com/407376 2554 CHECK(sent); // http://crbug.com/407376
2556 2555
2557 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers_, 2556 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers_,
2558 DidCommitProvisionalLoad(frame, is_new_navigation)); 2557 DidCommitProvisionalLoad(frame, is_new_navigation));
2559 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, 2558 FOR_EACH_OBSERVER(
2560 DidCommitProvisionalLoad( 2559 RenderFrameObserver, observers_,
2561 is_new_navigation, 2560 DidCommitProvisionalLoad(is_new_navigation,
2562 navigation_state->was_within_same_page())); 2561 navigation_state->GetWasWithinSamePage()));
2563 2562
2564 if (!frame->parent()) { // Only for top frames. 2563 if (!frame->parent()) { // Only for top frames.
2565 RenderThreadImpl* render_thread_impl = RenderThreadImpl::current(); 2564 RenderThreadImpl* render_thread_impl = RenderThreadImpl::current();
2566 if (render_thread_impl) { // Can be NULL in tests. 2565 if (render_thread_impl) { // Can be NULL in tests.
2567 render_thread_impl->histogram_customizer()-> 2566 render_thread_impl->histogram_customizer()->
2568 RenderViewNavigatedToHost(GURL(GetLoadingUrl()).host(), 2567 RenderViewNavigatedToHost(GURL(GetLoadingUrl()).host(),
2569 RenderViewImpl::GetRenderViewCount()); 2568 RenderViewImpl::GetRenderViewCount());
2570 } 2569 }
2571 } 2570 }
2572 2571
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
2766 // could end up having a non-null pending navigation params. We just need to 2765 // could end up having a non-null pending navigation params. We just need to
2767 // update the ExtraData on the datasource so that others who read the 2766 // update the ExtraData on the datasource so that others who read the
2768 // ExtraData will get the new NavigationState. Similarly, if we did not 2767 // ExtraData will get the new NavigationState. Similarly, if we did not
2769 // initiate this navigation, then we need to take care to reset any pre- 2768 // initiate this navigation, then we need to take care to reset any pre-
2770 // existing navigation state to a content-initiated navigation state. 2769 // existing navigation state to a content-initiated navigation state.
2771 // DidCreateDataSource conveniently takes care of this for us. 2770 // DidCreateDataSource conveniently takes care of this for us.
2772 didCreateDataSource(frame, frame->dataSource()); 2771 didCreateDataSource(frame, frame->dataSource());
2773 2772
2774 DocumentState* document_state = 2773 DocumentState* document_state =
2775 DocumentState::FromDataSource(frame->dataSource()); 2774 DocumentState::FromDataSource(frame->dataSource());
2776 NavigationState* new_state = document_state->navigation_state(); 2775 static_cast<NavigationStateImpl*>(document_state->navigation_state())
2777 new_state->set_was_within_same_page(true); 2776 ->set_was_within_same_page(true);
2778 2777
2779 didCommitProvisionalLoad(frame, item, commit_type); 2778 didCommitProvisionalLoad(frame, item, commit_type);
2780 } 2779 }
2781 2780
2782 void RenderFrameImpl::didUpdateCurrentHistoryItem(blink::WebLocalFrame* frame) { 2781 void RenderFrameImpl::didUpdateCurrentHistoryItem(blink::WebLocalFrame* frame) {
2783 DCHECK(!frame_ || frame_ == frame); 2782 DCHECK(!frame_ || frame_ == frame);
2784 // TODO(nasko): Move implementation here. Needed methods: 2783 // TODO(nasko): Move implementation here. Needed methods:
2785 // * StartNavStateSyncTimerIfNecessary 2784 // * StartNavStateSyncTimerIfNecessary
2786 render_view_->didUpdateCurrentHistoryItem(frame); 2785 render_view_->didUpdateCurrentHistoryItem(frame);
2787 } 2786 }
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
2983 top_frame = frame; 2982 top_frame = frame;
2984 WebDataSource* provisional_data_source = top_frame->provisionalDataSource(); 2983 WebDataSource* provisional_data_source = top_frame->provisionalDataSource();
2985 WebDataSource* top_data_source = top_frame->dataSource(); 2984 WebDataSource* top_data_source = top_frame->dataSource();
2986 WebDataSource* data_source = 2985 WebDataSource* data_source =
2987 provisional_data_source ? provisional_data_source : top_data_source; 2986 provisional_data_source ? provisional_data_source : top_data_source;
2988 2987
2989 DocumentState* document_state = DocumentState::FromDataSource(data_source); 2988 DocumentState* document_state = DocumentState::FromDataSource(data_source);
2990 DCHECK(document_state); 2989 DCHECK(document_state);
2991 InternalDocumentStateData* internal_data = 2990 InternalDocumentStateData* internal_data =
2992 InternalDocumentStateData::FromDocumentState(document_state); 2991 InternalDocumentStateData::FromDocumentState(document_state);
2993 NavigationState* navigation_state = document_state->navigation_state(); 2992 NavigationStateImpl* navigation_state =
2994 ui::PageTransition transition_type = navigation_state->transition_type(); 2993 static_cast<NavigationStateImpl*>(document_state->navigation_state());
2994 ui::PageTransition transition_type =
2995 navigation_state->common_params().transition;
2995 WebDataSource* frame_ds = frame->provisionalDataSource(); 2996 WebDataSource* frame_ds = frame->provisionalDataSource();
2996 if (frame_ds && frame_ds->isClientRedirect()) { 2997 if (frame_ds && frame_ds->isClientRedirect()) {
2997 transition_type = ui::PageTransitionFromInt( 2998 transition_type = ui::PageTransitionFromInt(
2998 transition_type | ui::PAGE_TRANSITION_CLIENT_REDIRECT); 2999 transition_type | ui::PAGE_TRANSITION_CLIENT_REDIRECT);
2999 } 3000 }
3000 3001
3001 GURL request_url(request.url()); 3002 GURL request_url(request.url());
3002 GURL new_url; 3003 GURL new_url;
3003 if (GetContentClient()->renderer()->WillSendRequest( 3004 if (GetContentClient()->renderer()->WillSendRequest(
3004 frame, 3005 frame,
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
3053 } 3054 }
3054 3055
3055 // Add an empty HTTP origin header for non GET methods if none is currently 3056 // Add an empty HTTP origin header for non GET methods if none is currently
3056 // present. 3057 // present.
3057 request.addHTTPOriginIfNeeded(WebString()); 3058 request.addHTTPOriginIfNeeded(WebString());
3058 3059
3059 // Attach |should_replace_current_entry| state to requests so that, should 3060 // Attach |should_replace_current_entry| state to requests so that, should
3060 // this navigation later require a request transfer, all state is preserved 3061 // this navigation later require a request transfer, all state is preserved
3061 // when it is re-created in the new process. 3062 // when it is re-created in the new process.
3062 bool should_replace_current_entry = false; 3063 bool should_replace_current_entry = false;
3063 if (navigation_state->is_content_initiated()) { 3064 if (navigation_state->IsContentInitiated()) {
3064 should_replace_current_entry = data_source->replacesCurrentHistoryItem(); 3065 should_replace_current_entry = data_source->replacesCurrentHistoryItem();
3065 } else { 3066 } else {
3066 // If the navigation is browser-initiated, the NavigationState contains the 3067 // If the navigation is browser-initiated, the NavigationState contains the
3067 // correct value instead of the WebDataSource. 3068 // correct value instead of the WebDataSource.
3068 // 3069 //
3069 // TODO(davidben): Avoid this awkward duplication of state. See comment on 3070 // TODO(davidben): Avoid this awkward duplication of state. See comment on
3070 // NavigationState::should_replace_current_entry(). 3071 // NavigationState::should_replace_current_entry().
3071 should_replace_current_entry = 3072 should_replace_current_entry =
3072 navigation_state->should_replace_current_entry(); 3073 navigation_state->start_params().should_replace_current_entry;
3073 } 3074 }
3074 3075
3075 int provider_id = kInvalidServiceWorkerProviderId; 3076 int provider_id = kInvalidServiceWorkerProviderId;
3076 if (request.frameType() == blink::WebURLRequest::FrameTypeTopLevel || 3077 if (request.frameType() == blink::WebURLRequest::FrameTypeTopLevel ||
3077 request.frameType() == blink::WebURLRequest::FrameTypeNested) { 3078 request.frameType() == blink::WebURLRequest::FrameTypeNested) {
3078 // |provisionalDataSource| may be null in some content::ResourceFetcher 3079 // |provisionalDataSource| may be null in some content::ResourceFetcher
3079 // use cases, we don't hook those requests. 3080 // use cases, we don't hook those requests.
3080 if (frame->provisionalDataSource()) { 3081 if (frame->provisionalDataSource()) {
3081 ServiceWorkerNetworkProvider* provider = 3082 ServiceWorkerNetworkProvider* provider =
3082 ServiceWorkerNetworkProvider::FromDocumentState( 3083 ServiceWorkerNetworkProvider::FromDocumentState(
(...skipping 20 matching lines...) Expand all
3103 RequestExtraData* extra_data = new RequestExtraData(); 3104 RequestExtraData* extra_data = new RequestExtraData();
3104 extra_data->set_visibility_state(render_view_->visibilityState()); 3105 extra_data->set_visibility_state(render_view_->visibilityState());
3105 extra_data->set_custom_user_agent(custom_user_agent); 3106 extra_data->set_custom_user_agent(custom_user_agent);
3106 extra_data->set_requested_with(requested_with); 3107 extra_data->set_requested_with(requested_with);
3107 extra_data->set_render_frame_id(routing_id_); 3108 extra_data->set_render_frame_id(routing_id_);
3108 extra_data->set_is_main_frame(!parent); 3109 extra_data->set_is_main_frame(!parent);
3109 extra_data->set_frame_origin( 3110 extra_data->set_frame_origin(
3110 GURL(frame->document().securityOrigin().toString())); 3111 GURL(frame->document().securityOrigin().toString()));
3111 extra_data->set_parent_is_main_frame(parent && !parent->parent()); 3112 extra_data->set_parent_is_main_frame(parent && !parent->parent());
3112 extra_data->set_parent_render_frame_id(parent_routing_id); 3113 extra_data->set_parent_render_frame_id(parent_routing_id);
3113 extra_data->set_allow_download(navigation_state->allow_download()); 3114 extra_data->set_allow_download(
3115 navigation_state->common_params().allow_download);
3114 extra_data->set_transition_type(transition_type); 3116 extra_data->set_transition_type(transition_type);
3115 extra_data->set_should_replace_current_entry(should_replace_current_entry); 3117 extra_data->set_should_replace_current_entry(should_replace_current_entry);
3116 extra_data->set_transferred_request_child_id( 3118 extra_data->set_transferred_request_child_id(
3117 navigation_state->transferred_request_child_id()); 3119 navigation_state->start_params().transferred_request_child_id);
3118 extra_data->set_transferred_request_request_id( 3120 extra_data->set_transferred_request_request_id(
3119 navigation_state->transferred_request_request_id()); 3121 navigation_state->start_params().transferred_request_request_id);
3120 extra_data->set_service_worker_provider_id(provider_id); 3122 extra_data->set_service_worker_provider_id(provider_id);
3121 extra_data->set_stream_override(stream_override.Pass()); 3123 extra_data->set_stream_override(stream_override.Pass());
3122 request.setExtraData(extra_data); 3124 request.setExtraData(extra_data);
3123 3125
3124 DocumentState* top_document_state = 3126 DocumentState* top_document_state =
3125 DocumentState::FromDataSource(top_data_source); 3127 DocumentState::FromDataSource(top_data_source);
3126 if (top_document_state) { 3128 if (top_document_state) {
3127 // TODO(gavinp): separate out prefetching and prerender field trials 3129 // TODO(gavinp): separate out prefetching and prerender field trials
3128 // if the rel=prerender rel type is sticking around. 3130 // if the rel=prerender rel type is sticking around.
3129 if (request.requestContext() == WebURLRequest::RequestContextPrefetch) 3131 if (request.requestContext() == WebURLRequest::RequestContextPrefetch)
3130 top_document_state->set_was_prefetcher(true); 3132 top_document_state->set_was_prefetcher(true);
3131 } 3133 }
3132 3134
3133 // This is an instance where we embed a copy of the routing id 3135 // This is an instance where we embed a copy of the routing id
3134 // into the data portion of the message. This can cause problems if we 3136 // into the data portion of the message. This can cause problems if we
3135 // don't register this id on the browser side, since the download manager 3137 // don't register this id on the browser side, since the download manager
3136 // expects to find a RenderViewHost based off the id. 3138 // expects to find a RenderViewHost based off the id.
3137 request.setRequestorID(render_view_->GetRoutingID()); 3139 request.setRequestorID(render_view_->GetRoutingID());
3138 request.setHasUserGesture(WebUserGestureIndicator::isProcessingUserGesture()); 3140 request.setHasUserGesture(WebUserGestureIndicator::isProcessingUserGesture());
3139 3141
3140 if (!navigation_state->extra_headers().empty()) { 3142 if (!navigation_state->start_params().extra_headers.empty()) {
3141 for (net::HttpUtil::HeadersIterator i( 3143 for (net::HttpUtil::HeadersIterator i(
3142 navigation_state->extra_headers().begin(), 3144 navigation_state->start_params().extra_headers.begin(),
3143 navigation_state->extra_headers().end(), "\n"); 3145 navigation_state->start_params().extra_headers.end(), "\n");
3144 i.GetNext(); ) { 3146 i.GetNext();) {
3145 if (LowerCaseEqualsASCII(i.name(), "referer")) { 3147 if (LowerCaseEqualsASCII(i.name(), "referer")) {
3146 WebString referrer = WebSecurityPolicy::generateReferrerHeader( 3148 WebString referrer = WebSecurityPolicy::generateReferrerHeader(
3147 blink::WebReferrerPolicyDefault, 3149 blink::WebReferrerPolicyDefault,
3148 request.url(), 3150 request.url(),
3149 WebString::fromUTF8(i.values())); 3151 WebString::fromUTF8(i.values()));
3150 request.setHTTPReferrer(referrer, blink::WebReferrerPolicyDefault); 3152 request.setHTTPReferrer(referrer, blink::WebReferrerPolicyDefault);
3151 } else { 3153 } else {
3152 request.setHTTPHeaderField(WebString::fromUTF8(i.name()), 3154 request.setHTTPHeaderField(WebString::fromUTF8(i.name()),
3153 WebString::fromUTF8(i.values())); 3155 WebString::fromUTF8(i.values()));
3154 } 3156 }
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after
3689 blink::WebFrame* frame, 3691 blink::WebFrame* frame,
3690 blink::WebHistoryCommitType commit_type) { 3692 blink::WebHistoryCommitType commit_type) {
3691 DCHECK(!frame_ || frame_ == frame); 3693 DCHECK(!frame_ || frame_ == frame);
3692 WebDataSource* ds = frame->dataSource(); 3694 WebDataSource* ds = frame->dataSource();
3693 DCHECK(ds); 3695 DCHECK(ds);
3694 3696
3695 const WebURLRequest& request = ds->request(); 3697 const WebURLRequest& request = ds->request();
3696 const WebURLResponse& response = ds->response(); 3698 const WebURLResponse& response = ds->response();
3697 3699
3698 DocumentState* document_state = DocumentState::FromDataSource(ds); 3700 DocumentState* document_state = DocumentState::FromDataSource(ds);
3699 NavigationState* navigation_state = document_state->navigation_state(); 3701 NavigationStateImpl* navigation_state =
3702 static_cast<NavigationStateImpl*>(document_state->navigation_state());
3700 InternalDocumentStateData* internal_data = 3703 InternalDocumentStateData* internal_data =
3701 InternalDocumentStateData::FromDocumentState(document_state); 3704 InternalDocumentStateData::FromDocumentState(document_state);
3702 3705
3703 FrameHostMsg_DidCommitProvisionalLoad_Params params; 3706 FrameHostMsg_DidCommitProvisionalLoad_Params params;
3704 params.http_status_code = response.httpStatusCode(); 3707 params.http_status_code = response.httpStatusCode();
3705 params.url_is_unreachable = ds->hasUnreachableURL(); 3708 params.url_is_unreachable = ds->hasUnreachableURL();
3706 params.is_post = false; 3709 params.is_post = false;
3707 params.post_id = -1; 3710 params.post_id = -1;
3708 params.page_id = render_view_->page_id_; 3711 params.page_id = render_view_->page_id_;
3709 // We need to track the RenderViewHost routing_id because of downstream 3712 // We need to track the RenderViewHost routing_id because of downstream
3710 // dependencies (crbug.com/392171 DownloadRequestHandle, SaveFileManager, 3713 // dependencies (crbug.com/392171 DownloadRequestHandle, SaveFileManager,
3711 // ResourceDispatcherHostImpl, MediaStreamUIProxy, 3714 // ResourceDispatcherHostImpl, MediaStreamUIProxy,
3712 // SpeechRecognitionDispatcherHost and possibly others). They look up the view 3715 // SpeechRecognitionDispatcherHost and possibly others). They look up the view
3713 // based on the ID stored in the resource requests. Once those dependencies 3716 // based on the ID stored in the resource requests. Once those dependencies
3714 // are unwound or moved to RenderFrameHost (crbug.com/304341) we can move the 3717 // are unwound or moved to RenderFrameHost (crbug.com/304341) we can move the
3715 // client to be based on the routing_id of the RenderFrameHost. 3718 // client to be based on the routing_id of the RenderFrameHost.
3716 params.render_view_routing_id = render_view_->routing_id(); 3719 params.render_view_routing_id = render_view_->routing_id();
3717 params.socket_address.set_host(response.remoteIPAddress().utf8()); 3720 params.socket_address.set_host(response.remoteIPAddress().utf8());
3718 params.socket_address.set_port(response.remotePort()); 3721 params.socket_address.set_port(response.remotePort());
3719 WebURLResponseExtraDataImpl* extra_data = GetExtraDataFromResponse(response); 3722 WebURLResponseExtraDataImpl* extra_data = GetExtraDataFromResponse(response);
3720 if (extra_data) 3723 if (extra_data)
3721 params.was_fetched_via_proxy = extra_data->was_fetched_via_proxy(); 3724 params.was_fetched_via_proxy = extra_data->was_fetched_via_proxy();
3722 params.was_within_same_page = navigation_state->was_within_same_page(); 3725 params.was_within_same_page = navigation_state->GetWasWithinSamePage();
3723 params.security_info = response.securityInfo(); 3726 params.security_info = response.securityInfo();
3724 3727
3725 // Set the URL to be displayed in the browser UI to the user. 3728 // Set the URL to be displayed in the browser UI to the user.
3726 params.url = GetLoadingUrl(); 3729 params.url = GetLoadingUrl();
3727 DCHECK(!is_swapped_out_ || params.url == GURL(kSwappedOutURL)); 3730 DCHECK(!is_swapped_out_ || params.url == GURL(kSwappedOutURL));
3728 3731
3729 // Set the origin of the frame. This will be replicated to the corresponding 3732 // Set the origin of the frame. This will be replicated to the corresponding
3730 // RenderFrameProxies in other processes. 3733 // RenderFrameProxies in other processes.
3731 // TODO(alexmos): Origins for URLs with non-standard schemes are excluded due 3734 // TODO(alexmos): Origins for URLs with non-standard schemes are excluded due
3732 // to https://crbug.com/439608 and will be replicated as unique origins. 3735 // to https://crbug.com/439608 and will be replicated as unique origins.
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
3784 if (host_zoom != render_view_->host_zoom_levels_.end()) { 3787 if (host_zoom != render_view_->host_zoom_levels_.end()) {
3785 // This zoom level was merely recorded transiently for this load. We can 3788 // This zoom level was merely recorded transiently for this load. We can
3786 // erase it now. If at some point we reload this page, the browser will 3789 // erase it now. If at some point we reload this page, the browser will
3787 // send us a new, up-to-date zoom level. 3790 // send us a new, up-to-date zoom level.
3788 render_view_->host_zoom_levels_.erase(host_zoom); 3791 render_view_->host_zoom_levels_.erase(host_zoom);
3789 } 3792 }
3790 3793
3791 // Update contents MIME type for main frame. 3794 // Update contents MIME type for main frame.
3792 params.contents_mime_type = ds->response().mimeType().utf8(); 3795 params.contents_mime_type = ds->response().mimeType().utf8();
3793 3796
3794 params.transition = navigation_state->transition_type(); 3797 params.transition = navigation_state->common_params().transition;
3795 if (!ui::PageTransitionIsMainFrame(params.transition)) { 3798 if (!ui::PageTransitionIsMainFrame(params.transition)) {
3796 // If the main frame does a load, it should not be reported as a subframe 3799 // If the main frame does a load, it should not be reported as a subframe
3797 // navigation. This can occur in the following case: 3800 // navigation. This can occur in the following case:
3798 // 1. You're on a site with frames. 3801 // 1. You're on a site with frames.
3799 // 2. You do a subframe navigation. This is stored with transition type 3802 // 2. You do a subframe navigation. This is stored with transition type
3800 // MANUAL_SUBFRAME. 3803 // MANUAL_SUBFRAME.
3801 // 3. You navigate to some non-frame site, say, google.com. 3804 // 3. You navigate to some non-frame site, say, google.com.
3802 // 4. You navigate back to the page from step 2. Since it was initially 3805 // 4. You navigate back to the page from step 2. Since it was initially
3803 // MANUAL_SUBFRAME, it will be that same transition type here. 3806 // MANUAL_SUBFRAME, it will be that same transition type here.
3804 // We don't want that, because any navigation that changes the toplevel 3807 // We don't want that, because any navigation that changes the toplevel
(...skipping 22 matching lines...) Expand all
3827 3830
3828 // Send the user agent override back. 3831 // Send the user agent override back.
3829 params.is_overriding_user_agent = internal_data->is_overriding_user_agent(); 3832 params.is_overriding_user_agent = internal_data->is_overriding_user_agent();
3830 3833
3831 // Track the URL of the original request. We use the first entry of the 3834 // Track the URL of the original request. We use the first entry of the
3832 // redirect chain if it exists because the chain may have started in another 3835 // redirect chain if it exists because the chain may have started in another
3833 // process. 3836 // process.
3834 params.original_request_url = GetOriginalRequestURL(ds); 3837 params.original_request_url = GetOriginalRequestURL(ds);
3835 3838
3836 params.history_list_was_cleared = 3839 params.history_list_was_cleared =
3837 navigation_state->history_list_was_cleared(); 3840 navigation_state->history_params().should_clear_history_list;
3838 3841
3839 params.report_type = static_cast<FrameMsg_UILoadMetricsReportType::Value>( 3842 params.report_type = static_cast<FrameMsg_UILoadMetricsReportType::Value>(
3840 frame->dataSource()->request().inputPerfMetricReportPolicy()); 3843 frame->dataSource()->request().inputPerfMetricReportPolicy());
3841 params.ui_timestamp = base::TimeTicks() + base::TimeDelta::FromSecondsD( 3844 params.ui_timestamp = base::TimeTicks() + base::TimeDelta::FromSecondsD(
3842 frame->dataSource()->request().uiStartTime()); 3845 frame->dataSource()->request().uiStartTime());
3843 3846
3844 // Save some histogram data so we can compute the average memory used per 3847 // Save some histogram data so we can compute the average memory used per
3845 // page load of the glyphs. 3848 // page load of the glyphs.
3846 UMA_HISTOGRAM_COUNTS_10000("Memory.GlyphPagesPerLoad", 3849 UMA_HISTOGRAM_COUNTS_10000("Memory.GlyphPagesPerLoad",
3847 blink::WebGlyphCache::pageCount()); 3850 blink::WebGlyphCache::pageCount());
3848 3851
3849 // This message needs to be sent before any of allowScripts(), 3852 // This message needs to be sent before any of allowScripts(),
3850 // allowImages(), allowPlugins() is called for the new page, so that when 3853 // allowImages(), allowPlugins() is called for the new page, so that when
3851 // these functions send a ViewHostMsg_ContentBlocked message, it arrives 3854 // these functions send a ViewHostMsg_ContentBlocked message, it arrives
3852 // after the FrameHostMsg_DidCommitProvisionalLoad message. 3855 // after the FrameHostMsg_DidCommitProvisionalLoad message.
3853 Send(new FrameHostMsg_DidCommitProvisionalLoad(routing_id_, params)); 3856 Send(new FrameHostMsg_DidCommitProvisionalLoad(routing_id_, params));
3854 } else { 3857 } else {
3855 // Subframe navigation: the type depends on whether this navigation 3858 // Subframe navigation: the type depends on whether this navigation
3856 // generated a new session history entry. When they do generate a session 3859 // generated a new session history entry. When they do generate a session
3857 // history entry, it means the user initiated the navigation and we should 3860 // history entry, it means the user initiated the navigation and we should
3858 // mark it as such. 3861 // mark it as such.
3859 if (commit_type == blink::WebStandardCommit) 3862 if (commit_type == blink::WebStandardCommit)
3860 params.transition = ui::PAGE_TRANSITION_MANUAL_SUBFRAME; 3863 params.transition = ui::PAGE_TRANSITION_MANUAL_SUBFRAME;
3861 else 3864 else
3862 params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME; 3865 params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME;
3863 3866
3864 DCHECK(!navigation_state->history_list_was_cleared()); 3867 DCHECK(!navigation_state->history_params().should_clear_history_list);
3865 params.history_list_was_cleared = false; 3868 params.history_list_was_cleared = false;
3866 params.report_type = FrameMsg_UILoadMetricsReportType::NO_REPORT; 3869 params.report_type = FrameMsg_UILoadMetricsReportType::NO_REPORT;
3867 3870
3868 // Don't send this message while the subframe is swapped out. 3871 // Don't send this message while the subframe is swapped out.
3869 if (!is_swapped_out()) 3872 if (!is_swapped_out())
3870 Send(new FrameHostMsg_DidCommitProvisionalLoad(routing_id_, params)); 3873 Send(new FrameHostMsg_DidCommitProvisionalLoad(routing_id_, params));
3871 } 3874 }
3872 3875
3873 // If we end up reusing this WebRequest (for example, due to a #ref click), 3876 // If we end up reusing this WebRequest (for example, due to a #ref click),
3874 // we don't want the transition type to persist. Just clear it. 3877 // we don't want the transition type to persist. Just clear it.
3875 navigation_state->set_transition_type(ui::PAGE_TRANSITION_LINK); 3878 navigation_state->common_params().transition = ui::PAGE_TRANSITION_LINK;
3876 } 3879 }
3877 3880
3878 void RenderFrameImpl::didStartLoading(bool to_different_document) { 3881 void RenderFrameImpl::didStartLoading(bool to_different_document) {
3879 TRACE_EVENT1("navigation", "RenderFrameImpl::didStartLoading", 3882 TRACE_EVENT1("navigation", "RenderFrameImpl::didStartLoading",
3880 "id", routing_id_); 3883 "id", routing_id_);
3881 render_view_->FrameDidStartLoading(frame_); 3884 render_view_->FrameDidStartLoading(frame_);
3882 Send(new FrameHostMsg_DidStartLoading(routing_id_, to_different_document)); 3885 Send(new FrameHostMsg_DidStartLoading(routing_id_, to_different_document));
3883 } 3886 }
3884 3887
3885 void RenderFrameImpl::didStopLoading() { 3888 void RenderFrameImpl::didStopLoading() {
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
4020 } 4023 }
4021 } 4024 }
4022 4025
4023 // Webkit is asking whether to navigate to a new URL. 4026 // Webkit is asking whether to navigate to a new URL.
4024 // This is fine normally, except if we're showing UI from one security 4027 // This is fine normally, except if we're showing UI from one security
4025 // context and they're trying to navigate to a different context. 4028 // context and they're trying to navigate to a different context.
4026 const GURL& url = info.urlRequest.url(); 4029 const GURL& url = info.urlRequest.url();
4027 4030
4028 // A content initiated navigation may have originated from a link-click, 4031 // A content initiated navigation may have originated from a link-click,
4029 // script, drag-n-drop operation, etc. 4032 // script, drag-n-drop operation, etc.
4030 bool is_content_initiated = static_cast<DocumentState*>(info.extraData)-> 4033 DocumentState* document_state = static_cast<DocumentState*>(info.extraData);
4031 navigation_state()->is_content_initiated(); 4034 bool is_content_initiated =
4035 static_cast<NavigationStateImpl*>(document_state->navigation_state())
Charlie Reis 2015/03/17 03:26:31 Why do you need this static cast? IsContentInitia
clamy 2015/03/17 16:08:18 Done (it was not initially).
4036 ->IsContentInitiated();
4032 4037
4033 // Experimental: 4038 // Experimental:
4034 // If --enable-strict-site-isolation is enabled, send all top-level 4039 // If --enable-strict-site-isolation is enabled, send all top-level
4035 // navigations to the browser to let it swap processes when crossing site 4040 // navigations to the browser to let it swap processes when crossing site
4036 // boundaries. This is currently expected to break some script calls and 4041 // boundaries. This is currently expected to break some script calls and
4037 // navigations, such as form submissions. 4042 // navigations, such as form submissions.
4038 bool force_swap_due_to_flag = 4043 bool force_swap_due_to_flag =
4039 command_line.HasSwitch(switches::kEnableStrictSiteIsolation); 4044 command_line.HasSwitch(switches::kEnableStrictSiteIsolation);
4040 if (force_swap_due_to_flag && 4045 if (force_swap_due_to_flag &&
4041 !info.frame->parent() && (is_content_initiated || info.isRedirect)) { 4046 !info.frame->parent() && (is_content_initiated || info.isRedirect)) {
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
4201 WebNavigationPolicy policy) { 4206 WebNavigationPolicy policy) {
4202 DCHECK_EQ(frame_, frame); 4207 DCHECK_EQ(frame_, frame);
4203 4208
4204 FrameHostMsg_OpenURL_Params params; 4209 FrameHostMsg_OpenURL_Params params;
4205 params.url = url; 4210 params.url = url;
4206 params.referrer = referrer; 4211 params.referrer = referrer;
4207 params.disposition = RenderViewImpl::NavigationPolicyToDisposition(policy); 4212 params.disposition = RenderViewImpl::NavigationPolicyToDisposition(policy);
4208 WebDataSource* ds = frame->provisionalDataSource(); 4213 WebDataSource* ds = frame->provisionalDataSource();
4209 if (ds) { 4214 if (ds) {
4210 DocumentState* document_state = DocumentState::FromDataSource(ds); 4215 DocumentState* document_state = DocumentState::FromDataSource(ds);
4211 NavigationState* navigation_state = document_state->navigation_state(); 4216 NavigationStateImpl* navigation_state =
4212 if (navigation_state->is_content_initiated()) { 4217 static_cast<NavigationStateImpl*>(document_state->navigation_state());
4218 if (navigation_state->IsContentInitiated()) {
4213 params.should_replace_current_entry = 4219 params.should_replace_current_entry =
4214 ds->replacesCurrentHistoryItem() && 4220 ds->replacesCurrentHistoryItem() &&
4215 render_view_->history_list_length_; 4221 render_view_->history_list_length_;
4216 } else { 4222 } else {
4217 // This is necessary to preserve the should_replace_current_entry value on 4223 // This is necessary to preserve the should_replace_current_entry value on
4218 // cross-process redirects, in the event it was set by a previous process. 4224 // cross-process redirects, in the event it was set by a previous process.
4219 // 4225 //
4220 // TODO(davidben): Avoid this awkward duplication of state. See comment on 4226 // TODO(davidben): Avoid this awkward duplication of state. See comment on
4221 // NavigationState::should_replace_current_entry(). 4227 // NavigationState::should_replace_current_entry().
4222 params.should_replace_current_entry = 4228 params.should_replace_current_entry =
4223 navigation_state->should_replace_current_entry(); 4229 navigation_state->start_params().should_replace_current_entry;
4224 } 4230 }
4225 } else { 4231 } else {
4226 params.should_replace_current_entry = false; 4232 params.should_replace_current_entry = false;
4227 } 4233 }
4228 params.user_gesture = WebUserGestureIndicator::isProcessingUserGesture(); 4234 params.user_gesture = WebUserGestureIndicator::isProcessingUserGesture();
4229 if (GetContentClient()->renderer()->AllowPopup()) 4235 if (GetContentClient()->renderer()->AllowPopup())
4230 params.user_gesture = true; 4236 params.user_gesture = true;
4231 4237
4232 if (policy == blink::WebNavigationPolicyNewBackgroundTab || 4238 if (policy == blink::WebNavigationPolicyNewBackgroundTab ||
4233 policy == blink::WebNavigationPolicyNewForegroundTab || 4239 policy == blink::WebNavigationPolicyNewForegroundTab ||
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
4523 4529
4524 #if defined(ENABLE_BROWSER_CDMS) 4530 #if defined(ENABLE_BROWSER_CDMS)
4525 RendererCdmManager* RenderFrameImpl::GetCdmManager() { 4531 RendererCdmManager* RenderFrameImpl::GetCdmManager() {
4526 if (!cdm_manager_) 4532 if (!cdm_manager_)
4527 cdm_manager_ = new RendererCdmManager(this); 4533 cdm_manager_ = new RendererCdmManager(this);
4528 return cdm_manager_; 4534 return cdm_manager_;
4529 } 4535 }
4530 #endif // defined(ENABLE_BROWSER_CDMS) 4536 #endif // defined(ENABLE_BROWSER_CDMS)
4531 4537
4532 } // namespace content 4538 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698