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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/platform/RuntimeEnabledFeatures.in ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/web/ChromeClientImpl.cpp
diff --git a/third_party/WebKit/Source/web/ChromeClientImpl.cpp b/third_party/WebKit/Source/web/ChromeClientImpl.cpp
index b099c8b0037714bcd3463ba62248f777e0b2a660..3431dd885759e57b6e33e6fd9c706833a4f37680 100644
--- a/third_party/WebKit/Source/web/ChromeClientImpl.cpp
+++ b/third_party/WebKit/Source/web/ChromeClientImpl.cpp
@@ -110,6 +110,44 @@
namespace blink {
+namespace {
+
+const char* dialogTypeToString(ChromeClient::DialogType dialogType)
+{
+ switch (dialogType) {
+ case ChromeClient::AlertDialog:
+ return "alert";
+ case ChromeClient::ConfirmDialog:
+ return "confirm";
+ case ChromeClient::PromptDialog:
+ return "prompt";
+ case ChromeClient::HTMLDialog:
+ ASSERT_NOT_REACHED();
+ }
+ ASSERT_NOT_REACHED();
+ return "";
+}
+
+const char* dismissalTypeToString(Document::PageDismissalType dismissalType)
+{
+ switch (dismissalType) {
+ case Document::BeforeUnloadDismissal:
+ return "beforeunload";
+ case Document::PageHideDismissal:
+ return "pagehide";
+ case Document::UnloadVisibilityChangeDismissal:
+ return "visibilitychange";
+ case Document::UnloadDismissal:
+ return "unload";
+ case Document::NoDismissal:
+ ASSERT_NOT_REACHED();
+ }
+ ASSERT_NOT_REACHED();
+ return "";
+}
+
+} // namespace
+
class CompositorAnimationTimeline;
// Converts a AXObjectCache::AXNotification to a WebAXEvent
@@ -859,20 +897,7 @@ DOMWindow* ChromeClientImpl::pagePopupWindowForTesting() const
bool ChromeClientImpl::shouldOpenModalDialogDuringPageDismissal(const DialogType& dialogType, const String& dialogMessage, Document::PageDismissalType dismissalType) const
{
- const char* const kDialogs[] = { "alert", "confirm", "prompt" };
- int dialog = static_cast<int>(dialogType);
- ASSERT_WITH_SECURITY_IMPLICATION(0 <= dialog);
- ASSERT_WITH_SECURITY_IMPLICATION(dialog < static_cast<int>(WTF_ARRAY_LENGTH(kDialogs)));
-
- const char* const kDismissals[] = { "beforeunload", "pagehide", "unload" };
- int dismissal = static_cast<int>(dismissalType) - 1; // Exclude NoDismissal.
- ASSERT_WITH_SECURITY_IMPLICATION(0 <= dismissal);
- ASSERT_WITH_SECURITY_IMPLICATION(dismissal < static_cast<int>(WTF_ARRAY_LENGTH(kDismissals)));
-
- DEFINE_STATIC_LOCAL(EnumerationHistogram, dialogDismissalHistogram, ("Renderer.ModalDialogsDuringPageDismissal", WTF_ARRAY_LENGTH(kDialogs) * WTF_ARRAY_LENGTH(kDismissals)));
- dialogDismissalHistogram.count(dismissal * WTF_ARRAY_LENGTH(kDialogs) + dialog);
-
- String message = String("Blocked ") + kDialogs[dialog] + "('" + dialogMessage + "') during " + kDismissals[dismissal] + ".";
+ String message = String("Blocked ") + dialogTypeToString(dialogType) + "('" + dialogMessage + "') during " + dismissalTypeToString(dismissalType) + ".";
m_webView->mainFrame()->addMessageToConsole(WebConsoleMessage(WebConsoleMessage::LevelError, message));
return false;
« 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