| 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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 private: | 89 private: |
| 90 double m_delay; | 90 double m_delay; |
| 91 bool m_lockBackForwardList; | 91 bool m_lockBackForwardList; |
| 92 bool m_isLocationChange; | 92 bool m_isLocationChange; |
| 93 bool m_wasUserGesture; | 93 bool m_wasUserGesture; |
| 94 RefPtr<UserGestureToken> m_userGestureToken; | 94 RefPtr<UserGestureToken> m_userGestureToken; |
| 95 }; | 95 }; |
| 96 | 96 |
| 97 class ScheduledURLNavigation : public ScheduledNavigation { | 97 class ScheduledURLNavigation : public ScheduledNavigation { |
| 98 protected: | 98 protected: |
| 99 ScheduledURLNavigation(double delay, Document* originDocument, const String&
url, const String& referrer, bool lockBackForwardList, bool isLocationChange) | 99 ScheduledURLNavigation(double delay, Document* originDocument, const String&
url, const AtomicString& referrer, bool lockBackForwardList, bool isLocationCha
nge) |
| 100 : ScheduledNavigation(delay, lockBackForwardList, isLocationChange) | 100 : ScheduledNavigation(delay, lockBackForwardList, isLocationChange) |
| 101 , m_originDocument(originDocument) | 101 , m_originDocument(originDocument) |
| 102 , m_url(url) | 102 , m_url(url) |
| 103 , m_referrer(referrer) | 103 , m_referrer(referrer) |
| 104 { | 104 { |
| 105 } | 105 } |
| 106 | 106 |
| 107 virtual void fire(Frame* frame) | 107 virtual void fire(Frame* frame) |
| 108 { | 108 { |
| 109 OwnPtr<UserGestureIndicator> gestureIndicator = createUserGestureIndicat
or(); | 109 OwnPtr<UserGestureIndicator> gestureIndicator = createUserGestureIndicat
or(); |
| 110 FrameLoadRequest request(m_originDocument.get(), ResourceRequest(KURL(Pa
rsedURLString, m_url), m_referrer), "_self"); | 110 FrameLoadRequest request(m_originDocument.get(), ResourceRequest(KURL(Pa
rsedURLString, m_url), m_referrer), "_self"); |
| 111 request.setLockBackForwardList(lockBackForwardList()); | 111 request.setLockBackForwardList(lockBackForwardList()); |
| 112 request.setClientRedirect(ClientRedirect); | 112 request.setClientRedirect(ClientRedirect); |
| 113 frame->loader().load(request); | 113 frame->loader().load(request); |
| 114 } | 114 } |
| 115 | 115 |
| 116 Document* originDocument() const { return m_originDocument.get(); } | 116 Document* originDocument() const { return m_originDocument.get(); } |
| 117 String url() const { return m_url; } | 117 String url() const { return m_url; } |
| 118 String referrer() const { return m_referrer; } | 118 const AtomicString& referrer() const { return m_referrer; } |
| 119 | 119 |
| 120 private: | 120 private: |
| 121 RefPtr<Document> m_originDocument; | 121 RefPtr<Document> m_originDocument; |
| 122 String m_url; | 122 String m_url; |
| 123 String m_referrer; | 123 AtomicString m_referrer; |
| 124 }; | 124 }; |
| 125 | 125 |
| 126 class ScheduledRedirect : public ScheduledURLNavigation { | 126 class ScheduledRedirect : public ScheduledURLNavigation { |
| 127 public: | 127 public: |
| 128 ScheduledRedirect(double delay, Document* originDocument, const String& url,
bool lockBackForwardList) | 128 ScheduledRedirect(double delay, Document* originDocument, const String& url,
bool lockBackForwardList) |
| 129 : ScheduledURLNavigation(delay, originDocument, url, String(), lockBackF
orwardList, false) | 129 : ScheduledURLNavigation(delay, originDocument, url, nullAtom, lockBackF
orwardList, false) |
| 130 { | 130 { |
| 131 clearUserGesture(); | 131 clearUserGesture(); |
| 132 } | 132 } |
| 133 | 133 |
| 134 virtual bool shouldStartTimer(Frame* frame) { return frame->loader().allAnce
storsAreComplete(); } | 134 virtual bool shouldStartTimer(Frame* frame) { return frame->loader().allAnce
storsAreComplete(); } |
| 135 | 135 |
| 136 virtual void fire(Frame* frame) | 136 virtual void fire(Frame* frame) |
| 137 { | 137 { |
| 138 OwnPtr<UserGestureIndicator> gestureIndicator = createUserGestureIndicat
or(); | 138 OwnPtr<UserGestureIndicator> gestureIndicator = createUserGestureIndicat
or(); |
| 139 FrameLoadRequest request(originDocument(), ResourceRequest(KURL(ParsedUR
LString, url()), referrer()), "_self"); | 139 FrameLoadRequest request(originDocument(), ResourceRequest(KURL(ParsedUR
LString, url()), referrer()), "_self"); |
| 140 request.setLockBackForwardList(lockBackForwardList()); | 140 request.setLockBackForwardList(lockBackForwardList()); |
| 141 if (equalIgnoringFragmentIdentifier(frame->document()->url(), request.re
sourceRequest().url())) | 141 if (equalIgnoringFragmentIdentifier(frame->document()->url(), request.re
sourceRequest().url())) |
| 142 request.resourceRequest().setCachePolicy(ReloadIgnoringCacheData); | 142 request.resourceRequest().setCachePolicy(ReloadIgnoringCacheData); |
| 143 request.setClientRedirect(ClientRedirect); | 143 request.setClientRedirect(ClientRedirect); |
| 144 frame->loader().load(request); | 144 frame->loader().load(request); |
| 145 } | 145 } |
| 146 }; | 146 }; |
| 147 | 147 |
| 148 class ScheduledLocationChange : public ScheduledURLNavigation { | 148 class ScheduledLocationChange : public ScheduledURLNavigation { |
| 149 public: | 149 public: |
| 150 ScheduledLocationChange(Document* originDocument, const String& url, const S
tring& referrer, bool lockBackForwardList) | 150 ScheduledLocationChange(Document* originDocument, const String& url, const A
tomicString& referrer, bool lockBackForwardList) |
| 151 : ScheduledURLNavigation(0.0, originDocument, url, referrer, lockBackFor
wardList, true) { } | 151 : ScheduledURLNavigation(0.0, originDocument, url, referrer, lockBackFor
wardList, true) { } |
| 152 }; | 152 }; |
| 153 | 153 |
| 154 class ScheduledRefresh : public ScheduledURLNavigation { | 154 class ScheduledRefresh : public ScheduledURLNavigation { |
| 155 public: | 155 public: |
| 156 ScheduledRefresh(Document* originDocument, const String& url, const String&
referrer) | 156 ScheduledRefresh(Document* originDocument, const String& url, const AtomicSt
ring& referrer) |
| 157 : ScheduledURLNavigation(0.0, originDocument, url, referrer, true, true) | 157 : ScheduledURLNavigation(0.0, originDocument, url, referrer, true, true) |
| 158 { | 158 { |
| 159 } | 159 } |
| 160 | 160 |
| 161 virtual void fire(Frame* frame) | 161 virtual void fire(Frame* frame) |
| 162 { | 162 { |
| 163 OwnPtr<UserGestureIndicator> gestureIndicator = createUserGestureIndicat
or(); | 163 OwnPtr<UserGestureIndicator> gestureIndicator = createUserGestureIndicat
or(); |
| 164 FrameLoadRequest request(originDocument(), ResourceRequest(KURL(ParsedUR
LString, url()), referrer(), ReloadIgnoringCacheData), "_self"); | 164 FrameLoadRequest request(originDocument(), ResourceRequest(KURL(ParsedUR
LString, url()), referrer(), ReloadIgnoringCacheData), "_self"); |
| 165 request.setLockBackForwardList(lockBackForwardList()); | 165 request.setLockBackForwardList(lockBackForwardList()); |
| 166 request.setClientRedirect(ClientRedirect); | 166 request.setClientRedirect(ClientRedirect); |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 | 301 |
| 302 lockBackForwardList = lockBackForwardList || mustLockBackForwardList(m_frame
); | 302 lockBackForwardList = lockBackForwardList || mustLockBackForwardList(m_frame
); |
| 303 | 303 |
| 304 // If the URL we're going to navigate to is the same as the current one, exc
ept for the | 304 // If the URL we're going to navigate to is the same as the current one, exc
ept for the |
| 305 // fragment part, we don't need to schedule the location change. We'll skip
this | 305 // fragment part, we don't need to schedule the location change. We'll skip
this |
| 306 // optimization for cross-origin navigations to minimize the navigator's abi
lity to | 306 // optimization for cross-origin navigations to minimize the navigator's abi
lity to |
| 307 // execute timing attacks. | 307 // execute timing attacks. |
| 308 if (originDocument->securityOrigin()->canAccess(m_frame->document()->securit
yOrigin())) { | 308 if (originDocument->securityOrigin()->canAccess(m_frame->document()->securit
yOrigin())) { |
| 309 KURL parsedURL(ParsedURLString, url); | 309 KURL parsedURL(ParsedURLString, url); |
| 310 if (parsedURL.hasFragmentIdentifier() && equalIgnoringFragmentIdentifier
(m_frame->document()->url(), parsedURL)) { | 310 if (parsedURL.hasFragmentIdentifier() && equalIgnoringFragmentIdentifier
(m_frame->document()->url(), parsedURL)) { |
| 311 FrameLoadRequest request(originDocument, ResourceRequest(m_frame->do
cument()->completeURL(url), referrer), "_self"); | 311 FrameLoadRequest request(originDocument, ResourceRequest(m_frame->do
cument()->completeURL(url), AtomicString(referrer)), "_self"); |
| 312 request.setLockBackForwardList(lockBackForwardList); | 312 request.setLockBackForwardList(lockBackForwardList); |
| 313 request.setClientRedirect(ClientRedirect); | 313 request.setClientRedirect(ClientRedirect); |
| 314 m_frame->loader().load(request); | 314 m_frame->loader().load(request); |
| 315 return; | 315 return; |
| 316 } | 316 } |
| 317 } | 317 } |
| 318 | 318 |
| 319 schedule(adoptPtr(new ScheduledLocationChange(originDocument, url, referrer,
lockBackForwardList))); | 319 schedule(adoptPtr(new ScheduledLocationChange(originDocument, url, AtomicStr
ing(referrer), lockBackForwardList))); |
| 320 } | 320 } |
| 321 | 321 |
| 322 void NavigationScheduler::scheduleFormSubmission(PassRefPtr<FormSubmission> subm
ission) | 322 void NavigationScheduler::scheduleFormSubmission(PassRefPtr<FormSubmission> subm
ission) |
| 323 { | 323 { |
| 324 ASSERT(m_frame->page()); | 324 ASSERT(m_frame->page()); |
| 325 schedule(adoptPtr(new ScheduledFormSubmission(submission, mustLockBackForwar
dList(m_frame)))); | 325 schedule(adoptPtr(new ScheduledFormSubmission(submission, mustLockBackForwar
dList(m_frame)))); |
| 326 } | 326 } |
| 327 | 327 |
| 328 void NavigationScheduler::scheduleRefresh() | 328 void NavigationScheduler::scheduleRefresh() |
| 329 { | 329 { |
| 330 if (!shouldScheduleNavigation()) | 330 if (!shouldScheduleNavigation()) |
| 331 return; | 331 return; |
| 332 const KURL& url = m_frame->document()->url(); | 332 const KURL& url = m_frame->document()->url(); |
| 333 if (url.isEmpty()) | 333 if (url.isEmpty()) |
| 334 return; | 334 return; |
| 335 | 335 |
| 336 schedule(adoptPtr(new ScheduledRefresh(m_frame->document(), url.string(), m_
frame->document()->outgoingReferrer()))); | 336 schedule(adoptPtr(new ScheduledRefresh(m_frame->document(), url.string(), At
omicString(m_frame->document()->outgoingReferrer())))); |
| 337 } | 337 } |
| 338 | 338 |
| 339 void NavigationScheduler::scheduleHistoryNavigation(int steps) | 339 void NavigationScheduler::scheduleHistoryNavigation(int steps) |
| 340 { | 340 { |
| 341 if (!shouldScheduleNavigation()) | 341 if (!shouldScheduleNavigation()) |
| 342 return; | 342 return; |
| 343 | 343 |
| 344 // Invalid history navigations (such as history.forward() during a new load)
have the side effect of cancelling any scheduled | 344 // Invalid history navigations (such as history.forward() during a new load)
have the side effect of cancelling any scheduled |
| 345 // redirects. We also avoid the possibility of cancelling the current load b
y avoiding the scheduled redirection altogether. | 345 // redirects. We also avoid the possibility of cancelling the current load b
y avoiding the scheduled redirection altogether. |
| 346 BackForwardClient& backForward = m_frame->page()->backForward(); | 346 BackForwardClient& backForward = m_frame->page()->backForward(); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 | 394 |
| 395 void NavigationScheduler::cancel() | 395 void NavigationScheduler::cancel() |
| 396 { | 396 { |
| 397 if (m_timer.isActive()) | 397 if (m_timer.isActive()) |
| 398 InspectorInstrumentation::frameClearedScheduledNavigation(m_frame); | 398 InspectorInstrumentation::frameClearedScheduledNavigation(m_frame); |
| 399 m_timer.stop(); | 399 m_timer.stop(); |
| 400 m_redirect.clear(); | 400 m_redirect.clear(); |
| 401 } | 401 } |
| 402 | 402 |
| 403 } // namespace WebCore | 403 } // namespace WebCore |
| OLD | NEW |