Title: [186247] trunk/Source/WebKit2
Revision
186247
Author
ander...@apple.com
Date
2015-07-02 17:08:18 -0700 (Thu, 02 Jul 2015)

Log Message

Provide API to clear the HSTS cache
https://bugs.webkit.org/show_bug.cgi?id=146565
rdar://problem/20023805

Reviewed by Tim Horton.

* NetworkProcess/NetworkProcess.cpp:
(WebKit::NetworkProcess::deleteWebsiteData):
* NetworkProcess/NetworkProcess.h:
* NetworkProcess/cocoa/NetworkProcessCocoa.mm:
(WebKit::NetworkProcess::clearHSTSCache):
* Shared/WebsiteData/WebsiteDataTypes.h:
* UIProcess/API/Cocoa/WKWebsiteDataRecord.mm:
(dataTypesToString):
* UIProcess/API/Cocoa/WKWebsiteDataRecordInternal.h:
(WebKit::toWebsiteDataTypes):
(WebKit::toWKWebsiteDataTypes):
* UIProcess/API/Cocoa/WKWebsiteDataRecordPrivate.h:
* UIProcess/WebsiteData/WebsiteDataStore.cpp:
(WebKit::computeNetworkProcessAccessTypeForDataRemoval):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (186246 => 186247)


--- trunk/Source/WebKit2/ChangeLog	2015-07-02 23:53:10 UTC (rev 186246)
+++ trunk/Source/WebKit2/ChangeLog	2015-07-03 00:08:18 UTC (rev 186247)
@@ -1,3 +1,26 @@
+2015-07-02  Anders Carlsson  <ander...@apple.com>
+
+        Provide API to clear the HSTS cache
+        https://bugs.webkit.org/show_bug.cgi?id=146565
+        rdar://problem/20023805
+
+        Reviewed by Tim Horton.
+
+        * NetworkProcess/NetworkProcess.cpp:
+        (WebKit::NetworkProcess::deleteWebsiteData):
+        * NetworkProcess/NetworkProcess.h:
+        * NetworkProcess/cocoa/NetworkProcessCocoa.mm:
+        (WebKit::NetworkProcess::clearHSTSCache):
+        * Shared/WebsiteData/WebsiteDataTypes.h:
+        * UIProcess/API/Cocoa/WKWebsiteDataRecord.mm:
+        (dataTypesToString):
+        * UIProcess/API/Cocoa/WKWebsiteDataRecordInternal.h:
+        (WebKit::toWebsiteDataTypes):
+        (WebKit::toWKWebsiteDataTypes):
+        * UIProcess/API/Cocoa/WKWebsiteDataRecordPrivate.h:
+        * UIProcess/WebsiteData/WebsiteDataStore.cpp:
+        (WebKit::computeNetworkProcessAccessTypeForDataRemoval):
+
 2015-07-02  Mark Lam  <mark....@apple.com>
 
         Gardening: fix broken 32-bit build..

Modified: trunk/Source/WebKit2/NetworkProcess/NetworkProcess.cpp (186246 => 186247)


--- trunk/Source/WebKit2/NetworkProcess/NetworkProcess.cpp	2015-07-02 23:53:10 UTC (rev 186246)
+++ trunk/Source/WebKit2/NetworkProcess/NetworkProcess.cpp	2015-07-03 00:08:18 UTC (rev 186247)
@@ -348,6 +348,11 @@
 
 void NetworkProcess::deleteWebsiteData(SessionID sessionID, uint64_t websiteDataTypes, std::chrono::system_clock::time_point modifiedSince, uint64_t callbackID)
 {
+    if (websiteDataTypes & WebsiteDataTypeHSTSCache) {
+        if (auto* networkStorageSession = SessionTracker::session(sessionID))
+            clearHSTSCache(*networkStorageSession, modifiedSince);
+    }
+
     if (websiteDataTypes & WebsiteDataTypeCookies) {
         if (auto* networkStorageSession = SessionTracker::session(sessionID))
             deleteAllCookiesModifiedSince(*networkStorageSession, modifiedSince);

Modified: trunk/Source/WebKit2/NetworkProcess/NetworkProcess.h (186246 => 186247)


--- trunk/Source/WebKit2/NetworkProcess/NetworkProcess.h	2015-07-02 23:53:10 UTC (rev 186246)
+++ trunk/Source/WebKit2/NetworkProcess/NetworkProcess.h	2015-07-03 00:08:18 UTC (rev 186247)
@@ -45,6 +45,7 @@
 
 namespace WebCore {
 class CertificateInfo;
+class NetworkStorageSession;
 class SecurityOrigin;
 }
 
@@ -95,6 +96,9 @@
     static void clearCFURLCacheForOrigins(const Vector<SecurityOriginData>&);
 #endif
 
+#if PLATFORM(COCOA)
+    void clearHSTSCache(WebCore::NetworkStorageSession&, std::chrono::system_clock::time_point modifiedSince);
+#endif
 
 private:
     NetworkProcess();

Modified: trunk/Source/WebKit2/NetworkProcess/cocoa/NetworkProcessCocoa.mm (186246 => 186247)


--- trunk/Source/WebKit2/NetworkProcess/cocoa/NetworkProcessCocoa.mm	2015-07-02 23:53:10 UTC (rev 186246)
+++ trunk/Source/WebKit2/NetworkProcess/cocoa/NetworkProcessCocoa.mm	2015-07-03 00:08:18 UTC (rev 186247)
@@ -34,6 +34,7 @@
 #import "SandboxExtension.h"
 #import "SecurityOriginData.h"
 #import <WebCore/CFNetworkSPI.h>
+#import <WebCore/NetworkStorageSession.h>
 #import <WebCore/PublicSuffix.h>
 #import <WebCore/ResourceRequestCFNet.h>
 #import <WebCore/SecurityOrigin.h>
@@ -212,6 +213,14 @@
     }
 }
 
+void NetworkProcess::clearHSTSCache(WebCore::NetworkStorageSession& session, std::chrono::system_clock::time_point modifiedSince)
+{
+    NSTimeInterval timeInterval = std::chrono::duration_cast<std::chrono::duration<double>>(modifiedSince.time_since_epoch()).count();
+    NSDate *date = [NSDate dateWithTimeIntervalSince1970:timeInterval];
+
+    _CFNetworkResetHSTSHostsSinceDate(session.platformSession(), (__bridge CFDateRef)date);
+}
+
 static void clearNSURLCache(dispatch_group_t group, std::chrono::system_clock::time_point modifiedSince, const std::function<void ()>& completionHandler)
 {
     dispatch_group_async(group, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), [modifiedSince, completionHandler] {

Modified: trunk/Source/WebKit2/Shared/WebsiteData/WebsiteDataTypes.h (186246 => 186247)


--- trunk/Source/WebKit2/Shared/WebsiteData/WebsiteDataTypes.h	2015-07-02 23:53:10 UTC (rev 186246)
+++ trunk/Source/WebKit2/Shared/WebsiteData/WebsiteDataTypes.h	2015-07-03 00:08:18 UTC (rev 186247)
@@ -38,8 +38,9 @@
     WebsiteDataTypeWebSQLDatabases = 1 << 6,
     WebsiteDataTypeIndexedDBDatabases = 1 << 7,
     WebsiteDataTypeMediaKeys = 1 << 8,
+    WebsiteDataTypeHSTSCache = 1 << 9,
 #if ENABLE(NETSCAPE_PLUGIN_API)
-    WebsiteDataTypePlugInData = 1 << 9,
+    WebsiteDataTypePlugInData = 1 << 10,
 #endif
 };
 

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebsiteDataRecord.mm (186246 => 186247)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebsiteDataRecord.mm	2015-07-02 23:53:10 UTC (rev 186246)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebsiteDataRecord.mm	2015-07-03 00:08:18 UTC (rev 186247)
@@ -40,6 +40,7 @@
 NSString * const WKWebsiteDataTypeIndexedDBDatabases = @"WKWebsiteDataTypeIndexedDBDatabases";
 
 NSString * const _WKWebsiteDataTypeMediaKeys = @"_WKWebsiteDataTypeMediaKeys";
+NSString * const _WKWebsiteDataTypeHSTSCache = @"_WKWebsiteDataTypeHSTSCache";
 
 #if PLATFORM(MAC)
 NSString * const _WKWebsiteDataTypePlugInData = @"_WKWebsiteDataTypePlugInData";
@@ -74,6 +75,8 @@
         [array addObject:@"Web SQL"];
     if ([dataTypes containsObject:WKWebsiteDataTypeIndexedDBDatabases])
         [array addObject:@"IndexedDB"];
+    if ([dataTypes containsObject:_WKWebsiteDataTypeHSTSCache])
+        [array addObject:@"HSTS Cache"];
     if ([dataTypes containsObject:_WKWebsiteDataTypeMediaKeys])
         [array addObject:@"Media Keys"];
 #if PLATFORM(MAC)

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebsiteDataRecordInternal.h (186246 => 186247)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebsiteDataRecordInternal.h	2015-07-02 23:53:10 UTC (rev 186246)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebsiteDataRecordInternal.h	2015-07-03 00:08:18 UTC (rev 186247)
@@ -60,6 +60,8 @@
         websiteDataTypes |= WebsiteDataTypes::WebsiteDataTypeWebSQLDatabases;
     if ([wkWebsiteDataTypes containsObject:WKWebsiteDataTypeIndexedDBDatabases])
         websiteDataTypes |= WebsiteDataTypes::WebsiteDataTypeIndexedDBDatabases;
+    if ([wkWebsiteDataTypes containsObject:_WKWebsiteDataTypeHSTSCache])
+        websiteDataTypes |= WebsiteDataTypes::WebsiteDataTypeHSTSCache;
     if ([wkWebsiteDataTypes containsObject:_WKWebsiteDataTypeMediaKeys])
         websiteDataTypes |= WebsiteDataTypes::WebsiteDataTypeMediaKeys;
 #if ENABLE(NETSCAPE_PLUGIN_API)
@@ -91,6 +93,8 @@
         [wkWebsiteDataTypes addObject:WKWebsiteDataTypeWebSQLDatabases];
     if (websiteDataTypes & WebsiteDataTypes::WebsiteDataTypeIndexedDBDatabases)
         [wkWebsiteDataTypes addObject:WKWebsiteDataTypeIndexedDBDatabases];
+    if (websiteDataTypes & WebsiteDataTypes::WebsiteDataTypeHSTSCache)
+        [wkWebsiteDataTypes addObject:_WKWebsiteDataTypeHSTSCache];
     if (websiteDataTypes & WebsiteDataTypes::WebsiteDataTypeMediaKeys)
         [wkWebsiteDataTypes addObject:_WKWebsiteDataTypeMediaKeys];
 #if ENABLE(NETSCAPE_PLUGIN_API)

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebsiteDataRecordPrivate.h (186246 => 186247)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebsiteDataRecordPrivate.h	2015-07-02 23:53:10 UTC (rev 186246)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebsiteDataRecordPrivate.h	2015-07-03 00:08:18 UTC (rev 186247)
@@ -27,6 +27,7 @@
 
 #if WK_API_ENABLED
 
+WK_EXTERN NSString * const _WKWebsiteDataTypeHSTSCache WK_AVAILABLE(WK_MAC_TBA, WK_IOS_TBA);
 WK_EXTERN NSString * const _WKWebsiteDataTypeMediaKeys WK_AVAILABLE(WK_MAC_TBA, WK_IOS_TBA);
 
 #if !TARGET_OS_IPHONE

Modified: trunk/Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.cpp (186246 => 186247)


--- trunk/Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.cpp	2015-07-02 23:53:10 UTC (rev 186246)
+++ trunk/Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.cpp	2015-07-03 00:08:18 UTC (rev 186247)
@@ -451,6 +451,9 @@
     if (dataTypes & WebsiteDataTypeDiskCache && !isNonPersistentStore)
         processAccessType = std::max(processAccessType, ProcessAccessType::Launch);
 
+    if (dataTypes & WebsiteDataTypeHSTSCache)
+        processAccessType = std::max(processAccessType, ProcessAccessType::Launch);
+
     return processAccessType;
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to