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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 #include "wtf/text/WTFString.h" | 42 #include "wtf/text/WTFString.h" |
43 | 43 |
44 namespace blink { | 44 namespace blink { |
45 | 45 |
46 class CancellableTaskFactory; | 46 class CancellableTaskFactory; |
47 class Document; | 47 class Document; |
48 class FormSubmission; | 48 class FormSubmission; |
49 class LocalFrame; | 49 class LocalFrame; |
50 class ScheduledNavigation; | 50 class ScheduledNavigation; |
51 | 51 |
52 class CORE_EXPORT NavigationScheduler final : public NoBaseWillBeGarbageCollecte
dFinalized<NavigationScheduler> { | 52 class CORE_EXPORT NavigationScheduler final : public GarbageCollectedFinalized<N
avigationScheduler> { |
53 WTF_MAKE_NONCOPYABLE(NavigationScheduler); | 53 WTF_MAKE_NONCOPYABLE(NavigationScheduler); |
54 USING_FAST_MALLOC_WILL_BE_REMOVED(NavigationScheduler); | |
55 public: | 54 public: |
56 static PassOwnPtrWillBeRawPtr<NavigationScheduler> create(LocalFrame* frame) | 55 static RawPtr<NavigationScheduler> create(LocalFrame* frame) |
57 { | 56 { |
58 return adoptPtrWillBeNoop(new NavigationScheduler(frame)); | 57 return new NavigationScheduler(frame); |
59 } | 58 } |
60 | 59 |
61 ~NavigationScheduler(); | 60 ~NavigationScheduler(); |
62 | 61 |
63 bool locationChangePending(); | 62 bool locationChangePending(); |
64 bool isNavigationScheduledWithin(double intervalInSeconds) const; | 63 bool isNavigationScheduledWithin(double intervalInSeconds) const; |
65 | 64 |
66 void scheduleRedirect(double delay, const String& url); | 65 void scheduleRedirect(double delay, const String& url); |
67 void scheduleLocationChange(Document*, const String& url, bool replacesCurre
ntItem = true); | 66 void scheduleLocationChange(Document*, const String& url, bool replacesCurre
ntItem = true); |
68 void schedulePageBlock(Document*); | 67 void schedulePageBlock(Document*); |
69 void scheduleFormSubmission(Document*, PassRefPtrWillBeRawPtr<FormSubmission
>); | 68 void scheduleFormSubmission(Document*, RawPtr<FormSubmission>); |
70 void scheduleReload(); | 69 void scheduleReload(); |
71 | 70 |
72 void startTimer(); | 71 void startTimer(); |
73 void cancel(); | 72 void cancel(); |
74 | 73 |
75 DECLARE_TRACE(); | 74 DECLARE_TRACE(); |
76 | 75 |
77 private: | 76 private: |
78 explicit NavigationScheduler(LocalFrame*); | 77 explicit NavigationScheduler(LocalFrame*); |
79 | 78 |
80 bool shouldScheduleReload() const; | 79 bool shouldScheduleReload() const; |
81 bool shouldScheduleNavigation(const String& url) const; | 80 bool shouldScheduleNavigation(const String& url) const; |
82 | 81 |
83 void navigateTask(); | 82 void navigateTask(); |
84 void schedule(PassOwnPtrWillBeRawPtr<ScheduledNavigation>); | 83 void schedule(RawPtr<ScheduledNavigation>); |
85 | 84 |
86 static bool mustReplaceCurrentItem(LocalFrame* targetFrame); | 85 static bool mustReplaceCurrentItem(LocalFrame* targetFrame); |
87 | 86 |
88 RawPtrWillBeMember<LocalFrame> m_frame; | 87 Member<LocalFrame> m_frame; |
89 OwnPtr<CancellableTaskFactory> m_navigateTaskFactory; | 88 OwnPtr<CancellableTaskFactory> m_navigateTaskFactory; |
90 OwnPtrWillBeMember<ScheduledNavigation> m_redirect; | 89 Member<ScheduledNavigation> m_redirect; |
91 }; | 90 }; |
92 | 91 |
93 class NavigationDisablerForBeforeUnload { | 92 class NavigationDisablerForBeforeUnload { |
94 WTF_MAKE_NONCOPYABLE(NavigationDisablerForBeforeUnload); | 93 WTF_MAKE_NONCOPYABLE(NavigationDisablerForBeforeUnload); |
95 STACK_ALLOCATED(); | 94 STACK_ALLOCATED(); |
96 public: | 95 public: |
97 NavigationDisablerForBeforeUnload() | 96 NavigationDisablerForBeforeUnload() |
98 { | 97 { |
99 s_navigationDisableCount++; | 98 s_navigationDisableCount++; |
100 } | 99 } |
101 ~NavigationDisablerForBeforeUnload() | 100 ~NavigationDisablerForBeforeUnload() |
102 { | 101 { |
103 ASSERT(s_navigationDisableCount); | 102 ASSERT(s_navigationDisableCount); |
104 s_navigationDisableCount--; | 103 s_navigationDisableCount--; |
105 } | 104 } |
106 static bool isNavigationAllowed() { return !s_navigationDisableCount; } | 105 static bool isNavigationAllowed() { return !s_navigationDisableCount; } |
107 | 106 |
108 private: | 107 private: |
109 static unsigned s_navigationDisableCount; | 108 static unsigned s_navigationDisableCount; |
110 }; | 109 }; |
111 | 110 |
112 } // namespace blink | 111 } // namespace blink |
113 | 112 |
114 #endif // NavigationScheduler_h | 113 #endif // NavigationScheduler_h |
OLD | NEW |