| 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 28 matching lines...) Expand all Loading... |
| 39 #include "core/frame/csp/ContentSecurityPolicy.h" | 39 #include "core/frame/csp/ContentSecurityPolicy.h" |
| 40 #include "core/html/HTMLFormElement.h" | 40 #include "core/html/HTMLFormElement.h" |
| 41 #include "core/inspector/InspectorInstrumentation.h" | 41 #include "core/inspector/InspectorInstrumentation.h" |
| 42 #include "core/loader/DocumentLoader.h" | 42 #include "core/loader/DocumentLoader.h" |
| 43 #include "core/loader/FormState.h" | 43 #include "core/loader/FormState.h" |
| 44 #include "core/loader/FormSubmission.h" | 44 #include "core/loader/FormSubmission.h" |
| 45 #include "core/loader/FrameLoadRequest.h" | 45 #include "core/loader/FrameLoadRequest.h" |
| 46 #include "core/loader/FrameLoader.h" | 46 #include "core/loader/FrameLoader.h" |
| 47 #include "core/loader/FrameLoaderClient.h" | 47 #include "core/loader/FrameLoaderClient.h" |
| 48 #include "core/loader/FrameLoaderStateMachine.h" | 48 #include "core/loader/FrameLoaderStateMachine.h" |
| 49 #include "core/page/BackForwardClient.h" | |
| 50 #include "core/page/Page.h" | 49 #include "core/page/Page.h" |
| 51 #include "platform/SharedBuffer.h" | 50 #include "platform/SharedBuffer.h" |
| 52 #include "platform/UserGestureIndicator.h" | 51 #include "platform/UserGestureIndicator.h" |
| 53 #include "wtf/CurrentTime.h" | 52 #include "wtf/CurrentTime.h" |
| 54 | 53 |
| 55 namespace blink { | 54 namespace blink { |
| 56 | 55 |
| 57 unsigned NavigationDisablerForBeforeUnload::s_navigationDisableCount = 0; | 56 unsigned NavigationDisablerForBeforeUnload::s_navigationDisableCount = 0; |
| 58 | 57 |
| 59 class ScheduledNavigation { | 58 class ScheduledNavigation { |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 { | 177 { |
| 179 OwnPtr<UserGestureIndicator> gestureIndicator = createUserGestureIndicat
or(); | 178 OwnPtr<UserGestureIndicator> gestureIndicator = createUserGestureIndicat
or(); |
| 180 SubstituteData substituteData(SharedBuffer::create(), "text/plain", "UTF
-8", KURL(), ForceSynchronousLoad); | 179 SubstituteData substituteData(SharedBuffer::create(), "text/plain", "UTF
-8", KURL(), ForceSynchronousLoad); |
| 181 FrameLoadRequest request(originDocument(), url(), substituteData); | 180 FrameLoadRequest request(originDocument(), url(), substituteData); |
| 182 request.setLockBackForwardList(true); | 181 request.setLockBackForwardList(true); |
| 183 request.setClientRedirect(ClientRedirect); | 182 request.setClientRedirect(ClientRedirect); |
| 184 frame->loader().load(request); | 183 frame->loader().load(request); |
| 185 } | 184 } |
| 186 }; | 185 }; |
| 187 | 186 |
| 188 class ScheduledHistoryNavigation final : public ScheduledNavigation { | |
| 189 public: | |
| 190 explicit ScheduledHistoryNavigation(int historySteps) | |
| 191 : ScheduledNavigation(0, false, true) | |
| 192 , m_historySteps(historySteps) | |
| 193 { | |
| 194 } | |
| 195 | |
| 196 virtual void fire(LocalFrame* frame) override | |
| 197 { | |
| 198 OwnPtr<UserGestureIndicator> gestureIndicator = createUserGestureIndicat
or(); | |
| 199 // go(i!=0) from a frame navigates into the history of the frame only, | |
| 200 // in both IE and NS (but not in Mozilla). We can't easily do that. | |
| 201 frame->page()->deprecatedLocalMainFrame()->loader().client()->navigateBa
ckForward(m_historySteps); | |
| 202 } | |
| 203 | |
| 204 private: | |
| 205 int m_historySteps; | |
| 206 }; | |
| 207 | |
| 208 class ScheduledFormSubmission final : public ScheduledNavigation { | 187 class ScheduledFormSubmission final : public ScheduledNavigation { |
| 209 public: | 188 public: |
| 210 ScheduledFormSubmission(PassRefPtrWillBeRawPtr<FormSubmission> submission, b
ool lockBackForwardList) | 189 ScheduledFormSubmission(PassRefPtrWillBeRawPtr<FormSubmission> submission, b
ool lockBackForwardList) |
| 211 : ScheduledNavigation(0, lockBackForwardList, true) | 190 : ScheduledNavigation(0, lockBackForwardList, true) |
| 212 , m_submission(submission) | 191 , m_submission(submission) |
| 213 { | 192 { |
| 214 ASSERT(m_submission->state()); | 193 ASSERT(m_submission->state()); |
| 215 } | 194 } |
| 216 | 195 |
| 217 virtual void fire(LocalFrame* frame) override | 196 virtual void fire(LocalFrame* frame) override |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 | 312 |
| 334 void NavigationScheduler::scheduleReload() | 313 void NavigationScheduler::scheduleReload() |
| 335 { | 314 { |
| 336 if (!shouldScheduleNavigation()) | 315 if (!shouldScheduleNavigation()) |
| 337 return; | 316 return; |
| 338 if (m_frame->document()->url().isEmpty()) | 317 if (m_frame->document()->url().isEmpty()) |
| 339 return; | 318 return; |
| 340 schedule(adoptPtr(new ScheduledReload)); | 319 schedule(adoptPtr(new ScheduledReload)); |
| 341 } | 320 } |
| 342 | 321 |
| 343 void NavigationScheduler::scheduleHistoryNavigation(int steps) | |
| 344 { | |
| 345 if (!shouldScheduleNavigation()) | |
| 346 return; | |
| 347 | |
| 348 // Invalid history navigations (such as history.forward() during a new load)
have the side effect of cancelling any scheduled | |
| 349 // redirects. We also avoid the possibility of cancelling the current load b
y avoiding the scheduled redirection altogether. | |
| 350 BackForwardClient& backForward = m_frame->page()->backForward(); | |
| 351 if (steps > backForward.forwardListCount() || -steps > backForward.backListC
ount()) { | |
| 352 cancel(); | |
| 353 return; | |
| 354 } | |
| 355 | |
| 356 // In all other cases, schedule the history traversal to occur asynchronousl
y. | |
| 357 if (steps) | |
| 358 schedule(adoptPtr(new ScheduledHistoryNavigation(steps))); | |
| 359 else | |
| 360 schedule(adoptPtr(new ScheduledReload)); | |
| 361 } | |
| 362 | |
| 363 void NavigationScheduler::timerFired(Timer<NavigationScheduler>*) | 322 void NavigationScheduler::timerFired(Timer<NavigationScheduler>*) |
| 364 { | 323 { |
| 365 if (!m_frame->page()) | 324 if (!m_frame->page()) |
| 366 return; | 325 return; |
| 367 if (m_frame->page()->defersLoading()) { | 326 if (m_frame->page()->defersLoading()) { |
| 368 InspectorInstrumentation::frameClearedScheduledNavigation(m_frame); | 327 InspectorInstrumentation::frameClearedScheduledNavigation(m_frame); |
| 369 return; | 328 return; |
| 370 } | 329 } |
| 371 | 330 |
| 372 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get()); | 331 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get()); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 m_timer.stop(); | 377 m_timer.stop(); |
| 419 m_redirect.clear(); | 378 m_redirect.clear(); |
| 420 } | 379 } |
| 421 | 380 |
| 422 void NavigationScheduler::trace(Visitor* visitor) | 381 void NavigationScheduler::trace(Visitor* visitor) |
| 423 { | 382 { |
| 424 visitor->trace(m_frame); | 383 visitor->trace(m_frame); |
| 425 } | 384 } |
| 426 | 385 |
| 427 } // namespace blink | 386 } // namespace blink |
| OLD | NEW |