Title: [171160] trunk/Source
Revision
171160
Author
beid...@apple.com
Date
2014-07-16 17:20:21 -0700 (Wed, 16 Jul 2014)

Log Message

Add WebSecurityOrigin "webSecurityOriginFromDatabaseIdentifier" SPI and change _websiteDataURLForContainerWithURL: SPI

Source/WebCore:
https://bugs.webkit.org/show_bug.cgi?id=134984

Reviewed by Dan Bernstein.

* WebCore.exp.in:
* page/SecurityOrigin.cpp:
(WebCore::SecurityOrigin::maybeCreateFromDatabaseIdentifier): Add a form of createFromDatabaseIdentifier
    that can fail and return a nullptr.
(WebCore::SecurityOrigin::createFromDatabaseIdentifier): Use maybeCreateFromDatabaseIdentifier before creating
    the empty origin.
* page/SecurityOrigin.h:

Source/WebKit/mac:
<rdar://problem/17454712> and https://bugs.webkit.org/show_bug.cgi?id=134984

Reviewed by Dan Bernstein.

* WebCoreSupport/WebSecurityOrigin.mm:
(+[WebSecurityOrigin webSecurityOriginFromDatabaseIdentifier:]): Added.
(-[WebSecurityOrigin initWithURL:]): Update using RefPtr API to avoid a ref().
* WebCoreSupport/WebSecurityOriginPrivate.h:

Source/WebKit2:
<rdar://problem/17454712> and https://bugs.webkit.org/show_bug.cgi?id=134984

Reviewed by Dan Bernstein.

Change _websiteDataURLForContainerWithURL: SPI to include an optional bundle identifier argument:
* UIProcess/API/Cocoa/WKProcessPool.mm:
(+[WKProcessPool _websiteDataURLForContainerWithURL:bundleIdentifierIfNotInContainer:]):
(+[WKProcessPool _websiteDataURLForContainerWithURL:]): Deleted.
* UIProcess/API/Cocoa/WKProcessPoolPrivate.h:

Add a big shiny comment in a few key places:
* DatabaseProcess/DatabaseProcess.cpp:
(WebKit::DatabaseProcess::initializeDatabaseProcess):
* DatabaseProcess/IndexedDB/UniqueIDBDatabase.cpp:
(WebKit::UniqueIDBDatabase::UniqueIDBDatabase):
* UIProcess/WebContext.cpp:
(WebKit::WebContext::applyPlatformSpecificConfigurationDefaults):
(WebKit::WebContext::ensureDatabaseProcess):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (171159 => 171160)


--- trunk/Source/WebCore/ChangeLog	2014-07-17 00:00:34 UTC (rev 171159)
+++ trunk/Source/WebCore/ChangeLog	2014-07-17 00:20:21 UTC (rev 171160)
@@ -1,3 +1,25 @@
+2014-07-16  Brady Eidson  <beid...@apple.com>
+
+        Add WebSecurityOrigin "webSecurityOriginFromDatabaseIdentifier" SPI and change _websiteDataURLForContainerWithURL: SPI
+        <rdar://problem/17454712> and https://bugs.webkit.org/show_bug.cgi?id=134984
+
+        Reviewed by Dan Bernstein.
+
+        Change _websiteDataURLForContainerWithURL: SPI to include an optional bundle identifier argument:
+        * UIProcess/API/Cocoa/WKProcessPool.mm:
+        (+[WKProcessPool _websiteDataURLForContainerWithURL:bundleIdentifierIfNotInContainer:]):
+        (+[WKProcessPool _websiteDataURLForContainerWithURL:]): Deleted.
+        * UIProcess/API/Cocoa/WKProcessPoolPrivate.h:
+
+        Add a big shiny comment in a few key places:
+        * DatabaseProcess/DatabaseProcess.cpp:
+        (WebKit::DatabaseProcess::initializeDatabaseProcess):
+        * DatabaseProcess/IndexedDB/UniqueIDBDatabase.cpp:
+        (WebKit::UniqueIDBDatabase::UniqueIDBDatabase):
+        * UIProcess/WebContext.cpp:
+        (WebKit::WebContext::applyPlatformSpecificConfigurationDefaults):
+        (WebKit::WebContext::ensureDatabaseProcess):
+
 2014-07-16  Roger Fong  <roger_f...@apple.com>
 
         Captions container should not clip content.

Modified: trunk/Source/WebCore/WebCore.exp.in (171159 => 171160)


--- trunk/Source/WebCore/WebCore.exp.in	2014-07-17 00:00:34 UTC (rev 171159)
+++ trunk/Source/WebCore/WebCore.exp.in	2014-07-17 00:20:21 UTC (rev 171160)
@@ -434,6 +434,7 @@
 __ZN7WebCore14ScrollbarTheme5themeEv
 __ZN7WebCore14SecurityOrigin16createFromStringERKN3WTF6StringE
 __ZN7WebCore14SecurityOrigin28createFromDatabaseIdentifierERKN3WTF6StringE
+__ZN7WebCore14SecurityOrigin33maybeCreateFromDatabaseIdentifierERKN3WTF6StringE
 __ZN7WebCore14SecurityOrigin6createERKN3WTF6StringES4_i
 __ZN7WebCore14SecurityOrigin6createERKNS_3URLE
 __ZN7WebCore14SecurityPolicy18setLocalLoadPolicyENS0_15LocalLoadPolicyE

Modified: trunk/Source/WebCore/page/SecurityOrigin.cpp (171159 => 171160)


--- trunk/Source/WebCore/page/SecurityOrigin.cpp	2014-07-17 00:00:34 UTC (rev 171159)
+++ trunk/Source/WebCore/page/SecurityOrigin.cpp	2014-07-17 00:20:21 UTC (rev 171160)
@@ -495,33 +495,33 @@
 
 static const char separatorCharacter = '_';
 
-PassRefPtr<SecurityOrigin> SecurityOrigin::createFromDatabaseIdentifier(const String& databaseIdentifier)
+PassRefPtr<SecurityOrigin> SecurityOrigin::maybeCreateFromDatabaseIdentifier(const String& databaseIdentifier)
 { 
     // Make sure there's a first separator
     size_t separator1 = databaseIdentifier.find(separatorCharacter);
     if (separator1 == notFound)
-        return create(URL());
+        return nullptr;
         
     // Make sure there's a second separator
     size_t separator2 = databaseIdentifier.reverseFind(separatorCharacter);
     if (separator2 == notFound)
-        return create(URL());
-        
+        return nullptr;
+
     // Ensure there were at least 2 separator characters. Some hostnames on intranets have
     // underscores in them, so we'll assume that any additional underscores are part of the host.
     if (separator1 == separator2)
-        return create(URL());
-        
+        return nullptr;
+
     // Make sure the port section is a valid port number or doesn't exist
     bool portOkay;
     int port = databaseIdentifier.right(databaseIdentifier.length() - separator2 - 1).toInt(&portOkay);
     bool portAbsent = (separator2 == databaseIdentifier.length() - 1);
     if (!(portOkay || portAbsent))
-        return create(URL());
-    
+        return nullptr;
+
     if (port < 0 || port > MaxAllowedPort)
-        return create(URL());
-        
+        return nullptr;
+
     // Split out the 3 sections of data
     String protocol = databaseIdentifier.substring(0, separator1);
     String host = databaseIdentifier.substring(separator1 + 1, separator2 - separator1 - 1);
@@ -530,6 +530,14 @@
     return create(URL(URL(), protocol + "://" + host + ":" + String::number(port) + "/"));
 }
 
+PassRefPtr<SecurityOrigin> SecurityOrigin::createFromDatabaseIdentifier(const String& databaseIdentifier)
+{
+    RefPtr<SecurityOrigin> origin = maybeCreateFromDatabaseIdentifier(databaseIdentifier);
+    if (origin)
+        return origin.release();
+    return create(URL());
+}
+
 PassRefPtr<SecurityOrigin> SecurityOrigin::create(const String& protocol, const String& host, int port)
 {
     if (port < 0 || port > MaxAllowedPort)

Modified: trunk/Source/WebCore/page/SecurityOrigin.h (171159 => 171160)


--- trunk/Source/WebCore/page/SecurityOrigin.h	2014-07-17 00:00:34 UTC (rev 171159)
+++ trunk/Source/WebCore/page/SecurityOrigin.h	2014-07-17 00:20:21 UTC (rev 171160)
@@ -54,6 +54,11 @@
     static PassRefPtr<SecurityOrigin> createUnique();
 
     static PassRefPtr<SecurityOrigin> createFromDatabaseIdentifier(const String&);
+    // Alternate form of createFromDatabaseIdentifier that returns a nullptr on failure, instead of an empty origin.
+    // FIXME: Many users of createFromDatabaseIdentifier seem to expect maybeCreateFromDatabaseIdentifier behavior,
+    // but they aren't getting it so they might be buggy.
+    static PassRefPtr<SecurityOrigin> maybeCreateFromDatabaseIdentifier(const String&);
+
     static PassRefPtr<SecurityOrigin> createFromString(const String&);
     static PassRefPtr<SecurityOrigin> create(const String& protocol, const String& host, int port);
 

Modified: trunk/Source/WebKit/mac/ChangeLog (171159 => 171160)


--- trunk/Source/WebKit/mac/ChangeLog	2014-07-17 00:00:34 UTC (rev 171159)
+++ trunk/Source/WebKit/mac/ChangeLog	2014-07-17 00:20:21 UTC (rev 171160)
@@ -1,3 +1,14 @@
+2014-07-16  Brady Eidson  <beid...@apple.com>
+
+        Add WebSecurityOrigin "webSecurityOriginFromDatabaseIdentifier" SPI and change _websiteDataURLForContainerWithURL: SPI
+        <rdar://problem/17454712> and https://bugs.webkit.org/show_bug.cgi?id=134984
+
+        Reviewed by Dan Bernstein.
+
+        * WebCoreSupport/WebSecurityOrigin.mm:
+        (+[WebSecurityOrigin webSecurityOriginFromDatabaseIdentifier:]): Added.
+        (-[WebSecurityOrigin initWithURL:]): Update using RefPtr API to avoid a ref().
+
 2014-07-15  Myles C. Maxfield  <mmaxfi...@apple.com>
 
         [OSX] [WK1] Crash when exiting fullscreen
@@ -14,6 +25,8 @@
         * WebView/WebFullScreenController.mm:
         (-[WebFullScreenController enterFullScreen:]):
 
+        * WebCoreSupport/WebSecurityOriginPrivate.h:
+
 2014-07-14  Bear Travis  <betra...@adobe.com>
 
         [Feature Queries] Enable Feature Queries on Mac

Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebSecurityOrigin.mm (171159 => 171160)


--- trunk/Source/WebKit/mac/WebCoreSupport/WebSecurityOrigin.mm	2014-07-17 00:00:34 UTC (rev 171159)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebSecurityOrigin.mm	2014-07-17 00:20:21 UTC (rev 171160)
@@ -38,6 +38,16 @@
 using namespace WebCore;
 
 @implementation WebSecurityOrigin
+
++ (id)webSecurityOriginFromDatabaseIdentifier:(NSString *)databaseIdentifier
+{
+    RefPtr<SecurityOrigin> origin = SecurityOrigin::maybeCreateFromDatabaseIdentifier(databaseIdentifier);
+    if (!origin)
+        return nil;
+
+    return [[[WebSecurityOrigin alloc] _initWithWebCoreSecurityOrigin:origin.get()] autorelease];
+}
+
 - (id)initWithURL:(NSURL *)url
 {
     self = [super init];
@@ -45,8 +55,8 @@
         return nil;
 
     RefPtr<SecurityOrigin> origin = SecurityOrigin::create(URL([url absoluteURL]));
-    origin->ref();
-    _private = reinterpret_cast<WebSecurityOriginPrivate *>(origin.get());
+    SecurityOrigin* rawOrigin = origin.release().leakRef();
+    _private = reinterpret_cast<WebSecurityOriginPrivate *>(rawOrigin);
 
     return self;
 }

Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebSecurityOriginPrivate.h (171159 => 171160)


--- trunk/Source/WebKit/mac/WebCoreSupport/WebSecurityOriginPrivate.h	2014-07-17 00:00:34 UTC (rev 171159)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebSecurityOriginPrivate.h	2014-07-17 00:20:21 UTC (rev 171160)
@@ -35,6 +35,8 @@
     id<WebQuotaManager> _databaseQuotaManager;
 }
 
++ (id)webSecurityOriginFromDatabaseIdentifier:(NSString *)databaseIdentifier;
+
 - (id)initWithURL:(NSURL *)url;
 
 - (NSString *)protocol;

Modified: trunk/Source/WebKit2/ChangeLog (171159 => 171160)


--- trunk/Source/WebKit2/ChangeLog	2014-07-17 00:00:34 UTC (rev 171159)
+++ trunk/Source/WebKit2/ChangeLog	2014-07-17 00:20:21 UTC (rev 171160)
@@ -1,3 +1,25 @@
+2014-07-16  Brady Eidson  <beid...@apple.com>
+
+        Add WebSecurityOrigin "webSecurityOriginFromDatabaseIdentifier" SPI and change _websiteDataURLForContainerWithURL: SPI
+        <rdar://problem/17454712> and https://bugs.webkit.org/show_bug.cgi?id=134984
+
+        Reviewed by Dan Bernstein.
+
+        Change _websiteDataURLForContainerWithURL: SPI to include an optional bundle identifier argument:
+        * UIProcess/API/Cocoa/WKProcessPool.mm:
+        (+[WKProcessPool _websiteDataURLForContainerWithURL:bundleIdentifierIfNotInContainer:]):
+        (+[WKProcessPool _websiteDataURLForContainerWithURL:]): Deleted.
+        * UIProcess/API/Cocoa/WKProcessPoolPrivate.h:
+
+        Add a big shiny comment in a few key places:
+        * DatabaseProcess/DatabaseProcess.cpp:
+        (WebKit::DatabaseProcess::initializeDatabaseProcess):
+        * DatabaseProcess/IndexedDB/UniqueIDBDatabase.cpp:
+        (WebKit::UniqueIDBDatabase::UniqueIDBDatabase):
+        * UIProcess/WebContext.cpp:
+        (WebKit::WebContext::applyPlatformSpecificConfigurationDefaults):
+        (WebKit::WebContext::ensureDatabaseProcess):
+
 2014-07-16  Enrica Casucci  <enr...@apple.com>
 
         REGRESSION (iOS WebKit2): Cannot scroll while dragging a selection.

Modified: trunk/Source/WebKit2/DatabaseProcess/DatabaseProcess.cpp (171159 => 171160)


--- trunk/Source/WebKit2/DatabaseProcess/DatabaseProcess.cpp	2014-07-17 00:00:34 UTC (rev 171159)
+++ trunk/Source/WebKit2/DatabaseProcess/DatabaseProcess.cpp	2014-07-17 00:20:21 UTC (rev 171160)
@@ -97,6 +97,10 @@
 
 void DatabaseProcess::initializeDatabaseProcess(const DatabaseProcessCreationParameters& parameters)
 {
+    // *********
+    // IMPORTANT: Do not change the directory structure for indexed databases on disk without first consulting a reviewer from Apple (<rdar://problem/17454712>)
+    // *********
+
     m_indexedDatabaseDirectory = parameters.indexedDatabaseDirectory;
     SandboxExtension::consumePermanently(parameters.indexedDatabaseDirectoryExtensionHandle);
 

Modified: trunk/Source/WebKit2/DatabaseProcess/IndexedDB/UniqueIDBDatabase.cpp (171159 => 171160)


--- trunk/Source/WebKit2/DatabaseProcess/IndexedDB/UniqueIDBDatabase.cpp	2014-07-17 00:00:34 UTC (rev 171159)
+++ trunk/Source/WebKit2/DatabaseProcess/IndexedDB/UniqueIDBDatabase.cpp	2014-07-17 00:20:21 UTC (rev 171160)
@@ -62,6 +62,10 @@
     if (m_inMemory)
         return;
 
+    // *********
+    // IMPORTANT: Do not change the directory structure for indexed databases on disk without first consulting a reviewer from Apple (<rdar://problem/17454712>)
+    // *********
+
     // Each unique Indexed Database exists in a directory named for the database, which exists in a directory representing its opening origin.
     m_databaseRelativeDirectory = pathByAppendingComponent(databaseFilenameIdentifier(identifier.openingOrigin()), filenameForDatabaseName());
 

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKProcessPool.mm (171159 => 171160)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKProcessPool.mm	2014-07-17 00:00:34 UTC (rev 171159)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKProcessPool.mm	2014-07-17 00:20:21 UTC (rev 171160)
@@ -105,10 +105,14 @@
 
 @implementation WKProcessPool (WKPrivate)
 
-+ (NSURL *)_websiteDataURLForContainerWithURL:(NSURL *)containerURL
++ (NSURL *)_websiteDataURLForContainerWithURL:(NSURL *)containerURL bundleIdentifierIfNotInContainer:(NSString *)bundleIdentifier
 {
     NSURL *url = "" URLByAppendingPathComponent:@"Library" isDirectory:YES];
     url = "" URLByAppendingPathComponent:@"WebKit" isDirectory:YES];
+
+    if (!WebKit::processHasContainer() && bundleIdentifier)
+        url = "" URLByAppendingPathComponent:bundleIdentifier isDirectory:YES];
+
     return [url URLByAppendingPathComponent:@"WebsiteData" isDirectory:YES];
 }
 

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h (171159 => 171160)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h	2014-07-17 00:00:34 UTC (rev 171159)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h	2014-07-17 00:20:21 UTC (rev 171160)
@@ -44,7 +44,7 @@
 
 @property (nonatomic, weak, setter=_setDownloadDelegate:) id <_WKDownloadDelegate> _downloadDelegate;
 
-+ (NSURL *)_websiteDataURLForContainerWithURL:(NSURL *)containerURL;
++ (NSURL *)_websiteDataURLForContainerWithURL:(NSURL *)containerURL bundleIdentifierIfNotInContainer:(NSString *)bundleIdentifier;
 
 @end
 

Modified: trunk/Source/WebKit2/UIProcess/WebContext.cpp (171159 => 171160)


--- trunk/Source/WebKit2/UIProcess/WebContext.cpp	2014-07-17 00:00:34 UTC (rev 171159)
+++ trunk/Source/WebKit2/UIProcess/WebContext.cpp	2014-07-17 00:20:21 UTC (rev 171160)
@@ -129,6 +129,9 @@
     if (!configuration.webSQLDatabaseDirectory)
         configuration.webSQLDatabaseDirectory = platformDefaultWebSQLDatabaseDirectory();
 
+    // *********
+    // IMPORTANT: Do not change the directory structure for indexed databases on disk without first consulting a reviewer from Apple (<rdar://problem/17454712>)
+    // *********
     if (!configuration.indexedDBDatabaseDirectory)
         configuration.indexedDBDatabaseDirectory = platformDefaultIndexedDBDatabaseDirectory();
 }
@@ -466,6 +469,9 @@
 
     ASSERT(!m_indexedDBDatabaseDirectory.isEmpty());
 
+    // *********
+    // IMPORTANT: Do not change the directory structure for indexed databases on disk without first consulting a reviewer from Apple (<rdar://problem/17454712>)
+    // *********
     DatabaseProcessCreationParameters parameters;
     parameters.indexedDatabaseDirectory = m_indexedDBDatabaseDirectory;
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to