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