Changeset 185876 in webkit


Ignore:
Timestamp:
Jun 23, 2015 9:45:30 AM (9 years ago)
Author:
mitz@apple.com
Message:

<rdar://problem/21342465> Make -[WKWebView _certificateChain] public.
https://bugs.webkit.org/show_bug.cgi?id=145886

Reviewed by Sam Weinig.

  • Shared/WebCertificateInfo.h:

(WebKit::WebCertificateInfo::create): Changed to return a Ref rather than a PassRefPtr.

  • UIProcess/API/Cocoa/WKBrowsingContextController.mm: Added no-op overrides of new

PageLoadState::Observer functions to PageLoadStateObserver.

  • UIProcess/API/Cocoa/WKProcessGroup.mm:

(-[WKProcessGroup _setAllowsSpecificHTTPSCertificate:forHost:]): Updated for change to
WebCertificateInfo::create.

  • UIProcess/API/Cocoa/WKProcessPool.mm:

(-[WKProcessPool _setAllowsSpecificHTTPSCertificate:forHost:]): Ditto.

  • UIProcess/API/Cocoa/WKWebView.h: Declared new certificateChain property on WKWebView.
  • UIProcess/API/Cocoa/WKWebView.mm:

(-[WKWebView certificateChain]): Added. Returns the certificate chain from the page load
state, or an empty array if there is no certificate chain.

  • UIProcess/API/Cocoa/WKWebViewPrivate.h: Deprecated _certificateChain.
  • UIProcess/Cocoa/NavigationState.h: Declared overrides of new PageLoadState::Observer

functions.

  • UIProcess/Cocoa/NavigationState.mm:

(WebKit::NavigationState::willChangeCertificateInfo): Override to call
-willChangeValueForKey:.
(WebKit::NavigationState::didChangeCertificateInfo): Override to call
-didChangeValueForKey:.

  • UIProcess/PageLoadState.cpp:

(WebKit::PageLoadState::commitChanges): Call the new observer functions
willChangeCertificateInfo and didChangeCertificateInfo.
(WebKit::PageLoadState::didCommitLoad): Added new certificateInfo parameter, which is stored
in the uncommitted state.

  • UIProcess/PageLoadState.h:

(WebKit::PageLoadState::certificateInfo): Added this getter.

  • UIProcess/WebFrameProxy.cpp:

(WebKit::WebFrameProxy::didCommitLoad): Changed the parameter type from
WebCore::CertificateInfo to WebCertificateInfo.

  • UIProcess/WebFrameProxy.h:
  • UIProcess/WebPageProxy.cpp:

(WebKit::WebPageProxy::didCommitLoadForFrame): Pass the certificate info to
PageLoadState::didCommitLoad.

Location:
trunk/Source/WebKit2
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r185866 r185876  
     12015-06-23  Dan Bernstein  <mitz@apple.com>
     2
     3        <rdar://problem/21342465> Make -[WKWebView _certificateChain] public.
     4        https://bugs.webkit.org/show_bug.cgi?id=145886
     5
     6        Reviewed by Sam Weinig.
     7
     8        * Shared/WebCertificateInfo.h:
     9        (WebKit::WebCertificateInfo::create): Changed to return a Ref rather than a PassRefPtr.
     10
     11        * UIProcess/API/Cocoa/WKBrowsingContextController.mm: Added no-op overrides of new
     12        PageLoadState::Observer functions to PageLoadStateObserver.
     13
     14        * UIProcess/API/Cocoa/WKProcessGroup.mm:
     15        (-[WKProcessGroup _setAllowsSpecificHTTPSCertificate:forHost:]): Updated for change to
     16        WebCertificateInfo::create.
     17
     18        * UIProcess/API/Cocoa/WKProcessPool.mm:
     19        (-[WKProcessPool _setAllowsSpecificHTTPSCertificate:forHost:]): Ditto.
     20
     21        * UIProcess/API/Cocoa/WKWebView.h: Declared new certificateChain property on WKWebView.
     22
     23        * UIProcess/API/Cocoa/WKWebView.mm:
     24        (-[WKWebView certificateChain]): Added. Returns the certificate chain from the page load
     25        state, or an empty array if there is no certificate chain.
     26
     27        * UIProcess/API/Cocoa/WKWebViewPrivate.h: Deprecated _certificateChain.
     28
     29        * UIProcess/Cocoa/NavigationState.h: Declared overrides of new PageLoadState::Observer
     30        functions.
     31        * UIProcess/Cocoa/NavigationState.mm:
     32        (WebKit::NavigationState::willChangeCertificateInfo): Override to call
     33        -willChangeValueForKey:.
     34        (WebKit::NavigationState::didChangeCertificateInfo): Override to call
     35        -didChangeValueForKey:.
     36
     37        * UIProcess/PageLoadState.cpp:
     38        (WebKit::PageLoadState::commitChanges): Call the new observer functions
     39        willChangeCertificateInfo and didChangeCertificateInfo.
     40        (WebKit::PageLoadState::didCommitLoad): Added new certificateInfo parameter, which is stored
     41        in the uncommitted state.
     42        * UIProcess/PageLoadState.h:
     43        (WebKit::PageLoadState::certificateInfo): Added this getter.
     44
     45        * UIProcess/WebFrameProxy.cpp:
     46        (WebKit::WebFrameProxy::didCommitLoad): Changed the parameter type from
     47        WebCore::CertificateInfo to WebCertificateInfo.
     48        * UIProcess/WebFrameProxy.h:
     49
     50        * UIProcess/WebPageProxy.cpp:
     51        (WebKit::WebPageProxy::didCommitLoadForFrame): Pass the certificate info to
     52        PageLoadState::didCommitLoad.
     53
    1542015-06-22  Gyuyoung Kim  <gyuyoung.kim@webkit.org>
    255
  • trunk/Source/WebKit2/Shared/WebCertificateInfo.h

    r160487 r185876  
    2929#include "APIObject.h"
    3030#include <WebCore/CertificateInfo.h>
    31 #include <wtf/PassRefPtr.h>
     31#include <wtf/Ref.h>
    3232
    3333namespace WebKit {
     
    3535class WebCertificateInfo : public API::ObjectImpl<API::Object::Type::CertificateInfo> {
    3636public:
    37     static PassRefPtr<WebCertificateInfo> create(const WebCore::CertificateInfo& info)
     37    static Ref<WebCertificateInfo> create(const WebCore::CertificateInfo& info)
    3838    {
    39         return adoptRef(new WebCertificateInfo(info));
     39        return adoptRef(*new WebCertificateInfo(info));
    4040    }
    4141
  • trunk/Source/WebKit2/UIProcess/API/Cocoa/WKBrowsingContextController.mm

    r184982 r185876  
    126126    virtual void willChangeNetworkRequestsInProgress() override { }
    127127    virtual void didChangeNetworkRequestsInProgress() override { }
     128    virtual void willChangeCertificateInfo() override { }
     129    virtual void didChangeCertificateInfo() override { }
    128130
    129131    WKBrowsingContextController *m_controller;
  • trunk/Source/WebKit2/UIProcess/API/Cocoa/WKProcessGroup.mm

    r180424 r185876  
    228228- (void)_setAllowsSpecificHTTPSCertificate:(NSArray *)certificateChain forHost:(NSString *)host
    229229{
    230     _processPool->allowSpecificHTTPSCertificateForHost(WebCertificateInfo::create(WebCore::CertificateInfo((CFArrayRef)certificateChain)).get(), host);
     230    _processPool->allowSpecificHTTPSCertificateForHost(WebCertificateInfo::create(WebCore::CertificateInfo((CFArrayRef)certificateChain)).ptr(), host);
    231231}
    232232
  • trunk/Source/WebKit2/UIProcess/API/Cocoa/WKProcessPool.mm

    r181906 r185876  
    131131- (void)_setAllowsSpecificHTTPSCertificate:(NSArray *)certificateChain forHost:(NSString *)host
    132132{
    133     _processPool->allowSpecificHTTPSCertificateForHost(WebKit::WebCertificateInfo::create(WebCore::CertificateInfo((CFArrayRef)certificateChain)).get(), host);
     133    _processPool->allowSpecificHTTPSCertificateForHost(WebKit::WebCertificateInfo::create(WebCore::CertificateInfo((CFArrayRef)certificateChain)).ptr(), host);
    134134}
    135135
  • trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.h

    r181859 r185876  
    165165@property (nonatomic, readonly) BOOL hasOnlySecureContent;
    166166
     167/*! @abstract An array of SecCertificateRef objects forming the certificate
     168 chain for the currently committed navigation.
     169 @discussion The certificates are ordered from leaf (at index 0) to anchor.
     170 @link WKWebView @/link is key-value observing (KVO) compliant for this property.
     171 */
     172@property (nonatomic, readonly, copy) NSArray *certificateChain WK_AVAILABLE(WK_MAC_TBA, WK_IOS_TBA);
     173
    167174/*! @abstract A Boolean value indicating whether there is a back item in
    168175 the back-forward list that can be navigated to.
  • trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm

    r185840 r185876  
    518518}
    519519
     520- (NSArray *)certificateChain
     521{
     522    auto certificateInfo = _page->pageLoadState().certificateInfo();
     523    if (!certificateInfo)
     524        return @[ ];
     525
     526    return (NSArray *)certificateInfo->certificateInfo().certificateChain() ?: @[ ];
     527}
     528
    520529- (BOOL)canGoBack
    521530{
  • trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h

    r185840 r185876  
    6666- (void)_loadAlternateHTMLString:(NSString *)string baseURL:(NSURL *)baseURL forUnreachableURL:(NSURL *)unreachableURL;
    6767
    68 @property (nonatomic, readonly) NSArray *_certificateChain;
     68@property (nonatomic, readonly) NSArray *_certificateChain WK_DEPRECATED(10_10, WK_MAC_TBA, 8_0, WK_IOS_TBA, "use -certificateChain");
    6969@property (nonatomic, readonly) NSURL *_committedURL;
    7070@property (nonatomic, readonly) NSString *_MIMEType;
  • trunk/Source/WebKit2/UIProcess/Cocoa/NavigationState.h

    r185680 r185876  
    139139    virtual void willChangeNetworkRequestsInProgress() override;
    140140    virtual void didChangeNetworkRequestsInProgress() override;
     141    virtual void willChangeCertificateInfo() override;
     142    virtual void didChangeCertificateInfo() override;
    141143
    142144    WKWebView *m_webView;
  • trunk/Source/WebKit2/UIProcess/Cocoa/NavigationState.mm

    r185680 r185876  
    841841}
    842842
     843void NavigationState::willChangeCertificateInfo()
     844{
     845    [m_webView willChangeValueForKey:@"certificateChain"];
     846}
     847
     848void NavigationState::didChangeCertificateInfo()
     849{
     850    [m_webView didChangeValueForKey:@"certificateChain"];
     851}
     852
    843853} // namespace WebKit
    844854
  • trunk/Source/WebKit2/UIProcess/PageLoadState.cpp

    r181317 r185876  
    102102    bool estimatedProgressChanged = estimatedProgress(m_committedState) != estimatedProgress(m_uncommittedState);
    103103    bool networkRequestsInProgressChanged = m_committedState.networkRequestsInProgress != m_uncommittedState.networkRequestsInProgress;
     104    bool certificateInfoChanged = m_committedState.certificateInfo != m_uncommittedState.certificateInfo;
    104105
    105106    if (canGoBackChanged)
     
    119120    if (networkRequestsInProgressChanged)
    120121        callObserverCallback(&Observer::willChangeNetworkRequestsInProgress);
     122    if (certificateInfoChanged)
     123        callObserverCallback(&Observer::willChangeCertificateInfo);
    121124
    122125    m_committedState = m_uncommittedState;
    123126
    124127    // The "did" ordering is the reverse of the "will". This is a requirement of Cocoa Key-Value Observing.
     128    if (certificateInfoChanged)
     129        callObserverCallback(&Observer::didChangeCertificateInfo);
    125130    if (networkRequestsInProgressChanged)
    126131        callObserverCallback(&Observer::didChangeNetworkRequestsInProgress);
     
    268273}
    269274
    270 void PageLoadState::didCommitLoad(const Transaction::Token& token, bool hasInsecureContent)
     275void PageLoadState::didCommitLoad(const Transaction::Token& token, WebCertificateInfo& certificateInfo, bool hasInsecureContent)
    271276{
    272277    ASSERT_UNUSED(token, &token.m_pageLoadState == this);
     
    275280    m_uncommittedState.state = State::Committed;
    276281    m_uncommittedState.hasInsecureContent = hasInsecureContent;
     282    m_uncommittedState.certificateInfo = &certificateInfo;
    277283
    278284    m_uncommittedState.url = m_uncommittedState.provisionalURL;
  • trunk/Source/WebKit2/UIProcess/PageLoadState.h

    r181317 r185876  
    2727#define PageLoadState_h
    2828
     29#include "WebCertificateInfo.h"
    2930#include <wtf/text/WTFString.h>
    3031
    3132namespace WebKit {
    3233
     34class WebCertificateInfo;
    3335class WebPageProxy;
    3436
     
    7173        virtual void willChangeNetworkRequestsInProgress() = 0;
    7274        virtual void didChangeNetworkRequestsInProgress() = 0;
     75
     76        virtual void willChangeCertificateInfo() = 0;
     77        virtual void didChangeCertificateInfo() = 0;
    7378    };
    7479
     
    124129    bool networkRequestsInProgress() const { return m_committedState.networkRequestsInProgress; }
    125130
     131    WebCertificateInfo* certificateInfo() const { return m_committedState.certificateInfo.get(); }
     132
    126133    const String& pendingAPIRequestURL() const;
    127134    void setPendingAPIRequestURL(const Transaction::Token&, const String&);
     
    132139    void didFailProvisionalLoad(const Transaction::Token&);
    133140
    134     void didCommitLoad(const Transaction::Token&, bool hasInsecureContent);
     141    void didCommitLoad(const Transaction::Token&, WebCertificateInfo&, bool hasInsecureContent);
    135142    void didFinishLoad(const Transaction::Token&);
    136143    void didFailLoad(const Transaction::Token&);
     
    192199        double estimatedProgress;
    193200        bool networkRequestsInProgress;
     201
     202        RefPtr<WebCertificateInfo> certificateInfo;
    194203    };
    195204
  • trunk/Source/WebKit2/UIProcess/WebFrameProxy.cpp

    r184370 r185876  
    140140}
    141141
    142 void WebFrameProxy::didCommitLoad(const String& contentType, const WebCore::CertificateInfo& certificateInfo)
     142void WebFrameProxy::didCommitLoad(const String& contentType, WebCertificateInfo& certificateInfo)
    143143{
    144144    m_frameLoadState.didCommitLoad();
     
    147147    m_MIMEType = contentType;
    148148    m_isFrameSet = false;
    149     m_certificateInfo = WebCertificateInfo::create(certificateInfo);
     149    m_certificateInfo = &certificateInfo;
    150150}
    151151
  • trunk/Source/WebKit2/UIProcess/WebFrameProxy.h

    r184370 r185876  
    4848    class ArgumentDecoder;
    4949    class Connection;
    50 }
    51 
    52 namespace WebCore {
    53 class CertificateInfo;
    5450}
    5551
     
    112108    void didReceiveServerRedirectForProvisionalLoad(const String& url);
    113109    void didFailProvisionalLoad();
    114     void didCommitLoad(const String& contentType, const WebCore::CertificateInfo&);
     110    void didCommitLoad(const String& contentType, WebCertificateInfo&);
    115111    void didFinishLoad();
    116112    void didFailLoad();
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp

    r185840 r185876  
    29432943    auto transaction = m_pageLoadState.transaction();
    29442944    bool markPageInsecure = m_treatsSHA1CertificatesAsInsecure && certificateInfo.containsNonRootSHA1SignedCertificate();
     2945    Ref<WebCertificateInfo> webCertificateInfo = WebCertificateInfo::create(certificateInfo);
    29452946    if (frame->isMainFrame())
    2946         m_pageLoadState.didCommitLoad(transaction, markPageInsecure);
     2947        m_pageLoadState.didCommitLoad(transaction, webCertificateInfo, markPageInsecure);
    29472948    else if (markPageInsecure)
    29482949        m_pageLoadState.didDisplayOrRunInsecureContent(transaction);
     
    29572958    clearLoadDependentCallbacks();
    29582959
    2959     frame->didCommitLoad(mimeType, certificateInfo);
     2960    frame->didCommitLoad(mimeType, webCertificateInfo);
    29602961
    29612962    if (frame->isMainFrame()) {
Note: See TracChangeset for help on using the changeset viewer.