| 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 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 return; | 415 return; |
| 416 | 416 |
| 417 OwnPtr<ScheduledNavigation> redirect(m_redirect.release()); | 417 OwnPtr<ScheduledNavigation> redirect(m_redirect.release()); |
| 418 redirect->fire(m_frame); | 418 redirect->fire(m_frame); |
| 419 } | 419 } |
| 420 | 420 |
| 421 void NavigationScheduler::schedule(PassOwnPtr<ScheduledNavigation> redirect) | 421 void NavigationScheduler::schedule(PassOwnPtr<ScheduledNavigation> redirect) |
| 422 { | 422 { |
| 423 ASSERT(m_frame->page()); | 423 ASSERT(m_frame->page()); |
| 424 | 424 |
| 425 RefPtr<Frame> protect(m_frame); |
| 426 |
| 425 // If a redirect was scheduled during a load, then stop the current load. | 427 // If a redirect was scheduled during a load, then stop the current load. |
| 426 // Otherwise when the current load transitions from a provisional to a | 428 // Otherwise when the current load transitions from a provisional to a |
| 427 // committed state, pending redirects may be cancelled. | 429 // committed state, pending redirects may be cancelled. |
| 428 if (redirect->wasDuringLoad()) { | 430 if (redirect->wasDuringLoad()) { |
| 429 if (DocumentLoader* provisionalDocumentLoader = m_frame->loader()->provi
sionalDocumentLoader()) | 431 if (DocumentLoader* provisionalDocumentLoader = m_frame->loader()->provi
sionalDocumentLoader()) |
| 430 provisionalDocumentLoader->stopLoading(); | 432 provisionalDocumentLoader->stopLoading(); |
| 431 m_frame->loader()->stopLoading(UnloadEventPolicyUnloadAndPageHide); | 433 m_frame->loader()->stopLoading(UnloadEventPolicyUnloadAndPageHide); |
| 432 } | 434 } |
| 433 | 435 |
| 434 cancel(); | 436 cancel(); |
| 435 m_redirect = redirect; | 437 m_redirect = redirect; |
| 436 | 438 |
| 437 if (!m_frame->loader()->isComplete() && m_redirect->isLocationChange()) | 439 if (!m_frame->loader()->isComplete() && m_redirect->isLocationChange()) |
| 438 m_frame->loader()->completed(); | 440 m_frame->loader()->completed(); |
| 439 | 441 |
| 442 if (!m_frame->page()) |
| 443 return; |
| 444 |
| 440 startTimer(); | 445 startTimer(); |
| 441 } | 446 } |
| 442 | 447 |
| 443 void NavigationScheduler::startTimer() | 448 void NavigationScheduler::startTimer() |
| 444 { | 449 { |
| 445 if (!m_redirect) | 450 if (!m_redirect) |
| 446 return; | 451 return; |
| 447 | 452 |
| 448 ASSERT(m_frame->page()); | 453 ASSERT(m_frame->page()); |
| 449 if (m_timer.isActive()) | 454 if (m_timer.isActive()) |
| 450 return; | 455 return; |
| 451 if (!m_redirect->shouldStartTimer(m_frame)) | 456 if (!m_redirect->shouldStartTimer(m_frame)) |
| 452 return; | 457 return; |
| 453 | 458 |
| 454 m_timer.startOneShot(m_redirect->delay()); | 459 m_timer.startOneShot(m_redirect->delay()); |
| 455 m_redirect->didStartTimer(m_frame, &m_timer); | 460 m_redirect->didStartTimer(m_frame, &m_timer); |
| 456 } | 461 } |
| 457 | 462 |
| 458 void NavigationScheduler::cancel(bool newLoadInProgress) | 463 void NavigationScheduler::cancel(bool newLoadInProgress) |
| 459 { | 464 { |
| 460 m_timer.stop(); | 465 m_timer.stop(); |
| 461 | 466 |
| 462 OwnPtr<ScheduledNavigation> redirect(m_redirect.release()); | 467 OwnPtr<ScheduledNavigation> redirect(m_redirect.release()); |
| 463 if (redirect) | 468 if (redirect) |
| 464 redirect->didStopTimer(m_frame, newLoadInProgress); | 469 redirect->didStopTimer(m_frame, newLoadInProgress); |
| 465 } | 470 } |
| 466 | 471 |
| 467 } // namespace WebCore | 472 } // namespace WebCore |
| OLD | NEW |