Revision control
Copy as Markdown
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
package org.mozilla.tv.firefox.ext
import android.os.Bundle
import mozilla.components.browser.session.Session
import java.util.WeakHashMap
// Extension methods on the Session class. This is used for additional session data that is not part
// of the upstream browser-session component yet.
private val extensions = WeakHashMap<Session, SessionExtension>()
private fun getOrPutExtension(session: Session): SessionExtension {
extensions[session]?.let { return it }
return SessionExtension().also {
extensions[session] = it
}
}
private class SessionExtension {
var savedWebViewState: Bundle? = null
}
/**
* Saving the state attached ot a session.
*
* Temporary solution until we can use the browser-engine component.
*
* Component upstream issue:
*/
var Session.savedWebViewState: Bundle?
get() = getOrPutExtension(this).savedWebViewState
set(value) { getOrPutExtension(this).savedWebViewState = value }
val Session.isYoutubeTV: Boolean
get() = url.isUriYouTubeTV