Chromium Code Reviews| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 45 #include "core/loader/FrameLoader.h" | 45 #include "core/loader/FrameLoader.h" |
| 46 #include "core/loader/FrameLoaderClient.h" | 46 #include "core/loader/FrameLoaderClient.h" |
| 47 #include "core/loader/FrameLoaderStateMachine.h" | 47 #include "core/loader/FrameLoaderStateMachine.h" |
| 48 #include "core/page/Page.h" | 48 #include "core/page/Page.h" |
| 49 #include "platform/SharedBuffer.h" | 49 #include "platform/SharedBuffer.h" |
| 50 #include "platform/UserGestureIndicator.h" | 50 #include "platform/UserGestureIndicator.h" |
| 51 #include "wtf/CurrentTime.h" | 51 #include "wtf/CurrentTime.h" |
| 52 | 52 |
| 53 namespace blink { | 53 namespace blink { |
| 54 | 54 |
| 55 unsigned NavigationDisablerForBeforeUnload::s_navigationDisableCount = 0; | 55 unsigned NavigationDisabler::s_navigationDisableCount = 0; |
| 56 | |
| 57 FrameNavigationDisabler::FrameNavigationDisabler(LocalFrame* frame) | |
| 58 : m_navigationScheduler(frame->navigationScheduler()) | |
| 59 { | |
| 60 m_navigationScheduler.disableFrameNavigation(); | |
| 61 } | |
| 62 | |
| 63 FrameNavigationDisabler::~FrameNavigationDisabler() | |
| 64 { | |
| 65 m_navigationScheduler.enableFrameNavigation(); | |
|
Nate Chapin
2015/06/09 00:15:20
Is it possible for NavigationScheduler to be delet
michaeln
2015/06/09 01:15:02
Not as currently used at its only callsite. It's u
| |
| 66 } | |
| 56 | 67 |
| 57 class ScheduledNavigation : public NoBaseWillBeGarbageCollectedFinalized<Schedul edNavigation> { | 68 class ScheduledNavigation : public NoBaseWillBeGarbageCollectedFinalized<Schedul edNavigation> { |
| 58 WTF_MAKE_NONCOPYABLE(ScheduledNavigation); WTF_MAKE_FAST_ALLOCATED_WILL_BE_R EMOVED(ScheduledNavigation); | 69 WTF_MAKE_NONCOPYABLE(ScheduledNavigation); WTF_MAKE_FAST_ALLOCATED_WILL_BE_R EMOVED(ScheduledNavigation); |
| 59 public: | 70 public: |
| 60 ScheduledNavigation(double delay, Document* originDocument, bool lockBackFor wardList, bool isLocationChange) | 71 ScheduledNavigation(double delay, Document* originDocument, bool lockBackFor wardList, bool isLocationChange) |
| 61 : m_delay(delay) | 72 : m_delay(delay) |
| 62 , m_originDocument(originDocument) | 73 , m_originDocument(originDocument) |
| 63 , m_lockBackForwardList(lockBackForwardList) | 74 , m_lockBackForwardList(lockBackForwardList) |
| 64 , m_isLocationChange(isLocationChange) | 75 , m_isLocationChange(isLocationChange) |
| 65 , m_wasUserGesture(UserGestureIndicator::processingUserGesture()) | 76 , m_wasUserGesture(UserGestureIndicator::processingUserGesture()) |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 256 { | 267 { |
| 257 } | 268 } |
| 258 | 269 |
| 259 bool NavigationScheduler::locationChangePending() | 270 bool NavigationScheduler::locationChangePending() |
| 260 { | 271 { |
| 261 return m_redirect && m_redirect->isLocationChange(); | 272 return m_redirect && m_redirect->isLocationChange(); |
| 262 } | 273 } |
| 263 | 274 |
| 264 inline bool NavigationScheduler::shouldScheduleReload() const | 275 inline bool NavigationScheduler::shouldScheduleReload() const |
| 265 { | 276 { |
| 266 return m_frame->page() && NavigationDisablerForBeforeUnload::isNavigationAll owed(); | 277 return m_frame->page() && isFrameNavigationAllowed() && NavigationDisabler:: isNavigationAllowed(); |
| 267 } | 278 } |
| 268 | 279 |
| 269 inline bool NavigationScheduler::shouldScheduleNavigation(const String& url) con st | 280 inline bool NavigationScheduler::shouldScheduleNavigation(const String& url) con st |
| 270 { | 281 { |
| 271 return m_frame->page() && (protocolIsJavaScript(url) || NavigationDisablerFo rBeforeUnload::isNavigationAllowed()); | 282 return m_frame->page() && isFrameNavigationAllowed() && (protocolIsJavaScrip t(url) || NavigationDisabler::isNavigationAllowed()); |
| 272 } | 283 } |
| 273 | 284 |
| 274 void NavigationScheduler::scheduleRedirect(double delay, const String& url) | 285 void NavigationScheduler::scheduleRedirect(double delay, const String& url) |
| 275 { | 286 { |
| 276 if (!shouldScheduleNavigation(url)) | 287 if (!shouldScheduleNavigation(url)) |
| 277 return; | 288 return; |
| 278 if (delay < 0 || delay > INT_MAX / 1000) | 289 if (delay < 0 || delay > INT_MAX / 1000) |
| 279 return; | 290 return; |
| 280 if (url.isEmpty()) | 291 if (url.isEmpty()) |
| 281 return; | 292 return; |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 416 m_redirect.clear(); | 427 m_redirect.clear(); |
| 417 } | 428 } |
| 418 | 429 |
| 419 DEFINE_TRACE(NavigationScheduler) | 430 DEFINE_TRACE(NavigationScheduler) |
| 420 { | 431 { |
| 421 visitor->trace(m_frame); | 432 visitor->trace(m_frame); |
| 422 visitor->trace(m_redirect); | 433 visitor->trace(m_redirect); |
| 423 } | 434 } |
| 424 | 435 |
| 425 } // namespace blink | 436 } // namespace blink |
| OLD | NEW |