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

Unified Diff: third_party/WebKit/Source/core/dom/Document.cpp

Issue 2780953002: When historyEntryRequiresUserGesture is enabled, exempt docs that have been committed for 5 seconds (Closed)
Patch Set: Address ojan's comments Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/dom/Document.cpp
diff --git a/third_party/WebKit/Source/core/dom/Document.cpp b/third_party/WebKit/Source/core/dom/Document.cpp
index 43aaf0a8818e7d3dffa5b297bf1756910e408cac..7d1a15d2fdb92e8ac60ec11186a3e4ea0269a116 100644
--- a/third_party/WebKit/Source/core/dom/Document.cpp
+++ b/third_party/WebKit/Source/core/dom/Document.cpp
@@ -282,6 +282,10 @@ static const unsigned cMaxWriteRecursionDepth = 21;
// adequate, but a little high for dual G5s. :)
static const int cLayoutScheduleThreshold = 250;
+// After a document has been committed for this time, it can create a history
+// entry even if the user hasn't interacted with the document.
+static const int cElapsedTimeForHistoryEntryWithoutUserGestureMS = 5000;
+
// DOM Level 2 says (letters added):
//
// a) Name start characters must have one of the categories Ll, Lu, Lo, Lt, Nl.
@@ -3189,6 +3193,21 @@ int Document::elapsedTime() const {
return static_cast<int>((currentTime() - m_startTime) * 1000);
}
+bool Document::canCreateHistoryEntry() const {
+ // TODO(japhet): This flag controls an intervention to require a user gesture
+ // or a long time on page in order for a content-initiated navigation to add
+ // an entry to the back/forward list. Removing the flag and making this the
+ // default will require updating a couple hundred tests that currently depend
+ // on creating history entries without user gestures. I'm waiting to update
+ // the tests until the feature is proven to minimize churn.
+ // https://bugs.chromium.org/p/chromium/issues/detail?id=638198
+ if (!m_frame->settings()->getHistoryEntryRequiresUserGesture())
+ return true;
+ if (m_frame->hasReceivedUserGesture())
+ return true;
+ return elapsedTime() >= cElapsedTimeForHistoryEntryWithoutUserGestureMS;
+}
+
void Document::write(const SegmentedString& text,
Document* enteredDocument,
ExceptionState& exceptionState) {
« no previous file with comments | « third_party/WebKit/Source/core/dom/Document.h ('k') | third_party/WebKit/Source/core/loader/DocumentLoader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698