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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 WTF_MAKE_NONCOPYABLE(ScheduledNavigation); WTF_MAKE_FAST_ALLOCATED; | 59 WTF_MAKE_NONCOPYABLE(ScheduledNavigation); WTF_MAKE_FAST_ALLOCATED; |
60 public: | 60 public: |
61 ScheduledNavigation(double delay, bool lockHistory, bool lockBackForwardList
, bool wasDuringLoad, bool isLocationChange) | 61 ScheduledNavigation(double delay, bool lockHistory, bool lockBackForwardList
, bool wasDuringLoad, bool isLocationChange) |
62 : m_delay(delay) | 62 : m_delay(delay) |
63 , m_lockHistory(lockHistory) | 63 , m_lockHistory(lockHistory) |
64 , m_lockBackForwardList(lockBackForwardList) | 64 , m_lockBackForwardList(lockBackForwardList) |
65 , m_wasDuringLoad(wasDuringLoad) | 65 , m_wasDuringLoad(wasDuringLoad) |
66 , m_isLocationChange(isLocationChange) | 66 , m_isLocationChange(isLocationChange) |
67 , m_wasUserGesture(ScriptController::processingUserGesture()) | 67 , m_wasUserGesture(ScriptController::processingUserGesture()) |
68 { | 68 { |
| 69 if (m_wasUserGesture) |
| 70 m_userGestureToken = UserGestureIndicator::currentToken(); |
69 } | 71 } |
70 virtual ~ScheduledNavigation() { } | 72 virtual ~ScheduledNavigation() { } |
71 | 73 |
72 virtual void fire(Frame*) = 0; | 74 virtual void fire(Frame*) = 0; |
73 | 75 |
74 virtual bool shouldStartTimer(Frame*) { return true; } | 76 virtual bool shouldStartTimer(Frame*) { return true; } |
75 virtual void didStartTimer(Frame*, Timer<NavigationScheduler>*) { } | 77 virtual void didStartTimer(Frame*, Timer<NavigationScheduler>*) { } |
76 virtual void didStopTimer(Frame*) { } | 78 virtual void didStopTimer(Frame*) { } |
77 | 79 |
78 double delay() const { return m_delay; } | 80 double delay() const { return m_delay; } |
79 bool lockHistory() const { return m_lockHistory; } | 81 bool lockHistory() const { return m_lockHistory; } |
80 bool lockBackForwardList() const { return m_lockBackForwardList; } | 82 bool lockBackForwardList() const { return m_lockBackForwardList; } |
81 bool wasDuringLoad() const { return m_wasDuringLoad; } | 83 bool wasDuringLoad() const { return m_wasDuringLoad; } |
82 bool isLocationChange() const { return m_isLocationChange; } | 84 bool isLocationChange() const { return m_isLocationChange; } |
83 bool wasUserGesture() const { return m_wasUserGesture; } | 85 PassOwnPtr<UserGestureIndicator> createUserGestureIndicator() |
| 86 { |
| 87 if (m_wasUserGesture && m_userGestureToken) |
| 88 return adoptPtr(new UserGestureIndicator(m_userGestureToken)); |
| 89 else |
| 90 return adoptPtr(new UserGestureIndicator(DefinitelyNotProcessingUser
Gesture)); |
| 91 } |
84 | 92 |
85 protected: | 93 protected: |
86 void clearUserGesture() { m_wasUserGesture = false; } | 94 void clearUserGesture() { m_wasUserGesture = false; } |
87 | 95 |
88 private: | 96 private: |
89 double m_delay; | 97 double m_delay; |
90 bool m_lockHistory; | 98 bool m_lockHistory; |
91 bool m_lockBackForwardList; | 99 bool m_lockBackForwardList; |
92 bool m_wasDuringLoad; | 100 bool m_wasDuringLoad; |
93 bool m_isLocationChange; | 101 bool m_isLocationChange; |
94 bool m_wasUserGesture; | 102 bool m_wasUserGesture; |
| 103 RefPtr<UserGestureToken> m_userGestureToken; |
95 }; | 104 }; |
96 | 105 |
97 class ScheduledURLNavigation : public ScheduledNavigation { | 106 class ScheduledURLNavigation : public ScheduledNavigation { |
98 protected: | 107 protected: |
99 ScheduledURLNavigation(double delay, SecurityOrigin* securityOrigin, const S
tring& url, const String& referrer, bool lockHistory, bool lockBackForwardList,
bool duringLoad, bool isLocationChange) | 108 ScheduledURLNavigation(double delay, SecurityOrigin* securityOrigin, const S
tring& url, const String& referrer, bool lockHistory, bool lockBackForwardList,
bool duringLoad, bool isLocationChange) |
100 : ScheduledNavigation(delay, lockHistory, lockBackForwardList, duringLoa
d, isLocationChange) | 109 : ScheduledNavigation(delay, lockHistory, lockBackForwardList, duringLoa
d, isLocationChange) |
101 , m_securityOrigin(securityOrigin) | 110 , m_securityOrigin(securityOrigin) |
102 , m_url(url) | 111 , m_url(url) |
103 , m_referrer(referrer) | 112 , m_referrer(referrer) |
104 , m_haveToldClient(false) | 113 , m_haveToldClient(false) |
105 { | 114 { |
106 } | 115 } |
107 | 116 |
108 virtual void fire(Frame* frame) | 117 virtual void fire(Frame* frame) |
109 { | 118 { |
110 UserGestureIndicator gestureIndicator(wasUserGesture() ? DefinitelyProce
ssingNewUserGesture : DefinitelyNotProcessingUserGesture); | 119 OwnPtr<UserGestureIndicator> gestureIndicator = createUserGestureIndicat
or(); |
111 frame->loader()->changeLocation(m_securityOrigin.get(), KURL(ParsedURLSt
ring, m_url), m_referrer, lockHistory(), lockBackForwardList(), false); | 120 frame->loader()->changeLocation(m_securityOrigin.get(), KURL(ParsedURLSt
ring, m_url), m_referrer, lockHistory(), lockBackForwardList(), false); |
112 } | 121 } |
113 | 122 |
114 virtual void didStartTimer(Frame* frame, Timer<NavigationScheduler>* timer) | 123 virtual void didStartTimer(Frame* frame, Timer<NavigationScheduler>* timer) |
115 { | 124 { |
116 if (m_haveToldClient) | 125 if (m_haveToldClient) |
117 return; | 126 return; |
118 m_haveToldClient = true; | 127 m_haveToldClient = true; |
119 | 128 |
120 UserGestureIndicator gestureIndicator(wasUserGesture() ? DefinitelyProce
ssingNewUserGesture : DefinitelyNotProcessingUserGesture); | 129 OwnPtr<UserGestureIndicator> gestureIndicator = createUserGestureIndicat
or(); |
121 frame->loader()->clientRedirected(KURL(ParsedURLString, m_url), delay(),
currentTime() + timer->nextFireInterval(), lockBackForwardList()); | 130 frame->loader()->clientRedirected(KURL(ParsedURLString, m_url), delay(),
currentTime() + timer->nextFireInterval(), lockBackForwardList()); |
122 } | 131 } |
123 | 132 |
124 virtual void didStopTimer(Frame* frame) | 133 virtual void didStopTimer(Frame* frame) |
125 { | 134 { |
126 if (!m_haveToldClient) | 135 if (!m_haveToldClient) |
127 return; | 136 return; |
128 | 137 |
129 // Do not set a UserGestureIndicator because | 138 // Do not set a UserGestureIndicator because |
130 // clientRedirectCancelledOrFinished() is also called from many places | 139 // clientRedirectCancelledOrFinished() is also called from many places |
(...skipping 20 matching lines...) Expand all Loading... |
151 ScheduledRedirect(double delay, SecurityOrigin* securityOrigin, const String
& url, bool lockHistory, bool lockBackForwardList) | 160 ScheduledRedirect(double delay, SecurityOrigin* securityOrigin, const String
& url, bool lockHistory, bool lockBackForwardList) |
152 : ScheduledURLNavigation(delay, securityOrigin, url, String(), lockHisto
ry, lockBackForwardList, false, false) | 161 : ScheduledURLNavigation(delay, securityOrigin, url, String(), lockHisto
ry, lockBackForwardList, false, false) |
153 { | 162 { |
154 clearUserGesture(); | 163 clearUserGesture(); |
155 } | 164 } |
156 | 165 |
157 virtual bool shouldStartTimer(Frame* frame) { return frame->loader()->allAnc
estorsAreComplete(); } | 166 virtual bool shouldStartTimer(Frame* frame) { return frame->loader()->allAnc
estorsAreComplete(); } |
158 | 167 |
159 virtual void fire(Frame* frame) | 168 virtual void fire(Frame* frame) |
160 { | 169 { |
161 UserGestureIndicator gestureIndicator(wasUserGesture() ? DefinitelyProce
ssingNewUserGesture : DefinitelyNotProcessingUserGesture); | 170 OwnPtr<UserGestureIndicator> gestureIndicator = createUserGestureIndicat
or(); |
162 bool refresh = equalIgnoringFragmentIdentifier(frame->document()->url(),
KURL(ParsedURLString, url())); | 171 bool refresh = equalIgnoringFragmentIdentifier(frame->document()->url(),
KURL(ParsedURLString, url())); |
163 frame->loader()->changeLocation(securityOrigin(), KURL(ParsedURLString,
url()), referrer(), lockHistory(), lockBackForwardList(), refresh); | 172 frame->loader()->changeLocation(securityOrigin(), KURL(ParsedURLString,
url()), referrer(), lockHistory(), lockBackForwardList(), refresh); |
164 } | 173 } |
165 }; | 174 }; |
166 | 175 |
167 class ScheduledLocationChange : public ScheduledURLNavigation { | 176 class ScheduledLocationChange : public ScheduledURLNavigation { |
168 public: | 177 public: |
169 ScheduledLocationChange(SecurityOrigin* securityOrigin, const String& url, c
onst String& referrer, bool lockHistory, bool lockBackForwardList, bool duringLo
ad) | 178 ScheduledLocationChange(SecurityOrigin* securityOrigin, const String& url, c
onst String& referrer, bool lockHistory, bool lockBackForwardList, bool duringLo
ad) |
170 : ScheduledURLNavigation(0.0, securityOrigin, url, referrer, lockHistory
, lockBackForwardList, duringLoad, true) { } | 179 : ScheduledURLNavigation(0.0, securityOrigin, url, referrer, lockHistory
, lockBackForwardList, duringLoad, true) { } |
171 }; | 180 }; |
172 | 181 |
173 class ScheduledRefresh : public ScheduledURLNavigation { | 182 class ScheduledRefresh : public ScheduledURLNavigation { |
174 public: | 183 public: |
175 ScheduledRefresh(SecurityOrigin* securityOrigin, const String& url, const St
ring& referrer) | 184 ScheduledRefresh(SecurityOrigin* securityOrigin, const String& url, const St
ring& referrer) |
176 : ScheduledURLNavigation(0.0, securityOrigin, url, referrer, true, true,
false, true) | 185 : ScheduledURLNavigation(0.0, securityOrigin, url, referrer, true, true,
false, true) |
177 { | 186 { |
178 } | 187 } |
179 | 188 |
180 virtual void fire(Frame* frame) | 189 virtual void fire(Frame* frame) |
181 { | 190 { |
182 UserGestureIndicator gestureIndicator(wasUserGesture() ? DefinitelyProce
ssingNewUserGesture : DefinitelyNotProcessingUserGesture); | 191 OwnPtr<UserGestureIndicator> gestureIndicator = createUserGestureIndicat
or(); |
183 frame->loader()->changeLocation(securityOrigin(), KURL(ParsedURLString,
url()), referrer(), lockHistory(), lockBackForwardList(), true); | 192 frame->loader()->changeLocation(securityOrigin(), KURL(ParsedURLString,
url()), referrer(), lockHistory(), lockBackForwardList(), true); |
184 } | 193 } |
185 }; | 194 }; |
186 | 195 |
187 class ScheduledHistoryNavigation : public ScheduledNavigation { | 196 class ScheduledHistoryNavigation : public ScheduledNavigation { |
188 public: | 197 public: |
189 explicit ScheduledHistoryNavigation(int historySteps) | 198 explicit ScheduledHistoryNavigation(int historySteps) |
190 : ScheduledNavigation(0, false, false, false, true) | 199 : ScheduledNavigation(0, false, false, false, true) |
191 , m_historySteps(historySteps) | 200 , m_historySteps(historySteps) |
192 { | 201 { |
193 } | 202 } |
194 | 203 |
195 virtual void fire(Frame* frame) | 204 virtual void fire(Frame* frame) |
196 { | 205 { |
197 UserGestureIndicator gestureIndicator(wasUserGesture() ? DefinitelyProce
ssingNewUserGesture : DefinitelyNotProcessingUserGesture); | 206 OwnPtr<UserGestureIndicator> gestureIndicator = createUserGestureIndicat
or(); |
198 | 207 |
199 if (!m_historySteps) { | 208 if (!m_historySteps) { |
200 // Special case for go(0) from a frame -> reload only the frame | 209 // Special case for go(0) from a frame -> reload only the frame |
201 // To follow Firefox and IE's behavior, history reload can only navi
gate the self frame. | 210 // To follow Firefox and IE's behavior, history reload can only navi
gate the self frame. |
202 frame->loader()->urlSelected(frame->document()->url(), "_self", 0, l
ockHistory(), lockBackForwardList(), MaybeSendReferrer); | 211 frame->loader()->urlSelected(frame->document()->url(), "_self", 0, l
ockHistory(), lockBackForwardList(), MaybeSendReferrer); |
203 return; | 212 return; |
204 } | 213 } |
205 // go(i!=0) from a frame navigates into the history of the frame only, | 214 // go(i!=0) from a frame navigates into the history of the frame only, |
206 // in both IE and NS (but not in Mozilla). We can't easily do that. | 215 // in both IE and NS (but not in Mozilla). We can't easily do that. |
207 frame->page()->backForward()->goBackOrForward(m_historySteps); | 216 frame->page()->backForward()->goBackOrForward(m_historySteps); |
208 } | 217 } |
209 | 218 |
210 private: | 219 private: |
211 int m_historySteps; | 220 int m_historySteps; |
212 }; | 221 }; |
213 | 222 |
214 class ScheduledFormSubmission : public ScheduledNavigation { | 223 class ScheduledFormSubmission : public ScheduledNavigation { |
215 public: | 224 public: |
216 ScheduledFormSubmission(PassRefPtr<FormSubmission> submission, bool lockBack
ForwardList, bool duringLoad) | 225 ScheduledFormSubmission(PassRefPtr<FormSubmission> submission, bool lockBack
ForwardList, bool duringLoad) |
217 : ScheduledNavigation(0, submission->lockHistory(), lockBackForwardList,
duringLoad, true) | 226 : ScheduledNavigation(0, submission->lockHistory(), lockBackForwardList,
duringLoad, true) |
218 , m_submission(submission) | 227 , m_submission(submission) |
219 , m_haveToldClient(false) | 228 , m_haveToldClient(false) |
220 { | 229 { |
221 ASSERT(m_submission->state()); | 230 ASSERT(m_submission->state()); |
222 } | 231 } |
223 | 232 |
224 virtual void fire(Frame* frame) | 233 virtual void fire(Frame* frame) |
225 { | 234 { |
226 UserGestureIndicator gestureIndicator(wasUserGesture() ? DefinitelyProce
ssingNewUserGesture : DefinitelyNotProcessingUserGesture); | 235 OwnPtr<UserGestureIndicator> gestureIndicator = createUserGestureIndicat
or(); |
227 | 236 |
228 // The submitForm function will find a target frame before using the red
irection timer. | 237 // The submitForm function will find a target frame before using the red
irection timer. |
229 // Now that the timer has fired, we need to repeat the security check wh
ich normally is done when | 238 // Now that the timer has fired, we need to repeat the security check wh
ich normally is done when |
230 // selecting a target, in case conditions have changed. Other code paths
avoid this by targeting | 239 // selecting a target, in case conditions have changed. Other code paths
avoid this by targeting |
231 // without leaving a time window. If we fail the check just silently dro
p the form submission. | 240 // without leaving a time window. If we fail the check just silently dro
p the form submission. |
232 Document* requestingDocument = m_submission->state()->sourceDocument(); | 241 Document* requestingDocument = m_submission->state()->sourceDocument(); |
233 if (!requestingDocument->canNavigate(frame)) | 242 if (!requestingDocument->canNavigate(frame)) |
234 return; | 243 return; |
235 FrameLoadRequest frameRequest(requestingDocument->document()->securityOr
igin()); | 244 FrameLoadRequest frameRequest(requestingDocument->document()->securityOr
igin()); |
236 m_submission->populateFrameLoadRequest(frameRequest); | 245 m_submission->populateFrameLoadRequest(frameRequest); |
237 frame->loader()->loadFrameRequest(frameRequest, lockHistory(), lockBackF
orwardList(), m_submission->event(), m_submission->state(), MaybeSendReferrer); | 246 frame->loader()->loadFrameRequest(frameRequest, lockHistory(), lockBackF
orwardList(), m_submission->event(), m_submission->state(), MaybeSendReferrer); |
238 } | 247 } |
239 | 248 |
240 virtual void didStartTimer(Frame* frame, Timer<NavigationScheduler>* timer) | 249 virtual void didStartTimer(Frame* frame, Timer<NavigationScheduler>* timer) |
241 { | 250 { |
242 if (m_haveToldClient) | 251 if (m_haveToldClient) |
243 return; | 252 return; |
244 m_haveToldClient = true; | 253 m_haveToldClient = true; |
245 | 254 |
246 UserGestureIndicator gestureIndicator(wasUserGesture() ? DefinitelyProce
ssingNewUserGesture : DefinitelyNotProcessingUserGesture); | 255 OwnPtr<UserGestureIndicator> gestureIndicator = createUserGestureIndicat
or(); |
247 frame->loader()->clientRedirected(m_submission->requestURL(), delay(), c
urrentTime() + timer->nextFireInterval(), lockBackForwardList()); | 256 frame->loader()->clientRedirected(m_submission->requestURL(), delay(), c
urrentTime() + timer->nextFireInterval(), lockBackForwardList()); |
248 } | 257 } |
249 | 258 |
250 virtual void didStopTimer(Frame* frame) | 259 virtual void didStopTimer(Frame* frame) |
251 { | 260 { |
252 if (!m_haveToldClient) | 261 if (!m_haveToldClient) |
253 return; | 262 return; |
254 | 263 |
255 // Do not set a UserGestureIndicator because | 264 // Do not set a UserGestureIndicator because |
256 // clientRedirectCancelledOrFinished() is also called from many places | 265 // clientRedirectCancelledOrFinished() is also called from many places |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
475 if (m_timer.isActive()) | 484 if (m_timer.isActive()) |
476 InspectorInstrumentation::frameClearedScheduledNavigation(m_frame); | 485 InspectorInstrumentation::frameClearedScheduledNavigation(m_frame); |
477 m_timer.stop(); | 486 m_timer.stop(); |
478 | 487 |
479 OwnPtr<ScheduledNavigation> redirect(m_redirect.release()); | 488 OwnPtr<ScheduledNavigation> redirect(m_redirect.release()); |
480 if (redirect) | 489 if (redirect) |
481 redirect->didStopTimer(m_frame); | 490 redirect->didStopTimer(m_frame); |
482 } | 491 } |
483 | 492 |
484 } // namespace WebCore | 493 } // namespace WebCore |
OLD | NEW |