-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Web Extensions: Parsing for Create() Bookmark function #47248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Web Extensions: Parsing for Create() Bookmark function #47248
Conversation
EWS run on previous version of this PR (hash e2a9977) |
e2a9977
to
47efa34
Compare
EWS run on previous version of this PR (hash 47efa34) |
Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIBookmarksCocoa.mm
Outdated
Show resolved
Hide resolved
Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIBookmarksCocoa.mm
Outdated
Show resolved
Hide resolved
Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIBookmarksCocoa.mm
Outdated
Show resolved
Hide resolved
Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIBookmarksCocoa.mm
Show resolved
Hide resolved
Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIBookmarksCocoa.mm
Outdated
Show resolved
Hide resolved
Source/WebKit/WebProcess/Extensions/API/WebExtensionAPIBookmarks.h
Outdated
Show resolved
Hide resolved
47efa34
to
cc2a9e2
Compare
EWS run on previous version of this PR (hash cc2a9e2) |
Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIBookmarksCocoa.mm
Outdated
Show resolved
Hide resolved
Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIBookmarksCocoa.mm
Show resolved
Hide resolved
Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIBookmarksCocoa.mm
Outdated
Show resolved
Hide resolved
Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIBookmarksCocoa.mm
Outdated
Show resolved
Hide resolved
Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIBookmarksCocoa.mm
Outdated
Show resolved
Hide resolved
Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIBookmarksCocoa.mm
Outdated
Show resolved
Hide resolved
Source/WebKit/WebProcess/Extensions/API/WebExtensionAPIBookmarks.h
Outdated
Show resolved
Hide resolved
Source/WebKit/WebProcess/Extensions/API/WebExtensionAPIBookmarks.h
Outdated
Show resolved
Hide resolved
Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIBookmarksCocoa.mm
Outdated
Show resolved
Hide resolved
Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIBookmarksCocoa.mm
Outdated
Show resolved
Hide resolved
cc2a9e2
to
9b87032
Compare
EWS run on previous version of this PR (hash 9b87032) |
|
||
static NSDictionary *toWebAPI(const WebExtensionAPIBookmarks::MockBookmarkNode& node) | ||
{ | ||
NSString* typeString = toWebAPI(node.type, node.url.createNSString().get()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NSString* typeString = toWebAPI(node.type, node.url.createNSString().get()); |
dateAddedKey: @(node.dateAdded.secondsSinceEpoch().milliseconds()), | ||
typeKey: bookmarkKey | ||
typeKey: typeString |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typeKey: typeString | |
typeKey: toWebAPI(node.type, node.url.createNSString().get()); |
@@ -67,15 +108,32 @@ | |||
if (!validateDictionary(bookmark, @"bookmark", requiredKeys, types, outExceptionString)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (!validateDictionary(bookmark, @"bookmark", requiredKeys, types, outExceptionString)) | |
if (!validateDictionary(bookmark, @"bookmark", nil, types, outExceptionString)) |
Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIBookmarksCocoa.mm
Outdated
Show resolved
Hide resolved
@@ -67,15 +108,32 @@ | |||
if (!validateDictionary(bookmark, @"bookmark", requiredKeys, types, outExceptionString)) | |||
return; | |||
|
|||
parsedDetails.index = objectForKey<NSNumber>(bookmark, indexKey).intValue; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parsedDetails.index = objectForKey<NSNumber>(bookmark, indexKey).intValue; | |
parsedDetails.index = objectForKey<NSNumber>(bookmark, indexKey).unsignedLongValue; |
parsedDetails.url = objectForKey<NSString>(bookmark, urlKey); | ||
|
||
if (bookmark[typeKey]) { | ||
std::optional<WebExtensionAPIBookmarks::BookmarkTreeNodeType> parsedType = toImpl(dynamic_objc_cast<NSString>(bookmark[typeKey])); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
std::optional<WebExtensionAPIBookmarks::BookmarkTreeNodeType> parsedType = toImpl(dynamic_objc_cast<NSString>(bookmark[typeKey])); | |
auto parsedType = toTypeImpl(dynamic_objc_cast<NSString>(bookmark[typeKey])); |
return tempNode; | ||
} | ||
|
||
static std::optional<WebExtensionAPIBookmarks::BookmarkTreeNodeType> toImpl(NSString *typeString) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
static std::optional<WebExtensionAPIBookmarks::BookmarkTreeNodeType> toImpl(NSString *typeString) | |
static std::optional<WebExtensionAPIBookmarks::BookmarkTreeNodeType> toTypeImpl(NSString *typeString) |
if (!parsedType) | ||
*outExceptionString = toErrorString(nullString(), typeKey, @"it must specify either 'bookmark' or 'folder'").createNSString().autorelease(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (!parsedType) | |
*outExceptionString = toErrorString(nullString(), typeKey, @"it must specify either 'bookmark' or 'folder'").createNSString().autorelease(); | |
if (!parsedType) { | |
*outExceptionString = toErrorString(nullString(), typeKey, @"it must specify either 'bookmark' or 'folder'").createNSString().autorelease(); | |
return; | |
} |
private: | ||
|
||
public: | ||
enum class BookmarkTreeNodeType { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
enum class BookmarkTreeNodeType { | |
enum class BookmarkTreeNodeType : uint_8_t { |
}; | ||
|
||
struct CreateDetails { | ||
std::optional<int> index; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
std::optional<int> index; | |
std::optional<size_t> index; |
9b87032
to
2092a9f
Compare
EWS run on current version of this PR (hash 2092a9f) |
rdar://154231013 https://bugs.webkit.org/show_bug.cgi?id=294932 Reviewed by Timothy Hatcher. Parses the create function using a CreateDetails Object which takes in the parameters for the dictionary. For now this info from the dictionary is put into MockBookmarkNodes. Also makes sure default type of a bookmark create request is assigned properly and dateAdded is a parameter you can set only for testing purposes. Created tests for these as well. * Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIBookmarksCocoa.mm: (WebKit::toWebAPI): (WebKit::toTypeImpl): (WebKit::WebExtensionAPIBookmarks::createBookmark): (WebKit::WebExtensionAPIBookmarks::getRecent): (WebKit::WebExtensionAPIBookmarks::createDictionaryFromNode): * Source/WebKit/WebProcess/Extensions/API/WebExtensionAPIBookmarks.h: * Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIBookmarks.mm: (TestWebKitAPI::TEST_F(WKWebExtensionAPIBookmarks, BookmarksAPICreateParse)): Canonical link: https://commits.webkit.org/296824@main
2092a9f
to
7c3bccb
Compare
Committed 296824@main (7c3bccb): https://commits.webkit.org/296824@main Reviewed commits have been landed. Closing PR #47248 and removing active labels. |
7c3bccb
2092a9f
🛠 playstation