Title: [143341] trunk/Source/WebKit2
Revision
143341
Author
carlo...@webkit.org
Date
2013-02-19 08:50:36 -0800 (Tue, 19 Feb 2013)

Log Message

[GTK] Move the API to get TLS certificate from WebKitURIResponse to WebKitWebView
https://bugs.webkit.org/show_bug.cgi?id=110190

Reviewed by Anders Carlsson.

Add webkit_web_view_get_tls_info() and remove
webkit_uri_response_get_https_status(). This way I can be sure
that when called after load has been committed the certificate
will be available. It also makes the API easier to use.

* UIProcess/API/gtk/WebKitURIResponse.cpp:
* UIProcess/API/gtk/WebKitURIResponse.h:
* UIProcess/API/gtk/WebKitURIResponsePrivate.h:
* UIProcess/API/gtk/WebKitWebView.cpp:
(webkitWebViewLoadChanged):
(mainResourceResponseChangedCallback):
(webkit_web_view_get_tls_info):
* UIProcess/API/gtk/WebKitWebView.h:
* UIProcess/API/gtk/docs/webkit2gtk-sections.txt:
* UIProcess/API/gtk/tests/TestSSL.cpp:

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (143340 => 143341)


--- trunk/Source/WebKit2/ChangeLog	2013-02-19 16:50:24 UTC (rev 143340)
+++ trunk/Source/WebKit2/ChangeLog	2013-02-19 16:50:36 UTC (rev 143341)
@@ -1,3 +1,26 @@
+2013-02-19  Carlos Garcia Campos  <cgar...@igalia.com>
+
+        [GTK] Move the API to get TLS certificate from WebKitURIResponse to WebKitWebView
+        https://bugs.webkit.org/show_bug.cgi?id=110190
+
+        Reviewed by Anders Carlsson.
+
+        Add webkit_web_view_get_tls_info() and remove
+        webkit_uri_response_get_https_status(). This way I can be sure
+        that when called after load has been committed the certificate
+        will be available. It also makes the API easier to use.
+
+        * UIProcess/API/gtk/WebKitURIResponse.cpp:
+        * UIProcess/API/gtk/WebKitURIResponse.h:
+        * UIProcess/API/gtk/WebKitURIResponsePrivate.h:
+        * UIProcess/API/gtk/WebKitWebView.cpp:
+        (webkitWebViewLoadChanged):
+        (mainResourceResponseChangedCallback):
+        (webkit_web_view_get_tls_info):
+        * UIProcess/API/gtk/WebKitWebView.h:
+        * UIProcess/API/gtk/docs/webkit2gtk-sections.txt:
+        * UIProcess/API/gtk/tests/TestSSL.cpp:
+
 2013-02-19  Mikhail Pozdnyakov  <mikhail.pozdnya...@intel.com>
 
         [WK2][EFL] Eliminate access to WK2 C++ internals from ewk_view functions

Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitURIResponse.cpp (143340 => 143341)


--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitURIResponse.cpp	2013-02-19 16:50:24 UTC (rev 143340)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitURIResponse.cpp	2013-02-19 16:50:36 UTC (rev 143341)
@@ -20,8 +20,6 @@
 #include "config.h"
 #include "WebKitURIResponse.h"
 
-#include "PlatformCertificateInfo.h"
-#include "WebCertificateInfo.h"
 #include "WebKitPrivate.h"
 #include "WebKitURIResponsePrivate.h"
 #include <glib/gi18n-lib.h>
@@ -218,31 +216,6 @@
 }
 
 /**
- * webkit_uri_response_get_https_status:
- * @response: a #WebKitURIResponse
- * @certificate: (out) (transfer none): return location for a #GTlsCertificate
- * @errors: (out): return location for a #GTlsCertificateFlags the verification status of @certificate
- *
- * Retrieves the #GTlsCertificate associated with the @response connection,
- * and the #GTlsCertificateFlags showing what problems, if any, have been found
- * with that certificate.
- * If the response connection is not HTTPS, this function returns %FALSE.
- *
- * Returns: %TRUE if @response connection uses HTTPS or %FALSE otherwise.
- */
-gboolean webkit_uri_response_get_https_status(WebKitURIResponse* response, GTlsCertificate** certificate, GTlsCertificateFlags* errors)
-{
-    g_return_val_if_fail(WEBKIT_IS_URI_RESPONSE(response), FALSE);
-
-    if (certificate)
-        *certificate = response->priv->resourceResponse.soupMessageCertificate();
-    if (errors)
-        *errors = response->priv->resourceResponse.soupMessageTLSErrors();
-
-    return !!response->priv->resourceResponse.soupMessageCertificate();
-}
-
-/**
  * webkit_uri_response_get_suggested_filename:
  * @response: a #WebKitURIResponse
  *
@@ -276,9 +249,3 @@
     return uriResponse->priv->resourceResponse;
 }
 
-void webkitURIResponseSetCertificateInfo(WebKitURIResponse* response, WebCertificateInfo* certificate)
-{
-    const PlatformCertificateInfo& certificateInfo = certificate->platformCertificateInfo();
-    response->priv->resourceResponse.setSoupMessageCertificate(certificateInfo.certificate());
-    response->priv->resourceResponse.setSoupMessageTLSErrors(certificateInfo.tlsErrors());
-}

Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitURIResponse.h (143340 => 143341)


--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitURIResponse.h	2013-02-19 16:50:24 UTC (rev 143340)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitURIResponse.h	2013-02-19 16:50:36 UTC (rev 143341)
@@ -67,10 +67,6 @@
 WEBKIT_API const gchar *
 webkit_uri_response_get_mime_type          (WebKitURIResponse    *response);
 
-WEBKIT_API gboolean
-webkit_uri_response_get_https_status       (WebKitURIResponse    *response,
-                                            GTlsCertificate     **certificate,
-                                            GTlsCertificateFlags *errors);
 WEBKIT_API const gchar *
 webkit_uri_response_get_suggested_filename (WebKitURIResponse    *response);
 

Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitURIResponsePrivate.h (143340 => 143341)


--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitURIResponsePrivate.h	2013-02-19 16:50:24 UTC (rev 143340)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitURIResponsePrivate.h	2013-02-19 16:50:36 UTC (rev 143341)
@@ -26,12 +26,10 @@
 #ifndef WebKitURIResponsePrivate_h
 #define WebKitURIResponsePrivate_h
 
-#include "WebCertificateInfo.h"
 #include "WebKitURIResponse.h"
 #include <WebCore/ResourceResponse.h>
 
 WebKitURIResponse* webkitURIResponseCreateForResourceResponse(const WebCore::ResourceResponse&);
 const WebCore::ResourceResponse& webkitURIResponseGetResourceResponse(WebKitURIResponse*);
-void webkitURIResponseSetCertificateInfo(WebKitURIResponse*, WebKit::WebCertificateInfo*);
 
 #endif // WebKitURIResponsePrivate_h

Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp (143340 => 143341)


--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp	2013-02-19 16:50:24 UTC (rev 143340)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp	2013-02-19 16:50:36 UTC (rev 143341)
@@ -21,6 +21,8 @@
 #include "config.h"
 #include "WebKitWebView.h"
 
+#include "PlatformCertificateInfo.h"
+#include "WebCertificateInfo.h"
 #include "WebContextMenuItem.h"
 #include "WebContextMenuItemData.h"
 #include "WebData.h"
@@ -1308,15 +1310,6 @@
     g_object_thaw_notify(G_OBJECT(webView));
 }
 
-static void setCertificateToMainResource(WebKitWebView* webView)
-{
-    WebKitWebViewPrivate* priv = webView->priv;
-    ASSERT(priv->mainResource.get());
-
-    webkitURIResponseSetCertificateInfo(webkit_web_resource_get_response(priv->mainResource.get()),
-                                        webkitWebResourceGetFrame(priv->mainResource.get())->certificateInfo());
-}
-
 static void webkitWebViewEmitLoadChanged(WebKitWebView* webView, WebKitLoadEvent loadEvent)
 {
     if (loadEvent == WEBKIT_LOAD_STARTED) {
@@ -1367,8 +1360,7 @@
             // main resource available when load has been committed, so we delay the emission of
             // load-changed signal until main resource object has been created.
             priv->waitingForMainResource = true;
-        } else
-            setCertificateToMainResource(webView);
+        }
     }
 
     if (priv->waitingForMainResource)
@@ -1527,7 +1519,6 @@
 static void mainResourceResponseChangedCallback(WebKitWebResource*, GParamSpec*, WebKitWebView* webView)
 {
     webkitWebViewDisconnectMainResourceResponseChangedSignalHandler(webView);
-    setCertificateToMainResource(webView);
     webkitWebViewEmitDelayedLoadEvents(webView);
 }
 
@@ -2897,3 +2888,37 @@
 
     return webView->priv->viewMode;
 }
+
+/**
+ * webkit_web_view_get_tls_info:
+ * @web_view: a #WebKitWebView
+ * @certificate: (out) (transfer none): return location for a #GTlsCertificate
+ * @errors: (out): return location for a #GTlsCertificateFlags the verification status of @certificate
+ *
+ * Retrieves the #GTlsCertificate associated with the @web_view connection,
+ * and the #GTlsCertificateFlags showing what problems, if any, have been found
+ * with that certificate.
+ * If the connection is not HTTPS, this function returns %FALSE.
+ * This function should be called after a response has been received from the
+ * server, so you can connect to #WebKitWebView::load-changed and call this function
+ * when it's emitted with %WEBKIT_LOAD_COMMITTED event.
+ *
+ * Returns: %TRUE if the @web_view connection uses HTTPS and a response has been received
+ *    from the server, or %FALSE otherwise.
+ */
+gboolean webkit_web_view_get_tls_info(WebKitWebView* webView, GTlsCertificate** certificate, GTlsCertificateFlags* errors)
+{
+    g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), FALSE);
+
+    WebFrameProxy* mainFrame = getPage(webView)->mainFrame();
+    if (!mainFrame)
+        return FALSE;
+
+    const PlatformCertificateInfo& certificateInfo = mainFrame->certificateInfo()->platformCertificateInfo();
+    if (certificate)
+        *certificate = certificateInfo.certificate();
+    if (errors)
+        *errors = certificateInfo.tlsErrors();
+
+    return !!certificateInfo.certificate();
+}

Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h (143340 => 143341)


--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h	2013-02-19 16:50:24 UTC (rev 143340)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h	2013-02-19 16:50:36 UTC (rev 143341)
@@ -414,6 +414,11 @@
 WEBKIT_API WebKitViewMode
 webkit_web_view_get_view_mode                        (WebKitWebView             *web_view);
 
+WEBKIT_API gboolean
+webkit_web_view_get_tls_info                         (WebKitWebView             *web_view,
+                                                      GTlsCertificate          **certificate,
+                                                      GTlsCertificateFlags      *errors);
+
 G_END_DECLS
 
 #endif

Modified: trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt (143340 => 143341)


--- trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt	2013-02-19 16:50:24 UTC (rev 143340)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt	2013-02-19 16:50:36 UTC (rev 143341)
@@ -133,6 +133,7 @@
 webkit_web_view_download_uri
 webkit_web_view_set_view_mode
 webkit_web_view_get_view_mode
+webkit_web_view_get_tls_info
 
 <SUBSECTION WebKitJavascriptResult>
 WebKitJavascriptResult
@@ -351,7 +352,6 @@
 webkit_uri_response_get_status_code
 webkit_uri_response_get_content_length
 webkit_uri_response_get_mime_type
-webkit_uri_response_get_https_status
 webkit_uri_response_get_suggested_filename
 
 <SUBSECTION Standard>

Modified: trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestSSL.cpp (143340 => 143341)


--- trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestSSL.cpp	2013-02-19 16:50:24 UTC (rev 143340)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestSSL.cpp	2013-02-19 16:50:36 UTC (rev 143341)
@@ -46,13 +46,8 @@
 
     virtual void loadCommitted()
     {
-        WebKitWebResource* resource = webkit_web_view_get_main_resource(m_webView);
-        g_assert(resource);
-        WebKitURIResponse* response = webkit_web_resource_get_response(resource);
-        g_assert(response);
-
         GTlsCertificate* certificate = 0;
-        webkit_uri_response_get_https_status(response, &certificate, &m_tlsErrors);
+        webkit_web_view_get_tls_info(m_webView, &certificate, &m_tlsErrors);
         m_certificate = certificate;
         LoadTrackingTest::loadCommitted();
     }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to