Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Tweak WebCore::setMetadataURL function
https://bugs.webkit.org/show_bug.cgi?id=170786

Reviewed by Beth Dakin.

Source/WebCore:

Get rid of the "referrer" parameter, it isn't used. Make the remaining parameters const. Swap the
urlString and path parameters since that makes more sense. Use String instead of NSString in the call to WKSetMetadataURL.

* platform/FileSystem.cpp:
(WebCore::setMetadataURL): Deleted.
* platform/FileSystem.h:
* platform/mac/FileSystemMac.mm:
(WebCore::setMetadataURL):

Source/WebKit2:

Update for WebCore changes.

* UIProcess/Cocoa/WebViewImpl.mm:
(WebKit::WebViewImpl::namesOfPromisedFilesDroppedAtDestination):

Canonical link: https://commits.webkit.org/187714@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@215290 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Anders Carlsson committed Apr 12, 2017
1 parent 38dd0ac commit a1270f6
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 12 deletions.
16 changes: 16 additions & 0 deletions Source/WebCore/ChangeLog
@@ -1,3 +1,19 @@
2017-04-12 Anders Carlsson <andersca@apple.com>

Tweak WebCore::setMetadataURL function
https://bugs.webkit.org/show_bug.cgi?id=170786

Reviewed by Beth Dakin.

Get rid of the "referrer" parameter, it isn't used. Make the remaining parameters const. Swap the
urlString and path parameters since that makes more sense. Use String instead of NSString in the call to WKSetMetadataURL.

* platform/FileSystem.cpp:
(WebCore::setMetadataURL): Deleted.
* platform/FileSystem.h:
* platform/mac/FileSystemMac.mm:
(WebCore::setMetadataURL):

2017-04-12 Myles C. Maxfield <mmaxfield@apple.com>

Well-known variations should clamp to the values listed in the @font-face block
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/platform/FileSystem.cpp
Expand Up @@ -255,7 +255,7 @@ bool filesHaveSameVolume(const String& fileA, const String& fileB)

#if !PLATFORM(MAC)

void setMetadataURL(String&, const String&, const String&)
void setMetadataURL(const String&, const String&)
{
}

Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/platform/FileSystem.h
Expand Up @@ -146,7 +146,7 @@ WEBCORE_EXPORT String directoryName(const String&);
WEBCORE_EXPORT bool getVolumeFreeSpace(const String&, uint64_t&);
WEBCORE_EXPORT std::optional<int32_t> getFileDeviceId(const CString&);

WEBCORE_EXPORT void setMetadataURL(String& URLString, const String& referrer, const String& path);
WEBCORE_EXPORT void setMetadataURL(const String& path, const String& urlString);

bool canExcludeFromBackup(); // Returns true if any file can ever be excluded from backup.
bool excludeFromBackup(const String&); // Returns true if successful.
Expand Down
17 changes: 8 additions & 9 deletions Source/WebCore/platform/mac/FileSystemMac.mm
Expand Up @@ -48,18 +48,17 @@ bool deleteEmptyDirectory(const String& path)
return !rmdir(fileSystemRepresentation(path).data());
}

void setMetadataURL(String& URLString, const String& referrer, const String& path)
void setMetadataURL(const String& path, const String& metadataURLString)
{
NSURL *URL = URLWithUserTypedString(URLString, nil);
if (URL)
URLString = userVisibleString(URLByRemovingUserInfo(URL));
String urlString;
if (NSURL *url = URLWithUserTypedString(urlString, nil))
urlString = userVisibleString(URLByRemovingUserInfo(url));
else
urlString = metadataURLString;

// Call WKSetMetadataURL on a background queue because it can take some time.
NSString *URLStringCopy = URLString;
NSString *referrerCopy = referrer;
NSString *pathCopy = path;
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
wkSetMetadataURL(URLStringCopy, referrerCopy, [NSString stringWithUTF8String:[pathCopy fileSystemRepresentation]]);
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), [path = path.isolatedCopy(), urlString = urlString.isolatedCopy()] {
wkSetMetadataURL(urlString, nil, [NSString stringWithUTF8String:[path fileSystemRepresentation]]);
});
}

Expand Down
12 changes: 12 additions & 0 deletions Source/WebKit2/ChangeLog
@@ -1,3 +1,15 @@
2017-04-12 Anders Carlsson <andersca@apple.com>

Tweak WebCore::setMetadataURL function
https://bugs.webkit.org/show_bug.cgi?id=170786

Reviewed by Beth Dakin.

Update for WebCore changes.

* UIProcess/Cocoa/WebViewImpl.mm:
(WebKit::WebViewImpl::namesOfPromisedFilesDroppedAtDestination):

2017-04-12 Brent Fulgham <bfulgham@apple.com>

[WK2][Mac] Stop allowing access to disk arbitration process
Expand Down
2 changes: 1 addition & 1 deletion Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm
Expand Up @@ -3912,7 +3912,7 @@ static BOOL fileExists(NSString *path)
LOG_ERROR("Failed to create image file via -[NSFileWrapper writeToURL:options:originalContentsURL:error:]");

if (!m_promisedURL.isEmpty())
WebCore::setMetadataURL(m_promisedURL, "", String(path));
WebCore::setMetadataURL(String(path), m_promisedURL);

return [NSArray arrayWithObject:[path lastPathComponent]];
}
Expand Down

0 comments on commit a1270f6

Please sign in to comment.