Changeset 150938 in webkit


Ignore:
Timestamp:
May 29, 2013 5:10:59 PM (11 years ago)
Author:
andersca@apple.com
Message:

WebKit should expose HSTS APIs to determine whether a host is in the HSTS cache and to reset HSTS policies
https://bugs.webkit.org/show_bug.cgi?id=117010
<rdar://problem/13689666>

Reviewed by Tim Horton.

  • UIProcess/API/C/mac/WKContextPrivateMac.h:
  • UIProcess/API/C/mac/WKContextPrivateMac.mm:
  • UIProcess/API/C/mac/WKPagePrivateMac.cpp:
  • UIProcess/API/C/mac/WKPagePrivateMac.h:
  • UIProcess/WebContext.h:

(WebContext):

  • UIProcess/mac/WebContextMac.mm:

(WebKit):
(WebKit::privateBrowsingSession):
(WebKit::WebContext::isURLKnownHSTSHost):
(WebKit::WebContext::resetHSTSHosts):

Location:
trunk/Source/WebKit2
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r150936 r150938  
     12013-05-29  Anders Carlsson  <andersca@apple.com>
     2
     3        WebKit should expose HSTS APIs to determine whether a host is in the HSTS cache and to reset HSTS policies
     4        https://bugs.webkit.org/show_bug.cgi?id=117010
     5        <rdar://problem/13689666>
     6
     7        Reviewed by Tim Horton.
     8
     9        * UIProcess/API/C/mac/WKContextPrivateMac.h:
     10        * UIProcess/API/C/mac/WKContextPrivateMac.mm:
     11        * UIProcess/API/C/mac/WKPagePrivateMac.cpp:
     12        * UIProcess/API/C/mac/WKPagePrivateMac.h:
     13        * UIProcess/WebContext.h:
     14        (WebContext):
     15        * UIProcess/mac/WebContextMac.mm:
     16        (WebKit):
     17        (WebKit::privateBrowsingSession):
     18        (WebKit::WebContext::isURLKnownHSTSHost):
     19        (WebKit::WebContext::resetHSTSHosts):
     20
    1212013-05-29  Tim Horton  <timothy_horton@apple.com>
    222
  • trunk/Source/WebKit2/UIProcess/API/C/mac/WKContextPrivateMac.h

    r149904 r150938  
    4343WK_EXPORT void WKContextGetInfoForInstalledPlugIns(WKContextRef context, WKContextGetInfoForInstalledPlugInsBlock block);
    4444
     45WK_EXPORT void WKContextResetHSTSHosts(WKContextRef context);
    4546
    4647/* DEPRECATED -  Please use constants from WKPluginInformation instead. */
  • trunk/Source/WebKit2/UIProcess/API/C/mac/WKContextPrivateMac.mm

    r149904 r150938  
    8888}
    8989
     90void WKContextResetHSTSHosts(WKContextRef context)
     91{
     92    return toImpl(context)->resetHSTSHosts();
     93}
     94
    9095
    9196/* DEPRECATED -  Please use constants from WKPluginInformation instead. */
  • trunk/Source/WebKit2/UIProcess/API/C/mac/WKPagePrivateMac.cpp

    r95901 r150938  
    2828
    2929#include "WKAPICast.h"
     30#include "WebContext.h"
     31#include "WebPageGroup.h"
    3032#include "WebPageProxy.h"
     33#include "WebPreferences.h"
    3134
    3235using namespace WebKit;
     
    3639    return toImpl(pageRef)->processIdentifier();
    3740}
     41
     42bool WKPageIsURLKnownHSTSHost(WKPageRef page, WKURLRef url)
     43{
     44    WebPageProxy* webPageProxy = toImpl(page);
     45    bool privateBrowsingEnabled = webPageProxy->pageGroup()->preferences()->privateBrowsingEnabled();
     46
     47    return webPageProxy->process()->context()->isURLKnownHSTSHost(toImpl(url)->string(), privateBrowsingEnabled);
     48}
  • trunk/Source/WebKit2/UIProcess/API/C/mac/WKPagePrivateMac.h

    r95901 r150938  
    3434
    3535WK_EXPORT pid_t WKPageGetProcessIdentifier(WKPageRef page);
     36WK_EXPORT bool WKPageIsURLKnownHSTSHost(WKPageRef page, WKURLRef url);
    3637
    3738#ifdef __cplusplus
  • trunk/Source/WebKit2/UIProcess/WebContext.h

    r150314 r150938  
    298298    void processDidCachePage(WebProcessProxy*);
    299299
     300    bool isURLKnownHSTSHost(const String& urlString, bool privateBrowsingEnabled) const;
     301    void resetHSTSHosts();
     302
    300303private:
    301304    WebContext(ProcessModel, const String& injectedBundlePath);
  • trunk/Source/WebKit2/UIProcess/mac/WebContextMac.mm

    r149476 r150938  
    4747#endif
    4848
     49
     50#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
     51
     52#if __has_include(<CFNetwork/CFURLProtocolPriv.h>)
     53#include <CFNetwork/CFURLProtocolPriv.h>
     54#else
     55extern "C" Boolean _CFNetworkIsKnownHSTSHostWithSession(CFURLRef url, CFURLStorageSessionRef session);
     56extern "C" void _CFNetworkResetHSTSHostsWithSession(CFURLStorageSessionRef session);
     57#endif
     58
     59#endif
     60
    4961using namespace WebCore;
    5062
     
    561573}
    562574
     575#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
     576static CFURLStorageSessionRef privateBrowsingSession()
     577{
     578    static CFURLStorageSessionRef session;
     579    static dispatch_once_t once;
     580    dispatch_once(&once, ^{
     581        NSString *identifier = [NSString stringWithFormat:@"%@.PrivateBrowsing", [[NSBundle mainBundle] bundleIdentifier]];
     582
     583        session = WKCreatePrivateStorageSession((CFStringRef)identifier);
     584    });
     585
     586    return session;
     587}
     588#endif
     589
     590bool WebContext::isURLKnownHSTSHost(const String& urlString, bool privateBrowsingEnabled) const
     591{
     592#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
     593    RetainPtr<CFURLRef> url = KURL(KURL(), urlString).createCFURL();
     594
     595    return _CFNetworkIsKnownHSTSHostWithSession(url.get(), privateBrowsingEnabled ? privateBrowsingSession() : nullptr);
     596#else
     597    return false;
     598#endif
     599}
     600
     601void WebContext::resetHSTSHosts()
     602{
     603#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
     604    _CFNetworkResetHSTSHostsWithSession(nullptr);
     605    _CFNetworkResetHSTSHostsWithSession(privateBrowsingSession());
     606#endif
     607}
     608
    563609} // namespace WebKit
Note: See TracChangeset for help on using the changeset viewer.