Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Commit

Permalink
Remove user agent override from json
Browse files Browse the repository at this point in the history
  • Loading branch information
keianhzo committed Oct 28, 2019
1 parent b62b760 commit 67a2950
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
18 changes: 17 additions & 1 deletion app/src/common/shared/org/mozilla/vrbrowser/browser/Services.kt
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,16 @@ import mozilla.components.support.rustlog.RustLog
import org.mozilla.geckoview.AllowOrDeny
import org.mozilla.geckoview.GeckoResult
import org.mozilla.geckoview.GeckoSession
import org.mozilla.geckoview.GeckoSessionSettings
import org.mozilla.vrbrowser.browser.engine.SessionStore
import org.mozilla.vrbrowser.R
import java.net.URI
import java.net.URISyntaxException

class Services(context: Context, places: Places): GeckoSession.NavigationDelegate {
companion object {
const val ACCOUNTS_HOST = "accounts.firefox.com"
const val USER_AGENT_OVERRIDE = "Mozilla/5.0 (Android 7.1.1; Mobile; rv:71.0) Gecko/71.0 Firefox/71.0"
const val CLIENT_ID = "7ad9917f6c55fb77"
const val REDIRECT_URL = "https://accounts.firefox.com/oauth/success/$CLIENT_ID"
}
Expand Down Expand Up @@ -81,7 +86,6 @@ class Services(context: Context, places: Places): GeckoSession.NavigationDelegat
}
}
}

val accountManager = FxaAccountManager(
context = context,
serverConfig = ServerConfig.release(CLIENT_ID, REDIRECT_URL),
Expand All @@ -105,6 +109,18 @@ class Services(context: Context, places: Places): GeckoSession.NavigationDelegat
}

override fun onLoadRequest(geckoSession: GeckoSession, loadRequest: GeckoSession.NavigationDelegate.LoadRequest): GeckoResult<AllowOrDeny>? {
val uri: URI
try {
// Temporarily set the UA to VR to overcome an issue with the FxA login site not working with a desktop UA in FxR.
// Should be removed when that's fixed.
uri = URI(loadRequest.uri)
if (uri.host.startsWith(ACCOUNTS_HOST)) {
SessionStore.get().activeSession.geckoSession.settings.userAgentOverride = USER_AGENT_OVERRIDE
}

} catch (e: URISyntaxException) {
}

if (loadRequest.uri.startsWith(REDIRECT_URL)) {
val parsedUri = Uri.parse(loadRequest.uri)

Expand Down
3 changes: 1 addition & 2 deletions app/src/main/assets/userAgentOverride.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"744723238cc3c00582d7ff9e8ece83e6503a3926d8c07491672d5da3634be41e1d41580dd3694b663c0d0a5e64280a2b411a1346e6ed0d53d694835781cf6436": "Mozilla/5.0 (X11; Linux x86_64; rv:69) Gecko/20100101 Firefox/69.0",
"ae0755740e4354ac67025056e775ad06d8a529ae4f37244fbb02d72199e2c780311e47aa9895079b980ec4bfa676f1f39c4ab41ea995c524e52bde9a73623da2": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12) AppleWebKit/602.1.21 (KHTML, like Gecko) Version/9.2 Safari/602.1.21",
"e6137b4c2f49a3917c2c90a50fb270a5eebb962f2c72344ae2e29e321bb21891e5ca4fec06cae78e14f4a8510473e934234e9ec3f60e8415f5f6da754c55b9b1": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12) AppleWebKit/602.1.21 (KHTML, like Gecko) Version/9.2 Safari/602.1.21",
"4616a533b40cd2b4bc133589b9350f4747ef7746d064dc7e87ee11cae33a12e5c199d31a8e273db0dc950b56e51157a2b705c6324e274b32178ec7c74781e2af": "Mozilla/5.0 (Android 7.1.1; Mobile; rv:71.0) Gecko/71.0 Firefox/71.0"
"e6137b4c2f49a3917c2c90a50fb270a5eebb962f2c72344ae2e29e321bb21891e5ca4fec06cae78e14f4a8510473e934234e9ec3f60e8415f5f6da754c55b9b1": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12) AppleWebKit/602.1.21 (KHTML, like Gecko) Version/9.2 Safari/602.1.21"
}

0 comments on commit 67a2950

Please sign in to comment.