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

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

Issue 2323563002: Add a flag to require a user gesture to add an entry to the back/forward list. (Closed)
Patch Set: Rebase Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 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 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 documentLoader->replaceDocumentWhileExecutingJavaScriptURL(init, source); 367 documentLoader->replaceDocumentWhileExecutingJavaScriptURL(init, source);
368 } 368 }
369 369
370 void FrameLoader::clearProvisionalHistoryItem() 370 void FrameLoader::clearProvisionalHistoryItem()
371 { 371 {
372 m_provisionalItem.clear(); 372 m_provisionalItem.clear();
373 } 373 }
374 374
375 void FrameLoader::setHistoryItemStateForCommit(FrameLoadType loadType, HistoryCo mmitType historyCommitType, HistoryNavigationType navigationType) 375 void FrameLoader::setHistoryItemStateForCommit(FrameLoadType loadType, HistoryCo mmitType historyCommitType, HistoryNavigationType navigationType)
376 { 376 {
377 if (m_frame->settings()->historyEntryRequiresUserGesture() && historyCommitT ype == StandardCommit)
378 UserGestureIndicator::clearProcessedUserGestureSinceLoad();
379
377 HistoryItem* oldItem = m_currentItem; 380 HistoryItem* oldItem = m_currentItem;
378 if (isBackForwardLoadType(loadType) && m_provisionalItem) 381 if (isBackForwardLoadType(loadType) && m_provisionalItem)
379 m_currentItem = m_provisionalItem.release(); 382 m_currentItem = m_provisionalItem.release();
380 else 383 else
381 m_currentItem = HistoryItem::create(); 384 m_currentItem = HistoryItem::create();
382 m_currentItem->setURL(m_documentLoader->urlForHistory()); 385 m_currentItem->setURL(m_documentLoader->urlForHistory());
383 m_currentItem->setDocumentState(m_frame->document()->formElementsState()); 386 m_currentItem->setDocumentState(m_frame->document()->formElementsState());
384 m_currentItem->setTarget(m_frame->tree().uniqueName()); 387 m_currentItem->setTarget(m_frame->tree().uniqueName());
385 m_currentItem->setReferrer(SecurityPolicy::generateReferrer(m_documentLoader ->request().getReferrerPolicy(), m_currentItem->url(), m_documentLoader->request ().httpReferrer())); 388 m_currentItem->setReferrer(SecurityPolicy::generateReferrer(m_documentLoader ->request().getReferrerPolicy(), m_currentItem->url(), m_documentLoader->request ().httpReferrer()));
386 m_currentItem->setFormInfoFromRequest(m_documentLoader->request()); 389 m_currentItem->setFormInfoFromRequest(m_documentLoader->request());
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
718 721
719 // Generate start and stop notifications only when loader is completed so th at we 722 // Generate start and stop notifications only when loader is completed so th at we
720 // don't fire them for fragment redirection that happens in window.onload ha ndler. 723 // don't fire them for fragment redirection that happens in window.onload ha ndler.
721 // See https://bugs.webkit.org/show_bug.cgi?id=31838 724 // See https://bugs.webkit.org/show_bug.cgi?id=31838
722 if (m_frame->document()->loadEventFinished()) 725 if (m_frame->document()->loadEventFinished())
723 client()->didStartLoading(NavigationWithinSameDocument); 726 client()->didStartLoading(NavigationWithinSameDocument);
724 727
725 HistoryCommitType historyCommitType = loadTypeToCommitType(type); 728 HistoryCommitType historyCommitType = loadTypeToCommitType(type);
726 if (!m_currentItem) 729 if (!m_currentItem)
727 historyCommitType = HistoryInertCommit; 730 historyCommitType = HistoryInertCommit;
731 if (m_frame->settings()->historyEntryRequiresUserGesture() && !UserGestureIn dicator::processedUserGestureSinceLoad() && initiatingDocument)
732 historyCommitType = HistoryInertCommit;
728 733
729 setHistoryItemStateForCommit(type, historyCommitType, sameDocumentNavigation Source == SameDocumentNavigationHistoryApi ? HistoryNavigationType::HistoryApi : HistoryNavigationType::Fragment); 734 setHistoryItemStateForCommit(type, historyCommitType, sameDocumentNavigation Source == SameDocumentNavigationHistoryApi ? HistoryNavigationType::HistoryApi : HistoryNavigationType::Fragment);
730 if (sameDocumentNavigationSource == SameDocumentNavigationHistoryApi) { 735 if (sameDocumentNavigationSource == SameDocumentNavigationHistoryApi) {
731 m_currentItem->setStateObject(std::move(data)); 736 m_currentItem->setStateObject(std::move(data));
732 m_currentItem->setScrollRestorationType(scrollRestorationType); 737 m_currentItem->setScrollRestorationType(scrollRestorationType);
733 } 738 }
734 client()->dispatchDidNavigateWithinPage(m_currentItem.get(), historyCommitTy pe, !!initiatingDocument); 739 client()->dispatchDidNavigateWithinPage(m_currentItem.get(), historyCommitTy pe, !!initiatingDocument);
735 client()->dispatchDidReceiveTitle(m_frame->document()->title()); 740 client()->dispatchDidReceiveTitle(m_frame->document()->title());
736 if (m_frame->document()->loadEventFinished()) 741 if (m_frame->document()->loadEventFinished())
737 client()->didStopLoading(); 742 client()->didStopLoading();
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
831 return FrameLoadTypeReplaceCurrentItem; 836 return FrameLoadTypeReplaceCurrentItem;
832 837
833 if (request.resourceRequest().url() == m_documentLoader->urlForHistory()) { 838 if (request.resourceRequest().url() == m_documentLoader->urlForHistory()) {
834 if (!request.originDocument()) 839 if (!request.originDocument())
835 return FrameLoadTypeReloadMainResource; 840 return FrameLoadTypeReloadMainResource;
836 return request.resourceRequest().httpMethod() == HTTPNames::POST ? Frame LoadTypeStandard : FrameLoadTypeReplaceCurrentItem; 841 return request.resourceRequest().httpMethod() == HTTPNames::POST ? Frame LoadTypeStandard : FrameLoadTypeReplaceCurrentItem;
837 } 842 }
838 843
839 if (request.substituteData().failingURL() == m_documentLoader->urlForHistory () && m_loadType == FrameLoadTypeReload) 844 if (request.substituteData().failingURL() == m_documentLoader->urlForHistory () && m_loadType == FrameLoadTypeReload)
840 return FrameLoadTypeReload; 845 return FrameLoadTypeReload;
846
847 if (m_frame->settings()->historyEntryRequiresUserGesture() && !UserGestureIn dicator::processedUserGestureSinceLoad() && request.originDocument())
848 return FrameLoadTypeReplaceCurrentItem;
849
841 return FrameLoadTypeStandard; 850 return FrameLoadTypeStandard;
842 } 851 }
843 852
844 bool FrameLoader::prepareRequestForThisFrame(FrameLoadRequest& request) 853 bool FrameLoader::prepareRequestForThisFrame(FrameLoadRequest& request)
845 { 854 {
846 // If no origin Document* was specified, skip remaining security checks and assume the caller has fully initialized the FrameLoadRequest. 855 // If no origin Document* was specified, skip remaining security checks and assume the caller has fully initialized the FrameLoadRequest.
847 if (!request.originDocument()) 856 if (!request.originDocument())
848 return true; 857 return true;
849 858
850 KURL url = request.resourceRequest().url(); 859 KURL url = request.resourceRequest().url();
(...skipping 802 matching lines...) Expand 10 before | Expand all | Expand 10 after
1653 tracedValue->setString("documentLoaderURL", m_documentLoader ? m_documentLoa der->url() : String()); 1662 tracedValue->setString("documentLoaderURL", m_documentLoader ? m_documentLoa der->url() : String());
1654 return tracedValue; 1663 return tracedValue;
1655 } 1664 }
1656 1665
1657 inline void FrameLoader::takeObjectSnapshot() const 1666 inline void FrameLoader::takeObjectSnapshot() const
1658 { 1667 {
1659 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID("loading", "FrameLoader", this, toTraced Value()); 1668 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID("loading", "FrameLoader", this, toTraced Value());
1660 } 1669 }
1661 1670
1662 } // namespace blink 1671 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/frame/Settings.in ('k') | third_party/WebKit/Source/web/WebSettingsImpl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698