Changeset 143341 in webkit


Ignore:
Timestamp:
Feb 19, 2013 8:50:36 AM (11 years ago)
Author:
Carlos Garcia Campos
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:
Location:
trunk/Source/WebKit2
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r143339 r143341  
     12013-02-19  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK] Move the API to get TLS certificate from WebKitURIResponse to WebKitWebView
     4        https://bugs.webkit.org/show_bug.cgi?id=110190
     5
     6        Reviewed by Anders Carlsson.
     7
     8        Add webkit_web_view_get_tls_info() and remove
     9        webkit_uri_response_get_https_status(). This way I can be sure
     10        that when called after load has been committed the certificate
     11        will be available. It also makes the API easier to use.
     12
     13        * UIProcess/API/gtk/WebKitURIResponse.cpp:
     14        * UIProcess/API/gtk/WebKitURIResponse.h:
     15        * UIProcess/API/gtk/WebKitURIResponsePrivate.h:
     16        * UIProcess/API/gtk/WebKitWebView.cpp:
     17        (webkitWebViewLoadChanged):
     18        (mainResourceResponseChangedCallback):
     19        (webkit_web_view_get_tls_info):
     20        * UIProcess/API/gtk/WebKitWebView.h:
     21        * UIProcess/API/gtk/docs/webkit2gtk-sections.txt:
     22        * UIProcess/API/gtk/tests/TestSSL.cpp:
     23
    1242013-02-19  Mikhail Pozdnyakov  <mikhail.pozdnyakov@intel.com>
    225
  • trunk/Source/WebKit2/UIProcess/API/gtk/WebKitURIResponse.cpp

    r137469 r143341  
    2121#include "WebKitURIResponse.h"
    2222
    23 #include "PlatformCertificateInfo.h"
    24 #include "WebCertificateInfo.h"
    2523#include "WebKitPrivate.h"
    2624#include "WebKitURIResponsePrivate.h"
     
    219217
    220218/**
    221  * webkit_uri_response_get_https_status:
    222  * @response: a #WebKitURIResponse
    223  * @certificate: (out) (transfer none): return location for a #GTlsCertificate
    224  * @errors: (out): return location for a #GTlsCertificateFlags the verification status of @certificate
    225  *
    226  * Retrieves the #GTlsCertificate associated with the @response connection,
    227  * and the #GTlsCertificateFlags showing what problems, if any, have been found
    228  * with that certificate.
    229  * If the response connection is not HTTPS, this function returns %FALSE.
    230  *
    231  * Returns: %TRUE if @response connection uses HTTPS or %FALSE otherwise.
    232  */
    233 gboolean webkit_uri_response_get_https_status(WebKitURIResponse* response, GTlsCertificate** certificate, GTlsCertificateFlags* errors)
    234 {
    235     g_return_val_if_fail(WEBKIT_IS_URI_RESPONSE(response), FALSE);
    236 
    237     if (certificate)
    238         *certificate = response->priv->resourceResponse.soupMessageCertificate();
    239     if (errors)
    240         *errors = response->priv->resourceResponse.soupMessageTLSErrors();
    241 
    242     return !!response->priv->resourceResponse.soupMessageCertificate();
    243 }
    244 
    245 /**
    246219 * webkit_uri_response_get_suggested_filename:
    247220 * @response: a #WebKitURIResponse
     
    277250}
    278251
    279 void webkitURIResponseSetCertificateInfo(WebKitURIResponse* response, WebCertificateInfo* certificate)
    280 {
    281     const PlatformCertificateInfo& certificateInfo = certificate->platformCertificateInfo();
    282     response->priv->resourceResponse.setSoupMessageCertificate(certificateInfo.certificate());
    283     response->priv->resourceResponse.setSoupMessageTLSErrors(certificateInfo.tlsErrors());
    284 }
  • trunk/Source/WebKit2/UIProcess/API/gtk/WebKitURIResponse.h

    r125910 r143341  
    6868webkit_uri_response_get_mime_type          (WebKitURIResponse    *response);
    6969
    70 WEBKIT_API gboolean
    71 webkit_uri_response_get_https_status       (WebKitURIResponse    *response,
    72                                             GTlsCertificate     **certificate,
    73                                             GTlsCertificateFlags *errors);
    7470WEBKIT_API const gchar *
    7571webkit_uri_response_get_suggested_filename (WebKitURIResponse    *response);
  • trunk/Source/WebKit2/UIProcess/API/gtk/WebKitURIResponsePrivate.h

    r141096 r143341  
    2727#define WebKitURIResponsePrivate_h
    2828
    29 #include "WebCertificateInfo.h"
    3029#include "WebKitURIResponse.h"
    3130#include <WebCore/ResourceResponse.h>
     
    3332WebKitURIResponse* webkitURIResponseCreateForResourceResponse(const WebCore::ResourceResponse&);
    3433const WebCore::ResourceResponse& webkitURIResponseGetResourceResponse(WebKitURIResponse*);
    35 void webkitURIResponseSetCertificateInfo(WebKitURIResponse*, WebKit::WebCertificateInfo*);
    3634
    3735#endif // WebKitURIResponsePrivate_h
  • trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp

    r143302 r143341  
    2222#include "WebKitWebView.h"
    2323
     24#include "PlatformCertificateInfo.h"
     25#include "WebCertificateInfo.h"
    2426#include "WebContextMenuItem.h"
    2527#include "WebContextMenuItemData.h"
     
    13091311}
    13101312
    1311 static void setCertificateToMainResource(WebKitWebView* webView)
    1312 {
    1313     WebKitWebViewPrivate* priv = webView->priv;
    1314     ASSERT(priv->mainResource.get());
    1315 
    1316     webkitURIResponseSetCertificateInfo(webkit_web_resource_get_response(priv->mainResource.get()),
    1317                                         webkitWebResourceGetFrame(priv->mainResource.get())->certificateInfo());
    1318 }
    1319 
    13201313static void webkitWebViewEmitLoadChanged(WebKitWebView* webView, WebKitLoadEvent loadEvent)
    13211314{
     
    13681361            // load-changed signal until main resource object has been created.
    13691362            priv->waitingForMainResource = true;
    1370         } else
    1371             setCertificateToMainResource(webView);
     1363        }
    13721364    }
    13731365
     
    15281520{
    15291521    webkitWebViewDisconnectMainResourceResponseChangedSignalHandler(webView);
    1530     setCertificateToMainResource(webView);
    15311522    webkitWebViewEmitDelayedLoadEvents(webView);
    15321523}
     
    28982889    return webView->priv->viewMode;
    28992890}
     2891
     2892/**
     2893 * webkit_web_view_get_tls_info:
     2894 * @web_view: a #WebKitWebView
     2895 * @certificate: (out) (transfer none): return location for a #GTlsCertificate
     2896 * @errors: (out): return location for a #GTlsCertificateFlags the verification status of @certificate
     2897 *
     2898 * Retrieves the #GTlsCertificate associated with the @web_view connection,
     2899 * and the #GTlsCertificateFlags showing what problems, if any, have been found
     2900 * with that certificate.
     2901 * If the connection is not HTTPS, this function returns %FALSE.
     2902 * This function should be called after a response has been received from the
     2903 * server, so you can connect to #WebKitWebView::load-changed and call this function
     2904 * when it's emitted with %WEBKIT_LOAD_COMMITTED event.
     2905 *
     2906 * Returns: %TRUE if the @web_view connection uses HTTPS and a response has been received
     2907 *    from the server, or %FALSE otherwise.
     2908 */
     2909gboolean webkit_web_view_get_tls_info(WebKitWebView* webView, GTlsCertificate** certificate, GTlsCertificateFlags* errors)
     2910{
     2911    g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), FALSE);
     2912
     2913    WebFrameProxy* mainFrame = getPage(webView)->mainFrame();
     2914    if (!mainFrame)
     2915        return FALSE;
     2916
     2917    const PlatformCertificateInfo& certificateInfo = mainFrame->certificateInfo()->platformCertificateInfo();
     2918    if (certificate)
     2919        *certificate = certificateInfo.certificate();
     2920    if (errors)
     2921        *errors = certificateInfo.tlsErrors();
     2922
     2923    return !!certificateInfo.certificate();
     2924}
  • trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h

    r143302 r143341  
    415415webkit_web_view_get_view_mode                        (WebKitWebView             *web_view);
    416416
     417WEBKIT_API gboolean
     418webkit_web_view_get_tls_info                         (WebKitWebView             *web_view,
     419                                                      GTlsCertificate          **certificate,
     420                                                      GTlsCertificateFlags      *errors);
     421
    417422G_END_DECLS
    418423
  • trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt

    r143302 r143341  
    134134webkit_web_view_set_view_mode
    135135webkit_web_view_get_view_mode
     136webkit_web_view_get_tls_info
    136137
    137138<SUBSECTION WebKitJavascriptResult>
     
    352353webkit_uri_response_get_content_length
    353354webkit_uri_response_get_mime_type
    354 webkit_uri_response_get_https_status
    355355webkit_uri_response_get_suggested_filename
    356356
  • trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestSSL.cpp

    r138273 r143341  
    4747    virtual void loadCommitted()
    4848    {
    49         WebKitWebResource* resource = webkit_web_view_get_main_resource(m_webView);
    50         g_assert(resource);
    51         WebKitURIResponse* response = webkit_web_resource_get_response(resource);
    52         g_assert(response);
    53 
    5449        GTlsCertificate* certificate = 0;
    55         webkit_uri_response_get_https_status(response, &certificate, &m_tlsErrors);
     50        webkit_web_view_get_tls_info(m_webView, &certificate, &m_tlsErrors);
    5651        m_certificate = certificate;
    5752        LoadTrackingTest::loadCommitted();
Note: See TracChangeset for help on using the changeset viewer.