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

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

Issue 2487403002: Allow navigations to frames that aren't being unloaded in the unload handler. (Closed)
Patch Set: Created 4 years, 1 month 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 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
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. 4 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved.
5 * (http://www.torchmobile.com/) 5 * (http://www.torchmobile.com/)
6 * Copyright (C) 2009 Adam Barth. All rights reserved. 6 * Copyright (C) 2009 Adam Barth. All rights reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
10 * are met: 10 * are met:
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 double navigationStart = 99 double navigationStart =
100 frame->loader().provisionalDocumentLoader()->timing().navigationStart(); 100 frame->loader().provisionalDocumentLoader()->timing().navigationStart();
101 if (navigationStart) { 101 if (navigationStart) {
102 scheduledClobberAbortTimeHistogram.count(monotonicallyIncreasingTime() - 102 scheduledClobberAbortTimeHistogram.count(monotonicallyIncreasingTime() -
103 navigationStart); 103 navigationStart);
104 } 104 }
105 } 105 }
106 106
107 } // namespace 107 } // namespace
108 108
109 unsigned NavigationDisablerForUnload::s_navigationDisableCount = 0;
110
111 class ScheduledNavigation 109 class ScheduledNavigation
112 : public GarbageCollectedFinalized<ScheduledNavigation> { 110 : public GarbageCollectedFinalized<ScheduledNavigation> {
113 WTF_MAKE_NONCOPYABLE(ScheduledNavigation); 111 WTF_MAKE_NONCOPYABLE(ScheduledNavigation);
114 112
115 public: 113 public:
116 ScheduledNavigation(double delay, 114 ScheduledNavigation(double delay,
117 Document* originDocument, 115 Document* originDocument,
118 bool replacesCurrentItem, 116 bool replacesCurrentItem,
119 bool isLocationChange) 117 bool isLocationChange)
120 : m_delay(delay), 118 : m_delay(delay),
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 } 356 }
359 357
360 bool NavigationScheduler::locationChangePending() { 358 bool NavigationScheduler::locationChangePending() {
361 return m_redirect && m_redirect->isLocationChange(); 359 return m_redirect && m_redirect->isLocationChange();
362 } 360 }
363 361
364 bool NavigationScheduler::isNavigationScheduledWithin(double interval) const { 362 bool NavigationScheduler::isNavigationScheduledWithin(double interval) const {
365 return m_redirect && m_redirect->delay() <= interval; 363 return m_redirect && m_redirect->delay() <= interval;
366 } 364 }
367 365
368 // TODO(dcheng): There are really two different load blocking concepts at work
369 // here and they have been incorrectly tangled together.
370 //
371 // 1. NavigationDisablerForUnload is for blocking navigation scheduling during
372 // a beforeunload or unload events. Scheduled navigations during
373 // beforeunload would make it possible to get trapped in an endless loop of
374 // beforeunload dialogs. Scheduled navigations during the unload handler
375 // makes is possible to cancel a navigation that was initiated right before
376 // it commits.
377 //
378 // Checking Frame::isNavigationAllowed() doesn't make sense in this context:
379 // NavigationScheduler is always cleared when a new load commits, so it's
380 // impossible for a scheduled navigation to clobber a navigation that just
381 // committed.
382 //
383 // 2. FrameNavigationDisabler / LocalFrame::isNavigationAllowed() are intended
384 // to prevent Documents from being reattached during destruction, since it
385 // can cause bugs with security origin confusion. This is primarily intended
386 // to block /synchronous/ navigations during things lke
387 // Document::detachLayoutTree().
388 inline bool NavigationScheduler::shouldScheduleReload() const { 366 inline bool NavigationScheduler::shouldScheduleReload() const {
389 return m_frame->page() && m_frame->isNavigationAllowed() && 367 return m_frame->page() && m_frame->isNavigationAllowed();
390 NavigationDisablerForUnload::isNavigationAllowed();
391 } 368 }
392 369
393 inline bool NavigationScheduler::shouldScheduleNavigation( 370 inline bool NavigationScheduler::shouldScheduleNavigation(
394 const String& url) const { 371 const String& url) const {
395 return m_frame->page() && m_frame->isNavigationAllowed() && 372 return m_frame->page() && m_frame->isNavigationAllowed();
396 (protocolIsJavaScript(url) ||
397 NavigationDisablerForUnload::isNavigationAllowed());
398 } 373 }
399 374
400 void NavigationScheduler::scheduleRedirect(double delay, const String& url) { 375 void NavigationScheduler::scheduleRedirect(double delay, const String& url) {
401 if (!shouldScheduleNavigation(url)) 376 if (!shouldScheduleNavigation(url))
402 return; 377 return;
403 if (delay < 0 || delay > INT_MAX / 1000) 378 if (delay < 0 || delay > INT_MAX / 1000)
404 return; 379 return;
405 if (url.isEmpty()) 380 if (url.isEmpty())
406 return; 381 return;
407 382
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 m_navigateTaskFactory->cancel(); 524 m_navigateTaskFactory->cancel();
550 m_redirect.clear(); 525 m_redirect.clear();
551 } 526 }
552 527
553 DEFINE_TRACE(NavigationScheduler) { 528 DEFINE_TRACE(NavigationScheduler) {
554 visitor->trace(m_frame); 529 visitor->trace(m_frame);
555 visitor->trace(m_redirect); 530 visitor->trace(m_redirect);
556 } 531 }
557 532
558 } // namespace blink 533 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698