Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(17)

Side by Side Diff: third_party/WebKit/Source/core/loader/NavigationScheduler.cpp

Issue 1969723004: Add a counter and a deprecation message when navigating in an unload handler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: adding line number to test expectation Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 16 matching lines...) Expand all
27 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31 31
32 #include "core/loader/NavigationScheduler.h" 32 #include "core/loader/NavigationScheduler.h"
33 33
34 #include "bindings/core/v8/ScriptController.h" 34 #include "bindings/core/v8/ScriptController.h"
35 #include "core/events/Event.h" 35 #include "core/events/Event.h"
36 #include "core/fetch/ResourceLoaderOptions.h" 36 #include "core/fetch/ResourceLoaderOptions.h"
37 #include "core/frame/Deprecation.h"
37 #include "core/frame/LocalFrame.h" 38 #include "core/frame/LocalFrame.h"
38 #include "core/frame/csp/ContentSecurityPolicy.h" 39 #include "core/frame/csp/ContentSecurityPolicy.h"
39 #include "core/html/HTMLFormElement.h" 40 #include "core/html/HTMLFormElement.h"
40 #include "core/inspector/InspectorInstrumentation.h" 41 #include "core/inspector/InspectorInstrumentation.h"
41 #include "core/loader/DocumentLoader.h" 42 #include "core/loader/DocumentLoader.h"
42 #include "core/loader/FormSubmission.h" 43 #include "core/loader/FormSubmission.h"
43 #include "core/loader/FrameLoadRequest.h" 44 #include "core/loader/FrameLoadRequest.h"
44 #include "core/loader/FrameLoader.h" 45 #include "core/loader/FrameLoader.h"
45 #include "core/loader/FrameLoaderClient.h" 46 #include "core/loader/FrameLoaderClient.h"
46 #include "core/loader/FrameLoaderStateMachine.h" 47 #include "core/loader/FrameLoaderStateMachine.h"
47 #include "core/page/Page.h" 48 #include "core/page/Page.h"
48 #include "platform/SharedBuffer.h" 49 #include "platform/SharedBuffer.h"
49 #include "platform/UserGestureIndicator.h" 50 #include "platform/UserGestureIndicator.h"
50 #include "platform/scheduler/CancellableTaskFactory.h" 51 #include "platform/scheduler/CancellableTaskFactory.h"
51 #include "public/platform/Platform.h" 52 #include "public/platform/Platform.h"
52 #include "public/platform/WebCachePolicy.h" 53 #include "public/platform/WebCachePolicy.h"
53 #include "public/platform/WebScheduler.h" 54 #include "public/platform/WebScheduler.h"
54 #include "wtf/CurrentTime.h" 55 #include "wtf/CurrentTime.h"
55 56
56 namespace blink { 57 namespace blink {
57 58
58 unsigned NavigationDisablerForBeforeUnload::s_navigationDisableCount = 0; 59 unsigned NavigationDisablerForBeforeUnload::s_navigationDisableCount = 0;
60 unsigned NavigationCounterForUnload::s_inUnloadHandler = 0;
59 61
60 class ScheduledNavigation : public GarbageCollectedFinalized<ScheduledNavigation > { 62 class ScheduledNavigation : public GarbageCollectedFinalized<ScheduledNavigation > {
61 WTF_MAKE_NONCOPYABLE(ScheduledNavigation); 63 WTF_MAKE_NONCOPYABLE(ScheduledNavigation);
62 public: 64 public:
63 ScheduledNavigation(double delay, Document* originDocument, bool replacesCur rentItem, bool isLocationChange) 65 ScheduledNavigation(double delay, Document* originDocument, bool replacesCur rentItem, bool isLocationChange)
64 : m_delay(delay) 66 : m_delay(delay)
65 , m_originDocument(originDocument) 67 , m_originDocument(originDocument)
66 , m_replacesCurrentItem(replacesCurrentItem) 68 , m_replacesCurrentItem(replacesCurrentItem)
67 , m_isLocationChange(isLocationChange) 69 , m_isLocationChange(isLocationChange)
68 , m_wasUserGesture(UserGestureIndicator::processingUserGesture()) 70 , m_wasUserGesture(UserGestureIndicator::processingUserGesture())
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 342
341 replacesCurrentItem = replacesCurrentItem || mustReplaceCurrentItem(m_frame) ; 343 replacesCurrentItem = replacesCurrentItem || mustReplaceCurrentItem(m_frame) ;
342 344
343 // If the URL we're going to navigate to is the same as the current one, exc ept for the 345 // If the URL we're going to navigate to is the same as the current one, exc ept for the
344 // fragment part, we don't need to schedule the location change. We'll skip this 346 // fragment part, we don't need to schedule the location change. We'll skip this
345 // optimization for cross-origin navigations to minimize the navigator's abi lity to 347 // optimization for cross-origin navigations to minimize the navigator's abi lity to
346 // execute timing attacks. 348 // execute timing attacks.
347 if (originDocument->getSecurityOrigin()->canAccess(m_frame->document()->getS ecurityOrigin())) { 349 if (originDocument->getSecurityOrigin()->canAccess(m_frame->document()->getS ecurityOrigin())) {
348 KURL parsedURL(ParsedURLString, url); 350 KURL parsedURL(ParsedURLString, url);
349 if (parsedURL.hasFragmentIdentifier() && equalIgnoringFragmentIdentifier (m_frame->document()->url(), parsedURL)) { 351 if (parsedURL.hasFragmentIdentifier() && equalIgnoringFragmentIdentifier (m_frame->document()->url(), parsedURL)) {
352 if (NavigationCounterForUnload::inUnloadHandler())
353 Deprecation::countDeprecation(m_frame, UseCounter::UnloadHandler _Navigation);
354
350 FrameLoadRequest request(originDocument, m_frame->document()->comple teURL(url), "_self"); 355 FrameLoadRequest request(originDocument, m_frame->document()->comple teURL(url), "_self");
351 request.setReplacesCurrentItem(replacesCurrentItem); 356 request.setReplacesCurrentItem(replacesCurrentItem);
352 if (replacesCurrentItem) 357 if (replacesCurrentItem)
353 request.setClientRedirect(ClientRedirectPolicy::ClientRedirect); 358 request.setClientRedirect(ClientRedirectPolicy::ClientRedirect);
354 m_frame->loader().load(request); 359 m_frame->loader().load(request);
355 return; 360 return;
356 } 361 }
357 } 362 }
358 363
359 schedule(ScheduledLocationChange::create(originDocument, url, replacesCurren tItem)); 364 schedule(ScheduledLocationChange::create(originDocument, url, replacesCurren tItem));
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 m_redirect.clear(); 450 m_redirect.clear();
446 } 451 }
447 452
448 DEFINE_TRACE(NavigationScheduler) 453 DEFINE_TRACE(NavigationScheduler)
449 { 454 {
450 visitor->trace(m_frame); 455 visitor->trace(m_frame);
451 visitor->trace(m_redirect); 456 visitor->trace(m_redirect);
452 } 457 }
453 458
454 } // namespace blink 459 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/loader/NavigationScheduler.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698