bookmarks feature initial
This commit is contained in:
+211
@@ -0,0 +1,211 @@
|
||||
package eu.weblibre.flutter_mozilla_components.api
|
||||
|
||||
import eu.weblibre.flutter_mozilla_components.GlobalComponents
|
||||
import eu.weblibre.flutter_mozilla_components.pigeons.BookmarkInfo
|
||||
import eu.weblibre.flutter_mozilla_components.pigeons.BookmarkNode
|
||||
import eu.weblibre.flutter_mozilla_components.pigeons.BookmarkNodeType
|
||||
import eu.weblibre.flutter_mozilla_components.pigeons.GeckoBookmarksApi
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.SupervisorJob
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
|
||||
class GeckoBookmarksApiImpl() : GeckoBookmarksApi {
|
||||
companion object {
|
||||
private val coroutineScope = CoroutineScope(Dispatchers.Main + SupervisorJob())
|
||||
}
|
||||
|
||||
private val components by lazy {
|
||||
requireNotNull(GlobalComponents.components) { "Components not initialized" }
|
||||
}
|
||||
|
||||
fun mozilla.components.concept.storage.BookmarkNode.toPigeonBookmarkNode(): BookmarkNode {
|
||||
return BookmarkNode(
|
||||
type = when (this.type) {
|
||||
mozilla.components.concept.storage.BookmarkNodeType.ITEM -> BookmarkNodeType.ITEM
|
||||
mozilla.components.concept.storage.BookmarkNodeType.FOLDER -> BookmarkNodeType.FOLDER
|
||||
mozilla.components.concept.storage.BookmarkNodeType.SEPARATOR -> BookmarkNodeType.SEPARATOR
|
||||
},
|
||||
guid = this.guid,
|
||||
parentGuid = this.parentGuid,
|
||||
position = this.position?.toLong(),
|
||||
title = this.title,
|
||||
url = this.url,
|
||||
dateAdded = this.dateAdded,
|
||||
lastModified = this.lastModified,
|
||||
children = this.children?.map { it.toPigeonBookmarkNode() }
|
||||
)
|
||||
}
|
||||
|
||||
fun BookmarkNode.toConceptStorageBookmarkNode(): mozilla.components.concept.storage.BookmarkNode {
|
||||
return mozilla.components.concept.storage.BookmarkNode(
|
||||
type = when (this.type) {
|
||||
BookmarkNodeType.ITEM -> mozilla.components.concept.storage.BookmarkNodeType.ITEM
|
||||
BookmarkNodeType.FOLDER -> mozilla.components.concept.storage.BookmarkNodeType.FOLDER
|
||||
BookmarkNodeType.SEPARATOR -> mozilla.components.concept.storage.BookmarkNodeType.SEPARATOR
|
||||
},
|
||||
guid = this.guid,
|
||||
parentGuid = this.parentGuid,
|
||||
position = this.position?.toUInt(),
|
||||
title = this.title,
|
||||
url = this.url,
|
||||
dateAdded = this.dateAdded,
|
||||
lastModified = this.lastModified,
|
||||
children = this.children?.map { it.toConceptStorageBookmarkNode() }
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
override fun getTree(
|
||||
guid: String,
|
||||
recursive: Boolean,
|
||||
callback: (Result<BookmarkNode?>) -> Unit
|
||||
) {
|
||||
coroutineScope.launch {
|
||||
withContext(Dispatchers.Main) {
|
||||
val node = components.core.bookmarksStorage.getTree(guid, recursive)
|
||||
node.fold(
|
||||
{ node ->
|
||||
callback(Result.success(node?.toPigeonBookmarkNode()))
|
||||
},
|
||||
{ e -> callback(Result.failure(e)) })
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun getBookmark(
|
||||
guid: String,
|
||||
callback: (Result<BookmarkNode?>) -> Unit
|
||||
) {
|
||||
coroutineScope.launch {
|
||||
withContext(Dispatchers.Main) {
|
||||
components.core.bookmarksStorage.getBookmark(guid).fold(
|
||||
{ node -> callback(Result.success(node?.toPigeonBookmarkNode())) },
|
||||
{ e -> callback(Result.failure(e)) }
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun getBookmarksWithUrl(
|
||||
url: String,
|
||||
callback: (Result<List<BookmarkNode>>) -> Unit
|
||||
) {
|
||||
coroutineScope.launch {
|
||||
withContext(Dispatchers.Main) {
|
||||
components.core.bookmarksStorage.getBookmarksWithUrl(url).fold(
|
||||
{ nodes -> callback(Result.success(nodes.map { it.toPigeonBookmarkNode() })) },
|
||||
{ e -> callback(Result.failure(e)) }
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun getRecentBookmarks(
|
||||
limit: Long,
|
||||
maxAge: Long?,
|
||||
currentTime: Long,
|
||||
callback: (Result<List<BookmarkNode>>) -> Unit
|
||||
) {
|
||||
coroutineScope.launch {
|
||||
withContext(Dispatchers.Main) {
|
||||
components.core.bookmarksStorage.getRecentBookmarks(
|
||||
limit = limit.toInt(),
|
||||
maxAge = maxAge,
|
||||
currentTime = currentTime
|
||||
).fold(
|
||||
{ nodes -> callback(Result.success(nodes.map { it.toPigeonBookmarkNode() })) },
|
||||
{ e -> callback(Result.failure(e)) }
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun searchBookmarks(
|
||||
query: String,
|
||||
limit: Long,
|
||||
callback: (Result<List<BookmarkNode>>) -> Unit
|
||||
) {
|
||||
coroutineScope.launch {
|
||||
withContext(Dispatchers.Main) {
|
||||
components.core.bookmarksStorage.searchBookmarks(query, limit.toInt()).fold(
|
||||
{ nodes -> callback(Result.success(nodes.map { it.toPigeonBookmarkNode() })) },
|
||||
{ e -> callback(Result.failure(e)) }
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun addItem(
|
||||
parentGuid: String,
|
||||
url: String,
|
||||
title: String,
|
||||
position: Long?,
|
||||
callback: (Result<String>) -> Unit
|
||||
) {
|
||||
coroutineScope.launch {
|
||||
withContext(Dispatchers.Main) {
|
||||
components.core.bookmarksStorage.addItem(parentGuid, url, title, position?.toUInt())
|
||||
.fold(
|
||||
{ guid -> callback(Result.success(guid)) },
|
||||
{ e -> callback(Result.failure(e)) }
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun addFolder(
|
||||
parentGuid: String,
|
||||
title: String,
|
||||
position: Long?,
|
||||
callback: (Result<String>) -> Unit
|
||||
) {
|
||||
coroutineScope.launch {
|
||||
withContext(Dispatchers.Main) {
|
||||
components.core.bookmarksStorage.addFolder(parentGuid, title, position?.toUInt())
|
||||
.fold(
|
||||
{ guid -> callback(Result.success(guid)) },
|
||||
{ e -> callback(Result.failure(e)) }
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun updateNode(
|
||||
guid: String,
|
||||
info: BookmarkInfo,
|
||||
callback: (Result<Unit>) -> Unit
|
||||
) {
|
||||
coroutineScope.launch {
|
||||
withContext(Dispatchers.Main) {
|
||||
val conceptInfo = mozilla.components.concept.storage.BookmarkInfo(
|
||||
parentGuid = info.parentGuid,
|
||||
position = info.position?.toUInt(),
|
||||
title = info.title,
|
||||
url = info.url
|
||||
)
|
||||
components.core.bookmarksStorage.updateNode(guid, conceptInfo).fold(
|
||||
{ callback(Result.success(Unit)) },
|
||||
{ e -> callback(Result.failure(e)) }
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun deleteNode(
|
||||
guid: String,
|
||||
callback: (Result<Boolean>) -> Unit
|
||||
) {
|
||||
coroutineScope.launch {
|
||||
withContext(Dispatchers.Main) {
|
||||
components.core.bookmarksStorage.deleteNode(guid).fold(
|
||||
{ deleted -> callback(Result.success(deleted)) },
|
||||
{ e -> callback(Result.failure(e)) }
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+3
@@ -21,6 +21,7 @@ import eu.weblibre.flutter_mozilla_components.pigeons.BrowserExtensionEvents
|
||||
import eu.weblibre.flutter_mozilla_components.pigeons.ContentBlocking
|
||||
import eu.weblibre.flutter_mozilla_components.pigeons.GeckoAddonEvents
|
||||
import eu.weblibre.flutter_mozilla_components.pigeons.GeckoAddonsApi
|
||||
import eu.weblibre.flutter_mozilla_components.pigeons.GeckoBookmarksApi
|
||||
import eu.weblibre.flutter_mozilla_components.pigeons.GeckoBrowserApi
|
||||
import eu.weblibre.flutter_mozilla_components.pigeons.GeckoBrowserExtensionApi
|
||||
import eu.weblibre.flutter_mozilla_components.pigeons.GeckoContainerProxyApi
|
||||
@@ -55,6 +56,7 @@ import mozilla.components.support.base.log.Log
|
||||
import mozilla.components.support.base.log.sink.LogSink
|
||||
import org.mozilla.gecko.util.ThreadUtils.runOnUiThread
|
||||
import org.mozilla.geckoview.BuildConfig as GeckoViewBuildConfig
|
||||
import mozilla.appservices.places.BookmarkRoot
|
||||
|
||||
class PriorityAwareLogSink(
|
||||
private val minLogPriority: Log.Priority,
|
||||
@@ -259,6 +261,7 @@ class GeckoBrowserApiImpl : GeckoBrowserApi {
|
||||
)
|
||||
GeckoHistoryApi.setUp(_flutterPluginBinding.binaryMessenger, GeckoHistoryApiImpl())
|
||||
GeckoFetchApi.setUp(_flutterPluginBinding.binaryMessenger, GeckoFetchApiImpl())
|
||||
GeckoBookmarksApi.setUp(_flutterPluginBinding.binaryMessenger, GeckoBookmarksApiImpl())
|
||||
|
||||
ReaderViewEvents.setUp(
|
||||
_flutterPluginBinding.binaryMessenger,
|
||||
|
||||
+3
@@ -30,6 +30,7 @@ import mozilla.components.browser.session.storage.SessionStorage
|
||||
import mozilla.components.browser.state.engine.EngineMiddleware
|
||||
import mozilla.components.browser.state.engine.middleware.SessionPrioritizationMiddleware
|
||||
import mozilla.components.browser.state.store.BrowserStore
|
||||
import mozilla.components.browser.storage.sync.PlacesBookmarksStorage
|
||||
import mozilla.components.browser.storage.sync.PlacesHistoryStorage
|
||||
import mozilla.components.browser.thumbnails.ThumbnailsMiddleware
|
||||
import mozilla.components.browser.thumbnails.storage.ThumbnailStorage
|
||||
@@ -239,11 +240,13 @@ class Core(
|
||||
* private sessions).
|
||||
*/
|
||||
val lazyHistoryStorage = lazy { PlacesHistoryStorage(context) }
|
||||
val lazyBookmarksStorage = lazy { PlacesBookmarksStorage(context) }
|
||||
|
||||
/**
|
||||
* A convenience accessor to the [PlacesHistoryStorage].
|
||||
*/
|
||||
val historyStorage by lazy { lazyHistoryStorage.value }
|
||||
val bookmarksStorage by lazy { lazyBookmarksStorage.value }
|
||||
|
||||
val permissionStorage by lazy { PermissionStorage(geckoSitePermissionsStorage) }
|
||||
|
||||
|
||||
+512
-97
@@ -424,6 +424,18 @@ enum class GeckoFetchCookiePolicy(val raw: Int) {
|
||||
}
|
||||
}
|
||||
|
||||
enum class BookmarkNodeType(val raw: Int) {
|
||||
ITEM(0),
|
||||
FOLDER(1),
|
||||
SEPARATOR(2);
|
||||
|
||||
companion object {
|
||||
fun ofRaw(raw: Int): BookmarkNodeType? {
|
||||
return values().firstOrNull { it.raw == raw }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Translation options that map to the Gecko Translations Options.
|
||||
*
|
||||
@@ -2448,6 +2460,99 @@ data class GeckoFetchResponse (
|
||||
|
||||
override fun hashCode(): Int = toList().hashCode()
|
||||
}
|
||||
|
||||
/** Generated class from Pigeon that represents data sent in messages. */
|
||||
data class BookmarkNode (
|
||||
val type: BookmarkNodeType,
|
||||
val guid: String,
|
||||
val parentGuid: String? = null,
|
||||
val position: Long? = null,
|
||||
val title: String? = null,
|
||||
val url: String? = null,
|
||||
val dateAdded: Long,
|
||||
val lastModified: Long,
|
||||
val children: List<BookmarkNode>? = null
|
||||
)
|
||||
{
|
||||
companion object {
|
||||
fun fromList(pigeonVar_list: List<Any?>): BookmarkNode {
|
||||
val type = pigeonVar_list[0] as BookmarkNodeType
|
||||
val guid = pigeonVar_list[1] as String
|
||||
val parentGuid = pigeonVar_list[2] as String?
|
||||
val position = pigeonVar_list[3] as Long?
|
||||
val title = pigeonVar_list[4] as String?
|
||||
val url = pigeonVar_list[5] as String?
|
||||
val dateAdded = pigeonVar_list[6] as Long
|
||||
val lastModified = pigeonVar_list[7] as Long
|
||||
val children = pigeonVar_list[8] as List<BookmarkNode>?
|
||||
return BookmarkNode(type, guid, parentGuid, position, title, url, dateAdded, lastModified, children)
|
||||
}
|
||||
}
|
||||
fun toList(): List<Any?> {
|
||||
return listOf(
|
||||
type,
|
||||
guid,
|
||||
parentGuid,
|
||||
position,
|
||||
title,
|
||||
url,
|
||||
dateAdded,
|
||||
lastModified,
|
||||
children,
|
||||
)
|
||||
}
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (other !is BookmarkNode) {
|
||||
return false
|
||||
}
|
||||
if (this === other) {
|
||||
return true
|
||||
}
|
||||
return GeckoPigeonUtils.deepEquals(toList(), other.toList()) }
|
||||
|
||||
override fun hashCode(): Int = toList().hashCode()
|
||||
}
|
||||
|
||||
/**
|
||||
* Class for making alterations to any bookmark node
|
||||
*
|
||||
* Generated class from Pigeon that represents data sent in messages.
|
||||
*/
|
||||
data class BookmarkInfo (
|
||||
val parentGuid: String? = null,
|
||||
val position: Long? = null,
|
||||
val title: String? = null,
|
||||
val url: String? = null
|
||||
)
|
||||
{
|
||||
companion object {
|
||||
fun fromList(pigeonVar_list: List<Any?>): BookmarkInfo {
|
||||
val parentGuid = pigeonVar_list[0] as String?
|
||||
val position = pigeonVar_list[1] as Long?
|
||||
val title = pigeonVar_list[2] as String?
|
||||
val url = pigeonVar_list[3] as String?
|
||||
return BookmarkInfo(parentGuid, position, title, url)
|
||||
}
|
||||
}
|
||||
fun toList(): List<Any?> {
|
||||
return listOf(
|
||||
parentGuid,
|
||||
position,
|
||||
title,
|
||||
url,
|
||||
)
|
||||
}
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (other !is BookmarkInfo) {
|
||||
return false
|
||||
}
|
||||
if (this === other) {
|
||||
return true
|
||||
}
|
||||
return GeckoPigeonUtils.deepEquals(toList(), other.toList()) }
|
||||
|
||||
override fun hashCode(): Int = toList().hashCode()
|
||||
}
|
||||
private open class GeckoPigeonCodec : StandardMessageCodec() {
|
||||
override fun readValueOfType(type: Byte, buffer: ByteBuffer): Any? {
|
||||
return when (type) {
|
||||
@@ -2562,245 +2667,260 @@ private open class GeckoPigeonCodec : StandardMessageCodec() {
|
||||
}
|
||||
}
|
||||
151.toByte() -> {
|
||||
return (readValue(buffer) as? List<Any?>)?.let {
|
||||
TranslationOptions.fromList(it)
|
||||
return (readValue(buffer) as Long?)?.let {
|
||||
BookmarkNodeType.ofRaw(it.toInt())
|
||||
}
|
||||
}
|
||||
152.toByte() -> {
|
||||
return (readValue(buffer) as? List<Any?>)?.let {
|
||||
ReaderState.fromList(it)
|
||||
TranslationOptions.fromList(it)
|
||||
}
|
||||
}
|
||||
153.toByte() -> {
|
||||
return (readValue(buffer) as? List<Any?>)?.let {
|
||||
LastMediaAccessState.fromList(it)
|
||||
ReaderState.fromList(it)
|
||||
}
|
||||
}
|
||||
154.toByte() -> {
|
||||
return (readValue(buffer) as? List<Any?>)?.let {
|
||||
HistoryMetadataKey.fromList(it)
|
||||
LastMediaAccessState.fromList(it)
|
||||
}
|
||||
}
|
||||
155.toByte() -> {
|
||||
return (readValue(buffer) as? List<Any?>)?.let {
|
||||
PackageCategoryValue.fromList(it)
|
||||
HistoryMetadataKey.fromList(it)
|
||||
}
|
||||
}
|
||||
156.toByte() -> {
|
||||
return (readValue(buffer) as? List<Any?>)?.let {
|
||||
ExternalPackage.fromList(it)
|
||||
PackageCategoryValue.fromList(it)
|
||||
}
|
||||
}
|
||||
157.toByte() -> {
|
||||
return (readValue(buffer) as? List<Any?>)?.let {
|
||||
LoadUrlFlagsValue.fromList(it)
|
||||
ExternalPackage.fromList(it)
|
||||
}
|
||||
}
|
||||
158.toByte() -> {
|
||||
return (readValue(buffer) as? List<Any?>)?.let {
|
||||
SourceValue.fromList(it)
|
||||
LoadUrlFlagsValue.fromList(it)
|
||||
}
|
||||
}
|
||||
159.toByte() -> {
|
||||
return (readValue(buffer) as? List<Any?>)?.let {
|
||||
TabState.fromList(it)
|
||||
SourceValue.fromList(it)
|
||||
}
|
||||
}
|
||||
160.toByte() -> {
|
||||
return (readValue(buffer) as? List<Any?>)?.let {
|
||||
RecoverableTab.fromList(it)
|
||||
TabState.fromList(it)
|
||||
}
|
||||
}
|
||||
161.toByte() -> {
|
||||
return (readValue(buffer) as? List<Any?>)?.let {
|
||||
RecoverableBrowserState.fromList(it)
|
||||
RecoverableTab.fromList(it)
|
||||
}
|
||||
}
|
||||
162.toByte() -> {
|
||||
return (readValue(buffer) as? List<Any?>)?.let {
|
||||
IconRequest.fromList(it)
|
||||
RecoverableBrowserState.fromList(it)
|
||||
}
|
||||
}
|
||||
163.toByte() -> {
|
||||
return (readValue(buffer) as? List<Any?>)?.let {
|
||||
ResourceSize.fromList(it)
|
||||
IconRequest.fromList(it)
|
||||
}
|
||||
}
|
||||
164.toByte() -> {
|
||||
return (readValue(buffer) as? List<Any?>)?.let {
|
||||
Resource.fromList(it)
|
||||
ResourceSize.fromList(it)
|
||||
}
|
||||
}
|
||||
165.toByte() -> {
|
||||
return (readValue(buffer) as? List<Any?>)?.let {
|
||||
IconResult.fromList(it)
|
||||
Resource.fromList(it)
|
||||
}
|
||||
}
|
||||
166.toByte() -> {
|
||||
return (readValue(buffer) as? List<Any?>)?.let {
|
||||
CookiePartitionKey.fromList(it)
|
||||
IconResult.fromList(it)
|
||||
}
|
||||
}
|
||||
167.toByte() -> {
|
||||
return (readValue(buffer) as? List<Any?>)?.let {
|
||||
Cookie.fromList(it)
|
||||
CookiePartitionKey.fromList(it)
|
||||
}
|
||||
}
|
||||
168.toByte() -> {
|
||||
return (readValue(buffer) as? List<Any?>)?.let {
|
||||
VisitInfo.fromList(it)
|
||||
Cookie.fromList(it)
|
||||
}
|
||||
}
|
||||
169.toByte() -> {
|
||||
return (readValue(buffer) as? List<Any?>)?.let {
|
||||
HistoryItem.fromList(it)
|
||||
VisitInfo.fromList(it)
|
||||
}
|
||||
}
|
||||
170.toByte() -> {
|
||||
return (readValue(buffer) as? List<Any?>)?.let {
|
||||
HistoryState.fromList(it)
|
||||
HistoryItem.fromList(it)
|
||||
}
|
||||
}
|
||||
171.toByte() -> {
|
||||
return (readValue(buffer) as? List<Any?>)?.let {
|
||||
ReaderableState.fromList(it)
|
||||
HistoryState.fromList(it)
|
||||
}
|
||||
}
|
||||
172.toByte() -> {
|
||||
return (readValue(buffer) as? List<Any?>)?.let {
|
||||
SecurityInfoState.fromList(it)
|
||||
ReaderableState.fromList(it)
|
||||
}
|
||||
}
|
||||
173.toByte() -> {
|
||||
return (readValue(buffer) as? List<Any?>)?.let {
|
||||
TabContentState.fromList(it)
|
||||
SecurityInfoState.fromList(it)
|
||||
}
|
||||
}
|
||||
174.toByte() -> {
|
||||
return (readValue(buffer) as? List<Any?>)?.let {
|
||||
FindResultState.fromList(it)
|
||||
TabContentState.fromList(it)
|
||||
}
|
||||
}
|
||||
175.toByte() -> {
|
||||
return (readValue(buffer) as? List<Any?>)?.let {
|
||||
CustomSelectionAction.fromList(it)
|
||||
FindResultState.fromList(it)
|
||||
}
|
||||
}
|
||||
176.toByte() -> {
|
||||
return (readValue(buffer) as? List<Any?>)?.let {
|
||||
WebExtensionData.fromList(it)
|
||||
CustomSelectionAction.fromList(it)
|
||||
}
|
||||
}
|
||||
177.toByte() -> {
|
||||
return (readValue(buffer) as? List<Any?>)?.let {
|
||||
GeckoSuggestion.fromList(it)
|
||||
WebExtensionData.fromList(it)
|
||||
}
|
||||
}
|
||||
178.toByte() -> {
|
||||
return (readValue(buffer) as? List<Any?>)?.let {
|
||||
TabContent.fromList(it)
|
||||
GeckoSuggestion.fromList(it)
|
||||
}
|
||||
}
|
||||
179.toByte() -> {
|
||||
return (readValue(buffer) as? List<Any?>)?.let {
|
||||
ContentBlocking.fromList(it)
|
||||
TabContent.fromList(it)
|
||||
}
|
||||
}
|
||||
180.toByte() -> {
|
||||
return (readValue(buffer) as? List<Any?>)?.let {
|
||||
DohSettings.fromList(it)
|
||||
ContentBlocking.fromList(it)
|
||||
}
|
||||
}
|
||||
181.toByte() -> {
|
||||
return (readValue(buffer) as? List<Any?>)?.let {
|
||||
GeckoEngineSettings.fromList(it)
|
||||
DohSettings.fromList(it)
|
||||
}
|
||||
}
|
||||
182.toByte() -> {
|
||||
return (readValue(buffer) as? List<Any?>)?.let {
|
||||
AutocompleteResult.fromList(it)
|
||||
GeckoEngineSettings.fromList(it)
|
||||
}
|
||||
}
|
||||
183.toByte() -> {
|
||||
return (readValue(buffer) as? List<Any?>)?.let {
|
||||
UnknownHitResult.fromList(it)
|
||||
AutocompleteResult.fromList(it)
|
||||
}
|
||||
}
|
||||
184.toByte() -> {
|
||||
return (readValue(buffer) as? List<Any?>)?.let {
|
||||
ImageHitResult.fromList(it)
|
||||
UnknownHitResult.fromList(it)
|
||||
}
|
||||
}
|
||||
185.toByte() -> {
|
||||
return (readValue(buffer) as? List<Any?>)?.let {
|
||||
VideoHitResult.fromList(it)
|
||||
ImageHitResult.fromList(it)
|
||||
}
|
||||
}
|
||||
186.toByte() -> {
|
||||
return (readValue(buffer) as? List<Any?>)?.let {
|
||||
AudioHitResult.fromList(it)
|
||||
VideoHitResult.fromList(it)
|
||||
}
|
||||
}
|
||||
187.toByte() -> {
|
||||
return (readValue(buffer) as? List<Any?>)?.let {
|
||||
ImageSrcHitResult.fromList(it)
|
||||
AudioHitResult.fromList(it)
|
||||
}
|
||||
}
|
||||
188.toByte() -> {
|
||||
return (readValue(buffer) as? List<Any?>)?.let {
|
||||
PhoneHitResult.fromList(it)
|
||||
ImageSrcHitResult.fromList(it)
|
||||
}
|
||||
}
|
||||
189.toByte() -> {
|
||||
return (readValue(buffer) as? List<Any?>)?.let {
|
||||
EmailHitResult.fromList(it)
|
||||
PhoneHitResult.fromList(it)
|
||||
}
|
||||
}
|
||||
190.toByte() -> {
|
||||
return (readValue(buffer) as? List<Any?>)?.let {
|
||||
GeoHitResult.fromList(it)
|
||||
EmailHitResult.fromList(it)
|
||||
}
|
||||
}
|
||||
191.toByte() -> {
|
||||
return (readValue(buffer) as? List<Any?>)?.let {
|
||||
DownloadState.fromList(it)
|
||||
GeoHitResult.fromList(it)
|
||||
}
|
||||
}
|
||||
192.toByte() -> {
|
||||
return (readValue(buffer) as? List<Any?>)?.let {
|
||||
ShareInternetResourceState.fromList(it)
|
||||
DownloadState.fromList(it)
|
||||
}
|
||||
}
|
||||
193.toByte() -> {
|
||||
return (readValue(buffer) as? List<Any?>)?.let {
|
||||
AddonCollection.fromList(it)
|
||||
ShareInternetResourceState.fromList(it)
|
||||
}
|
||||
}
|
||||
194.toByte() -> {
|
||||
return (readValue(buffer) as? List<Any?>)?.let {
|
||||
GeckoPref.fromList(it)
|
||||
AddonCollection.fromList(it)
|
||||
}
|
||||
}
|
||||
195.toByte() -> {
|
||||
return (readValue(buffer) as? List<Any?>)?.let {
|
||||
ContainerSiteAssignment.fromList(it)
|
||||
GeckoPref.fromList(it)
|
||||
}
|
||||
}
|
||||
196.toByte() -> {
|
||||
return (readValue(buffer) as? List<Any?>)?.let {
|
||||
GeckoHeader.fromList(it)
|
||||
ContainerSiteAssignment.fromList(it)
|
||||
}
|
||||
}
|
||||
197.toByte() -> {
|
||||
return (readValue(buffer) as? List<Any?>)?.let {
|
||||
GeckoFetchRequest.fromList(it)
|
||||
GeckoHeader.fromList(it)
|
||||
}
|
||||
}
|
||||
198.toByte() -> {
|
||||
return (readValue(buffer) as? List<Any?>)?.let {
|
||||
GeckoFetchRequest.fromList(it)
|
||||
}
|
||||
}
|
||||
199.toByte() -> {
|
||||
return (readValue(buffer) as? List<Any?>)?.let {
|
||||
GeckoFetchResponse.fromList(it)
|
||||
}
|
||||
}
|
||||
200.toByte() -> {
|
||||
return (readValue(buffer) as? List<Any?>)?.let {
|
||||
BookmarkNode.fromList(it)
|
||||
}
|
||||
}
|
||||
201.toByte() -> {
|
||||
return (readValue(buffer) as? List<Any?>)?.let {
|
||||
BookmarkInfo.fromList(it)
|
||||
}
|
||||
}
|
||||
else -> super.readValueOfType(type, buffer)
|
||||
}
|
||||
}
|
||||
@@ -2894,198 +3014,210 @@ private open class GeckoPigeonCodec : StandardMessageCodec() {
|
||||
stream.write(150)
|
||||
writeValue(stream, value.raw.toLong())
|
||||
}
|
||||
is TranslationOptions -> {
|
||||
is BookmarkNodeType -> {
|
||||
stream.write(151)
|
||||
writeValue(stream, value.toList())
|
||||
writeValue(stream, value.raw.toLong())
|
||||
}
|
||||
is ReaderState -> {
|
||||
is TranslationOptions -> {
|
||||
stream.write(152)
|
||||
writeValue(stream, value.toList())
|
||||
}
|
||||
is LastMediaAccessState -> {
|
||||
is ReaderState -> {
|
||||
stream.write(153)
|
||||
writeValue(stream, value.toList())
|
||||
}
|
||||
is HistoryMetadataKey -> {
|
||||
is LastMediaAccessState -> {
|
||||
stream.write(154)
|
||||
writeValue(stream, value.toList())
|
||||
}
|
||||
is PackageCategoryValue -> {
|
||||
is HistoryMetadataKey -> {
|
||||
stream.write(155)
|
||||
writeValue(stream, value.toList())
|
||||
}
|
||||
is ExternalPackage -> {
|
||||
is PackageCategoryValue -> {
|
||||
stream.write(156)
|
||||
writeValue(stream, value.toList())
|
||||
}
|
||||
is LoadUrlFlagsValue -> {
|
||||
is ExternalPackage -> {
|
||||
stream.write(157)
|
||||
writeValue(stream, value.toList())
|
||||
}
|
||||
is SourceValue -> {
|
||||
is LoadUrlFlagsValue -> {
|
||||
stream.write(158)
|
||||
writeValue(stream, value.toList())
|
||||
}
|
||||
is TabState -> {
|
||||
is SourceValue -> {
|
||||
stream.write(159)
|
||||
writeValue(stream, value.toList())
|
||||
}
|
||||
is RecoverableTab -> {
|
||||
is TabState -> {
|
||||
stream.write(160)
|
||||
writeValue(stream, value.toList())
|
||||
}
|
||||
is RecoverableBrowserState -> {
|
||||
is RecoverableTab -> {
|
||||
stream.write(161)
|
||||
writeValue(stream, value.toList())
|
||||
}
|
||||
is IconRequest -> {
|
||||
is RecoverableBrowserState -> {
|
||||
stream.write(162)
|
||||
writeValue(stream, value.toList())
|
||||
}
|
||||
is ResourceSize -> {
|
||||
is IconRequest -> {
|
||||
stream.write(163)
|
||||
writeValue(stream, value.toList())
|
||||
}
|
||||
is Resource -> {
|
||||
is ResourceSize -> {
|
||||
stream.write(164)
|
||||
writeValue(stream, value.toList())
|
||||
}
|
||||
is IconResult -> {
|
||||
is Resource -> {
|
||||
stream.write(165)
|
||||
writeValue(stream, value.toList())
|
||||
}
|
||||
is CookiePartitionKey -> {
|
||||
is IconResult -> {
|
||||
stream.write(166)
|
||||
writeValue(stream, value.toList())
|
||||
}
|
||||
is Cookie -> {
|
||||
is CookiePartitionKey -> {
|
||||
stream.write(167)
|
||||
writeValue(stream, value.toList())
|
||||
}
|
||||
is VisitInfo -> {
|
||||
is Cookie -> {
|
||||
stream.write(168)
|
||||
writeValue(stream, value.toList())
|
||||
}
|
||||
is HistoryItem -> {
|
||||
is VisitInfo -> {
|
||||
stream.write(169)
|
||||
writeValue(stream, value.toList())
|
||||
}
|
||||
is HistoryState -> {
|
||||
is HistoryItem -> {
|
||||
stream.write(170)
|
||||
writeValue(stream, value.toList())
|
||||
}
|
||||
is ReaderableState -> {
|
||||
is HistoryState -> {
|
||||
stream.write(171)
|
||||
writeValue(stream, value.toList())
|
||||
}
|
||||
is SecurityInfoState -> {
|
||||
is ReaderableState -> {
|
||||
stream.write(172)
|
||||
writeValue(stream, value.toList())
|
||||
}
|
||||
is TabContentState -> {
|
||||
is SecurityInfoState -> {
|
||||
stream.write(173)
|
||||
writeValue(stream, value.toList())
|
||||
}
|
||||
is FindResultState -> {
|
||||
is TabContentState -> {
|
||||
stream.write(174)
|
||||
writeValue(stream, value.toList())
|
||||
}
|
||||
is CustomSelectionAction -> {
|
||||
is FindResultState -> {
|
||||
stream.write(175)
|
||||
writeValue(stream, value.toList())
|
||||
}
|
||||
is WebExtensionData -> {
|
||||
is CustomSelectionAction -> {
|
||||
stream.write(176)
|
||||
writeValue(stream, value.toList())
|
||||
}
|
||||
is GeckoSuggestion -> {
|
||||
is WebExtensionData -> {
|
||||
stream.write(177)
|
||||
writeValue(stream, value.toList())
|
||||
}
|
||||
is TabContent -> {
|
||||
is GeckoSuggestion -> {
|
||||
stream.write(178)
|
||||
writeValue(stream, value.toList())
|
||||
}
|
||||
is ContentBlocking -> {
|
||||
is TabContent -> {
|
||||
stream.write(179)
|
||||
writeValue(stream, value.toList())
|
||||
}
|
||||
is DohSettings -> {
|
||||
is ContentBlocking -> {
|
||||
stream.write(180)
|
||||
writeValue(stream, value.toList())
|
||||
}
|
||||
is GeckoEngineSettings -> {
|
||||
is DohSettings -> {
|
||||
stream.write(181)
|
||||
writeValue(stream, value.toList())
|
||||
}
|
||||
is AutocompleteResult -> {
|
||||
is GeckoEngineSettings -> {
|
||||
stream.write(182)
|
||||
writeValue(stream, value.toList())
|
||||
}
|
||||
is UnknownHitResult -> {
|
||||
is AutocompleteResult -> {
|
||||
stream.write(183)
|
||||
writeValue(stream, value.toList())
|
||||
}
|
||||
is ImageHitResult -> {
|
||||
is UnknownHitResult -> {
|
||||
stream.write(184)
|
||||
writeValue(stream, value.toList())
|
||||
}
|
||||
is VideoHitResult -> {
|
||||
is ImageHitResult -> {
|
||||
stream.write(185)
|
||||
writeValue(stream, value.toList())
|
||||
}
|
||||
is AudioHitResult -> {
|
||||
is VideoHitResult -> {
|
||||
stream.write(186)
|
||||
writeValue(stream, value.toList())
|
||||
}
|
||||
is ImageSrcHitResult -> {
|
||||
is AudioHitResult -> {
|
||||
stream.write(187)
|
||||
writeValue(stream, value.toList())
|
||||
}
|
||||
is PhoneHitResult -> {
|
||||
is ImageSrcHitResult -> {
|
||||
stream.write(188)
|
||||
writeValue(stream, value.toList())
|
||||
}
|
||||
is EmailHitResult -> {
|
||||
is PhoneHitResult -> {
|
||||
stream.write(189)
|
||||
writeValue(stream, value.toList())
|
||||
}
|
||||
is GeoHitResult -> {
|
||||
is EmailHitResult -> {
|
||||
stream.write(190)
|
||||
writeValue(stream, value.toList())
|
||||
}
|
||||
is DownloadState -> {
|
||||
is GeoHitResult -> {
|
||||
stream.write(191)
|
||||
writeValue(stream, value.toList())
|
||||
}
|
||||
is ShareInternetResourceState -> {
|
||||
is DownloadState -> {
|
||||
stream.write(192)
|
||||
writeValue(stream, value.toList())
|
||||
}
|
||||
is AddonCollection -> {
|
||||
is ShareInternetResourceState -> {
|
||||
stream.write(193)
|
||||
writeValue(stream, value.toList())
|
||||
}
|
||||
is GeckoPref -> {
|
||||
is AddonCollection -> {
|
||||
stream.write(194)
|
||||
writeValue(stream, value.toList())
|
||||
}
|
||||
is ContainerSiteAssignment -> {
|
||||
is GeckoPref -> {
|
||||
stream.write(195)
|
||||
writeValue(stream, value.toList())
|
||||
}
|
||||
is GeckoHeader -> {
|
||||
is ContainerSiteAssignment -> {
|
||||
stream.write(196)
|
||||
writeValue(stream, value.toList())
|
||||
}
|
||||
is GeckoFetchRequest -> {
|
||||
is GeckoHeader -> {
|
||||
stream.write(197)
|
||||
writeValue(stream, value.toList())
|
||||
}
|
||||
is GeckoFetchResponse -> {
|
||||
is GeckoFetchRequest -> {
|
||||
stream.write(198)
|
||||
writeValue(stream, value.toList())
|
||||
}
|
||||
is GeckoFetchResponse -> {
|
||||
stream.write(199)
|
||||
writeValue(stream, value.toList())
|
||||
}
|
||||
is BookmarkNode -> {
|
||||
stream.write(200)
|
||||
writeValue(stream, value.toList())
|
||||
}
|
||||
is BookmarkInfo -> {
|
||||
stream.write(201)
|
||||
writeValue(stream, value.toList())
|
||||
}
|
||||
else -> super.writeValue(stream, value)
|
||||
}
|
||||
}
|
||||
@@ -5594,3 +5726,286 @@ interface GeckoFetchApi {
|
||||
}
|
||||
}
|
||||
}
|
||||
/** Generated interface from Pigeon that represents a handler of messages from Flutter. */
|
||||
interface GeckoBookmarksApi {
|
||||
/**
|
||||
* Produces a bookmarks tree for the given guid string.
|
||||
*
|
||||
* @param guid The bookmark guid to obtain.
|
||||
* @param recursive Whether to recurse and obtain all levels of children.
|
||||
* @return The populated root starting from the guid.
|
||||
*/
|
||||
fun getTree(guid: String, recursive: Boolean, callback: (Result<BookmarkNode?>) -> Unit)
|
||||
/**
|
||||
* Obtains the details of a bookmark without children, if one exists with that guid. Otherwise, null.
|
||||
*
|
||||
* @param guid The bookmark guid to obtain.
|
||||
* @return The bookmark node or null if it does not exist.
|
||||
*/
|
||||
fun getBookmark(guid: String, callback: (Result<BookmarkNode?>) -> Unit)
|
||||
/**
|
||||
* Produces a list of all bookmarks with the given URL.
|
||||
*
|
||||
* @param url The URL string.
|
||||
* @return The list of bookmarks that match the URL
|
||||
*/
|
||||
fun getBookmarksWithUrl(url: String, callback: (Result<List<BookmarkNode>>) -> Unit)
|
||||
/**
|
||||
* Produces a list of the most recently added bookmarks.
|
||||
*
|
||||
* @param limit The maximum number of entries to return.
|
||||
* @param maxAge Optional parameter used to filter out entries older than this number of milliseconds.
|
||||
* @param currentTime Optional parameter for current time. Defaults toSystem.currentTimeMillis()
|
||||
* @return The list of bookmarks that have been recently added up to the limit number of items.
|
||||
*/
|
||||
fun getRecentBookmarks(limit: Long, maxAge: Long?, currentTime: Long, callback: (Result<List<BookmarkNode>>) -> Unit)
|
||||
/**
|
||||
* Searches bookmarks with a query string.
|
||||
*
|
||||
* @param query The query string to search.
|
||||
* @param limit The maximum number of entries to return.
|
||||
* @return The list of matching bookmark nodes up to the limit number of items.
|
||||
*/
|
||||
fun searchBookmarks(query: String, limit: Long, callback: (Result<List<BookmarkNode>>) -> Unit)
|
||||
/**
|
||||
* Adds a new bookmark item to a given node.
|
||||
*
|
||||
* Sync behavior: will add new bookmark item to remote devices.
|
||||
*
|
||||
* @param parentGuid The parent guid of the new node.
|
||||
* @param url The URL of the bookmark item to add.
|
||||
* @param title The title of the bookmark item to add.
|
||||
* @param position The optional position to add the new node or null to append.
|
||||
* @return The guid of the newly inserted bookmark item.
|
||||
*/
|
||||
fun addItem(parentGuid: String, url: String, title: String, position: Long?, callback: (Result<String>) -> Unit)
|
||||
/**
|
||||
* Adds a new bookmark folder to a given node.
|
||||
*
|
||||
* Sync behavior: will add new separator to remote devices.
|
||||
*
|
||||
* @param parentGuid The parent guid of the new node.
|
||||
* @param title The title of the bookmark folder to add.
|
||||
* @param position The optional position to add the new node or null to append.
|
||||
* @return The guid of the newly inserted bookmark item.
|
||||
*/
|
||||
fun addFolder(parentGuid: String, title: String, position: Long?, callback: (Result<String>) -> Unit)
|
||||
/**
|
||||
* Edits the properties of an existing bookmark item and/or moves an existing one underneath a new parent guid.
|
||||
*
|
||||
* Sync behavior: will alter bookmark item on remote devices.
|
||||
*
|
||||
* @param guid The guid of the item to update.
|
||||
* @param info The info to change in the bookmark.
|
||||
*/
|
||||
fun updateNode(guid: String, info: BookmarkInfo, callback: (Result<Unit>) -> Unit)
|
||||
/**
|
||||
* Deletes a bookmark node and all of its children, if any.
|
||||
*
|
||||
* Sync behavior: will remove bookmark from remote devices.
|
||||
*
|
||||
* @return Whether the bookmark existed or not.
|
||||
*/
|
||||
fun deleteNode(guid: String, callback: (Result<Boolean>) -> Unit)
|
||||
|
||||
companion object {
|
||||
/** The codec used by GeckoBookmarksApi. */
|
||||
val codec: MessageCodec<Any?> by lazy {
|
||||
GeckoPigeonCodec()
|
||||
}
|
||||
/** Sets up an instance of `GeckoBookmarksApi` to handle messages through the `binaryMessenger`. */
|
||||
@JvmOverloads
|
||||
fun setUp(binaryMessenger: BinaryMessenger, api: GeckoBookmarksApi?, messageChannelSuffix: String = "") {
|
||||
val separatedMessageChannelSuffix = if (messageChannelSuffix.isNotEmpty()) ".$messageChannelSuffix" else ""
|
||||
run {
|
||||
val channel = BasicMessageChannel<Any?>(binaryMessenger, "dev.flutter.pigeon.flutter_mozilla_components.GeckoBookmarksApi.getTree$separatedMessageChannelSuffix", codec)
|
||||
if (api != null) {
|
||||
channel.setMessageHandler { message, reply ->
|
||||
val args = message as List<Any?>
|
||||
val guidArg = args[0] as String
|
||||
val recursiveArg = args[1] as Boolean
|
||||
api.getTree(guidArg, recursiveArg) { result: Result<BookmarkNode?> ->
|
||||
val error = result.exceptionOrNull()
|
||||
if (error != null) {
|
||||
reply.reply(GeckoPigeonUtils.wrapError(error))
|
||||
} else {
|
||||
val data = result.getOrNull()
|
||||
reply.reply(GeckoPigeonUtils.wrapResult(data))
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
channel.setMessageHandler(null)
|
||||
}
|
||||
}
|
||||
run {
|
||||
val channel = BasicMessageChannel<Any?>(binaryMessenger, "dev.flutter.pigeon.flutter_mozilla_components.GeckoBookmarksApi.getBookmark$separatedMessageChannelSuffix", codec)
|
||||
if (api != null) {
|
||||
channel.setMessageHandler { message, reply ->
|
||||
val args = message as List<Any?>
|
||||
val guidArg = args[0] as String
|
||||
api.getBookmark(guidArg) { result: Result<BookmarkNode?> ->
|
||||
val error = result.exceptionOrNull()
|
||||
if (error != null) {
|
||||
reply.reply(GeckoPigeonUtils.wrapError(error))
|
||||
} else {
|
||||
val data = result.getOrNull()
|
||||
reply.reply(GeckoPigeonUtils.wrapResult(data))
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
channel.setMessageHandler(null)
|
||||
}
|
||||
}
|
||||
run {
|
||||
val channel = BasicMessageChannel<Any?>(binaryMessenger, "dev.flutter.pigeon.flutter_mozilla_components.GeckoBookmarksApi.getBookmarksWithUrl$separatedMessageChannelSuffix", codec)
|
||||
if (api != null) {
|
||||
channel.setMessageHandler { message, reply ->
|
||||
val args = message as List<Any?>
|
||||
val urlArg = args[0] as String
|
||||
api.getBookmarksWithUrl(urlArg) { result: Result<List<BookmarkNode>> ->
|
||||
val error = result.exceptionOrNull()
|
||||
if (error != null) {
|
||||
reply.reply(GeckoPigeonUtils.wrapError(error))
|
||||
} else {
|
||||
val data = result.getOrNull()
|
||||
reply.reply(GeckoPigeonUtils.wrapResult(data))
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
channel.setMessageHandler(null)
|
||||
}
|
||||
}
|
||||
run {
|
||||
val channel = BasicMessageChannel<Any?>(binaryMessenger, "dev.flutter.pigeon.flutter_mozilla_components.GeckoBookmarksApi.getRecentBookmarks$separatedMessageChannelSuffix", codec)
|
||||
if (api != null) {
|
||||
channel.setMessageHandler { message, reply ->
|
||||
val args = message as List<Any?>
|
||||
val limitArg = args[0] as Long
|
||||
val maxAgeArg = args[1] as Long?
|
||||
val currentTimeArg = args[2] as Long
|
||||
api.getRecentBookmarks(limitArg, maxAgeArg, currentTimeArg) { result: Result<List<BookmarkNode>> ->
|
||||
val error = result.exceptionOrNull()
|
||||
if (error != null) {
|
||||
reply.reply(GeckoPigeonUtils.wrapError(error))
|
||||
} else {
|
||||
val data = result.getOrNull()
|
||||
reply.reply(GeckoPigeonUtils.wrapResult(data))
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
channel.setMessageHandler(null)
|
||||
}
|
||||
}
|
||||
run {
|
||||
val channel = BasicMessageChannel<Any?>(binaryMessenger, "dev.flutter.pigeon.flutter_mozilla_components.GeckoBookmarksApi.searchBookmarks$separatedMessageChannelSuffix", codec)
|
||||
if (api != null) {
|
||||
channel.setMessageHandler { message, reply ->
|
||||
val args = message as List<Any?>
|
||||
val queryArg = args[0] as String
|
||||
val limitArg = args[1] as Long
|
||||
api.searchBookmarks(queryArg, limitArg) { result: Result<List<BookmarkNode>> ->
|
||||
val error = result.exceptionOrNull()
|
||||
if (error != null) {
|
||||
reply.reply(GeckoPigeonUtils.wrapError(error))
|
||||
} else {
|
||||
val data = result.getOrNull()
|
||||
reply.reply(GeckoPigeonUtils.wrapResult(data))
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
channel.setMessageHandler(null)
|
||||
}
|
||||
}
|
||||
run {
|
||||
val channel = BasicMessageChannel<Any?>(binaryMessenger, "dev.flutter.pigeon.flutter_mozilla_components.GeckoBookmarksApi.addItem$separatedMessageChannelSuffix", codec)
|
||||
if (api != null) {
|
||||
channel.setMessageHandler { message, reply ->
|
||||
val args = message as List<Any?>
|
||||
val parentGuidArg = args[0] as String
|
||||
val urlArg = args[1] as String
|
||||
val titleArg = args[2] as String
|
||||
val positionArg = args[3] as Long?
|
||||
api.addItem(parentGuidArg, urlArg, titleArg, positionArg) { result: Result<String> ->
|
||||
val error = result.exceptionOrNull()
|
||||
if (error != null) {
|
||||
reply.reply(GeckoPigeonUtils.wrapError(error))
|
||||
} else {
|
||||
val data = result.getOrNull()
|
||||
reply.reply(GeckoPigeonUtils.wrapResult(data))
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
channel.setMessageHandler(null)
|
||||
}
|
||||
}
|
||||
run {
|
||||
val channel = BasicMessageChannel<Any?>(binaryMessenger, "dev.flutter.pigeon.flutter_mozilla_components.GeckoBookmarksApi.addFolder$separatedMessageChannelSuffix", codec)
|
||||
if (api != null) {
|
||||
channel.setMessageHandler { message, reply ->
|
||||
val args = message as List<Any?>
|
||||
val parentGuidArg = args[0] as String
|
||||
val titleArg = args[1] as String
|
||||
val positionArg = args[2] as Long?
|
||||
api.addFolder(parentGuidArg, titleArg, positionArg) { result: Result<String> ->
|
||||
val error = result.exceptionOrNull()
|
||||
if (error != null) {
|
||||
reply.reply(GeckoPigeonUtils.wrapError(error))
|
||||
} else {
|
||||
val data = result.getOrNull()
|
||||
reply.reply(GeckoPigeonUtils.wrapResult(data))
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
channel.setMessageHandler(null)
|
||||
}
|
||||
}
|
||||
run {
|
||||
val channel = BasicMessageChannel<Any?>(binaryMessenger, "dev.flutter.pigeon.flutter_mozilla_components.GeckoBookmarksApi.updateNode$separatedMessageChannelSuffix", codec)
|
||||
if (api != null) {
|
||||
channel.setMessageHandler { message, reply ->
|
||||
val args = message as List<Any?>
|
||||
val guidArg = args[0] as String
|
||||
val infoArg = args[1] as BookmarkInfo
|
||||
api.updateNode(guidArg, infoArg) { result: Result<Unit> ->
|
||||
val error = result.exceptionOrNull()
|
||||
if (error != null) {
|
||||
reply.reply(GeckoPigeonUtils.wrapError(error))
|
||||
} else {
|
||||
reply.reply(GeckoPigeonUtils.wrapResult(null))
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
channel.setMessageHandler(null)
|
||||
}
|
||||
}
|
||||
run {
|
||||
val channel = BasicMessageChannel<Any?>(binaryMessenger, "dev.flutter.pigeon.flutter_mozilla_components.GeckoBookmarksApi.deleteNode$separatedMessageChannelSuffix", codec)
|
||||
if (api != null) {
|
||||
channel.setMessageHandler { message, reply ->
|
||||
val args = message as List<Any?>
|
||||
val guidArg = args[0] as String
|
||||
api.deleteNode(guidArg) { result: Result<Boolean> ->
|
||||
val error = result.exceptionOrNull()
|
||||
if (error != null) {
|
||||
reply.reply(GeckoPigeonUtils.wrapError(error))
|
||||
} else {
|
||||
val data = result.getOrNull()
|
||||
reply.reply(GeckoPigeonUtils.wrapResult(data))
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
channel.setMessageHandler(null)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ export 'src/data/models/load_url_flags.dart';
|
||||
export 'src/data/models/source.dart';
|
||||
export 'src/domain/entities/default_selection_actions.dart';
|
||||
export 'src/domain/services/gecko_addon.dart';
|
||||
export 'src/domain/services/gecko_bookmarks.dart';
|
||||
export 'src/domain/services/gecko_browser.dart';
|
||||
export 'src/domain/services/gecko_browser_extension.dart';
|
||||
export 'src/domain/services/gecko_container_proxy.dart';
|
||||
@@ -34,6 +35,9 @@ export 'src/pigeons/gecko.g.dart'
|
||||
show
|
||||
AddonCollection,
|
||||
AudioHitResult,
|
||||
BookmarkInfo,
|
||||
BookmarkNode,
|
||||
BookmarkNodeType,
|
||||
BounceTrackingProtectionMode,
|
||||
ColorScheme,
|
||||
ContentBlocking,
|
||||
|
||||
@@ -0,0 +1,131 @@
|
||||
import 'package:flutter_mozilla_components/src/pigeons/gecko.g.dart';
|
||||
|
||||
/// Enumeration of the ids of the roots of the bookmarks tree.
|
||||
///
|
||||
/// There are 5 "roots" in the bookmark tree. The actual root
|
||||
/// (which has no parent), and it's 4 children (which have the
|
||||
/// actual root as their parent).
|
||||
///
|
||||
/// You cannot delete or move any of these items.
|
||||
enum BookmarkRoot {
|
||||
root("root________", "Default"),
|
||||
menu("menu________", "Menu"),
|
||||
toolbar("toolbar_____", "Toolbar"),
|
||||
unfiled("unfiled_____", "Unified"),
|
||||
mobile("mobile______", "WebLibre");
|
||||
|
||||
final String id;
|
||||
final String displayName;
|
||||
|
||||
const BookmarkRoot(this.id, this.displayName);
|
||||
}
|
||||
|
||||
final bookmarkRootIds = BookmarkRoot.values.map((e) => e.id).toSet();
|
||||
final bookmarkRootDisplayNames = Map.fromEntries(
|
||||
BookmarkRoot.values.map((e) => MapEntry(e.id, e.displayName)),
|
||||
);
|
||||
|
||||
final _api = GeckoBookmarksApi();
|
||||
|
||||
class GeckoBookmarksService {
|
||||
/// Produces a bookmarks tree for the given guid string.
|
||||
///
|
||||
/// @param guid The bookmark guid to obtain.
|
||||
/// @param recursive Whether to recurse and obtain all levels of children.
|
||||
/// @return The populated root starting from the guid.
|
||||
Future<BookmarkNode?> getTree(String guid, {bool recursive = false}) {
|
||||
return _api.getTree(guid, recursive);
|
||||
}
|
||||
|
||||
/// Obtains the details of a bookmark without children, if one exists with that guid. Otherwise, null.
|
||||
///
|
||||
/// @param guid The bookmark guid to obtain.
|
||||
/// @return The bookmark node or null if it does not exist.
|
||||
Future<BookmarkNode?> getBookmark(String guid) {
|
||||
return _api.getBookmark(guid);
|
||||
}
|
||||
|
||||
/// Produces a list of all bookmarks with the given URL.
|
||||
///
|
||||
/// @param url The URL string.
|
||||
/// @return The list of bookmarks that match the URL
|
||||
Future<List<BookmarkNode>> getBookmarksWithUrl(Uri url) {
|
||||
return _api.getBookmarksWithUrl(url.toString());
|
||||
}
|
||||
|
||||
/// Produces a list of the most recently added bookmarks.
|
||||
///
|
||||
/// @param limit The maximum number of entries to return.
|
||||
/// @param maxAge Optional parameter used to filter out entries older than this number of milliseconds.
|
||||
/// @param currentTime Optional parameter for current time. Defaults toSystem.currentTimeMillis()
|
||||
/// @return The list of bookmarks that have been recently added up to the limit number of items.
|
||||
Future<List<BookmarkNode>> getRecentBookmarks(
|
||||
int limit, {
|
||||
Duration maxAge = Duration.zero,
|
||||
DateTime? currentTime,
|
||||
}) {
|
||||
return _api.getRecentBookmarks(
|
||||
limit,
|
||||
maxAge.inMilliseconds,
|
||||
(currentTime ?? DateTime.now()).millisecondsSinceEpoch,
|
||||
);
|
||||
}
|
||||
|
||||
/// Searches bookmarks with a query string.
|
||||
///
|
||||
/// @param query The query string to search.
|
||||
/// @param limit The maximum number of entries to return.
|
||||
/// @return The list of matching bookmark nodes up to the limit number of items.
|
||||
Future<List<BookmarkNode>> searchBookmarks(String query, {int limit = 10}) {
|
||||
return _api.searchBookmarks(query, limit);
|
||||
}
|
||||
|
||||
/// Adds a new bookmark item to a given node.
|
||||
///
|
||||
/// Sync behavior: will add new bookmark item to remote devices.
|
||||
///
|
||||
/// @param parentGuid The parent guid of the new node.
|
||||
/// @param url The URL of the bookmark item to add.
|
||||
/// @param title The title of the bookmark item to add.
|
||||
/// @param position The optional position to add the new node or null to append.
|
||||
/// @return The guid of the newly inserted bookmark item.
|
||||
Future<String> addItem(
|
||||
String parentGuid,
|
||||
Uri url,
|
||||
String title,
|
||||
int? position,
|
||||
) {
|
||||
return _api.addItem(parentGuid, url.toString(), title, position);
|
||||
}
|
||||
|
||||
/// Adds a new bookmark folder to a given node.
|
||||
///
|
||||
/// Sync behavior: will add new separator to remote devices.
|
||||
///
|
||||
/// @param parentGuid The parent guid of the new node.
|
||||
/// @param title The title of the bookmark folder to add.
|
||||
/// @param position The optional position to add the new node or null to append.
|
||||
/// @return The guid of the newly inserted bookmark item.
|
||||
Future<String> addFolder(String parentGuid, String title, int? position) {
|
||||
return _api.addFolder(parentGuid, title, position);
|
||||
}
|
||||
|
||||
/// Edits the properties of an existing bookmark item and/or moves an existing one underneath a new parent guid.
|
||||
///
|
||||
/// Sync behavior: will alter bookmark item on remote devices.
|
||||
///
|
||||
/// @param guid The guid of the item to update.
|
||||
/// @param info The info to change in the bookmark.
|
||||
Future<void> updateNode(String guid, BookmarkInfo info) {
|
||||
return _api.updateNode(guid, info);
|
||||
}
|
||||
|
||||
/// Deletes a bookmark node and all of its children, if any.
|
||||
///
|
||||
/// Sync behavior: will remove bookmark from remote devices.
|
||||
///
|
||||
/// @return Whether the bookmark existed or not.
|
||||
Future<bool> deleteNode(String guid) {
|
||||
return _api.deleteNode(guid);
|
||||
}
|
||||
}
|
||||
@@ -238,6 +238,12 @@ enum GeckoFetchCookiePolicy {
|
||||
omit,
|
||||
}
|
||||
|
||||
enum BookmarkNodeType {
|
||||
item,
|
||||
folder,
|
||||
separator,
|
||||
}
|
||||
|
||||
/// Translation options that map to the Gecko Translations Options.
|
||||
///
|
||||
/// @property downloadModel If the necessary models should be downloaded on request. If false, then
|
||||
@@ -3139,6 +3145,144 @@ class GeckoFetchResponse {
|
||||
;
|
||||
}
|
||||
|
||||
class BookmarkNode {
|
||||
BookmarkNode({
|
||||
required this.type,
|
||||
required this.guid,
|
||||
this.parentGuid,
|
||||
this.position,
|
||||
this.title,
|
||||
this.url,
|
||||
required this.dateAdded,
|
||||
required this.lastModified,
|
||||
this.children,
|
||||
});
|
||||
|
||||
BookmarkNodeType type;
|
||||
|
||||
String guid;
|
||||
|
||||
String? parentGuid;
|
||||
|
||||
int? position;
|
||||
|
||||
String? title;
|
||||
|
||||
String? url;
|
||||
|
||||
int dateAdded;
|
||||
|
||||
int lastModified;
|
||||
|
||||
List<BookmarkNode>? children;
|
||||
|
||||
List<Object?> _toList() {
|
||||
return <Object?>[
|
||||
type,
|
||||
guid,
|
||||
parentGuid,
|
||||
position,
|
||||
title,
|
||||
url,
|
||||
dateAdded,
|
||||
lastModified,
|
||||
children,
|
||||
];
|
||||
}
|
||||
|
||||
Object encode() {
|
||||
return _toList(); }
|
||||
|
||||
static BookmarkNode decode(Object result) {
|
||||
result as List<Object?>;
|
||||
return BookmarkNode(
|
||||
type: result[0]! as BookmarkNodeType,
|
||||
guid: result[1]! as String,
|
||||
parentGuid: result[2] as String?,
|
||||
position: result[3] as int?,
|
||||
title: result[4] as String?,
|
||||
url: result[5] as String?,
|
||||
dateAdded: result[6]! as int,
|
||||
lastModified: result[7]! as int,
|
||||
children: (result[8] as List<Object?>?)?.cast<BookmarkNode>(),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
// ignore: avoid_equals_and_hash_code_on_mutable_classes
|
||||
bool operator ==(Object other) {
|
||||
if (other is! BookmarkNode || other.runtimeType != runtimeType) {
|
||||
return false;
|
||||
}
|
||||
if (identical(this, other)) {
|
||||
return true;
|
||||
}
|
||||
return _deepEquals(encode(), other.encode());
|
||||
}
|
||||
|
||||
@override
|
||||
// ignore: avoid_equals_and_hash_code_on_mutable_classes
|
||||
int get hashCode => Object.hashAll(_toList())
|
||||
;
|
||||
}
|
||||
|
||||
/// Class for making alterations to any bookmark node
|
||||
class BookmarkInfo {
|
||||
BookmarkInfo({
|
||||
this.parentGuid,
|
||||
this.position,
|
||||
this.title,
|
||||
this.url,
|
||||
});
|
||||
|
||||
String? parentGuid;
|
||||
|
||||
int? position;
|
||||
|
||||
String? title;
|
||||
|
||||
String? url;
|
||||
|
||||
List<Object?> _toList() {
|
||||
return <Object?>[
|
||||
parentGuid,
|
||||
position,
|
||||
title,
|
||||
url,
|
||||
];
|
||||
}
|
||||
|
||||
Object encode() {
|
||||
return _toList(); }
|
||||
|
||||
static BookmarkInfo decode(Object result) {
|
||||
result as List<Object?>;
|
||||
return BookmarkInfo(
|
||||
parentGuid: result[0] as String?,
|
||||
position: result[1] as int?,
|
||||
title: result[2] as String?,
|
||||
url: result[3] as String?,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
// ignore: avoid_equals_and_hash_code_on_mutable_classes
|
||||
bool operator ==(Object other) {
|
||||
if (other is! BookmarkInfo || other.runtimeType != runtimeType) {
|
||||
return false;
|
||||
}
|
||||
if (identical(this, other)) {
|
||||
return true;
|
||||
}
|
||||
return _deepEquals(encode(), other.encode());
|
||||
}
|
||||
|
||||
@override
|
||||
// ignore: avoid_equals_and_hash_code_on_mutable_classes
|
||||
int get hashCode => Object.hashAll(_toList())
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
class _PigeonCodec extends StandardMessageCodec {
|
||||
const _PigeonCodec();
|
||||
@@ -3213,150 +3357,159 @@ class _PigeonCodec extends StandardMessageCodec {
|
||||
} else if (value is GeckoFetchCookiePolicy) {
|
||||
buffer.putUint8(150);
|
||||
writeValue(buffer, value.index);
|
||||
} else if (value is TranslationOptions) {
|
||||
} else if (value is BookmarkNodeType) {
|
||||
buffer.putUint8(151);
|
||||
writeValue(buffer, value.encode());
|
||||
} else if (value is ReaderState) {
|
||||
writeValue(buffer, value.index);
|
||||
} else if (value is TranslationOptions) {
|
||||
buffer.putUint8(152);
|
||||
writeValue(buffer, value.encode());
|
||||
} else if (value is LastMediaAccessState) {
|
||||
} else if (value is ReaderState) {
|
||||
buffer.putUint8(153);
|
||||
writeValue(buffer, value.encode());
|
||||
} else if (value is HistoryMetadataKey) {
|
||||
} else if (value is LastMediaAccessState) {
|
||||
buffer.putUint8(154);
|
||||
writeValue(buffer, value.encode());
|
||||
} else if (value is PackageCategoryValue) {
|
||||
} else if (value is HistoryMetadataKey) {
|
||||
buffer.putUint8(155);
|
||||
writeValue(buffer, value.encode());
|
||||
} else if (value is ExternalPackage) {
|
||||
} else if (value is PackageCategoryValue) {
|
||||
buffer.putUint8(156);
|
||||
writeValue(buffer, value.encode());
|
||||
} else if (value is LoadUrlFlagsValue) {
|
||||
} else if (value is ExternalPackage) {
|
||||
buffer.putUint8(157);
|
||||
writeValue(buffer, value.encode());
|
||||
} else if (value is SourceValue) {
|
||||
} else if (value is LoadUrlFlagsValue) {
|
||||
buffer.putUint8(158);
|
||||
writeValue(buffer, value.encode());
|
||||
} else if (value is TabState) {
|
||||
} else if (value is SourceValue) {
|
||||
buffer.putUint8(159);
|
||||
writeValue(buffer, value.encode());
|
||||
} else if (value is RecoverableTab) {
|
||||
} else if (value is TabState) {
|
||||
buffer.putUint8(160);
|
||||
writeValue(buffer, value.encode());
|
||||
} else if (value is RecoverableBrowserState) {
|
||||
} else if (value is RecoverableTab) {
|
||||
buffer.putUint8(161);
|
||||
writeValue(buffer, value.encode());
|
||||
} else if (value is IconRequest) {
|
||||
} else if (value is RecoverableBrowserState) {
|
||||
buffer.putUint8(162);
|
||||
writeValue(buffer, value.encode());
|
||||
} else if (value is ResourceSize) {
|
||||
} else if (value is IconRequest) {
|
||||
buffer.putUint8(163);
|
||||
writeValue(buffer, value.encode());
|
||||
} else if (value is Resource) {
|
||||
} else if (value is ResourceSize) {
|
||||
buffer.putUint8(164);
|
||||
writeValue(buffer, value.encode());
|
||||
} else if (value is IconResult) {
|
||||
} else if (value is Resource) {
|
||||
buffer.putUint8(165);
|
||||
writeValue(buffer, value.encode());
|
||||
} else if (value is CookiePartitionKey) {
|
||||
} else if (value is IconResult) {
|
||||
buffer.putUint8(166);
|
||||
writeValue(buffer, value.encode());
|
||||
} else if (value is Cookie) {
|
||||
} else if (value is CookiePartitionKey) {
|
||||
buffer.putUint8(167);
|
||||
writeValue(buffer, value.encode());
|
||||
} else if (value is VisitInfo) {
|
||||
} else if (value is Cookie) {
|
||||
buffer.putUint8(168);
|
||||
writeValue(buffer, value.encode());
|
||||
} else if (value is HistoryItem) {
|
||||
} else if (value is VisitInfo) {
|
||||
buffer.putUint8(169);
|
||||
writeValue(buffer, value.encode());
|
||||
} else if (value is HistoryState) {
|
||||
} else if (value is HistoryItem) {
|
||||
buffer.putUint8(170);
|
||||
writeValue(buffer, value.encode());
|
||||
} else if (value is ReaderableState) {
|
||||
} else if (value is HistoryState) {
|
||||
buffer.putUint8(171);
|
||||
writeValue(buffer, value.encode());
|
||||
} else if (value is SecurityInfoState) {
|
||||
} else if (value is ReaderableState) {
|
||||
buffer.putUint8(172);
|
||||
writeValue(buffer, value.encode());
|
||||
} else if (value is TabContentState) {
|
||||
} else if (value is SecurityInfoState) {
|
||||
buffer.putUint8(173);
|
||||
writeValue(buffer, value.encode());
|
||||
} else if (value is FindResultState) {
|
||||
} else if (value is TabContentState) {
|
||||
buffer.putUint8(174);
|
||||
writeValue(buffer, value.encode());
|
||||
} else if (value is CustomSelectionAction) {
|
||||
} else if (value is FindResultState) {
|
||||
buffer.putUint8(175);
|
||||
writeValue(buffer, value.encode());
|
||||
} else if (value is WebExtensionData) {
|
||||
} else if (value is CustomSelectionAction) {
|
||||
buffer.putUint8(176);
|
||||
writeValue(buffer, value.encode());
|
||||
} else if (value is GeckoSuggestion) {
|
||||
} else if (value is WebExtensionData) {
|
||||
buffer.putUint8(177);
|
||||
writeValue(buffer, value.encode());
|
||||
} else if (value is TabContent) {
|
||||
} else if (value is GeckoSuggestion) {
|
||||
buffer.putUint8(178);
|
||||
writeValue(buffer, value.encode());
|
||||
} else if (value is ContentBlocking) {
|
||||
} else if (value is TabContent) {
|
||||
buffer.putUint8(179);
|
||||
writeValue(buffer, value.encode());
|
||||
} else if (value is DohSettings) {
|
||||
} else if (value is ContentBlocking) {
|
||||
buffer.putUint8(180);
|
||||
writeValue(buffer, value.encode());
|
||||
} else if (value is GeckoEngineSettings) {
|
||||
} else if (value is DohSettings) {
|
||||
buffer.putUint8(181);
|
||||
writeValue(buffer, value.encode());
|
||||
} else if (value is AutocompleteResult) {
|
||||
} else if (value is GeckoEngineSettings) {
|
||||
buffer.putUint8(182);
|
||||
writeValue(buffer, value.encode());
|
||||
} else if (value is UnknownHitResult) {
|
||||
} else if (value is AutocompleteResult) {
|
||||
buffer.putUint8(183);
|
||||
writeValue(buffer, value.encode());
|
||||
} else if (value is ImageHitResult) {
|
||||
} else if (value is UnknownHitResult) {
|
||||
buffer.putUint8(184);
|
||||
writeValue(buffer, value.encode());
|
||||
} else if (value is VideoHitResult) {
|
||||
} else if (value is ImageHitResult) {
|
||||
buffer.putUint8(185);
|
||||
writeValue(buffer, value.encode());
|
||||
} else if (value is AudioHitResult) {
|
||||
} else if (value is VideoHitResult) {
|
||||
buffer.putUint8(186);
|
||||
writeValue(buffer, value.encode());
|
||||
} else if (value is ImageSrcHitResult) {
|
||||
} else if (value is AudioHitResult) {
|
||||
buffer.putUint8(187);
|
||||
writeValue(buffer, value.encode());
|
||||
} else if (value is PhoneHitResult) {
|
||||
} else if (value is ImageSrcHitResult) {
|
||||
buffer.putUint8(188);
|
||||
writeValue(buffer, value.encode());
|
||||
} else if (value is EmailHitResult) {
|
||||
} else if (value is PhoneHitResult) {
|
||||
buffer.putUint8(189);
|
||||
writeValue(buffer, value.encode());
|
||||
} else if (value is GeoHitResult) {
|
||||
} else if (value is EmailHitResult) {
|
||||
buffer.putUint8(190);
|
||||
writeValue(buffer, value.encode());
|
||||
} else if (value is DownloadState) {
|
||||
} else if (value is GeoHitResult) {
|
||||
buffer.putUint8(191);
|
||||
writeValue(buffer, value.encode());
|
||||
} else if (value is ShareInternetResourceState) {
|
||||
} else if (value is DownloadState) {
|
||||
buffer.putUint8(192);
|
||||
writeValue(buffer, value.encode());
|
||||
} else if (value is AddonCollection) {
|
||||
} else if (value is ShareInternetResourceState) {
|
||||
buffer.putUint8(193);
|
||||
writeValue(buffer, value.encode());
|
||||
} else if (value is GeckoPref) {
|
||||
} else if (value is AddonCollection) {
|
||||
buffer.putUint8(194);
|
||||
writeValue(buffer, value.encode());
|
||||
} else if (value is ContainerSiteAssignment) {
|
||||
} else if (value is GeckoPref) {
|
||||
buffer.putUint8(195);
|
||||
writeValue(buffer, value.encode());
|
||||
} else if (value is GeckoHeader) {
|
||||
} else if (value is ContainerSiteAssignment) {
|
||||
buffer.putUint8(196);
|
||||
writeValue(buffer, value.encode());
|
||||
} else if (value is GeckoFetchRequest) {
|
||||
} else if (value is GeckoHeader) {
|
||||
buffer.putUint8(197);
|
||||
writeValue(buffer, value.encode());
|
||||
} else if (value is GeckoFetchResponse) {
|
||||
} else if (value is GeckoFetchRequest) {
|
||||
buffer.putUint8(198);
|
||||
writeValue(buffer, value.encode());
|
||||
} else if (value is GeckoFetchResponse) {
|
||||
buffer.putUint8(199);
|
||||
writeValue(buffer, value.encode());
|
||||
} else if (value is BookmarkNode) {
|
||||
buffer.putUint8(200);
|
||||
writeValue(buffer, value.encode());
|
||||
} else if (value is BookmarkInfo) {
|
||||
buffer.putUint8(201);
|
||||
writeValue(buffer, value.encode());
|
||||
} else {
|
||||
super.writeValue(buffer, value);
|
||||
}
|
||||
@@ -3432,101 +3585,108 @@ class _PigeonCodec extends StandardMessageCodec {
|
||||
final int? value = readValue(buffer) as int?;
|
||||
return value == null ? null : GeckoFetchCookiePolicy.values[value];
|
||||
case 151:
|
||||
return TranslationOptions.decode(readValue(buffer)!);
|
||||
final int? value = readValue(buffer) as int?;
|
||||
return value == null ? null : BookmarkNodeType.values[value];
|
||||
case 152:
|
||||
return ReaderState.decode(readValue(buffer)!);
|
||||
return TranslationOptions.decode(readValue(buffer)!);
|
||||
case 153:
|
||||
return LastMediaAccessState.decode(readValue(buffer)!);
|
||||
return ReaderState.decode(readValue(buffer)!);
|
||||
case 154:
|
||||
return HistoryMetadataKey.decode(readValue(buffer)!);
|
||||
return LastMediaAccessState.decode(readValue(buffer)!);
|
||||
case 155:
|
||||
return PackageCategoryValue.decode(readValue(buffer)!);
|
||||
return HistoryMetadataKey.decode(readValue(buffer)!);
|
||||
case 156:
|
||||
return ExternalPackage.decode(readValue(buffer)!);
|
||||
return PackageCategoryValue.decode(readValue(buffer)!);
|
||||
case 157:
|
||||
return LoadUrlFlagsValue.decode(readValue(buffer)!);
|
||||
return ExternalPackage.decode(readValue(buffer)!);
|
||||
case 158:
|
||||
return SourceValue.decode(readValue(buffer)!);
|
||||
return LoadUrlFlagsValue.decode(readValue(buffer)!);
|
||||
case 159:
|
||||
return TabState.decode(readValue(buffer)!);
|
||||
return SourceValue.decode(readValue(buffer)!);
|
||||
case 160:
|
||||
return RecoverableTab.decode(readValue(buffer)!);
|
||||
return TabState.decode(readValue(buffer)!);
|
||||
case 161:
|
||||
return RecoverableBrowserState.decode(readValue(buffer)!);
|
||||
return RecoverableTab.decode(readValue(buffer)!);
|
||||
case 162:
|
||||
return IconRequest.decode(readValue(buffer)!);
|
||||
return RecoverableBrowserState.decode(readValue(buffer)!);
|
||||
case 163:
|
||||
return ResourceSize.decode(readValue(buffer)!);
|
||||
return IconRequest.decode(readValue(buffer)!);
|
||||
case 164:
|
||||
return Resource.decode(readValue(buffer)!);
|
||||
return ResourceSize.decode(readValue(buffer)!);
|
||||
case 165:
|
||||
return IconResult.decode(readValue(buffer)!);
|
||||
return Resource.decode(readValue(buffer)!);
|
||||
case 166:
|
||||
return CookiePartitionKey.decode(readValue(buffer)!);
|
||||
return IconResult.decode(readValue(buffer)!);
|
||||
case 167:
|
||||
return Cookie.decode(readValue(buffer)!);
|
||||
return CookiePartitionKey.decode(readValue(buffer)!);
|
||||
case 168:
|
||||
return VisitInfo.decode(readValue(buffer)!);
|
||||
return Cookie.decode(readValue(buffer)!);
|
||||
case 169:
|
||||
return HistoryItem.decode(readValue(buffer)!);
|
||||
return VisitInfo.decode(readValue(buffer)!);
|
||||
case 170:
|
||||
return HistoryState.decode(readValue(buffer)!);
|
||||
return HistoryItem.decode(readValue(buffer)!);
|
||||
case 171:
|
||||
return ReaderableState.decode(readValue(buffer)!);
|
||||
return HistoryState.decode(readValue(buffer)!);
|
||||
case 172:
|
||||
return SecurityInfoState.decode(readValue(buffer)!);
|
||||
return ReaderableState.decode(readValue(buffer)!);
|
||||
case 173:
|
||||
return TabContentState.decode(readValue(buffer)!);
|
||||
return SecurityInfoState.decode(readValue(buffer)!);
|
||||
case 174:
|
||||
return FindResultState.decode(readValue(buffer)!);
|
||||
return TabContentState.decode(readValue(buffer)!);
|
||||
case 175:
|
||||
return CustomSelectionAction.decode(readValue(buffer)!);
|
||||
return FindResultState.decode(readValue(buffer)!);
|
||||
case 176:
|
||||
return WebExtensionData.decode(readValue(buffer)!);
|
||||
return CustomSelectionAction.decode(readValue(buffer)!);
|
||||
case 177:
|
||||
return GeckoSuggestion.decode(readValue(buffer)!);
|
||||
return WebExtensionData.decode(readValue(buffer)!);
|
||||
case 178:
|
||||
return TabContent.decode(readValue(buffer)!);
|
||||
return GeckoSuggestion.decode(readValue(buffer)!);
|
||||
case 179:
|
||||
return ContentBlocking.decode(readValue(buffer)!);
|
||||
return TabContent.decode(readValue(buffer)!);
|
||||
case 180:
|
||||
return DohSettings.decode(readValue(buffer)!);
|
||||
return ContentBlocking.decode(readValue(buffer)!);
|
||||
case 181:
|
||||
return GeckoEngineSettings.decode(readValue(buffer)!);
|
||||
return DohSettings.decode(readValue(buffer)!);
|
||||
case 182:
|
||||
return AutocompleteResult.decode(readValue(buffer)!);
|
||||
return GeckoEngineSettings.decode(readValue(buffer)!);
|
||||
case 183:
|
||||
return UnknownHitResult.decode(readValue(buffer)!);
|
||||
return AutocompleteResult.decode(readValue(buffer)!);
|
||||
case 184:
|
||||
return ImageHitResult.decode(readValue(buffer)!);
|
||||
return UnknownHitResult.decode(readValue(buffer)!);
|
||||
case 185:
|
||||
return VideoHitResult.decode(readValue(buffer)!);
|
||||
return ImageHitResult.decode(readValue(buffer)!);
|
||||
case 186:
|
||||
return AudioHitResult.decode(readValue(buffer)!);
|
||||
return VideoHitResult.decode(readValue(buffer)!);
|
||||
case 187:
|
||||
return ImageSrcHitResult.decode(readValue(buffer)!);
|
||||
return AudioHitResult.decode(readValue(buffer)!);
|
||||
case 188:
|
||||
return PhoneHitResult.decode(readValue(buffer)!);
|
||||
return ImageSrcHitResult.decode(readValue(buffer)!);
|
||||
case 189:
|
||||
return EmailHitResult.decode(readValue(buffer)!);
|
||||
return PhoneHitResult.decode(readValue(buffer)!);
|
||||
case 190:
|
||||
return GeoHitResult.decode(readValue(buffer)!);
|
||||
return EmailHitResult.decode(readValue(buffer)!);
|
||||
case 191:
|
||||
return DownloadState.decode(readValue(buffer)!);
|
||||
return GeoHitResult.decode(readValue(buffer)!);
|
||||
case 192:
|
||||
return ShareInternetResourceState.decode(readValue(buffer)!);
|
||||
return DownloadState.decode(readValue(buffer)!);
|
||||
case 193:
|
||||
return AddonCollection.decode(readValue(buffer)!);
|
||||
return ShareInternetResourceState.decode(readValue(buffer)!);
|
||||
case 194:
|
||||
return GeckoPref.decode(readValue(buffer)!);
|
||||
return AddonCollection.decode(readValue(buffer)!);
|
||||
case 195:
|
||||
return ContainerSiteAssignment.decode(readValue(buffer)!);
|
||||
return GeckoPref.decode(readValue(buffer)!);
|
||||
case 196:
|
||||
return GeckoHeader.decode(readValue(buffer)!);
|
||||
return ContainerSiteAssignment.decode(readValue(buffer)!);
|
||||
case 197:
|
||||
return GeckoFetchRequest.decode(readValue(buffer)!);
|
||||
return GeckoHeader.decode(readValue(buffer)!);
|
||||
case 198:
|
||||
return GeckoFetchRequest.decode(readValue(buffer)!);
|
||||
case 199:
|
||||
return GeckoFetchResponse.decode(readValue(buffer)!);
|
||||
case 200:
|
||||
return BookmarkNode.decode(readValue(buffer)!);
|
||||
case 201:
|
||||
return BookmarkInfo.decode(readValue(buffer)!);
|
||||
default:
|
||||
return super.readValueOfType(type, buffer);
|
||||
}
|
||||
@@ -6734,3 +6894,306 @@ class GeckoFetchApi {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class GeckoBookmarksApi {
|
||||
/// Constructor for [GeckoBookmarksApi]. The [binaryMessenger] named argument is
|
||||
/// available for dependency injection. If it is left null, the default
|
||||
/// BinaryMessenger will be used which routes to the host platform.
|
||||
GeckoBookmarksApi({BinaryMessenger? binaryMessenger, String messageChannelSuffix = ''})
|
||||
: pigeonVar_binaryMessenger = binaryMessenger,
|
||||
pigeonVar_messageChannelSuffix = messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : '';
|
||||
final BinaryMessenger? pigeonVar_binaryMessenger;
|
||||
|
||||
static const MessageCodec<Object?> pigeonChannelCodec = _PigeonCodec();
|
||||
|
||||
final String pigeonVar_messageChannelSuffix;
|
||||
|
||||
/// Produces a bookmarks tree for the given guid string.
|
||||
///
|
||||
/// @param guid The bookmark guid to obtain.
|
||||
/// @param recursive Whether to recurse and obtain all levels of children.
|
||||
/// @return The populated root starting from the guid.
|
||||
Future<BookmarkNode?> getTree(String guid, bool recursive) async {
|
||||
final String pigeonVar_channelName = 'dev.flutter.pigeon.flutter_mozilla_components.GeckoBookmarksApi.getTree$pigeonVar_messageChannelSuffix';
|
||||
final BasicMessageChannel<Object?> pigeonVar_channel = BasicMessageChannel<Object?>(
|
||||
pigeonVar_channelName,
|
||||
pigeonChannelCodec,
|
||||
binaryMessenger: pigeonVar_binaryMessenger,
|
||||
);
|
||||
final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(<Object?>[guid, recursive]);
|
||||
final List<Object?>? pigeonVar_replyList =
|
||||
await pigeonVar_sendFuture as List<Object?>?;
|
||||
if (pigeonVar_replyList == null) {
|
||||
throw _createConnectionError(pigeonVar_channelName);
|
||||
} else if (pigeonVar_replyList.length > 1) {
|
||||
throw PlatformException(
|
||||
code: pigeonVar_replyList[0]! as String,
|
||||
message: pigeonVar_replyList[1] as String?,
|
||||
details: pigeonVar_replyList[2],
|
||||
);
|
||||
} else {
|
||||
return (pigeonVar_replyList[0] as BookmarkNode?);
|
||||
}
|
||||
}
|
||||
|
||||
/// Obtains the details of a bookmark without children, if one exists with that guid. Otherwise, null.
|
||||
///
|
||||
/// @param guid The bookmark guid to obtain.
|
||||
/// @return The bookmark node or null if it does not exist.
|
||||
Future<BookmarkNode?> getBookmark(String guid) async {
|
||||
final String pigeonVar_channelName = 'dev.flutter.pigeon.flutter_mozilla_components.GeckoBookmarksApi.getBookmark$pigeonVar_messageChannelSuffix';
|
||||
final BasicMessageChannel<Object?> pigeonVar_channel = BasicMessageChannel<Object?>(
|
||||
pigeonVar_channelName,
|
||||
pigeonChannelCodec,
|
||||
binaryMessenger: pigeonVar_binaryMessenger,
|
||||
);
|
||||
final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(<Object?>[guid]);
|
||||
final List<Object?>? pigeonVar_replyList =
|
||||
await pigeonVar_sendFuture as List<Object?>?;
|
||||
if (pigeonVar_replyList == null) {
|
||||
throw _createConnectionError(pigeonVar_channelName);
|
||||
} else if (pigeonVar_replyList.length > 1) {
|
||||
throw PlatformException(
|
||||
code: pigeonVar_replyList[0]! as String,
|
||||
message: pigeonVar_replyList[1] as String?,
|
||||
details: pigeonVar_replyList[2],
|
||||
);
|
||||
} else {
|
||||
return (pigeonVar_replyList[0] as BookmarkNode?);
|
||||
}
|
||||
}
|
||||
|
||||
/// Produces a list of all bookmarks with the given URL.
|
||||
///
|
||||
/// @param url The URL string.
|
||||
/// @return The list of bookmarks that match the URL
|
||||
Future<List<BookmarkNode>> getBookmarksWithUrl(String url) async {
|
||||
final String pigeonVar_channelName = 'dev.flutter.pigeon.flutter_mozilla_components.GeckoBookmarksApi.getBookmarksWithUrl$pigeonVar_messageChannelSuffix';
|
||||
final BasicMessageChannel<Object?> pigeonVar_channel = BasicMessageChannel<Object?>(
|
||||
pigeonVar_channelName,
|
||||
pigeonChannelCodec,
|
||||
binaryMessenger: pigeonVar_binaryMessenger,
|
||||
);
|
||||
final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(<Object?>[url]);
|
||||
final List<Object?>? pigeonVar_replyList =
|
||||
await pigeonVar_sendFuture as List<Object?>?;
|
||||
if (pigeonVar_replyList == null) {
|
||||
throw _createConnectionError(pigeonVar_channelName);
|
||||
} else if (pigeonVar_replyList.length > 1) {
|
||||
throw PlatformException(
|
||||
code: pigeonVar_replyList[0]! as String,
|
||||
message: pigeonVar_replyList[1] as String?,
|
||||
details: pigeonVar_replyList[2],
|
||||
);
|
||||
} else if (pigeonVar_replyList[0] == null) {
|
||||
throw PlatformException(
|
||||
code: 'null-error',
|
||||
message: 'Host platform returned null value for non-null return value.',
|
||||
);
|
||||
} else {
|
||||
return (pigeonVar_replyList[0] as List<Object?>?)!.cast<BookmarkNode>();
|
||||
}
|
||||
}
|
||||
|
||||
/// Produces a list of the most recently added bookmarks.
|
||||
///
|
||||
/// @param limit The maximum number of entries to return.
|
||||
/// @param maxAge Optional parameter used to filter out entries older than this number of milliseconds.
|
||||
/// @param currentTime Optional parameter for current time. Defaults toSystem.currentTimeMillis()
|
||||
/// @return The list of bookmarks that have been recently added up to the limit number of items.
|
||||
Future<List<BookmarkNode>> getRecentBookmarks(int limit, int? maxAge, int currentTime) async {
|
||||
final String pigeonVar_channelName = 'dev.flutter.pigeon.flutter_mozilla_components.GeckoBookmarksApi.getRecentBookmarks$pigeonVar_messageChannelSuffix';
|
||||
final BasicMessageChannel<Object?> pigeonVar_channel = BasicMessageChannel<Object?>(
|
||||
pigeonVar_channelName,
|
||||
pigeonChannelCodec,
|
||||
binaryMessenger: pigeonVar_binaryMessenger,
|
||||
);
|
||||
final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(<Object?>[limit, maxAge, currentTime]);
|
||||
final List<Object?>? pigeonVar_replyList =
|
||||
await pigeonVar_sendFuture as List<Object?>?;
|
||||
if (pigeonVar_replyList == null) {
|
||||
throw _createConnectionError(pigeonVar_channelName);
|
||||
} else if (pigeonVar_replyList.length > 1) {
|
||||
throw PlatformException(
|
||||
code: pigeonVar_replyList[0]! as String,
|
||||
message: pigeonVar_replyList[1] as String?,
|
||||
details: pigeonVar_replyList[2],
|
||||
);
|
||||
} else if (pigeonVar_replyList[0] == null) {
|
||||
throw PlatformException(
|
||||
code: 'null-error',
|
||||
message: 'Host platform returned null value for non-null return value.',
|
||||
);
|
||||
} else {
|
||||
return (pigeonVar_replyList[0] as List<Object?>?)!.cast<BookmarkNode>();
|
||||
}
|
||||
}
|
||||
|
||||
/// Searches bookmarks with a query string.
|
||||
///
|
||||
/// @param query The query string to search.
|
||||
/// @param limit The maximum number of entries to return.
|
||||
/// @return The list of matching bookmark nodes up to the limit number of items.
|
||||
Future<List<BookmarkNode>> searchBookmarks(String query, int limit) async {
|
||||
final String pigeonVar_channelName = 'dev.flutter.pigeon.flutter_mozilla_components.GeckoBookmarksApi.searchBookmarks$pigeonVar_messageChannelSuffix';
|
||||
final BasicMessageChannel<Object?> pigeonVar_channel = BasicMessageChannel<Object?>(
|
||||
pigeonVar_channelName,
|
||||
pigeonChannelCodec,
|
||||
binaryMessenger: pigeonVar_binaryMessenger,
|
||||
);
|
||||
final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(<Object?>[query, limit]);
|
||||
final List<Object?>? pigeonVar_replyList =
|
||||
await pigeonVar_sendFuture as List<Object?>?;
|
||||
if (pigeonVar_replyList == null) {
|
||||
throw _createConnectionError(pigeonVar_channelName);
|
||||
} else if (pigeonVar_replyList.length > 1) {
|
||||
throw PlatformException(
|
||||
code: pigeonVar_replyList[0]! as String,
|
||||
message: pigeonVar_replyList[1] as String?,
|
||||
details: pigeonVar_replyList[2],
|
||||
);
|
||||
} else if (pigeonVar_replyList[0] == null) {
|
||||
throw PlatformException(
|
||||
code: 'null-error',
|
||||
message: 'Host platform returned null value for non-null return value.',
|
||||
);
|
||||
} else {
|
||||
return (pigeonVar_replyList[0] as List<Object?>?)!.cast<BookmarkNode>();
|
||||
}
|
||||
}
|
||||
|
||||
/// Adds a new bookmark item to a given node.
|
||||
///
|
||||
/// Sync behavior: will add new bookmark item to remote devices.
|
||||
///
|
||||
/// @param parentGuid The parent guid of the new node.
|
||||
/// @param url The URL of the bookmark item to add.
|
||||
/// @param title The title of the bookmark item to add.
|
||||
/// @param position The optional position to add the new node or null to append.
|
||||
/// @return The guid of the newly inserted bookmark item.
|
||||
Future<String> addItem(String parentGuid, String url, String title, int? position) async {
|
||||
final String pigeonVar_channelName = 'dev.flutter.pigeon.flutter_mozilla_components.GeckoBookmarksApi.addItem$pigeonVar_messageChannelSuffix';
|
||||
final BasicMessageChannel<Object?> pigeonVar_channel = BasicMessageChannel<Object?>(
|
||||
pigeonVar_channelName,
|
||||
pigeonChannelCodec,
|
||||
binaryMessenger: pigeonVar_binaryMessenger,
|
||||
);
|
||||
final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(<Object?>[parentGuid, url, title, position]);
|
||||
final List<Object?>? pigeonVar_replyList =
|
||||
await pigeonVar_sendFuture as List<Object?>?;
|
||||
if (pigeonVar_replyList == null) {
|
||||
throw _createConnectionError(pigeonVar_channelName);
|
||||
} else if (pigeonVar_replyList.length > 1) {
|
||||
throw PlatformException(
|
||||
code: pigeonVar_replyList[0]! as String,
|
||||
message: pigeonVar_replyList[1] as String?,
|
||||
details: pigeonVar_replyList[2],
|
||||
);
|
||||
} else if (pigeonVar_replyList[0] == null) {
|
||||
throw PlatformException(
|
||||
code: 'null-error',
|
||||
message: 'Host platform returned null value for non-null return value.',
|
||||
);
|
||||
} else {
|
||||
return (pigeonVar_replyList[0] as String?)!;
|
||||
}
|
||||
}
|
||||
|
||||
/// Adds a new bookmark folder to a given node.
|
||||
///
|
||||
/// Sync behavior: will add new separator to remote devices.
|
||||
///
|
||||
/// @param parentGuid The parent guid of the new node.
|
||||
/// @param title The title of the bookmark folder to add.
|
||||
/// @param position The optional position to add the new node or null to append.
|
||||
/// @return The guid of the newly inserted bookmark item.
|
||||
Future<String> addFolder(String parentGuid, String title, int? position) async {
|
||||
final String pigeonVar_channelName = 'dev.flutter.pigeon.flutter_mozilla_components.GeckoBookmarksApi.addFolder$pigeonVar_messageChannelSuffix';
|
||||
final BasicMessageChannel<Object?> pigeonVar_channel = BasicMessageChannel<Object?>(
|
||||
pigeonVar_channelName,
|
||||
pigeonChannelCodec,
|
||||
binaryMessenger: pigeonVar_binaryMessenger,
|
||||
);
|
||||
final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(<Object?>[parentGuid, title, position]);
|
||||
final List<Object?>? pigeonVar_replyList =
|
||||
await pigeonVar_sendFuture as List<Object?>?;
|
||||
if (pigeonVar_replyList == null) {
|
||||
throw _createConnectionError(pigeonVar_channelName);
|
||||
} else if (pigeonVar_replyList.length > 1) {
|
||||
throw PlatformException(
|
||||
code: pigeonVar_replyList[0]! as String,
|
||||
message: pigeonVar_replyList[1] as String?,
|
||||
details: pigeonVar_replyList[2],
|
||||
);
|
||||
} else if (pigeonVar_replyList[0] == null) {
|
||||
throw PlatformException(
|
||||
code: 'null-error',
|
||||
message: 'Host platform returned null value for non-null return value.',
|
||||
);
|
||||
} else {
|
||||
return (pigeonVar_replyList[0] as String?)!;
|
||||
}
|
||||
}
|
||||
|
||||
/// Edits the properties of an existing bookmark item and/or moves an existing one underneath a new parent guid.
|
||||
///
|
||||
/// Sync behavior: will alter bookmark item on remote devices.
|
||||
///
|
||||
/// @param guid The guid of the item to update.
|
||||
/// @param info The info to change in the bookmark.
|
||||
Future<void> updateNode(String guid, BookmarkInfo info) async {
|
||||
final String pigeonVar_channelName = 'dev.flutter.pigeon.flutter_mozilla_components.GeckoBookmarksApi.updateNode$pigeonVar_messageChannelSuffix';
|
||||
final BasicMessageChannel<Object?> pigeonVar_channel = BasicMessageChannel<Object?>(
|
||||
pigeonVar_channelName,
|
||||
pigeonChannelCodec,
|
||||
binaryMessenger: pigeonVar_binaryMessenger,
|
||||
);
|
||||
final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(<Object?>[guid, info]);
|
||||
final List<Object?>? pigeonVar_replyList =
|
||||
await pigeonVar_sendFuture as List<Object?>?;
|
||||
if (pigeonVar_replyList == null) {
|
||||
throw _createConnectionError(pigeonVar_channelName);
|
||||
} else if (pigeonVar_replyList.length > 1) {
|
||||
throw PlatformException(
|
||||
code: pigeonVar_replyList[0]! as String,
|
||||
message: pigeonVar_replyList[1] as String?,
|
||||
details: pigeonVar_replyList[2],
|
||||
);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/// Deletes a bookmark node and all of its children, if any.
|
||||
///
|
||||
/// Sync behavior: will remove bookmark from remote devices.
|
||||
///
|
||||
/// @return Whether the bookmark existed or not.
|
||||
Future<bool> deleteNode(String guid) async {
|
||||
final String pigeonVar_channelName = 'dev.flutter.pigeon.flutter_mozilla_components.GeckoBookmarksApi.deleteNode$pigeonVar_messageChannelSuffix';
|
||||
final BasicMessageChannel<Object?> pigeonVar_channel = BasicMessageChannel<Object?>(
|
||||
pigeonVar_channelName,
|
||||
pigeonChannelCodec,
|
||||
binaryMessenger: pigeonVar_binaryMessenger,
|
||||
);
|
||||
final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(<Object?>[guid]);
|
||||
final List<Object?>? pigeonVar_replyList =
|
||||
await pigeonVar_sendFuture as List<Object?>?;
|
||||
if (pigeonVar_replyList == null) {
|
||||
throw _createConnectionError(pigeonVar_channelName);
|
||||
} else if (pigeonVar_replyList.length > 1) {
|
||||
throw PlatformException(
|
||||
code: pigeonVar_replyList[0]! as String,
|
||||
message: pigeonVar_replyList[1] as String?,
|
||||
details: pigeonVar_replyList[2],
|
||||
);
|
||||
} else if (pigeonVar_replyList[0] == null) {
|
||||
throw PlatformException(
|
||||
code: 'null-error',
|
||||
message: 'Host platform returned null value for non-null return value.',
|
||||
);
|
||||
} else {
|
||||
return (pigeonVar_replyList[0] as bool?)!;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1426,3 +1426,130 @@ abstract class GeckoFetchApi {
|
||||
@async
|
||||
GeckoFetchResponse fetch(GeckoFetchRequest request);
|
||||
}
|
||||
|
||||
enum BookmarkNodeType { item, folder, separator }
|
||||
|
||||
class BookmarkNode {
|
||||
final BookmarkNodeType type;
|
||||
final String guid;
|
||||
final String? parentGuid;
|
||||
final int? position;
|
||||
final String? title;
|
||||
final String? url;
|
||||
final int dateAdded;
|
||||
final int lastModified;
|
||||
final List<BookmarkNode>? children;
|
||||
|
||||
BookmarkNode({
|
||||
required this.type,
|
||||
required this.guid,
|
||||
required this.parentGuid,
|
||||
required this.position,
|
||||
required this.title,
|
||||
required this.url,
|
||||
required this.dateAdded,
|
||||
required this.lastModified,
|
||||
required this.children,
|
||||
});
|
||||
}
|
||||
|
||||
/// Class for making alterations to any bookmark node
|
||||
class BookmarkInfo {
|
||||
final String? parentGuid;
|
||||
final int? position;
|
||||
final String? title;
|
||||
final String? url;
|
||||
|
||||
BookmarkInfo({
|
||||
required this.parentGuid,
|
||||
required this.position,
|
||||
required this.title,
|
||||
required this.url,
|
||||
});
|
||||
}
|
||||
|
||||
@HostApi()
|
||||
abstract class GeckoBookmarksApi {
|
||||
/// Produces a bookmarks tree for the given guid string.
|
||||
///
|
||||
/// @param guid The bookmark guid to obtain.
|
||||
/// @param recursive Whether to recurse and obtain all levels of children.
|
||||
/// @return The populated root starting from the guid.
|
||||
@async
|
||||
BookmarkNode? getTree(String guid, bool recursive);
|
||||
|
||||
/// Obtains the details of a bookmark without children, if one exists with that guid. Otherwise, null.
|
||||
///
|
||||
/// @param guid The bookmark guid to obtain.
|
||||
/// @return The bookmark node or null if it does not exist.
|
||||
@async
|
||||
BookmarkNode? getBookmark(String guid);
|
||||
|
||||
/// Produces a list of all bookmarks with the given URL.
|
||||
///
|
||||
/// @param url The URL string.
|
||||
/// @return The list of bookmarks that match the URL
|
||||
@async
|
||||
List<BookmarkNode> getBookmarksWithUrl(String url);
|
||||
|
||||
/// Produces a list of the most recently added bookmarks.
|
||||
///
|
||||
/// @param limit The maximum number of entries to return.
|
||||
/// @param maxAge Optional parameter used to filter out entries older than this number of milliseconds.
|
||||
/// @param currentTime Optional parameter for current time. Defaults toSystem.currentTimeMillis()
|
||||
/// @return The list of bookmarks that have been recently added up to the limit number of items.
|
||||
@async
|
||||
List<BookmarkNode> getRecentBookmarks(
|
||||
int limit,
|
||||
int? maxAge,
|
||||
int currentTime,
|
||||
);
|
||||
|
||||
/// Searches bookmarks with a query string.
|
||||
///
|
||||
/// @param query The query string to search.
|
||||
/// @param limit The maximum number of entries to return.
|
||||
/// @return The list of matching bookmark nodes up to the limit number of items.
|
||||
@async
|
||||
List<BookmarkNode> searchBookmarks(String query, int limit);
|
||||
|
||||
/// Adds a new bookmark item to a given node.
|
||||
///
|
||||
/// Sync behavior: will add new bookmark item to remote devices.
|
||||
///
|
||||
/// @param parentGuid The parent guid of the new node.
|
||||
/// @param url The URL of the bookmark item to add.
|
||||
/// @param title The title of the bookmark item to add.
|
||||
/// @param position The optional position to add the new node or null to append.
|
||||
/// @return The guid of the newly inserted bookmark item.
|
||||
@async
|
||||
String addItem(String parentGuid, String url, String title, int? position);
|
||||
|
||||
/// Adds a new bookmark folder to a given node.
|
||||
///
|
||||
/// Sync behavior: will add new separator to remote devices.
|
||||
///
|
||||
/// @param parentGuid The parent guid of the new node.
|
||||
/// @param title The title of the bookmark folder to add.
|
||||
/// @param position The optional position to add the new node or null to append.
|
||||
/// @return The guid of the newly inserted bookmark item.
|
||||
@async
|
||||
String addFolder(String parentGuid, String title, int? position);
|
||||
|
||||
/// Edits the properties of an existing bookmark item and/or moves an existing one underneath a new parent guid.
|
||||
///
|
||||
/// Sync behavior: will alter bookmark item on remote devices.
|
||||
///
|
||||
/// @param guid The guid of the item to update.
|
||||
/// @param info The info to change in the bookmark.
|
||||
@async
|
||||
void updateNode(String guid, BookmarkInfo info);
|
||||
|
||||
/// Deletes a bookmark node and all of its children, if any.
|
||||
///
|
||||
/// Sync behavior: will remove bookmark from remote devices.
|
||||
///
|
||||
/// @return Whether the bookmark existed or not.
|
||||
@async
|
||||
bool deleteNode(String guid);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user