| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) | 3 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) |
| 4 * Copyright (C) 2009 Adam Barth. All rights reserved. | 4 * Copyright (C) 2009 Adam Barth. All rights reserved. |
| 5 * | 5 * |
| 6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
| 7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
| 8 * are met: | 8 * are met: |
| 9 * | 9 * |
| 10 * 1. Redistributions of source code must retain the above copyright | 10 * 1. Redistributions of source code must retain the above copyright |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 #include "wtf/OwnPtr.h" | 40 #include "wtf/OwnPtr.h" |
| 41 #include "wtf/PassOwnPtr.h" | 41 #include "wtf/PassOwnPtr.h" |
| 42 #include "wtf/PassRefPtr.h" | 42 #include "wtf/PassRefPtr.h" |
| 43 #include "wtf/text/WTFString.h" | 43 #include "wtf/text/WTFString.h" |
| 44 | 44 |
| 45 namespace blink { | 45 namespace blink { |
| 46 | 46 |
| 47 class Document; | 47 class Document; |
| 48 class FormSubmission; | 48 class FormSubmission; |
| 49 class LocalFrame; | 49 class LocalFrame; |
| 50 class NavigationScheduler; |
| 50 class ScheduledNavigation; | 51 class ScheduledNavigation; |
| 51 | 52 |
| 52 class NavigationDisablerForBeforeUnload { | 53 class NavigationDisablerForBeforeUnload { |
| 53 WTF_MAKE_NONCOPYABLE(NavigationDisablerForBeforeUnload); | 54 WTF_MAKE_NONCOPYABLE(NavigationDisablerForBeforeUnload); |
| 54 | 55 STACK_ALLOCATED(); |
| 55 public: | 56 public: |
| 56 NavigationDisablerForBeforeUnload() | 57 NavigationDisablerForBeforeUnload() |
| 57 { | 58 { |
| 58 s_navigationDisableCount++; | 59 s_navigationDisableCount++; |
| 59 } | 60 } |
| 60 ~NavigationDisablerForBeforeUnload() | 61 ~NavigationDisablerForBeforeUnload() |
| 61 { | 62 { |
| 62 ASSERT(s_navigationDisableCount); | 63 ASSERT(s_navigationDisableCount); |
| 63 s_navigationDisableCount--; | 64 s_navigationDisableCount--; |
| 64 } | 65 } |
| 65 static bool isNavigationAllowed() { return !s_navigationDisableCount; } | 66 static bool isNavigationAllowed() { return !s_navigationDisableCount; } |
| 66 | 67 |
| 67 private: | 68 private: |
| 68 static unsigned s_navigationDisableCount; | 69 static unsigned s_navigationDisableCount; |
| 69 }; | 70 }; |
| 70 | 71 |
| 72 class FrameNavigationDisabler { |
| 73 WTF_MAKE_NONCOPYABLE(FrameNavigationDisabler); |
| 74 STACK_ALLOCATED(); |
| 75 public: |
| 76 explicit FrameNavigationDisabler(LocalFrame*); |
| 77 ~FrameNavigationDisabler(); |
| 78 |
| 79 private: |
| 80 FrameNavigationDisabler() = delete; |
| 81 |
| 82 NavigationScheduler& m_navigationScheduler; |
| 83 }; |
| 84 |
| 71 class CORE_EXPORT NavigationScheduler final { | 85 class CORE_EXPORT NavigationScheduler final { |
| 72 WTF_MAKE_NONCOPYABLE(NavigationScheduler); | 86 WTF_MAKE_NONCOPYABLE(NavigationScheduler); |
| 73 DISALLOW_ALLOCATION(); | 87 DISALLOW_ALLOCATION(); |
| 74 public: | 88 public: |
| 75 explicit NavigationScheduler(LocalFrame*); | 89 explicit NavigationScheduler(LocalFrame*); |
| 76 ~NavigationScheduler(); | 90 ~NavigationScheduler(); |
| 77 | 91 |
| 78 bool locationChangePending(); | 92 bool locationChangePending(); |
| 79 | 93 |
| 80 void scheduleRedirect(double delay, const String& url); | 94 void scheduleRedirect(double delay, const String& url); |
| 81 void scheduleLocationChange(Document*, const String& url, bool lockBackForwa
rdList = true); | 95 void scheduleLocationChange(Document*, const String& url, bool lockBackForwa
rdList = true); |
| 82 void schedulePageBlock(Document*); | 96 void schedulePageBlock(Document*); |
| 83 void scheduleFormSubmission(Document*, PassRefPtrWillBeRawPtr<FormSubmission
>); | 97 void scheduleFormSubmission(Document*, PassRefPtrWillBeRawPtr<FormSubmission
>); |
| 84 void scheduleReload(); | 98 void scheduleReload(); |
| 85 | 99 |
| 86 void startTimer(); | 100 void startTimer(); |
| 87 void cancel(); | 101 void cancel(); |
| 88 | 102 |
| 89 DECLARE_TRACE(); | 103 DECLARE_TRACE(); |
| 90 | 104 |
| 91 private: | 105 private: |
| 106 friend class FrameNavigationDisabler; |
| 107 |
| 108 void disableFrameNavigation() { ++m_navigationDisableCount; } |
| 109 void enableFrameNavigation() { --m_navigationDisableCount; } |
| 110 bool isFrameNavigationAllowed() const { return !m_navigationDisableCount; } |
| 111 |
| 92 bool shouldScheduleReload() const; | 112 bool shouldScheduleReload() const; |
| 93 bool shouldScheduleNavigation(const String& url) const; | 113 bool shouldScheduleNavigation(const String& url) const; |
| 94 | 114 |
| 95 void timerFired(Timer<NavigationScheduler>*); | 115 void timerFired(Timer<NavigationScheduler>*); |
| 96 void schedule(PassOwnPtrWillBeRawPtr<ScheduledNavigation>); | 116 void schedule(PassOwnPtrWillBeRawPtr<ScheduledNavigation>); |
| 97 | 117 |
| 98 static bool mustLockBackForwardList(LocalFrame* targetFrame); | 118 static bool mustLockBackForwardList(LocalFrame* targetFrame); |
| 99 | 119 |
| 100 RawPtrWillBeMember<LocalFrame> m_frame; | 120 RawPtrWillBeMember<LocalFrame> m_frame; |
| 101 Timer<NavigationScheduler> m_timer; | 121 Timer<NavigationScheduler> m_timer; |
| 102 OwnPtrWillBeMember<ScheduledNavigation> m_redirect; | 122 OwnPtrWillBeMember<ScheduledNavigation> m_redirect; |
| 123 int m_navigationDisableCount; |
| 103 }; | 124 }; |
| 104 | 125 |
| 105 } // namespace blink | 126 } // namespace blink |
| 106 | 127 |
| 107 #endif // NavigationScheduler_h | 128 #endif // NavigationScheduler_h |
| OLD | NEW |