| 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 #include "core/loader/FrameLoaderStateMachine.h" | 48 #include "core/loader/FrameLoaderStateMachine.h" |
| 49 #include "core/page/Page.h" | 49 #include "core/page/Page.h" |
| 50 #include "platform/Histogram.h" | 50 #include "platform/Histogram.h" |
| 51 #include "platform/SharedBuffer.h" | 51 #include "platform/SharedBuffer.h" |
| 52 #include "platform/UserGestureIndicator.h" | 52 #include "platform/UserGestureIndicator.h" |
| 53 #include "platform/scheduler/CancellableTaskFactory.h" | 53 #include "platform/scheduler/CancellableTaskFactory.h" |
| 54 #include "public/platform/Platform.h" | 54 #include "public/platform/Platform.h" |
| 55 #include "public/platform/WebCachePolicy.h" | 55 #include "public/platform/WebCachePolicy.h" |
| 56 #include "public/platform/WebScheduler.h" | 56 #include "public/platform/WebScheduler.h" |
| 57 #include "wtf/CurrentTime.h" | 57 #include "wtf/CurrentTime.h" |
| 58 #include "wtf/PtrUtil.h" |
| 59 #include <memory> |
| 58 | 60 |
| 59 namespace blink { | 61 namespace blink { |
| 60 | 62 |
| 61 namespace { | 63 namespace { |
| 62 | 64 |
| 63 // Add new scheduled navigation types before ScheduledLastEntry | 65 // Add new scheduled navigation types before ScheduledLastEntry |
| 64 enum ScheduledNavigationType { | 66 enum ScheduledNavigationType { |
| 65 ScheduledReload, | 67 ScheduledReload, |
| 66 ScheduledFormSubmission, | 68 ScheduledFormSubmission, |
| 67 ScheduledURLNavigation, | 69 ScheduledURLNavigation, |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 virtual ~ScheduledNavigation() { } | 115 virtual ~ScheduledNavigation() { } |
| 114 | 116 |
| 115 virtual void fire(LocalFrame*) = 0; | 117 virtual void fire(LocalFrame*) = 0; |
| 116 | 118 |
| 117 virtual bool shouldStartTimer(LocalFrame*) { return true; } | 119 virtual bool shouldStartTimer(LocalFrame*) { return true; } |
| 118 | 120 |
| 119 double delay() const { return m_delay; } | 121 double delay() const { return m_delay; } |
| 120 Document* originDocument() const { return m_originDocument.get(); } | 122 Document* originDocument() const { return m_originDocument.get(); } |
| 121 bool replacesCurrentItem() const { return m_replacesCurrentItem; } | 123 bool replacesCurrentItem() const { return m_replacesCurrentItem; } |
| 122 bool isLocationChange() const { return m_isLocationChange; } | 124 bool isLocationChange() const { return m_isLocationChange; } |
| 123 PassOwnPtr<UserGestureIndicator> createUserGestureIndicator() | 125 std::unique_ptr<UserGestureIndicator> createUserGestureIndicator() |
| 124 { | 126 { |
| 125 if (m_wasUserGesture && m_userGestureToken) | 127 if (m_wasUserGesture && m_userGestureToken) |
| 126 return adoptPtr(new UserGestureIndicator(m_userGestureToken)); | 128 return wrapUnique(new UserGestureIndicator(m_userGestureToken)); |
| 127 return adoptPtr(new UserGestureIndicator(DefinitelyNotProcessingUserGest
ure)); | 129 return wrapUnique(new UserGestureIndicator(DefinitelyNotProcessingUserGe
sture)); |
| 128 } | 130 } |
| 129 | 131 |
| 130 DEFINE_INLINE_VIRTUAL_TRACE() | 132 DEFINE_INLINE_VIRTUAL_TRACE() |
| 131 { | 133 { |
| 132 visitor->trace(m_originDocument); | 134 visitor->trace(m_originDocument); |
| 133 } | 135 } |
| 134 | 136 |
| 135 protected: | 137 protected: |
| 136 void clearUserGesture() { m_wasUserGesture = false; } | 138 void clearUserGesture() { m_wasUserGesture = false; } |
| 137 | 139 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 150 : ScheduledNavigation(delay, originDocument, replacesCurrentItem, isLoca
tionChange) | 152 : ScheduledNavigation(delay, originDocument, replacesCurrentItem, isLoca
tionChange) |
| 151 , m_url(url) | 153 , m_url(url) |
| 152 , m_shouldCheckMainWorldContentSecurityPolicy(CheckContentSecurityPolicy
) | 154 , m_shouldCheckMainWorldContentSecurityPolicy(CheckContentSecurityPolicy
) |
| 153 { | 155 { |
| 154 if (ContentSecurityPolicy::shouldBypassMainWorld(originDocument)) | 156 if (ContentSecurityPolicy::shouldBypassMainWorld(originDocument)) |
| 155 m_shouldCheckMainWorldContentSecurityPolicy = DoNotCheckContentSecur
ityPolicy; | 157 m_shouldCheckMainWorldContentSecurityPolicy = DoNotCheckContentSecur
ityPolicy; |
| 156 } | 158 } |
| 157 | 159 |
| 158 void fire(LocalFrame* frame) override | 160 void fire(LocalFrame* frame) override |
| 159 { | 161 { |
| 160 OwnPtr<UserGestureIndicator> gestureIndicator = createUserGestureIndicat
or(); | 162 std::unique_ptr<UserGestureIndicator> gestureIndicator = createUserGestu
reIndicator(); |
| 161 FrameLoadRequest request(originDocument(), m_url, "_self", m_shouldCheck
MainWorldContentSecurityPolicy); | 163 FrameLoadRequest request(originDocument(), m_url, "_self", m_shouldCheck
MainWorldContentSecurityPolicy); |
| 162 request.setReplacesCurrentItem(replacesCurrentItem()); | 164 request.setReplacesCurrentItem(replacesCurrentItem()); |
| 163 request.setClientRedirect(ClientRedirectPolicy::ClientRedirect); | 165 request.setClientRedirect(ClientRedirectPolicy::ClientRedirect); |
| 164 | 166 |
| 165 ScheduledNavigationType type = isLocationChange() ? ScheduledNavigationT
ype::ScheduledLocationChange : ScheduledNavigationType::ScheduledURLNavigation; | 167 ScheduledNavigationType type = isLocationChange() ? ScheduledNavigationT
ype::ScheduledLocationChange : ScheduledNavigationType::ScheduledURLNavigation; |
| 166 maybeLogScheduledNavigationClobber(type, frame, request, gestureIndicato
r.get()); | 168 maybeLogScheduledNavigationClobber(type, frame, request, gestureIndicato
r.get()); |
| 167 frame->loader().load(request); | 169 frame->loader().load(request); |
| 168 } | 170 } |
| 169 | 171 |
| 170 String url() const { return m_url; } | 172 String url() const { return m_url; } |
| 171 | 173 |
| 172 private: | 174 private: |
| 173 String m_url; | 175 String m_url; |
| 174 ContentSecurityPolicyDisposition m_shouldCheckMainWorldContentSecurityPolicy
; | 176 ContentSecurityPolicyDisposition m_shouldCheckMainWorldContentSecurityPolicy
; |
| 175 }; | 177 }; |
| 176 | 178 |
| 177 class ScheduledRedirect final : public ScheduledURLNavigation { | 179 class ScheduledRedirect final : public ScheduledURLNavigation { |
| 178 public: | 180 public: |
| 179 static ScheduledRedirect* create(double delay, Document* originDocument, con
st String& url, bool replacesCurrentItem) | 181 static ScheduledRedirect* create(double delay, Document* originDocument, con
st String& url, bool replacesCurrentItem) |
| 180 { | 182 { |
| 181 return new ScheduledRedirect(delay, originDocument, url, replacesCurrent
Item); | 183 return new ScheduledRedirect(delay, originDocument, url, replacesCurrent
Item); |
| 182 } | 184 } |
| 183 | 185 |
| 184 bool shouldStartTimer(LocalFrame* frame) override { return frame->document()
->loadEventFinished(); } | 186 bool shouldStartTimer(LocalFrame* frame) override { return frame->document()
->loadEventFinished(); } |
| 185 | 187 |
| 186 void fire(LocalFrame* frame) override | 188 void fire(LocalFrame* frame) override |
| 187 { | 189 { |
| 188 OwnPtr<UserGestureIndicator> gestureIndicator = createUserGestureIndicat
or(); | 190 std::unique_ptr<UserGestureIndicator> gestureIndicator = createUserGestu
reIndicator(); |
| 189 FrameLoadRequest request(originDocument(), url(), "_self"); | 191 FrameLoadRequest request(originDocument(), url(), "_self"); |
| 190 request.setReplacesCurrentItem(replacesCurrentItem()); | 192 request.setReplacesCurrentItem(replacesCurrentItem()); |
| 191 if (equalIgnoringFragmentIdentifier(frame->document()->url(), request.re
sourceRequest().url())) | 193 if (equalIgnoringFragmentIdentifier(frame->document()->url(), request.re
sourceRequest().url())) |
| 192 request.resourceRequest().setCachePolicy(WebCachePolicy::ValidatingC
acheData); | 194 request.resourceRequest().setCachePolicy(WebCachePolicy::ValidatingC
acheData); |
| 193 request.setClientRedirect(ClientRedirectPolicy::ClientRedirect); | 195 request.setClientRedirect(ClientRedirectPolicy::ClientRedirect); |
| 194 maybeLogScheduledNavigationClobber(ScheduledNavigationType::ScheduledRed
irect, frame, request, gestureIndicator.get()); | 196 maybeLogScheduledNavigationClobber(ScheduledNavigationType::ScheduledRed
irect, frame, request, gestureIndicator.get()); |
| 195 frame->loader().load(request); | 197 frame->loader().load(request); |
| 196 } | 198 } |
| 197 | 199 |
| 198 private: | 200 private: |
| (...skipping 18 matching lines...) Expand all Loading... |
| 217 | 219 |
| 218 class ScheduledReload final : public ScheduledNavigation { | 220 class ScheduledReload final : public ScheduledNavigation { |
| 219 public: | 221 public: |
| 220 static ScheduledReload* create() | 222 static ScheduledReload* create() |
| 221 { | 223 { |
| 222 return new ScheduledReload; | 224 return new ScheduledReload; |
| 223 } | 225 } |
| 224 | 226 |
| 225 void fire(LocalFrame* frame) override | 227 void fire(LocalFrame* frame) override |
| 226 { | 228 { |
| 227 OwnPtr<UserGestureIndicator> gestureIndicator = createUserGestureIndicat
or(); | 229 std::unique_ptr<UserGestureIndicator> gestureIndicator = createUserGestu
reIndicator(); |
| 228 ResourceRequest resourceRequest = frame->loader().resourceRequestForRelo
ad(FrameLoadTypeReload, KURL(), ClientRedirectPolicy::ClientRedirect); | 230 ResourceRequest resourceRequest = frame->loader().resourceRequestForRelo
ad(FrameLoadTypeReload, KURL(), ClientRedirectPolicy::ClientRedirect); |
| 229 if (resourceRequest.isNull()) | 231 if (resourceRequest.isNull()) |
| 230 return; | 232 return; |
| 231 FrameLoadRequest request = FrameLoadRequest(nullptr, resourceRequest); | 233 FrameLoadRequest request = FrameLoadRequest(nullptr, resourceRequest); |
| 232 request.setClientRedirect(ClientRedirectPolicy::ClientRedirect); | 234 request.setClientRedirect(ClientRedirectPolicy::ClientRedirect); |
| 233 maybeLogScheduledNavigationClobber(ScheduledNavigationType::ScheduledRel
oad, frame, request, gestureIndicator.get()); | 235 maybeLogScheduledNavigationClobber(ScheduledNavigationType::ScheduledRel
oad, frame, request, gestureIndicator.get()); |
| 234 frame->loader().load(request, FrameLoadTypeReload); | 236 frame->loader().load(request, FrameLoadTypeReload); |
| 235 } | 237 } |
| 236 | 238 |
| 237 private: | 239 private: |
| 238 ScheduledReload() | 240 ScheduledReload() |
| 239 : ScheduledNavigation(0.0, nullptr, true, true) | 241 : ScheduledNavigation(0.0, nullptr, true, true) |
| 240 { | 242 { |
| 241 } | 243 } |
| 242 }; | 244 }; |
| 243 | 245 |
| 244 class ScheduledPageBlock final : public ScheduledURLNavigation { | 246 class ScheduledPageBlock final : public ScheduledURLNavigation { |
| 245 public: | 247 public: |
| 246 static ScheduledPageBlock* create(Document* originDocument, const String& ur
l) | 248 static ScheduledPageBlock* create(Document* originDocument, const String& ur
l) |
| 247 { | 249 { |
| 248 return new ScheduledPageBlock(originDocument, url); | 250 return new ScheduledPageBlock(originDocument, url); |
| 249 } | 251 } |
| 250 | 252 |
| 251 void fire(LocalFrame* frame) override | 253 void fire(LocalFrame* frame) override |
| 252 { | 254 { |
| 253 OwnPtr<UserGestureIndicator> gestureIndicator = createUserGestureIndicat
or(); | 255 std::unique_ptr<UserGestureIndicator> gestureIndicator = createUserGestu
reIndicator(); |
| 254 SubstituteData substituteData(SharedBuffer::create(), "text/plain", "UTF
-8", KURL(), ForceSynchronousLoad); | 256 SubstituteData substituteData(SharedBuffer::create(), "text/plain", "UTF
-8", KURL(), ForceSynchronousLoad); |
| 255 FrameLoadRequest request(originDocument(), url(), substituteData); | 257 FrameLoadRequest request(originDocument(), url(), substituteData); |
| 256 request.setReplacesCurrentItem(true); | 258 request.setReplacesCurrentItem(true); |
| 257 request.setClientRedirect(ClientRedirectPolicy::ClientRedirect); | 259 request.setClientRedirect(ClientRedirectPolicy::ClientRedirect); |
| 258 maybeLogScheduledNavigationClobber(ScheduledNavigationType::ScheduledPag
eBlock, frame, request, gestureIndicator.get()); | 260 maybeLogScheduledNavigationClobber(ScheduledNavigationType::ScheduledPag
eBlock, frame, request, gestureIndicator.get()); |
| 259 frame->loader().load(request); | 261 frame->loader().load(request); |
| 260 } | 262 } |
| 261 private: | 263 private: |
| 262 ScheduledPageBlock(Document* originDocument, const String& url) | 264 ScheduledPageBlock(Document* originDocument, const String& url) |
| 263 : ScheduledURLNavigation(0.0, originDocument, url, true, true) | 265 : ScheduledURLNavigation(0.0, originDocument, url, true, true) |
| 264 { | 266 { |
| 265 } | 267 } |
| 266 | 268 |
| 267 }; | 269 }; |
| 268 | 270 |
| 269 class ScheduledFormSubmission final : public ScheduledNavigation { | 271 class ScheduledFormSubmission final : public ScheduledNavigation { |
| 270 public: | 272 public: |
| 271 static ScheduledFormSubmission* create(Document* document, FormSubmission* s
ubmission, bool replacesCurrentItem) | 273 static ScheduledFormSubmission* create(Document* document, FormSubmission* s
ubmission, bool replacesCurrentItem) |
| 272 { | 274 { |
| 273 return new ScheduledFormSubmission(document, submission, replacesCurrent
Item); | 275 return new ScheduledFormSubmission(document, submission, replacesCurrent
Item); |
| 274 } | 276 } |
| 275 | 277 |
| 276 void fire(LocalFrame* frame) override | 278 void fire(LocalFrame* frame) override |
| 277 { | 279 { |
| 278 OwnPtr<UserGestureIndicator> gestureIndicator = createUserGestureIndicat
or(); | 280 std::unique_ptr<UserGestureIndicator> gestureIndicator = createUserGestu
reIndicator(); |
| 279 FrameLoadRequest frameRequest(originDocument()); | 281 FrameLoadRequest frameRequest(originDocument()); |
| 280 m_submission->populateFrameLoadRequest(frameRequest); | 282 m_submission->populateFrameLoadRequest(frameRequest); |
| 281 frameRequest.setReplacesCurrentItem(replacesCurrentItem()); | 283 frameRequest.setReplacesCurrentItem(replacesCurrentItem()); |
| 282 frameRequest.setTriggeringEvent(m_submission->event()); | 284 frameRequest.setTriggeringEvent(m_submission->event()); |
| 283 frameRequest.setForm(m_submission->form()); | 285 frameRequest.setForm(m_submission->form()); |
| 284 maybeLogScheduledNavigationClobber(ScheduledNavigationType::ScheduledFor
mSubmission, frame, frameRequest, gestureIndicator.get()); | 286 maybeLogScheduledNavigationClobber(ScheduledNavigationType::ScheduledFor
mSubmission, frame, frameRequest, gestureIndicator.get()); |
| 285 frame->loader().load(frameRequest); | 287 frame->loader().load(frameRequest); |
| 286 } | 288 } |
| 287 | 289 |
| 288 DEFINE_INLINE_VIRTUAL_TRACE() | 290 DEFINE_INLINE_VIRTUAL_TRACE() |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 495 m_redirect.clear(); | 497 m_redirect.clear(); |
| 496 } | 498 } |
| 497 | 499 |
| 498 DEFINE_TRACE(NavigationScheduler) | 500 DEFINE_TRACE(NavigationScheduler) |
| 499 { | 501 { |
| 500 visitor->trace(m_frame); | 502 visitor->trace(m_frame); |
| 501 visitor->trace(m_redirect); | 503 visitor->trace(m_redirect); |
| 502 } | 504 } |
| 503 | 505 |
| 504 } // namespace blink | 506 } // namespace blink |
| OLD | NEW |