| 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. | 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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 int value = gestureToken && gestureToken->hasGestures() | 91 int value = gestureToken && gestureToken->hasGestures() |
| 92 ? type + ScheduledLastEntry | 92 ? type + ScheduledLastEntry |
| 93 : type; | 93 : type; |
| 94 scheduledNavigationClobberHistogram.count(value); | 94 scheduledNavigationClobberHistogram.count(value); |
| 95 | 95 |
| 96 DEFINE_STATIC_LOCAL( | 96 DEFINE_STATIC_LOCAL( |
| 97 CustomCountHistogram, scheduledClobberAbortTimeHistogram, | 97 CustomCountHistogram, scheduledClobberAbortTimeHistogram, |
| 98 ("Navigation.Scheduled.MaybeCausedAbort.Time", 1, 10000, 50)); | 98 ("Navigation.Scheduled.MaybeCausedAbort.Time", 1, 10000, 50)); |
| 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 } // namespace | 107 } // namespace |
| 107 | 108 |
| 108 unsigned NavigationDisablerForUnload::s_navigationDisableCount = 0; | 109 unsigned NavigationDisablerForUnload::s_navigationDisableCount = 0; |
| 109 | 110 |
| 110 class ScheduledNavigation | 111 class ScheduledNavigation |
| 111 : public GarbageCollectedFinalized<ScheduledNavigation> { | 112 : public GarbageCollectedFinalized<ScheduledNavigation> { |
| 112 WTF_MAKE_NONCOPYABLE(ScheduledNavigation); | 113 WTF_MAKE_NONCOPYABLE(ScheduledNavigation); |
| 113 | 114 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 const String& url, | 158 const String& url, |
| 158 bool replacesCurrentItem, | 159 bool replacesCurrentItem, |
| 159 bool isLocationChange) | 160 bool isLocationChange) |
| 160 : ScheduledNavigation(delay, | 161 : ScheduledNavigation(delay, |
| 161 originDocument, | 162 originDocument, |
| 162 replacesCurrentItem, | 163 replacesCurrentItem, |
| 163 isLocationChange), | 164 isLocationChange), |
| 164 m_url(url), | 165 m_url(url), |
| 165 m_shouldCheckMainWorldContentSecurityPolicy( | 166 m_shouldCheckMainWorldContentSecurityPolicy( |
| 166 CheckContentSecurityPolicy) { | 167 CheckContentSecurityPolicy) { |
| 167 if (ContentSecurityPolicy::shouldBypassMainWorld(originDocument)) | 168 if (ContentSecurityPolicy::shouldBypassMainWorld(originDocument)) { |
| 168 m_shouldCheckMainWorldContentSecurityPolicy = | 169 m_shouldCheckMainWorldContentSecurityPolicy = |
| 169 DoNotCheckContentSecurityPolicy; | 170 DoNotCheckContentSecurityPolicy; |
| 171 } |
| 170 } | 172 } |
| 171 | 173 |
| 172 void fire(LocalFrame* frame) override { | 174 void fire(LocalFrame* frame) override { |
| 173 std::unique_ptr<UserGestureIndicator> gestureIndicator = | 175 std::unique_ptr<UserGestureIndicator> gestureIndicator = |
| 174 createUserGestureIndicator(); | 176 createUserGestureIndicator(); |
| 175 FrameLoadRequest request(originDocument(), m_url, "_self", | 177 FrameLoadRequest request(originDocument(), m_url, "_self", |
| 176 m_shouldCheckMainWorldContentSecurityPolicy); | 178 m_shouldCheckMainWorldContentSecurityPolicy); |
| 177 request.setReplacesCurrentItem(replacesCurrentItem()); | 179 request.setReplacesCurrentItem(replacesCurrentItem()); |
| 178 request.setClientRedirect(ClientRedirectPolicy::ClientRedirect); | 180 request.setClientRedirect(ClientRedirectPolicy::ClientRedirect); |
| 179 | 181 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 204 bool shouldStartTimer(LocalFrame* frame) override { | 206 bool shouldStartTimer(LocalFrame* frame) override { |
| 205 return frame->document()->loadEventFinished(); | 207 return frame->document()->loadEventFinished(); |
| 206 } | 208 } |
| 207 | 209 |
| 208 void fire(LocalFrame* frame) override { | 210 void fire(LocalFrame* frame) override { |
| 209 std::unique_ptr<UserGestureIndicator> gestureIndicator = | 211 std::unique_ptr<UserGestureIndicator> gestureIndicator = |
| 210 createUserGestureIndicator(); | 212 createUserGestureIndicator(); |
| 211 FrameLoadRequest request(originDocument(), url(), "_self"); | 213 FrameLoadRequest request(originDocument(), url(), "_self"); |
| 212 request.setReplacesCurrentItem(replacesCurrentItem()); | 214 request.setReplacesCurrentItem(replacesCurrentItem()); |
| 213 if (equalIgnoringFragmentIdentifier(frame->document()->url(), | 215 if (equalIgnoringFragmentIdentifier(frame->document()->url(), |
| 214 request.resourceRequest().url())) | 216 request.resourceRequest().url())) { |
| 215 request.resourceRequest().setCachePolicy( | 217 request.resourceRequest().setCachePolicy( |
| 216 WebCachePolicy::ValidatingCacheData); | 218 WebCachePolicy::ValidatingCacheData); |
| 219 } |
| 217 request.setClientRedirect(ClientRedirectPolicy::ClientRedirect); | 220 request.setClientRedirect(ClientRedirectPolicy::ClientRedirect); |
| 218 maybeLogScheduledNavigationClobber( | 221 maybeLogScheduledNavigationClobber( |
| 219 ScheduledNavigationType::ScheduledRedirect, frame); | 222 ScheduledNavigationType::ScheduledRedirect, frame); |
| 220 frame->loader().load(request); | 223 frame->loader().load(request); |
| 221 } | 224 } |
| 222 | 225 |
| 223 private: | 226 private: |
| 224 ScheduledRedirect(double delay, | 227 ScheduledRedirect(double delay, |
| 225 Document* originDocument, | 228 Document* originDocument, |
| 226 const String& url, | 229 const String& url, |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 NavigationScheduler::NavigationScheduler(LocalFrame* frame) | 344 NavigationScheduler::NavigationScheduler(LocalFrame* frame) |
| 342 : m_frame(frame), | 345 : m_frame(frame), |
| 343 m_navigateTaskFactory( | 346 m_navigateTaskFactory( |
| 344 CancellableTaskFactory::create(this, | 347 CancellableTaskFactory::create(this, |
| 345 &NavigationScheduler::navigateTask)), | 348 &NavigationScheduler::navigateTask)), |
| 346 m_frameType(m_frame->isMainFrame() | 349 m_frameType(m_frame->isMainFrame() |
| 347 ? WebScheduler::NavigatingFrameType::kMainFrame | 350 ? WebScheduler::NavigatingFrameType::kMainFrame |
| 348 : WebScheduler::NavigatingFrameType::kChildFrame) {} | 351 : WebScheduler::NavigatingFrameType::kChildFrame) {} |
| 349 | 352 |
| 350 NavigationScheduler::~NavigationScheduler() { | 353 NavigationScheduler::~NavigationScheduler() { |
| 351 if (m_navigateTaskFactory->isPending()) | 354 if (m_navigateTaskFactory->isPending()) { |
| 352 Platform::current()->currentThread()->scheduler()->removePendingNavigation( | 355 Platform::current()->currentThread()->scheduler()->removePendingNavigation( |
| 353 m_frameType); | 356 m_frameType); |
| 357 } |
| 354 } | 358 } |
| 355 | 359 |
| 356 bool NavigationScheduler::locationChangePending() { | 360 bool NavigationScheduler::locationChangePending() { |
| 357 return m_redirect && m_redirect->isLocationChange(); | 361 return m_redirect && m_redirect->isLocationChange(); |
| 358 } | 362 } |
| 359 | 363 |
| 360 bool NavigationScheduler::isNavigationScheduledWithin(double interval) const { | 364 bool NavigationScheduler::isNavigationScheduledWithin(double interval) const { |
| 361 return m_redirect && m_redirect->delay() <= interval; | 365 return m_redirect && m_redirect->delay() <= interval; |
| 362 } | 366 } |
| 363 | 367 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 | 399 |
| 396 void NavigationScheduler::scheduleRedirect(double delay, const String& url) { | 400 void NavigationScheduler::scheduleRedirect(double delay, const String& url) { |
| 397 if (!shouldScheduleNavigation(url)) | 401 if (!shouldScheduleNavigation(url)) |
| 398 return; | 402 return; |
| 399 if (delay < 0 || delay > INT_MAX / 1000) | 403 if (delay < 0 || delay > INT_MAX / 1000) |
| 400 return; | 404 return; |
| 401 if (url.isEmpty()) | 405 if (url.isEmpty()) |
| 402 return; | 406 return; |
| 403 | 407 |
| 404 // We want a new back/forward list item if the refresh timeout is > 1 second. | 408 // We want a new back/forward list item if the refresh timeout is > 1 second. |
| 405 if (!m_redirect || delay <= m_redirect->delay()) | 409 if (!m_redirect || delay <= m_redirect->delay()) { |
| 406 schedule( | 410 schedule( |
| 407 ScheduledRedirect::create(delay, m_frame->document(), url, delay <= 1)); | 411 ScheduledRedirect::create(delay, m_frame->document(), url, delay <= 1)); |
| 412 } |
| 408 } | 413 } |
| 409 | 414 |
| 410 bool NavigationScheduler::mustReplaceCurrentItem(LocalFrame* targetFrame) { | 415 bool NavigationScheduler::mustReplaceCurrentItem(LocalFrame* targetFrame) { |
| 411 // Non-user navigation before the page has finished firing onload should not | 416 // Non-user navigation before the page has finished firing onload should not |
| 412 // create a new back/forward item. See https://webkit.org/b/42861 for the | 417 // create a new back/forward item. See https://webkit.org/b/42861 for the |
| 413 // original motivation for this. | 418 // original motivation for this. |
| 414 if (!targetFrame->document()->loadEventFinished() && | 419 if (!targetFrame->document()->loadEventFinished() && |
| 415 !UserGestureIndicator::utilizeUserGesture()) | 420 !UserGestureIndicator::utilizeUserGesture()) |
| 416 return true; | 421 return true; |
| 417 | 422 |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 544 m_navigateTaskFactory->cancel(); | 549 m_navigateTaskFactory->cancel(); |
| 545 m_redirect.clear(); | 550 m_redirect.clear(); |
| 546 } | 551 } |
| 547 | 552 |
| 548 DEFINE_TRACE(NavigationScheduler) { | 553 DEFINE_TRACE(NavigationScheduler) { |
| 549 visitor->trace(m_frame); | 554 visitor->trace(m_frame); |
| 550 visitor->trace(m_redirect); | 555 visitor->trace(m_redirect); |
| 551 } | 556 } |
| 552 | 557 |
| 553 } // namespace blink | 558 } // namespace blink |
| OLD | NEW |