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

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

Issue 1444183003: Cancel javascript: URL navigations if the frame was navigated. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More comments Created 5 years, 1 month 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
« no previous file with comments | « third_party/WebKit/Source/core/loader/NavigationScheduler.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 #include "platform/SharedBuffer.h" 49 #include "platform/SharedBuffer.h"
50 #include "platform/UserGestureIndicator.h" 50 #include "platform/UserGestureIndicator.h"
51 #include "platform/scheduler/CancellableTaskFactory.h" 51 #include "platform/scheduler/CancellableTaskFactory.h"
52 #include "public/platform/Platform.h" 52 #include "public/platform/Platform.h"
53 #include "wtf/CurrentTime.h" 53 #include "wtf/CurrentTime.h"
54 54
55 namespace blink { 55 namespace blink {
56 56
57 unsigned NavigationDisablerForBeforeUnload::s_navigationDisableCount = 0; 57 unsigned NavigationDisablerForBeforeUnload::s_navigationDisableCount = 0;
58 58
59 FrameNavigationDisabler::FrameNavigationDisabler(LocalFrame* frame)
60 : m_navigationScheduler(&frame->navigationScheduler())
61 {
62 m_navigationScheduler->disableFrameNavigation();
63 }
64
65 FrameNavigationDisabler::~FrameNavigationDisabler()
66 {
67 m_navigationScheduler->enableFrameNavigation();
68 }
69
70 class ScheduledNavigation : public NoBaseWillBeGarbageCollectedFinalized<Schedul edNavigation> { 59 class ScheduledNavigation : public NoBaseWillBeGarbageCollectedFinalized<Schedul edNavigation> {
71 WTF_MAKE_NONCOPYABLE(ScheduledNavigation); USING_FAST_MALLOC_WILL_BE_REMOVED (ScheduledNavigation); 60 WTF_MAKE_NONCOPYABLE(ScheduledNavigation); USING_FAST_MALLOC_WILL_BE_REMOVED (ScheduledNavigation);
72 public: 61 public:
73 ScheduledNavigation(double delay, Document* originDocument, bool replacesCur rentItem, bool isLocationChange) 62 ScheduledNavigation(double delay, Document* originDocument, bool replacesCur rentItem, bool isLocationChange)
74 : m_delay(delay) 63 : m_delay(delay)
75 , m_originDocument(originDocument) 64 , m_originDocument(originDocument)
76 , m_replacesCurrentItem(replacesCurrentItem) 65 , m_replacesCurrentItem(replacesCurrentItem)
77 , m_isLocationChange(isLocationChange) 66 , m_isLocationChange(isLocationChange)
78 , m_wasUserGesture(UserGestureIndicator::processingUserGesture()) 67 , m_wasUserGesture(UserGestureIndicator::processingUserGesture())
79 { 68 {
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 { 251 {
263 ASSERT(m_submission->form()); 252 ASSERT(m_submission->form());
264 } 253 }
265 254
266 RefPtrWillBeMember<FormSubmission> m_submission; 255 RefPtrWillBeMember<FormSubmission> m_submission;
267 }; 256 };
268 257
269 NavigationScheduler::NavigationScheduler(LocalFrame* frame) 258 NavigationScheduler::NavigationScheduler(LocalFrame* frame)
270 : m_frame(frame) 259 : m_frame(frame)
271 , m_navigateTaskFactory(CancellableTaskFactory::create(this, &NavigationSche duler::navigateTask)) 260 , m_navigateTaskFactory(CancellableTaskFactory::create(this, &NavigationSche duler::navigateTask))
272 , m_navigationDisableCount(0)
273 { 261 {
274 } 262 }
275 263
276 NavigationScheduler::~NavigationScheduler() 264 NavigationScheduler::~NavigationScheduler()
277 { 265 {
278 // TODO(alexclarke): Can remove this if oilpan is on since any pending task should 266 // TODO(alexclarke): Can remove this if oilpan is on since any pending task should
279 // keep the NavigationScheduler alive. 267 // keep the NavigationScheduler alive.
280 if (m_navigateTaskFactory->isPending()) 268 if (m_navigateTaskFactory->isPending())
281 Platform::current()->currentThread()->scheduler()->removePendingNavigati on(); 269 Platform::current()->currentThread()->scheduler()->removePendingNavigati on();
282 } 270 }
283 271
284 bool NavigationScheduler::locationChangePending() 272 bool NavigationScheduler::locationChangePending()
285 { 273 {
286 return m_redirect && m_redirect->isLocationChange(); 274 return m_redirect && m_redirect->isLocationChange();
287 } 275 }
288 276
289 bool NavigationScheduler::isNavigationScheduled() const 277 bool NavigationScheduler::isNavigationScheduled() const
290 { 278 {
291 return m_redirect; 279 return m_redirect;
292 } 280 }
293 281
294 inline bool NavigationScheduler::shouldScheduleReload() const 282 inline bool NavigationScheduler::shouldScheduleReload() const
295 { 283 {
296 return m_frame->page() && isFrameNavigationAllowed() && NavigationDisablerFo rBeforeUnload::isNavigationAllowed(); 284 return m_frame->page() && m_frame->isNavigationAllowed() && NavigationDisabl erForBeforeUnload::isNavigationAllowed();
297 } 285 }
298 286
299 inline bool NavigationScheduler::shouldScheduleNavigation(const String& url) con st 287 inline bool NavigationScheduler::shouldScheduleNavigation(const String& url) con st
300 { 288 {
301 return m_frame->page() && isFrameNavigationAllowed() && (protocolIsJavaScrip t(url) || NavigationDisablerForBeforeUnload::isNavigationAllowed()); 289 return m_frame->page() && m_frame->isNavigationAllowed() && (protocolIsJavaS cript(url) || NavigationDisablerForBeforeUnload::isNavigationAllowed());
302 } 290 }
303 291
304 void NavigationScheduler::scheduleRedirect(double delay, const String& url) 292 void NavigationScheduler::scheduleRedirect(double delay, const String& url)
305 { 293 {
306 if (!shouldScheduleNavigation(url)) 294 if (!shouldScheduleNavigation(url))
307 return; 295 return;
308 if (delay < 0 || delay > INT_MAX / 1000) 296 if (delay < 0 || delay > INT_MAX / 1000)
309 return; 297 return;
310 if (url.isEmpty()) 298 if (url.isEmpty())
311 return; 299 return;
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 m_redirect.clear(); 432 m_redirect.clear();
445 } 433 }
446 434
447 DEFINE_TRACE(NavigationScheduler) 435 DEFINE_TRACE(NavigationScheduler)
448 { 436 {
449 visitor->trace(m_frame); 437 visitor->trace(m_frame);
450 visitor->trace(m_redirect); 438 visitor->trace(m_redirect);
451 } 439 }
452 440
453 } // namespace blink 441 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/loader/NavigationScheduler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698