Changeset 171792 in webkit


Ignore:
Timestamp:
Jul 30, 2014 12:06:43 AM (10 years ago)
Author:
Carlos Garcia Campos
Message:

[GTK] Remove WebKitCertificateInfo from WebKit2GTK+ API
https://bugs.webkit.org/show_bug.cgi?id=134830

Reviewed by Gustavo Noronha Silva.

Source/WebKit2:
It was added to make the API more convenient but it has ended up
making it more complicated. WebKitWebView::load-failed-with-tls-errors
now receives a GTlsCertificate + GTlsCertificateFlags and
webkit_web_context_allow_tls_certificate_for_host() receives a GTlsCertificate
since the errors are not actually needed. This makes the API more
consistent with the existing method webkit_web_view_get_tls_info().

  • PlatformGTK.cmake: Remove files from compilation.
  • UIProcess/API/gtk/WebKitCertificateInfo.cpp: Removed.
  • UIProcess/API/gtk/WebKitCertificateInfo.h: Removed.
  • UIProcess/API/gtk/WebKitCertificateInfoPrivate.h: Removed.
  • UIProcess/API/gtk/WebKitWebContext.cpp:

(webkit_web_context_allow_tls_certificate_for_host):

  • UIProcess/API/gtk/WebKitWebContext.h:
  • UIProcess/API/gtk/WebKitWebView.cpp:

(webkit_web_view_class_init):
(webkitWebViewLoadFailedWithTLSErrors):

  • UIProcess/API/gtk/WebKitWebView.h:
  • UIProcess/API/gtk/docs/webkit2gtk-docs.sgml:
  • UIProcess/API/gtk/docs/webkit2gtk-sections.txt:
  • UIProcess/API/gtk/webkit2.h:

Tools:
Update the SSL test for the API changes.

  • TestWebKitAPI/Tests/WebKit2Gtk/TestSSL.cpp:

(testLoadFailedWithTLSErrors):

Location:
trunk
Files:
3 deleted
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r171788 r171792  
     12014-07-29  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK] Remove WebKitCertificateInfo from WebKit2GTK+ API
     4        https://bugs.webkit.org/show_bug.cgi?id=134830
     5
     6        Reviewed by Gustavo Noronha Silva.
     7
     8        It was added to make the API more convenient but it has ended up
     9        making it more complicated. WebKitWebView::load-failed-with-tls-errors
     10        now receives a GTlsCertificate + GTlsCertificateFlags and
     11        webkit_web_context_allow_tls_certificate_for_host() receives a GTlsCertificate
     12        since the errors are not actually needed. This makes the API more
     13        consistent with the existing method webkit_web_view_get_tls_info().
     14
     15        * PlatformGTK.cmake: Remove files from compilation.
     16        * UIProcess/API/gtk/WebKitCertificateInfo.cpp: Removed.
     17        * UIProcess/API/gtk/WebKitCertificateInfo.h: Removed.
     18        * UIProcess/API/gtk/WebKitCertificateInfoPrivate.h: Removed.
     19        * UIProcess/API/gtk/WebKitWebContext.cpp:
     20        (webkit_web_context_allow_tls_certificate_for_host):
     21        * UIProcess/API/gtk/WebKitWebContext.h:
     22        * UIProcess/API/gtk/WebKitWebView.cpp:
     23        (webkit_web_view_class_init):
     24        (webkitWebViewLoadFailedWithTLSErrors):
     25        * UIProcess/API/gtk/WebKitWebView.h:
     26        * UIProcess/API/gtk/docs/webkit2gtk-docs.sgml:
     27        * UIProcess/API/gtk/docs/webkit2gtk-sections.txt:
     28        * UIProcess/API/gtk/webkit2.h:
     29
    1302014-07-29  Jinwoo Song  <jinwoo7.song@samsung.com>
    231
  • trunk/Source/WebKit2/PlatformGTK.cmake

    r171742 r171792  
    101101    UIProcess/API/gtk/WebKitBackForwardListItem.h
    102102    UIProcess/API/gtk/WebKitBackForwardListPrivate.h
    103     UIProcess/API/gtk/WebKitCertificateInfo.cpp
    104     UIProcess/API/gtk/WebKitCertificateInfo.h
    105     UIProcess/API/gtk/WebKitCertificateInfoPrivate.h
    106103    UIProcess/API/gtk/WebKitContextMenu.cpp
    107104    UIProcess/API/gtk/WebKitContextMenu.h
     
    325322    ${WEBKIT2_DIR}/UIProcess/API/gtk/WebKitBackForwardList.h
    326323    ${WEBKIT2_DIR}/UIProcess/API/gtk/WebKitBackForwardListItem.h
    327     ${WEBKIT2_DIR}/UIProcess/API/gtk/WebKitCertificateInfo.h
    328324    ${WEBKIT2_DIR}/UIProcess/API/gtk/WebKitCredential.h
    329325    ${WEBKIT2_DIR}/UIProcess/API/gtk/WebKitContextMenu.h
  • trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp

    r171742 r171792  
    2727#include "WebGeolocationManagerProxy.h"
    2828#include "WebKitBatteryProvider.h"
    29 #include "WebKitCertificateInfoPrivate.h"
    3029#include "WebKitCookieManagerPrivate.h"
    3130#include "WebKitDownloadClient.h"
     
    901900 * webkit_web_context_allow_tls_certificate_for_host:
    902901 * @context: a #WebKitWebContext
    903  * @info: a #WebKitCertificateInfo
     902 * @certificate: a #GTlsCertificate
    904903 * @host: the host for which a certificate is to be allowed
    905904 *
    906905 * Ignore further TLS errors on the @host for the certificate present in @info.
    907906 *
    908  * Since: 2.4
    909  */
    910 void webkit_web_context_allow_tls_certificate_for_host(WebKitWebContext* context, WebKitCertificateInfo* info, const gchar* host)
    911 {
    912     g_return_if_fail(WEBKIT_IS_WEB_CONTEXT(context));
    913     g_return_if_fail(info);
     907 * Since: 2.6
     908 */
     909void webkit_web_context_allow_tls_certificate_for_host(WebKitWebContext* context, GTlsCertificate* certificate, const gchar* host)
     910{
     911    g_return_if_fail(WEBKIT_IS_WEB_CONTEXT(context));
     912    g_return_if_fail(G_IS_TLS_CERTIFICATE(certificate));
    914913    g_return_if_fail(host);
    915914
    916     RefPtr<WebCertificateInfo> webCertificateInfo = WebCertificateInfo::create(webkitCertificateInfoGetCertificateInfo(info));
     915    RefPtr<WebCertificateInfo> webCertificateInfo = WebCertificateInfo::create(WebCore::CertificateInfo(certificate, static_cast<GTlsCertificateFlags>(0)));
    917916    context->priv->context->allowSpecificHTTPSCertificateForHost(webCertificateInfo.get(), String::fromUTF8(host));
    918917}
  • trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.h

    r163698 r171792  
    2626
    2727#include <glib-object.h>
    28 #include <webkit2/WebKitCertificateInfo.h>
    2928#include <webkit2/WebKitCookieManager.h>
    3029#include <webkit2/WebKitDefines.h>
     
    237236WEBKIT_API void
    238237webkit_web_context_allow_tls_certificate_for_host   (WebKitWebContext              *context,
    239                                                      WebKitCertificateInfo         *info,
     238                                                     GTlsCertificate               *certificate,
    240239                                                     const gchar                   *host);
    241240
  • trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp

    r171742 r171792  
    3030#include "WebKitAuthenticationRequestPrivate.h"
    3131#include "WebKitBackForwardListPrivate.h"
    32 #include "WebKitCertificateInfoPrivate.h"
    3332#include "WebKitContextMenuClient.h"
    3433#include "WebKitContextMenuItemPrivate.h"
     
    872871     * WebKitWebView::load-failed-with-tls-errors:
    873872     * @web_view: the #WebKitWebView on which the signal is emitted
    874      * @info: a #WebKitCertificateInfo
     873     * @certificate: a #GTlsCertificate
     874     * @errors: a #GTlsCertificateFlags with the verification status of @certificate
    875875     * @host: the host on which the error occurred
    876876     *
    877      * Emitted when a TLS error occurs during a load operation. The @info
    878      * object contains information about the error such as the #GTlsCertificate
    879      * and the #GTlsCertificateFlags. To allow an exception for this certificate
     877     * Emitted when a TLS error occurs during a load operation.
     878     * To allow an exception for this certificate
    880879     * and this host use webkit_web_context_allow_tls_certificate_for_host().
    881880     *
    882      * To handle this signal asynchronously you should copy the #WebKitCertificateInfo
    883      * with webkit_certificate_info_copy() and return %TRUE.
     881     * To handle this signal asynchronously you should call g_object_ref() on @certificate
     882     * and return %TRUE.
    884883     *
    885884     * If %FALSE is returned, #WebKitWebView::load-failed will be emitted. The load
     
    889888     *   %FALSE to propagate the event further.
    890889     *
    891      * Since: 2.4
     890     * Since: 2.6
    892891     */
    893892    signals[LOAD_FAILED_WITH_TLS_ERRORS] =
     
    897896            G_STRUCT_OFFSET(WebKitWebViewClass, load_failed_with_tls_errors),
    898897            g_signal_accumulator_true_handled, 0 /* accumulator data */,
    899             webkit_marshal_BOOLEAN__BOXED_STRING,
    900             G_TYPE_BOOLEAN, 2, /* number of parameters */
    901             WEBKIT_TYPE_CERTIFICATE_INFO  | G_SIGNAL_TYPE_STATIC_SCOPE,
     898            g_cclosure_marshal_generic,
     899            G_TYPE_BOOLEAN, 3,
     900            G_TYPE_TLS_CERTIFICATE,
     901            G_TYPE_TLS_CERTIFICATE_FLAGS,
    902902            G_TYPE_STRING);
    903903
     
    15831583    if (tlsErrorsPolicy == WEBKIT_TLS_ERRORS_POLICY_FAIL) {
    15841584        GUniquePtr<SoupURI> soupURI(soup_uri_new(failingURI));
    1585         WebKitCertificateInfo info(certificate, tlsErrors);
    15861585        gboolean returnValue;
    1587         g_signal_emit(webView, signals[LOAD_FAILED_WITH_TLS_ERRORS], 0, &info, soupURI->host, &returnValue);
     1586        g_signal_emit(webView, signals[LOAD_FAILED_WITH_TLS_ERRORS], 0, certificate, tlsErrors, soupURI->host, &returnValue);
    15881587        if (!returnValue)
    15891588            g_signal_emit(webView, signals[LOAD_FAILED], 0, WEBKIT_LOAD_STARTED, failingURI, error, &returnValue);
  • trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h

    r171742 r171792  
    236236                                                WebKitAuthenticationRequest *request);
    237237    gboolean   (* load_failed_with_tls_errors) (WebKitWebView               *web_view,
    238                                                 WebKitCertificateInfo       *info,
     238                                                GTlsCertificate             *certificate,
     239                                                GTlsCertificateFlags         errors,
    239240                                                const gchar                 *host);
    240241    void (*_webkit_reserved0) (void);
  • trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml

    r171742 r171792  
    4444    <xi:include href="xml/WebKitFormSubmissionRequest.xml"/>
    4545    <xi:include href="xml/WebKitSecurityManager.xml"/>
    46     <xi:include href="xml/WebKitCertificateInfo.xml"/>
    4746  </chapter>
    4847
  • trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt

    r171742 r171792  
    11431143webkit_script_world_get_type
    11441144</SECTION>
    1145 
    1146 <SECTION>
    1147 <FILE>WebKitCertificateInfo</FILE>
    1148 WebKitCertificateInfo
    1149 webkit_certificate_info_copy
    1150 webkit_certificate_info_free
    1151 webkit_certificate_info_get_tls_certificate
    1152 webkit_certificate_info_get_tls_errors
    1153 
    1154 <SUBSECTION Standard>
    1155 WEBKIT_TYPE_CERTIFICATE_INFO
    1156 
    1157 <SUBSECTION Private>
    1158 webkit_certificate_info_get_type
    1159 </SECTION>
  • trunk/Source/WebKit2/UIProcess/API/gtk/webkit2.h

    r171742 r171792  
    3131#include <webkit2/WebKitBackForwardList.h>
    3232#include <webkit2/WebKitBackForwardListItem.h>
    33 #include <webkit2/WebKitCertificateInfo.h>
    3433#include <webkit2/WebKitContextMenu.h>
    3534#include <webkit2/WebKitContextMenuActions.h>
  • trunk/Tools/ChangeLog

    r171789 r171792  
     12014-07-29  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK] Remove WebKitCertificateInfo from WebKit2GTK+ API
     4        https://bugs.webkit.org/show_bug.cgi?id=134830
     5
     6        Reviewed by Gustavo Noronha Silva.
     7
     8        Update the SSL test for the API changes.
     9
     10        * TestWebKitAPI/Tests/WebKit2Gtk/TestSSL.cpp:
     11        (testLoadFailedWithTLSErrors):
     12
    1132014-07-24  David Farler  <dfarler@apple.com>
    214
  • trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestSSL.cpp

    r168417 r171792  
    150150
    151151    TLSErrorsTest()
     152        : m_tlsErrors(static_cast<GTlsCertificateFlags>(0))
    152153    {
    153154        g_signal_connect(m_webView, "load-failed-with-tls-errors", G_CALLBACK(runLoadFailedWithTLSErrorsCallback), this);
     
    157158    {
    158159        g_signal_handlers_disconnect_matched(m_webView, G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, this);
    159         if (m_certificateInfo)
    160             webkit_certificate_info_free(m_certificateInfo);
    161     }
    162 
    163     static gboolean runLoadFailedWithTLSErrorsCallback(WebKitWebView*, WebKitCertificateInfo* info, const char* host, TLSErrorsTest* test)
    164     {
    165         test->runLoadFailedWithTLSErrors(info, host);
     160    }
     161
     162    static gboolean runLoadFailedWithTLSErrorsCallback(WebKitWebView*, GTlsCertificate* certificate, GTlsCertificateFlags tlsErrors, const char* host, TLSErrorsTest* test)
     163    {
     164        test->runLoadFailedWithTLSErrors(certificate, tlsErrors, host);
    166165        return TRUE;
    167166    }
    168167
    169     void runLoadFailedWithTLSErrors(WebKitCertificateInfo* info, const char* host)
    170     {
    171         if (m_certificateInfo)
    172             webkit_certificate_info_free(m_certificateInfo);
    173         m_certificateInfo = webkit_certificate_info_copy(info);
     168    void runLoadFailedWithTLSErrors(GTlsCertificate* certificate, GTlsCertificateFlags tlsErrors, const char* host)
     169    {
     170        assertObjectIsDeletedWhenTestFinishes(G_OBJECT(certificate));
     171        m_certificate = certificate;
     172        m_tlsErrors = tlsErrors;
    174173        m_host.reset(g_strdup(host));
    175174        g_main_loop_quit(m_mainLoop);
     
    181180    }
    182181
    183     WebKitCertificateInfo* certificateInfo()
    184     {
    185         return m_certificateInfo;
    186     }
    187 
    188     const char* host()
    189     {
    190         return m_host.get();
    191     }
     182    GTlsCertificate* certificate() const { return m_certificate.get(); }
     183    GTlsCertificateFlags tlsErrors() const { return m_tlsErrors; }
     184    const char* host() const { return m_host.get(); }
    192185
    193186private:
    194     WebKitCertificateInfo* m_certificateInfo;
     187    GRefPtr<GTlsCertificate> m_certificate;
     188    GTlsCertificateFlags m_tlsErrors;
    195189    GUniquePtr<char> m_host;
    196190};
     
    205199    test->waitUntilLoadFailedWithTLSErrors();
    206200    // Test the WebKitCertificateInfo API.
    207     g_assert(G_IS_TLS_CERTIFICATE(webkit_certificate_info_get_tls_certificate(test->certificateInfo())));
    208     g_assert_cmpuint(webkit_certificate_info_get_tls_errors(test->certificateInfo()), ==, G_TLS_CERTIFICATE_UNKNOWN_CA);
     201    g_assert(G_IS_TLS_CERTIFICATE(test->certificate()));
     202    g_assert_cmpuint(test->tlsErrors(), ==, G_TLS_CERTIFICATE_UNKNOWN_CA);
    209203    g_assert_cmpstr(test->host(), ==, soup_uri_get_host(kHttpsServer->baseURI()));
    210204    g_assert_cmpint(test->m_loadEvents[0], ==, LoadTrackingTest::ProvisionalLoadStarted);
     
    212206
    213207    // Test allowing an exception for this certificate on this host.
    214     webkit_web_context_allow_tls_certificate_for_host(context, test->certificateInfo(), test->host());
     208    webkit_web_context_allow_tls_certificate_for_host(context, test->certificate(), test->host());
    215209    // The page should now load without errors.
    216210    test->loadURI(kHttpsServer->getURIForPath("/test-tls/").data());
Note: See TracChangeset for help on using the changeset viewer.