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

Side by Side Diff: third_party/WebKit/Source/core/loader/FrameLoader.cpp

Issue 2148313002: Fix setHistoryItemStateForCommit for back/forward in subframes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Initial commit Created 4 years, 5 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 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv ed. 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv ed.
3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
4 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 4 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
5 * Copyright (C) 2008 Alp Toker <alp@atoker.com> 5 * Copyright (C) 2008 Alp Toker <alp@atoker.com>
6 * Copyright (C) Research In Motion Limited 2009. All rights reserved. 6 * Copyright (C) Research In Motion Limited 2009. All rights reserved.
7 * Copyright (C) 2011 Kris Jordan <krisjordan@gmail.com> 7 * Copyright (C) 2011 Kris Jordan <krisjordan@gmail.com>
8 * Copyright (C) 2011 Google Inc. All rights reserved. 8 * Copyright (C) 2011 Google Inc. All rights reserved.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 } 356 }
357 357
358 void FrameLoader::receivedMainResourceRedirect(const KURL& newURL) 358 void FrameLoader::receivedMainResourceRedirect(const KURL& newURL)
359 { 359 {
360 client()->dispatchDidReceiveServerRedirectForProvisionalLoad(); 360 client()->dispatchDidReceiveServerRedirectForProvisionalLoad();
361 // If a back/forward navigation redirects cross-origin, don't reuse any stat e from the HistoryItem. 361 // If a back/forward navigation redirects cross-origin, don't reuse any stat e from the HistoryItem.
362 if (m_provisionalItem && !SecurityOrigin::create(m_provisionalItem->url())-> isSameSchemeHostPort(SecurityOrigin::create(newURL).get())) 362 if (m_provisionalItem && !SecurityOrigin::create(m_provisionalItem->url())-> isSameSchemeHostPort(SecurityOrigin::create(newURL).get()))
363 m_provisionalItem.clear(); 363 m_provisionalItem.clear();
364 } 364 }
365 365
366 void FrameLoader::setHistoryItemStateForCommit(HistoryCommitType historyCommitTy pe, HistoryNavigationType navigationType) 366 void FrameLoader::setHistoryItemStateForCommit(FrameLoadType loadType, HistoryCo mmitType historyCommitType, HistoryNavigationType navigationType)
367 { 367 {
368 HistoryItem* oldItem = m_currentItem; 368 HistoryItem* oldItem = m_currentItem;
369 if (historyCommitType == BackForwardCommit && m_provisionalItem) 369 if (isBackForwardLoadType(loadType) && m_provisionalItem)
Charlie Reis 2016/07/14 20:45:47 It's non-trivial to write a isBackForwardCommitTyp
alexmos 2016/07/14 23:03:27 Acknowledged, either approach seems fine to me. T
370 m_currentItem = m_provisionalItem.release(); 370 m_currentItem = m_provisionalItem.release();
371 else 371 else
372 m_currentItem = HistoryItem::create(); 372 m_currentItem = HistoryItem::create();
373 m_currentItem->setURL(m_documentLoader->urlForHistory()); 373 m_currentItem->setURL(m_documentLoader->urlForHistory());
374 m_currentItem->setDocumentState(m_frame->document()->formElementsState()); 374 m_currentItem->setDocumentState(m_frame->document()->formElementsState());
375 m_currentItem->setTarget(m_frame->tree().uniqueName()); 375 m_currentItem->setTarget(m_frame->tree().uniqueName());
376 m_currentItem->setReferrer(SecurityPolicy::generateReferrer(m_documentLoader ->request().getReferrerPolicy(), m_currentItem->url(), m_documentLoader->request ().httpReferrer())); 376 m_currentItem->setReferrer(SecurityPolicy::generateReferrer(m_documentLoader ->request().getReferrerPolicy(), m_currentItem->url(), m_documentLoader->request ().httpReferrer()));
377 m_currentItem->setFormInfoFromRequest(m_documentLoader->request()); 377 m_currentItem->setFormInfoFromRequest(m_documentLoader->request());
378 378
379 // Don't propagate state from the old item to the new item if there isn't an old item (obviously), 379 // Don't propagate state from the old item to the new item if there isn't an old item (obviously),
380 // or if this is a back/forward navigation, since we explicitly want to rest ore the state we just 380 // or if this is a back/forward navigation, since we explicitly want to rest ore the state we just
381 // committed. 381 // committed.
382 if (!oldItem || historyCommitType == BackForwardCommit) 382 if (!oldItem || isBackForwardLoadType(loadType))
383 return; 383 return;
384 // Don't propagate state from the old item if this is a different-document n avigation, unless the before 384 // Don't propagate state from the old item if this is a different-document n avigation, unless the before
385 // and after pages are logically related. This means they have the same url (ignoring fragment) and 385 // and after pages are logically related. This means they have the same url (ignoring fragment) and
386 // the new item was loaded via reload or client redirect. 386 // the new item was loaded via reload or client redirect.
387 if (navigationType == HistoryNavigationType::DifferentDocument && (historyCo mmitType != HistoryInertCommit || !equalIgnoringFragmentIdentifier(oldItem->url( ), m_currentItem->url()))) 387 if (navigationType == HistoryNavigationType::DifferentDocument && (historyCo mmitType != HistoryInertCommit || !equalIgnoringFragmentIdentifier(oldItem->url( ), m_currentItem->url())))
388 return; 388 return;
389 m_currentItem->setDocumentSequenceNumber(oldItem->documentSequenceNumber()); 389 m_currentItem->setDocumentSequenceNumber(oldItem->documentSequenceNumber());
390 m_currentItem->setScrollPoint(oldItem->scrollPoint()); 390 m_currentItem->setScrollPoint(oldItem->scrollPoint());
391 m_currentItem->setVisualViewportScrollPoint(oldItem->visualViewportScrollPoi nt()); 391 m_currentItem->setVisualViewportScrollPoint(oldItem->visualViewportScrollPoi nt());
392 m_currentItem->setPageScaleFactor(oldItem->pageScaleFactor()); 392 m_currentItem->setPageScaleFactor(oldItem->pageScaleFactor());
(...skipping 28 matching lines...) Expand all
421 void FrameLoader::receivedFirstData() 421 void FrameLoader::receivedFirstData()
422 { 422 {
423 if (m_stateMachine.creatingInitialEmptyDocument()) 423 if (m_stateMachine.creatingInitialEmptyDocument())
424 return; 424 return;
425 425
426 HistoryCommitType historyCommitType = loadTypeToCommitType(m_loadType); 426 HistoryCommitType historyCommitType = loadTypeToCommitType(m_loadType);
427 if (historyCommitType == StandardCommit && (m_documentLoader->urlForHistory( ).isEmpty() || (opener() && !m_currentItem && m_documentLoader->originalRequest( ).url().isEmpty()))) 427 if (historyCommitType == StandardCommit && (m_documentLoader->urlForHistory( ).isEmpty() || (opener() && !m_currentItem && m_documentLoader->originalRequest( ).url().isEmpty())))
428 historyCommitType = HistoryInertCommit; 428 historyCommitType = HistoryInertCommit;
429 else if (historyCommitType == InitialCommitInChildFrame && MixedContentCheck er::isMixedContent(m_frame->tree().top()->securityContext()->getSecurityOrigin() , m_documentLoader->url())) 429 else if (historyCommitType == InitialCommitInChildFrame && MixedContentCheck er::isMixedContent(m_frame->tree().top()->securityContext()->getSecurityOrigin() , m_documentLoader->url()))
430 historyCommitType = HistoryInertCommit; 430 historyCommitType = HistoryInertCommit;
431 setHistoryItemStateForCommit(historyCommitType, HistoryNavigationType::Diffe rentDocument); 431 setHistoryItemStateForCommit(m_loadType, historyCommitType, HistoryNavigatio nType::DifferentDocument);
432 432
433 if (!m_stateMachine.committedMultipleRealLoads() && m_loadType == FrameLoadT ypeStandard) 433 if (!m_stateMachine.committedMultipleRealLoads() && m_loadType == FrameLoadT ypeStandard)
434 m_stateMachine.advanceTo(FrameLoaderStateMachine::CommittedMultipleRealL oads); 434 m_stateMachine.advanceTo(FrameLoaderStateMachine::CommittedMultipleRealL oads);
435 435
436 client()->dispatchDidCommitLoad(m_currentItem.get(), historyCommitType); 436 client()->dispatchDidCommitLoad(m_currentItem.get(), historyCommitType);
437 437
438 // When the embedder gets notified (above) that the new navigation has 438 // When the embedder gets notified (above) that the new navigation has
439 // committed, the embedder will drop the old Content Security Policy and 439 // committed, the embedder will drop the old Content Security Policy and
440 // therefore now is a good time to report to the embedder the Content 440 // therefore now is a good time to report to the embedder the Content
441 // Security Policies that have accumulated so far for the new navigation. 441 // Security Policies that have accumulated so far for the new navigation.
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
707 // Generate start and stop notifications only when loader is completed so th at we 707 // Generate start and stop notifications only when loader is completed so th at we
708 // don't fire them for fragment redirection that happens in window.onload ha ndler. 708 // don't fire them for fragment redirection that happens in window.onload ha ndler.
709 // See https://bugs.webkit.org/show_bug.cgi?id=31838 709 // See https://bugs.webkit.org/show_bug.cgi?id=31838
710 if (m_frame->document()->loadEventFinished()) 710 if (m_frame->document()->loadEventFinished())
711 client()->didStartLoading(NavigationWithinSameDocument); 711 client()->didStartLoading(NavigationWithinSameDocument);
712 712
713 HistoryCommitType historyCommitType = loadTypeToCommitType(type); 713 HistoryCommitType historyCommitType = loadTypeToCommitType(type);
714 if (!m_currentItem) 714 if (!m_currentItem)
715 historyCommitType = HistoryInertCommit; 715 historyCommitType = HistoryInertCommit;
716 716
717 setHistoryItemStateForCommit(historyCommitType, sameDocumentNavigationSource == SameDocumentNavigationHistoryApi ? HistoryNavigationType::HistoryApi : Histo ryNavigationType::Fragment); 717 setHistoryItemStateForCommit(type, historyCommitType, sameDocumentNavigation Source == SameDocumentNavigationHistoryApi ? HistoryNavigationType::HistoryApi : HistoryNavigationType::Fragment);
718 if (sameDocumentNavigationSource == SameDocumentNavigationHistoryApi) { 718 if (sameDocumentNavigationSource == SameDocumentNavigationHistoryApi) {
719 m_currentItem->setStateObject(data); 719 m_currentItem->setStateObject(data);
720 m_currentItem->setScrollRestorationType(scrollRestorationType); 720 m_currentItem->setScrollRestorationType(scrollRestorationType);
721 } 721 }
722 client()->dispatchDidNavigateWithinPage(m_currentItem.get(), historyCommitTy pe, !!initiatingDocument); 722 client()->dispatchDidNavigateWithinPage(m_currentItem.get(), historyCommitTy pe, !!initiatingDocument);
723 client()->dispatchDidReceiveTitle(m_frame->document()->title()); 723 client()->dispatchDidReceiveTitle(m_frame->document()->title());
724 if (m_frame->document()->loadEventFinished()) 724 if (m_frame->document()->loadEventFinished())
725 client()->didStopLoading(); 725 client()->didStopLoading();
726 } 726 }
727 727
(...skipping 885 matching lines...) Expand 10 before | Expand all | Expand 10 after
1613 tracedValue->setString("documentLoaderURL", m_documentLoader ? m_documentLoa der->url() : String()); 1613 tracedValue->setString("documentLoaderURL", m_documentLoader ? m_documentLoa der->url() : String());
1614 return tracedValue; 1614 return tracedValue;
1615 } 1615 }
1616 1616
1617 inline void FrameLoader::takeObjectSnapshot() const 1617 inline void FrameLoader::takeObjectSnapshot() const
1618 { 1618 {
1619 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID("loading", "FrameLoader", this, toTraced Value()); 1619 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID("loading", "FrameLoader", this, toTraced Value());
1620 } 1620 }
1621 1621
1622 } // namespace blink 1622 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698