NavigationScheduler.h [plain text]
#ifndef NavigationScheduler_h
#define NavigationScheduler_h
#include "Timer.h"
#include <wtf/Forward.h>
#include <wtf/Noncopyable.h>
#include <wtf/OwnPtr.h>
#include <wtf/PassOwnPtr.h>
#include <wtf/PassRefPtr.h>
namespace WebCore {
class FormSubmission;
class Frame;
class ScheduledNavigation;
class SecurityOrigin;
class NavigationDisablerForBeforeUnload {
WTF_MAKE_NONCOPYABLE(NavigationDisablerForBeforeUnload);
public:
NavigationDisablerForBeforeUnload()
{
s_navigationDisableCount++;
}
~NavigationDisablerForBeforeUnload()
{
ASSERT(s_navigationDisableCount);
s_navigationDisableCount--;
}
static bool isNavigationAllowed() { return !s_navigationDisableCount; }
private:
static unsigned s_navigationDisableCount;
};
class NavigationScheduler {
WTF_MAKE_NONCOPYABLE(NavigationScheduler);
public:
NavigationScheduler(Frame*);
~NavigationScheduler();
bool redirectScheduledDuringLoad();
bool locationChangePending();
void scheduleRedirect(double delay, const String& url);
void scheduleLocationChange(PassRefPtr<SecurityOrigin>, const String& url, const String& referrer, bool lockHistory = true, bool lockBackForwardList = true);
void scheduleFormSubmission(PassRefPtr<FormSubmission>);
void scheduleRefresh();
void scheduleHistoryNavigation(int steps);
void startTimer();
void cancel(bool newLoadInProgress = false);
void clear();
private:
bool shouldScheduleNavigation() const;
bool shouldScheduleNavigation(const String& url) const;
void timerFired(Timer<NavigationScheduler>*);
void schedule(PassOwnPtr<ScheduledNavigation>);
static bool mustLockBackForwardList(Frame* targetFrame);
Frame* m_frame;
Timer<NavigationScheduler> m_timer;
OwnPtr<ScheduledNavigation> m_redirect;
};
}
#endif // NavigationScheduler_h