2011-04-09 Sreeram Ramachandran <sreeram@google.com>
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 9 Apr 2011 08:01:20 +0000 (08:01 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 9 Apr 2011 08:01:20 +0000 (08:01 +0000)
        Reviewed by Ryosuke Niwa.

        Gather data on modal dialogs shown during unload events
        https://bugs.webkit.org/show_bug.cgi?id=58115

        Add a new method to the ChromeClient API to allow clients to receive
        notifications of modal dialogs dispatched during page dismissal events.
        The new method has a default empty definition; only chromium overrides
        it to keep track of histograms.

        No tests because this is a no-op for all ports except chromium (and it's
        not clear how to test chromium histograms from webkit).

        * page/Chrome.cpp:
        (WebCore::isDuringPageDismissal):
        (WebCore::willRunModalDialog):
        (WebCore::Chrome::runJavaScriptAlert):
        (WebCore::Chrome::runJavaScriptConfirm):
        (WebCore::Chrome::runJavaScriptPrompt):
        (WebCore::Chrome::willRunModalHTMLDialog):
        * page/Chrome.h:
        * page/ChromeClient.h:
        (WebCore::ChromeClient::willRunModalDialogDuringPageDismissal):
        * page/DOMWindow.cpp:
        (WebCore::DOMWindow::showModalDialog):
2011-04-09  Sreeram Ramachandran  <sreeram@google.com>

        Reviewed by Ryosuke Niwa.

        Gather data on modal dialogs shown during unload events
        https://bugs.webkit.org/show_bug.cgi?id=58115

        Implementation of the new API to receive notifications of modal dialogs
        dispatched during unload events. Count the notifications through a histogram.

        No tests because it's not clear how to test chromium histograms from webkit.

        * src/ChromeClientImpl.cpp:
        (WebKit::ChromeClientImpl::willRunModalDialogDuringPageDismissal):
        * src/ChromeClientImpl.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@83375 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/page/Chrome.cpp
Source/WebCore/page/Chrome.h
Source/WebCore/page/ChromeClient.h
Source/WebCore/page/DOMWindow.cpp
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/src/ChromeClientImpl.cpp
Source/WebKit/chromium/src/ChromeClientImpl.h

index 4a4d5f2..5dc5d78 100644 (file)
@@ -1,3 +1,31 @@
+2011-04-09  Sreeram Ramachandran  <sreeram@google.com>
+
+        Reviewed by Ryosuke Niwa.
+
+        Gather data on modal dialogs shown during unload events
+        https://bugs.webkit.org/show_bug.cgi?id=58115
+
+        Add a new method to the ChromeClient API to allow clients to receive
+        notifications of modal dialogs dispatched during page dismissal events.
+        The new method has a default empty definition; only chromium overrides
+        it to keep track of histograms.
+
+        No tests because this is a no-op for all ports except chromium (and it's
+        not clear how to test chromium histograms from webkit).
+
+        * page/Chrome.cpp:
+        (WebCore::isDuringPageDismissal):
+        (WebCore::willRunModalDialog):
+        (WebCore::Chrome::runJavaScriptAlert):
+        (WebCore::Chrome::runJavaScriptConfirm):
+        (WebCore::Chrome::runJavaScriptPrompt):
+        (WebCore::Chrome::willRunModalHTMLDialog):
+        * page/Chrome.h:
+        * page/ChromeClient.h:
+        (WebCore::ChromeClient::willRunModalDialogDuringPageDismissal):
+        * page/DOMWindow.cpp:
+        (WebCore::DOMWindow::showModalDialog):
+
 2011-04-08  David Humphrey  <david.humphrey@senecac.on.ca>
 
         Reviewed by Eric Carlson.
index 5881d5e..fa64677 100644 (file)
@@ -280,8 +280,16 @@ void Chrome::closeWindowSoon()
     m_client->closeWindowSoon();
 }
 
+static inline void willRunModalDialog(const Frame* frame, const ChromeClient::DialogType& dialogType, const ChromeClient* client)
+{
+    if (frame->loader()->pageDismissalEventBeingDispatched())
+        client->willRunModalDialogDuringPageDismissal(dialogType);
+}
+
 void Chrome::runJavaScriptAlert(Frame* frame, const String& message)
 {
+    willRunModalDialog(frame, ChromeClient::AlertDialog, m_client);
+
     // Defer loads in case the client method runs a new event loop that would
     // otherwise cause the load to continue while we're in the middle of executing JavaScript.
     PageGroupLoadDeferrer deferrer(m_page, true);
@@ -292,6 +300,8 @@ void Chrome::runJavaScriptAlert(Frame* frame, const String& message)
 
 bool Chrome::runJavaScriptConfirm(Frame* frame, const String& message)
 {
+    willRunModalDialog(frame, ChromeClient::ConfirmDialog, m_client);
+
     // Defer loads in case the client method runs a new event loop that would
     // otherwise cause the load to continue while we're in the middle of executing JavaScript.
     PageGroupLoadDeferrer deferrer(m_page, true);
@@ -302,6 +312,8 @@ bool Chrome::runJavaScriptConfirm(Frame* frame, const String& message)
 
 bool Chrome::runJavaScriptPrompt(Frame* frame, const String& prompt, const String& defaultValue, String& result)
 {
+    willRunModalDialog(frame, ChromeClient::PromptDialog, m_client);
+
     // Defer loads in case the client method runs a new event loop that would
     // otherwise cause the load to continue while we're in the middle of executing JavaScript.
     PageGroupLoadDeferrer deferrer(m_page, true);
@@ -547,4 +559,9 @@ bool Chrome::requiresFullscreenForVideoPlayback()
     return m_client->requiresFullscreenForVideoPlayback();
 }
 
+void Chrome::willRunModalHTMLDialog(const Frame* frame) const
+{
+    willRunModalDialog(frame, ChromeClient::HTMLDialog, m_client);
+}
+
 } // namespace WebCore
index 9984a7c..9e4f9dc 100644 (file)
@@ -175,6 +175,8 @@ namespace WebCore {
         void showContextMenu();
 #endif
 
+        void willRunModalHTMLDialog(const Frame*) const;
+
     private:
         Page* m_page;
         ChromeClient* m_client;
index f535ece..e2e7c9d 100644 (file)
@@ -303,6 +303,15 @@ namespace WebCore {
 
         virtual void didCompleteRubberBandForMainFrame(const IntSize&) const { }
 
+        enum DialogType {
+            AlertDialog = 0,
+            ConfirmDialog = 1,
+            PromptDialog = 2,
+            HTMLDialog = 3,
+            NumDialogTypes = 4
+        };
+        virtual void willRunModalDialogDuringPageDismissal(const DialogType&) const { }
+
     protected:
         virtual ~ChromeClient() { }
     };
index a8ef6c4..bb67070 100644 (file)
@@ -1838,6 +1838,9 @@ void DOMWindow::showModalDialog(const String& urlString, const String& dialogFea
     if (!firstFrame)
         return;
 
+    if (m_frame->page())
+        m_frame->page()->chrome()->willRunModalHTMLDialog(m_frame);
+
     if (!canShowModalDialogNow(m_frame) || !firstWindow->allowPopUp())
         return;
 
index f251dda..3b46081 100644 (file)
@@ -1,3 +1,19 @@
+2011-04-09  Sreeram Ramachandran  <sreeram@google.com>
+
+        Reviewed by Ryosuke Niwa.
+
+        Gather data on modal dialogs shown during unload events
+        https://bugs.webkit.org/show_bug.cgi?id=58115
+
+        Implementation of the new API to receive notifications of modal dialogs
+        dispatched during unload events. Count the notifications through a histogram.
+
+        No tests because it's not clear how to test chromium histograms from webkit.
+
+        * src/ChromeClientImpl.cpp:
+        (WebKit::ChromeClientImpl::willRunModalDialogDuringPageDismissal):
+        * src/ChromeClientImpl.h:
+
 2011-04-08  Aaron Boodman  <aa@chromium.org>
 
         Reviewed by Dmitry Titov.
index 99302cc..8b853c8 100644 (file)
@@ -54,6 +54,7 @@
 #include "Node.h"
 #include "NotificationPresenterImpl.h"
 #include "Page.h"
+#include "PlatformBridge.h"
 #include "PopupMenuChromium.h"
 #include "RenderWidget.h"
 #include "ScriptController.h"
@@ -905,4 +906,9 @@ PassRefPtr<SearchPopupMenu> ChromeClientImpl::createSearchPopupMenu(PopupMenuCli
     return adoptRef(new SearchPopupMenuChromium(client));
 }
 
+void ChromeClientImpl::willRunModalDialogDuringPageDismissal(const DialogType& dialogType) const
+{
+    PlatformBridge::histogramEnumeration("Renderer.ModalDialogsDuringPageDismissal", static_cast<int>(dialogType), static_cast<int>(NumDialogTypes));
+}
+
 } // namespace WebKit
index f3a48ee..afc3432 100644 (file)
@@ -191,6 +191,8 @@ public:
     virtual void showContextMenu() { }
 #endif
 
+    virtual void willRunModalDialogDuringPageDismissal(const DialogType&) const;
+
 private:
     void getPopupMenuInfo(WebCore::PopupContainer*, WebPopupMenuInfo*);
     void setCursor(const WebCursorInfo&);