Reviewed by Adam and Steve.
authordarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 6 Nov 2007 18:43:38 +0000 (18:43 +0000)
committerdarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 6 Nov 2007 18:43:38 +0000 (18:43 +0000)
        - added hooks needed to implement showModalDialog on Windows

        * Interfaces/IWebUIDelegate.idl: Added canRunModal, createModalDialog,
        and runModal functions to the end of IWebUIDelegate3.

        * WebChromeClient.h: Added uiDelegate and uiDelegate2 helper functions,
        so it's easier to write client functions.
        * WebChromeClient.cpp:
        (WebChromeClient::createWindow): Implemented dialog case. Calls IWebUIDelegate3.
        (WebChromeClient::canRunModal): Implemented. Calls IWebUIDelegate3.
        (WebChromeClient::runModal): Ditto.
        (WebChromeClient::uiDelegate): Added.
        (WebChromeClient::uiDelegate2): Added.
        (WebChromeClient::uiDelegate3): Added.

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

WebKit/win/ChangeLog
WebKit/win/Interfaces/IWebUIDelegate.idl
WebKit/win/WebChromeClient.cpp
WebKit/win/WebChromeClient.h

index 90c3e1fe65225c896bd8fb4003a054203b780c19..6f7d9c177b9102dbf1d97db4f1392a71cd0bcf90 100644 (file)
@@ -1,3 +1,22 @@
+2007-11-06  Darin Adler  <darin@apple.com>
+
+        Reviewed by Adam and Steve.
+
+        - added hooks needed to implement showModalDialog on Windows
+
+        * Interfaces/IWebUIDelegate.idl: Added canRunModal, createModalDialog,
+        and runModal functions to the end of IWebUIDelegate3.
+
+        * WebChromeClient.h: Added uiDelegate and uiDelegate2 helper functions,
+        so it's easier to write client functions.
+        * WebChromeClient.cpp:
+        (WebChromeClient::createWindow): Implemented dialog case. Calls IWebUIDelegate3.
+        (WebChromeClient::canRunModal): Implemented. Calls IWebUIDelegate3.
+        (WebChromeClient::runModal): Ditto.
+        (WebChromeClient::uiDelegate): Added.
+        (WebChromeClient::uiDelegate2): Added.
+        (WebChromeClient::uiDelegate3): Added.
+
 2007-11-06  Alexey Proskuryakov  <ap@webkit.org>
 
         Rubber-stamped by Adam Roben.
index 8774668e896a1be0ec5ad91528efd0d82de0e2d6..e4fc3418c822c95f19ad2cc26c3aeee328468912 100644 (file)
@@ -781,3 +781,20 @@ interface IWebUIDelegate2 : IWebUIDelegate
 
     HRESULT webViewPrintingMarginRect([in] IWebView* webView, [out, retval] RECT* rect);
 }
+
+/*!
+    @category WebUIDelegate3
+    @discussion A class that supplements the IWebUIDelegate interface
+*/
+[
+    object,
+    oleautomation,
+    uuid(DD544D90-C233-4562-8EFD-A8D3A0DEBC19),
+    pointer_default(unique)
+]
+interface IWebUIDelegate3 : IWebUIDelegate2
+{
+    HRESULT canRunModal([in] IWebView* webView, [out, retval] BOOL* canRunBoolean);
+    HRESULT createModalDialog([in] IWebView* sender, [in] IWebURLRequest* request, [out, retval] IWebView** newWebView);
+    HRESULT runModal([in] IWebView* webView);
+}
index b090db38354b3b7aeec0a155bb87382394779baa..eab7177942e54618d70672988024970fc9c72ab3 100644 (file)
@@ -134,19 +134,26 @@ void WebChromeClient::takeFocus(FocusDirection direction)
 
 Page* WebChromeClient::createWindow(Frame*, const FrameLoadRequest& frameLoadRequest, const WindowFeatures& features)
 {
+    if (features.dialog) {
+        COMPtr<IWebUIDelegate3> delegate = uiDelegate3();
+        if (!delegate)
+            return 0;
+        COMPtr<IWebMutableURLRequest> request(AdoptCOM, WebMutableURLRequest::createInstance(frameLoadRequest.resourceRequest()));
+        COMPtr<IWebView> dialog;
+        if (FAILED(delegate->createModalDialog(m_webView, request.get(), &dialog)))
+            return 0;
+        return core(dialog.get());
+    }
+
     Page* page = 0;
     IWebUIDelegate* uiDelegate = 0;
     IWebMutableURLRequest* request = WebMutableURLRequest::createInstance(frameLoadRequest.resourceRequest());
 
     if (SUCCEEDED(m_webView->uiDelegate(&uiDelegate))) {
-        if (features.dialog) {
-            notImplemented();
-        } else {
-            IWebView* webView = 0;
-            if (SUCCEEDED(uiDelegate->createWebViewWithRequest(m_webView, request, &webView))) {
-                page = core(webView);
-                webView->Release();
-            }
+        IWebView* webView = 0;
+        if (SUCCEEDED(uiDelegate->createWebViewWithRequest(m_webView, request, &webView))) {
+            page = core(webView);
+            webView->Release();
         }
     
         uiDelegate->Release();
@@ -167,22 +174,16 @@ void WebChromeClient::show()
 
 bool WebChromeClient::canRunModal()
 {
-    bool result = false;
-    IWebUIDelegate* uiDelegate = 0;
-    if (SUCCEEDED(m_webView->uiDelegate(&uiDelegate))) {
-        notImplemented();
-        uiDelegate->Release();
-    }
+    BOOL result = FALSE;
+    if (COMPtr<IWebUIDelegate3> delegate = uiDelegate3())
+        delegate->canRunModal(m_webView, &result);
     return result;
 }
 
 void WebChromeClient::runModal()
 {
-    IWebUIDelegate* uiDelegate = 0;
-    if (SUCCEEDED(m_webView->uiDelegate(&uiDelegate))) {
-        notImplemented();
-        uiDelegate->Release();
-    }
+    if (COMPtr<IWebUIDelegate3> delegate = uiDelegate3())
+        delegate->runModal(m_webView);
 }
 
 void WebChromeClient::setToolbarsVisible(bool visible)
@@ -463,3 +464,20 @@ bool WebChromeClient::runDatabaseSizeLimitPrompt(Frame*, const String&)
     notImplemented();
     return false;
 }
+
+COMPtr<IWebUIDelegate> WebChromeClient::uiDelegate()
+{
+    COMPtr<IWebUIDelegate> delegate;
+    m_webView->uiDelegate(&delegate);
+    return delegate;
+}
+
+COMPtr<IWebUIDelegate2> WebChromeClient::uiDelegate2()
+{
+    return COMPtr<IWebUIDelegate2>(Query, uiDelegate());
+}
+
+COMPtr<IWebUIDelegate3> WebChromeClient::uiDelegate3()
+{
+    return COMPtr<IWebUIDelegate3>(Query, uiDelegate());
+}
index 3501bae736c0d00ad533e1cc201d4537e98952fe..b434bcc38ee7513c2ddd5e9290ebc4f46797fef8 100644 (file)
  */
 
 #include <WebCore/ChromeClient.h>
+#include <WebCore/COMPtr.h>
 #include <WebCore/FocusDirection.h>
 #include <wtf/Forward.h>
 
 class WebView;
 
+interface IWebUIDelegate;
+interface IWebUIDelegate2;
+interface IWebUIDelegate3;
+
 class WebChromeClient : public WebCore::ChromeClient {
 public:
     WebChromeClient(WebView*);
@@ -94,6 +99,11 @@ public:
     virtual void print(WebCore::Frame*);
 
     virtual bool runDatabaseSizeLimitPrompt(WebCore::Frame*, const WebCore::String& origin);
+
 private:
+    COMPtr<IWebUIDelegate> uiDelegate();
+    COMPtr<IWebUIDelegate2> uiDelegate2();
+    COMPtr<IWebUIDelegate3> uiDelegate3();
+
     WebView* m_webView;
 };