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

Side by Side Diff: third_party/WebKit/Source/web/ChromeClientImpl.cpp

Issue 1778753003: Fire visibilitychange event on unload (behind the flag) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix tests Created 4 years, 9 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/Source/platform/RuntimeEnabledFeatures.in ('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) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 #include "web/WebPluginContainerImpl.h" 103 #include "web/WebPluginContainerImpl.h"
104 #include "web/WebSettingsImpl.h" 104 #include "web/WebSettingsImpl.h"
105 #include "web/WebViewImpl.h" 105 #include "web/WebViewImpl.h"
106 #include "wtf/text/CString.h" 106 #include "wtf/text/CString.h"
107 #include "wtf/text/CharacterNames.h" 107 #include "wtf/text/CharacterNames.h"
108 #include "wtf/text/StringBuilder.h" 108 #include "wtf/text/StringBuilder.h"
109 #include "wtf/text/StringConcatenate.h" 109 #include "wtf/text/StringConcatenate.h"
110 110
111 namespace blink { 111 namespace blink {
112 112
113 namespace {
114
115 const char* dialogTypeToString(ChromeClient::DialogType dialogType)
116 {
117 switch (dialogType) {
118 case ChromeClient::AlertDialog:
119 return "alert";
120 case ChromeClient::ConfirmDialog:
121 return "confirm";
122 case ChromeClient::PromptDialog:
123 return "prompt";
124 case ChromeClient::HTMLDialog:
125 ASSERT_NOT_REACHED();
126 }
127 ASSERT_NOT_REACHED();
128 return "";
129 }
130
131 const char* dismissalTypeToString(Document::PageDismissalType dismissalType)
132 {
133 switch (dismissalType) {
134 case Document::BeforeUnloadDismissal:
135 return "beforeunload";
136 case Document::PageHideDismissal:
137 return "pagehide";
138 case Document::UnloadVisibilityChangeDismissal:
139 return "visibilitychange";
140 case Document::UnloadDismissal:
141 return "unload";
142 case Document::NoDismissal:
143 ASSERT_NOT_REACHED();
144 }
145 ASSERT_NOT_REACHED();
146 return "";
147 }
148
149 } // namespace
150
113 class CompositorAnimationTimeline; 151 class CompositorAnimationTimeline;
114 152
115 // Converts a AXObjectCache::AXNotification to a WebAXEvent 153 // Converts a AXObjectCache::AXNotification to a WebAXEvent
116 static WebAXEvent toWebAXEvent(AXObjectCache::AXNotification notification) 154 static WebAXEvent toWebAXEvent(AXObjectCache::AXNotification notification)
117 { 155 {
118 // These enums have the same values; enforced in AssertMatchingEnums.cpp. 156 // These enums have the same values; enforced in AssertMatchingEnums.cpp.
119 return static_cast<WebAXEvent>(notification); 157 return static_cast<WebAXEvent>(notification);
120 } 158 }
121 159
122 ChromeClientImpl::ChromeClientImpl(WebViewImpl* webView) 160 ChromeClientImpl::ChromeClientImpl(WebViewImpl* webView)
(...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after
852 m_webView->closePagePopup(popup); 890 m_webView->closePagePopup(popup);
853 } 891 }
854 892
855 DOMWindow* ChromeClientImpl::pagePopupWindowForTesting() const 893 DOMWindow* ChromeClientImpl::pagePopupWindowForTesting() const
856 { 894 {
857 return m_webView->pagePopupWindow(); 895 return m_webView->pagePopupWindow();
858 } 896 }
859 897
860 bool ChromeClientImpl::shouldOpenModalDialogDuringPageDismissal(const DialogType & dialogType, const String& dialogMessage, Document::PageDismissalType dismissal Type) const 898 bool ChromeClientImpl::shouldOpenModalDialogDuringPageDismissal(const DialogType & dialogType, const String& dialogMessage, Document::PageDismissalType dismissal Type) const
861 { 899 {
862 const char* const kDialogs[] = { "alert", "confirm", "prompt" }; 900 String message = String("Blocked ") + dialogTypeToString(dialogType) + "('" + dialogMessage + "') during " + dismissalTypeToString(dismissalType) + ".";
863 int dialog = static_cast<int>(dialogType);
864 ASSERT_WITH_SECURITY_IMPLICATION(0 <= dialog);
865 ASSERT_WITH_SECURITY_IMPLICATION(dialog < static_cast<int>(WTF_ARRAY_LENGTH( kDialogs)));
866
867 const char* const kDismissals[] = { "beforeunload", "pagehide", "unload" };
868 int dismissal = static_cast<int>(dismissalType) - 1; // Exclude NoDismissal.
869 ASSERT_WITH_SECURITY_IMPLICATION(0 <= dismissal);
870 ASSERT_WITH_SECURITY_IMPLICATION(dismissal < static_cast<int>(WTF_ARRAY_LENG TH(kDismissals)));
871
872 DEFINE_STATIC_LOCAL(EnumerationHistogram, dialogDismissalHistogram, ("Render er.ModalDialogsDuringPageDismissal", WTF_ARRAY_LENGTH(kDialogs) * WTF_ARRAY_LENG TH(kDismissals)));
873 dialogDismissalHistogram.count(dismissal * WTF_ARRAY_LENGTH(kDialogs) + dial og);
874
875 String message = String("Blocked ") + kDialogs[dialog] + "('" + dialogMessag e + "') during " + kDismissals[dismissal] + ".";
876 m_webView->mainFrame()->addMessageToConsole(WebConsoleMessage(WebConsoleMess age::LevelError, message)); 901 m_webView->mainFrame()->addMessageToConsole(WebConsoleMessage(WebConsoleMess age::LevelError, message));
877 902
878 return false; 903 return false;
879 } 904 }
880 905
881 void ChromeClientImpl::setEventListenerProperties(WebEventListenerClass eventCla ss, WebEventListenerProperties properties) 906 void ChromeClientImpl::setEventListenerProperties(WebEventListenerClass eventCla ss, WebEventListenerProperties properties)
882 { 907 {
883 if (eventClass == WebEventListenerClass::Touch) 908 if (eventClass == WebEventListenerClass::Touch)
884 m_webView->hasTouchEventHandlers(properties != WebEventListenerPropertie s::Nothing); 909 m_webView->hasTouchEventHandlers(properties != WebEventListenerPropertie s::Nothing);
885 910
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
1058 if (m_webView->pageImportanceSignals()) 1083 if (m_webView->pageImportanceSignals())
1059 m_webView->pageImportanceSignals()->setIssuedNonGetFetchFromScript(); 1084 m_webView->pageImportanceSignals()->setIssuedNonGetFetchFromScript();
1060 } 1085 }
1061 1086
1062 PassOwnPtr<WebFrameScheduler> ChromeClientImpl::createFrameScheduler() 1087 PassOwnPtr<WebFrameScheduler> ChromeClientImpl::createFrameScheduler()
1063 { 1088 {
1064 return m_webView->scheduler()->createFrameScheduler().release(); 1089 return m_webView->scheduler()->createFrameScheduler().release();
1065 } 1090 }
1066 1091
1067 } // namespace blink 1092 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/RuntimeEnabledFeatures.in ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698