| OLD | NEW |
| 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. (http://www.t
orchmobile.com/) | 4 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) |
| 5 * Copyright (C) 2009 Adam Barth. All rights reserved. | 5 * Copyright (C) 2009 Adam Barth. All rights reserved. |
| 6 * | 6 * |
| 7 * Redistribution and use in source and binary forms, with or without | 7 * Redistribution and use in source and binary forms, with or without |
| 8 * modification, are permitted provided that the following conditions | 8 * modification, are permitted provided that the following conditions |
| 9 * are met: | 9 * are met: |
| 10 * | 10 * |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 | 90 |
| 91 DEFINE_STATIC_LOCAL(CustomCountHistogram, scheduledClobberAbortTimeHistogram
, ("Navigation.Scheduled.MaybeCausedAbort.Time", 1, 10000, 50)); | 91 DEFINE_STATIC_LOCAL(CustomCountHistogram, scheduledClobberAbortTimeHistogram
, ("Navigation.Scheduled.MaybeCausedAbort.Time", 1, 10000, 50)); |
| 92 double navigationStart = frame->loader().provisionalDocumentLoader()->timing
().navigationStart(); | 92 double navigationStart = frame->loader().provisionalDocumentLoader()->timing
().navigationStart(); |
| 93 if (navigationStart) | 93 if (navigationStart) |
| 94 scheduledClobberAbortTimeHistogram.count(monotonicallyIncreasingTime() -
navigationStart); | 94 scheduledClobberAbortTimeHistogram.count(monotonicallyIncreasingTime() -
navigationStart); |
| 95 } | 95 } |
| 96 | 96 |
| 97 } // namespace | 97 } // namespace |
| 98 | 98 |
| 99 unsigned NavigationDisablerForBeforeUnload::s_navigationDisableCount = 0; | 99 unsigned NavigationDisablerForBeforeUnload::s_navigationDisableCount = 0; |
| 100 unsigned NavigationCounterForUnload::s_inUnloadHandler = 0; | 100 unsigned NavigationDisablerForUnload::s_inUnloadHandler = 0; |
| 101 | 101 |
| 102 class ScheduledNavigation : public GarbageCollectedFinalized<ScheduledNavigation
> { | 102 class ScheduledNavigation : public GarbageCollectedFinalized<ScheduledNavigation
> { |
| 103 WTF_MAKE_NONCOPYABLE(ScheduledNavigation); | 103 WTF_MAKE_NONCOPYABLE(ScheduledNavigation); |
| 104 public: | 104 public: |
| 105 ScheduledNavigation(double delay, Document* originDocument, bool replacesCur
rentItem, bool isLocationChange) | 105 ScheduledNavigation(double delay, Document* originDocument, bool replacesCur
rentItem, bool isLocationChange) |
| 106 : m_delay(delay) | 106 : m_delay(delay) |
| 107 , m_originDocument(originDocument) | 107 , m_originDocument(originDocument) |
| 108 , m_replacesCurrentItem(replacesCurrentItem) | 108 , m_replacesCurrentItem(replacesCurrentItem) |
| 109 , m_isLocationChange(isLocationChange) | 109 , m_isLocationChange(isLocationChange) |
| 110 , m_wasUserGesture(UserGestureIndicator::processingUserGesture()) | 110 , m_wasUserGesture(UserGestureIndicator::processingUserGesture()) |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 // NavigationScheduler is always cleared when a new load commits, so it's | 336 // NavigationScheduler is always cleared when a new load commits, so it's |
| 337 // impossible for a scheduled navigation to clobber a navigation that just | 337 // impossible for a scheduled navigation to clobber a navigation that just |
| 338 // committed. | 338 // committed. |
| 339 // | 339 // |
| 340 // 2. FrameNavigationDisabler / LocalFrame::isNavigationAllowed() are intended | 340 // 2. FrameNavigationDisabler / LocalFrame::isNavigationAllowed() are intended |
| 341 // to prevent Documents from being reattached during destruction, since it | 341 // to prevent Documents from being reattached during destruction, since it |
| 342 // can cause bugs with security origin confusion. This is primarily intended | 342 // can cause bugs with security origin confusion. This is primarily intended |
| 343 // to block /synchronous/ navigations during things lke Document::detachLayou
tTree(). | 343 // to block /synchronous/ navigations during things lke Document::detachLayou
tTree(). |
| 344 inline bool NavigationScheduler::shouldScheduleReload() const | 344 inline bool NavigationScheduler::shouldScheduleReload() const |
| 345 { | 345 { |
| 346 return m_frame->page() && m_frame->isNavigationAllowed() && NavigationDisabl
erForBeforeUnload::isNavigationAllowed(); | 346 return m_frame->page() && m_frame->isNavigationAllowed() && NavigationDisabl
erForBeforeUnload::isNavigationAllowed() && !NavigationDisablerForUnload::inUnlo
adHandler(); |
| 347 } | 347 } |
| 348 | 348 |
| 349 inline bool NavigationScheduler::shouldScheduleNavigation(const String& url) con
st | 349 inline bool NavigationScheduler::shouldScheduleNavigation(const String& url) con
st |
| 350 { | 350 { |
| 351 return m_frame->page() && m_frame->isNavigationAllowed() && (protocolIsJavaS
cript(url) || NavigationDisablerForBeforeUnload::isNavigationAllowed()); | 351 return m_frame->page() && m_frame->isNavigationAllowed() && (protocolIsJavaS
cript(url) || NavigationDisablerForBeforeUnload::isNavigationAllowed()) && !Navi
gationDisablerForUnload::inUnloadHandler(); |
| 352 } | 352 } |
| 353 | 353 |
| 354 void NavigationScheduler::scheduleRedirect(double delay, const String& url) | 354 void NavigationScheduler::scheduleRedirect(double delay, const String& url) |
| 355 { | 355 { |
| 356 if (!shouldScheduleNavigation(url)) | 356 if (!shouldScheduleNavigation(url)) |
| 357 return; | 357 return; |
| 358 if (delay < 0 || delay > INT_MAX / 1000) | 358 if (delay < 0 || delay > INT_MAX / 1000) |
| 359 return; | 359 return; |
| 360 if (url.isEmpty()) | 360 if (url.isEmpty()) |
| 361 return; | 361 return; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 386 | 386 |
| 387 replacesCurrentItem = replacesCurrentItem || mustReplaceCurrentItem(m_frame)
; | 387 replacesCurrentItem = replacesCurrentItem || mustReplaceCurrentItem(m_frame)
; |
| 388 | 388 |
| 389 // If the URL we're going to navigate to is the same as the current one, exc
ept for the | 389 // If the URL we're going to navigate to is the same as the current one, exc
ept for the |
| 390 // fragment part, we don't need to schedule the location change. We'll skip
this | 390 // fragment part, we don't need to schedule the location change. We'll skip
this |
| 391 // optimization for cross-origin navigations to minimize the navigator's abi
lity to | 391 // optimization for cross-origin navigations to minimize the navigator's abi
lity to |
| 392 // execute timing attacks. | 392 // execute timing attacks. |
| 393 if (originDocument->getSecurityOrigin()->canAccess(m_frame->document()->getS
ecurityOrigin())) { | 393 if (originDocument->getSecurityOrigin()->canAccess(m_frame->document()->getS
ecurityOrigin())) { |
| 394 KURL parsedURL(ParsedURLString, url); | 394 KURL parsedURL(ParsedURLString, url); |
| 395 if (parsedURL.hasFragmentIdentifier() && equalIgnoringFragmentIdentifier
(m_frame->document()->url(), parsedURL)) { | 395 if (parsedURL.hasFragmentIdentifier() && equalIgnoringFragmentIdentifier
(m_frame->document()->url(), parsedURL)) { |
| 396 if (NavigationCounterForUnload::inUnloadHandler()) | |
| 397 Deprecation::countDeprecation(m_frame, UseCounter::UnloadHandler
_Navigation); | |
| 398 | 396 |
| 399 FrameLoadRequest request(originDocument, m_frame->document()->comple
teURL(url), "_self"); | 397 FrameLoadRequest request(originDocument, m_frame->document()->comple
teURL(url), "_self"); |
| 400 request.setReplacesCurrentItem(replacesCurrentItem); | 398 request.setReplacesCurrentItem(replacesCurrentItem); |
| 401 if (replacesCurrentItem) | 399 if (replacesCurrentItem) |
| 402 request.setClientRedirect(ClientRedirectPolicy::ClientRedirect); | 400 request.setClientRedirect(ClientRedirectPolicy::ClientRedirect); |
| 403 m_frame->loader().load(request); | 401 m_frame->loader().load(request); |
| 404 return; | 402 return; |
| 405 } | 403 } |
| 406 } | 404 } |
| 407 | 405 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 494 m_redirect.clear(); | 492 m_redirect.clear(); |
| 495 } | 493 } |
| 496 | 494 |
| 497 DEFINE_TRACE(NavigationScheduler) | 495 DEFINE_TRACE(NavigationScheduler) |
| 498 { | 496 { |
| 499 visitor->trace(m_frame); | 497 visitor->trace(m_frame); |
| 500 visitor->trace(m_redirect); | 498 visitor->trace(m_redirect); |
| 501 } | 499 } |
| 502 | 500 |
| 503 } // namespace blink | 501 } // namespace blink |
| OLD | NEW |