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

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

Issue 2801813005: Only show a beforeunload dialog if a frame has had a user gesture since its load. (Closed)
Patch Set: test fix Created 3 years, 7 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) 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 3153 matching lines...) Expand 10 before | Expand all | Expand 10 after
3164 BeforeUnloadEvent* before_unload_event = BeforeUnloadEvent::Create(); 3164 BeforeUnloadEvent* before_unload_event = BeforeUnloadEvent::Create();
3165 before_unload_event->initEvent(EventTypeNames::beforeunload, false, true); 3165 before_unload_event->initEvent(EventTypeNames::beforeunload, false, true);
3166 load_event_progress_ = kBeforeUnloadEventInProgress; 3166 load_event_progress_ = kBeforeUnloadEventInProgress;
3167 dom_window_->DispatchEvent(before_unload_event, this); 3167 dom_window_->DispatchEvent(before_unload_event, this);
3168 load_event_progress_ = kBeforeUnloadEventCompleted; 3168 load_event_progress_ = kBeforeUnloadEventCompleted;
3169 if (!before_unload_event->defaultPrevented()) 3169 if (!before_unload_event->defaultPrevented())
3170 DefaultEventHandler(before_unload_event); 3170 DefaultEventHandler(before_unload_event);
3171 if (!GetFrame() || before_unload_event->returnValue().IsNull()) 3171 if (!GetFrame() || before_unload_event->returnValue().IsNull())
3172 return true; 3172 return true;
3173 3173
3174 if (!GetFrame()->HasReceivedUserGesture()) {
3175 AddConsoleMessage(ConsoleMessage::Create(
3176 kJSMessageSource, kErrorMessageLevel,
3177 "Blocked attempt to show a 'beforeunload' confirmation panel for a "
3178 "frame that never had a user gesture since its load. "
3179 "https://www.chromestatus.com/feature/5082396709879808"));
3180 return true;
3181 }
3182
3174 if (did_allow_navigation) { 3183 if (did_allow_navigation) {
3175 AddConsoleMessage(ConsoleMessage::Create( 3184 AddConsoleMessage(ConsoleMessage::Create(
3176 kJSMessageSource, kErrorMessageLevel, 3185 kJSMessageSource, kErrorMessageLevel,
3177 "Blocked attempt to show multiple 'beforeunload' confirmation panels " 3186 "Blocked attempt to show multiple 'beforeunload' confirmation panels "
3178 "for a single navigation.")); 3187 "for a single navigation."));
3179 return true; 3188 return true;
3180 } 3189 }
3181 3190
3182 String text = before_unload_event->returnValue(); 3191 String text = before_unload_event->returnValue();
3183 if (chrome_client.OpenBeforeUnloadConfirmPanel(text, frame_, is_reload)) { 3192 if (chrome_client.OpenBeforeUnloadConfirmPanel(text, frame_, is_reload)) {
(...skipping 3595 matching lines...) Expand 10 before | Expand all | Expand 10 after
6779 } 6788 }
6780 6789
6781 void showLiveDocumentInstances() { 6790 void showLiveDocumentInstances() {
6782 WeakDocumentSet& set = liveDocumentSet(); 6791 WeakDocumentSet& set = liveDocumentSet();
6783 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); 6792 fprintf(stderr, "There are %u documents currently alive:\n", set.size());
6784 for (blink::Document* document : set) 6793 for (blink::Document* document : set)
6785 fprintf(stderr, "- Document %p URL: %s\n", document, 6794 fprintf(stderr, "- Document %p URL: %s\n", document,
6786 document->Url().GetString().Utf8().data()); 6795 document->Url().GetString().Utf8().data());
6787 } 6796 }
6788 #endif 6797 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698