| 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 NavigationDisablerForBeforeUnload::s_navigationDisableCount = 0; |
| 56 | 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(); |
| 66 } |
| 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()) |
| 66 { | 77 { |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 { | 253 { |
| 243 ASSERT(m_submission->form()); | 254 ASSERT(m_submission->form()); |
| 244 } | 255 } |
| 245 | 256 |
| 246 RefPtrWillBeMember<FormSubmission> m_submission; | 257 RefPtrWillBeMember<FormSubmission> m_submission; |
| 247 }; | 258 }; |
| 248 | 259 |
| 249 NavigationScheduler::NavigationScheduler(LocalFrame* frame) | 260 NavigationScheduler::NavigationScheduler(LocalFrame* frame) |
| 250 : m_frame(frame) | 261 : m_frame(frame) |
| 251 , m_timer(this, &NavigationScheduler::timerFired) | 262 , m_timer(this, &NavigationScheduler::timerFired) |
| 263 , m_navigationDisableCount(0) |
| 252 { | 264 { |
| 253 } | 265 } |
| 254 | 266 |
| 255 NavigationScheduler::~NavigationScheduler() | 267 NavigationScheduler::~NavigationScheduler() |
| 256 { | 268 { |
| 257 } | 269 } |
| 258 | 270 |
| 259 bool NavigationScheduler::locationChangePending() | 271 bool NavigationScheduler::locationChangePending() |
| 260 { | 272 { |
| 261 return m_redirect && m_redirect->isLocationChange(); | 273 return m_redirect && m_redirect->isLocationChange(); |
| 262 } | 274 } |
| 263 | 275 |
| 264 inline bool NavigationScheduler::shouldScheduleReload() const | 276 inline bool NavigationScheduler::shouldScheduleReload() const |
| 265 { | 277 { |
| 266 return m_frame->page() && NavigationDisablerForBeforeUnload::isNavigationAll
owed(); | 278 return m_frame->page() && isFrameNavigationAllowed() && NavigationDisablerFo
rBeforeUnload::isNavigationAllowed(); |
| 267 } | 279 } |
| 268 | 280 |
| 269 inline bool NavigationScheduler::shouldScheduleNavigation(const String& url) con
st | 281 inline bool NavigationScheduler::shouldScheduleNavigation(const String& url) con
st |
| 270 { | 282 { |
| 271 return m_frame->page() && (protocolIsJavaScript(url) || NavigationDisablerFo
rBeforeUnload::isNavigationAllowed()); | 283 return m_frame->page() && isFrameNavigationAllowed() && (protocolIsJavaScrip
t(url) || NavigationDisablerForBeforeUnload::isNavigationAllowed()); |
| 272 } | 284 } |
| 273 | 285 |
| 274 void NavigationScheduler::scheduleRedirect(double delay, const String& url) | 286 void NavigationScheduler::scheduleRedirect(double delay, const String& url) |
| 275 { | 287 { |
| 276 if (!shouldScheduleNavigation(url)) | 288 if (!shouldScheduleNavigation(url)) |
| 277 return; | 289 return; |
| 278 if (delay < 0 || delay > INT_MAX / 1000) | 290 if (delay < 0 || delay > INT_MAX / 1000) |
| 279 return; | 291 return; |
| 280 if (url.isEmpty()) | 292 if (url.isEmpty()) |
| 281 return; | 293 return; |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 m_redirect.clear(); | 428 m_redirect.clear(); |
| 417 } | 429 } |
| 418 | 430 |
| 419 DEFINE_TRACE(NavigationScheduler) | 431 DEFINE_TRACE(NavigationScheduler) |
| 420 { | 432 { |
| 421 visitor->trace(m_frame); | 433 visitor->trace(m_frame); |
| 422 visitor->trace(m_redirect); | 434 visitor->trace(m_redirect); |
| 423 } | 435 } |
| 424 | 436 |
| 425 } // namespace blink | 437 } // namespace blink |
| OLD | NEW |