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

Side by Side Diff: third_party/WebKit/Source/core/dom/Document.cpp

Issue 2750483007: Only show a beforeunload dialog if a frame has been interacted with. (Closed)
Patch Set: rev Created 3 years, 8 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
« no previous file with comments | « third_party/WebKit/LayoutTests/inspector-protocol/page/javascriptDialogEvents.html ('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) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All
7 * rights reserved. 7 * rights reserved.
8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved.
9 * (http://www.torchmobile.com/) 9 * (http://www.torchmobile.com/)
10 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. 10 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved.
(...skipping 3037 matching lines...) Expand 10 before | Expand all | Expand 10 after
3048 BeforeUnloadEvent* beforeUnloadEvent = BeforeUnloadEvent::create(); 3048 BeforeUnloadEvent* beforeUnloadEvent = BeforeUnloadEvent::create();
3049 beforeUnloadEvent->initEvent(EventTypeNames::beforeunload, false, true); 3049 beforeUnloadEvent->initEvent(EventTypeNames::beforeunload, false, true);
3050 m_loadEventProgress = BeforeUnloadEventInProgress; 3050 m_loadEventProgress = BeforeUnloadEventInProgress;
3051 m_domWindow->dispatchEvent(beforeUnloadEvent, this); 3051 m_domWindow->dispatchEvent(beforeUnloadEvent, this);
3052 m_loadEventProgress = BeforeUnloadEventCompleted; 3052 m_loadEventProgress = BeforeUnloadEventCompleted;
3053 if (!beforeUnloadEvent->defaultPrevented()) 3053 if (!beforeUnloadEvent->defaultPrevented())
3054 defaultEventHandler(beforeUnloadEvent); 3054 defaultEventHandler(beforeUnloadEvent);
3055 if (!frame() || beforeUnloadEvent->returnValue().isNull()) 3055 if (!frame() || beforeUnloadEvent->returnValue().isNull())
3056 return true; 3056 return true;
3057 3057
3058 if (!frame()->hasReceivedUserGesture()) {
3059 addConsoleMessage(ConsoleMessage::create(
3060 JSMessageSource, ErrorMessageLevel,
3061 "Blocked attempt to show a 'beforeunload' confirmation panel for a "
3062 "frame without a user gesture."));
3063 return true;
3064 }
3065
3058 if (didAllowNavigation) { 3066 if (didAllowNavigation) {
3059 addConsoleMessage(ConsoleMessage::create( 3067 addConsoleMessage(ConsoleMessage::create(
3060 JSMessageSource, ErrorMessageLevel, 3068 JSMessageSource, ErrorMessageLevel,
3061 "Blocked attempt to show multiple 'beforeunload' confirmation panels " 3069 "Blocked attempt to show multiple 'beforeunload' confirmation panels "
3062 "for a single navigation.")); 3070 "for a single navigation."));
3063 return true; 3071 return true;
3064 } 3072 }
3065 3073
3066 String text = beforeUnloadEvent->returnValue(); 3074 String text = beforeUnloadEvent->returnValue();
3067 if (chromeClient.openBeforeUnloadConfirmPanel(text, m_frame, isReload)) { 3075 if (chromeClient.openBeforeUnloadConfirmPanel(text, m_frame, isReload)) {
(...skipping 3573 matching lines...) Expand 10 before | Expand all | Expand 10 after
6641 } 6649 }
6642 6650
6643 void showLiveDocumentInstances() { 6651 void showLiveDocumentInstances() {
6644 WeakDocumentSet& set = liveDocumentSet(); 6652 WeakDocumentSet& set = liveDocumentSet();
6645 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); 6653 fprintf(stderr, "There are %u documents currently alive:\n", set.size());
6646 for (blink::Document* document : set) 6654 for (blink::Document* document : set)
6647 fprintf(stderr, "- Document %p URL: %s\n", document, 6655 fprintf(stderr, "- Document %p URL: %s\n", document,
6648 document->url().getString().utf8().data()); 6656 document->url().getString().utf8().data());
6649 } 6657 }
6650 #endif 6658 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/inspector-protocol/page/javascriptDialogEvents.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698