This repository has been archived by the owner on Jul 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 220
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AC WebExtensions + WebCompat + FxAWebChannels
- Loading branch information
Showing
32 changed files
with
1,263 additions
and
115 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
app/src/common/shared/org/mozilla/vrbrowser/browser/adapter/ComponentsAdapter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package org.mozilla.vrbrowser.browser.adapter | ||
|
||
import mozilla.components.browser.state.action.EngineAction | ||
import mozilla.components.browser.state.action.TabListAction | ||
import mozilla.components.browser.state.state.* | ||
import mozilla.components.browser.state.store.BrowserStore | ||
import org.mozilla.geckoview.GeckoSession | ||
import org.mozilla.vrbrowser.browser.components.GeckoEngineSession | ||
import org.mozilla.vrbrowser.browser.engine.Session | ||
|
||
class ComponentsAdapter private constructor( | ||
val store: BrowserStore = BrowserStore() | ||
) { | ||
companion object { | ||
private val instance: ComponentsAdapter = ComponentsAdapter() | ||
|
||
fun get(): ComponentsAdapter = instance | ||
} | ||
|
||
fun addSession(session: Session) { | ||
store.dispatch(TabListAction.AddTabAction( | ||
tab = session.toTabSessionState() | ||
)) | ||
} | ||
|
||
fun removeSession(session: Session) { | ||
store.dispatch(TabListAction.RemoveTabAction( | ||
tabId = session.id | ||
)) | ||
} | ||
|
||
fun selectSession(session: Session) { | ||
store.dispatch(TabListAction.SelectTabAction( | ||
tabId = session.id | ||
)) | ||
} | ||
|
||
fun link(tabId: String, geckoSession: GeckoSession) { | ||
store.dispatch(EngineAction.LinkEngineSessionAction( | ||
tabId, | ||
GeckoEngineSession(geckoSession) | ||
)) | ||
} | ||
|
||
fun unlink(tabId: String) { | ||
store.dispatch(EngineAction.UnlinkEngineSessionAction( | ||
tabId | ||
)) | ||
} | ||
} | ||
|
||
private fun Session.toTabSessionState(): TabSessionState { | ||
return TabSessionState( | ||
id = id, | ||
content = ContentState( | ||
url = currentUri, | ||
private = isPrivateMode, | ||
title = currentTitle | ||
), | ||
parentId = null, | ||
extensionState = emptyMap(), | ||
readerState = ReaderState(), | ||
engineState = EngineState( | ||
GeckoEngineSession(geckoSession), | ||
null | ||
) | ||
) | ||
} |
40 changes: 40 additions & 0 deletions
40
app/src/common/shared/org/mozilla/vrbrowser/browser/components/GeckoEngineSession.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package org.mozilla.vrbrowser.browser.components | ||
|
||
import mozilla.components.concept.engine.EngineSession | ||
import mozilla.components.concept.engine.EngineSessionState | ||
import mozilla.components.concept.engine.Settings | ||
import org.json.JSONObject | ||
import org.mozilla.geckoview.GeckoSession | ||
import org.mozilla.vrbrowser.browser.engine.SessionStore | ||
|
||
class GeckoEngineSession( | ||
val geckoSession: GeckoSession | ||
): EngineSession() { | ||
constructor() : | ||
this(SessionStore.get().createSession(false, false).geckoSession) | ||
|
||
override fun loadUrl(url: String, parent: EngineSession?, flags: LoadUrlFlags, additionalHeaders: Map<String, String>?) { | ||
geckoSession.loadUri(url) | ||
} | ||
|
||
override val settings: Settings = object : Settings() {} | ||
override fun clearFindMatches() = Unit | ||
override fun disableTrackingProtection() = Unit | ||
override fun enableTrackingProtection(policy: TrackingProtectionPolicy) = Unit | ||
override fun exitFullScreenMode() = Unit | ||
override fun findAll(text: String) = Unit | ||
override fun findNext(forward: Boolean) = Unit | ||
override fun goBack() = Unit | ||
override fun goForward() = Unit | ||
override fun loadData(data: String, mimeType: String, encoding: String) = Unit | ||
override fun recoverFromCrash(): Boolean = true | ||
override fun reload() = Unit | ||
override fun restoreState(state: EngineSessionState) = true | ||
override fun saveState(): EngineSessionState = DummyEngineSessionState() | ||
override fun stopLoading() = Unit | ||
override fun toggleDesktopMode(enable: Boolean, reload: Boolean) = Unit | ||
} | ||
|
||
private class DummyEngineSessionState : EngineSessionState { | ||
override fun toJSON(): JSONObject = JSONObject() | ||
} |
Oops, something went wrong.