Skip to content
This repository has been archived by the owner on Feb 20, 2023. It is now read-only.

FxA WebChannels integration #4931

Merged
merged 4 commits into from
Sep 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 51 additions & 7 deletions app/metrics.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -816,21 +816,65 @@ sync_auth:
notification_emails:
- fenix-core@mozilla.com
expires: "2020-03-01"
scan_pairing:
sign_up:
type: event
description: >
A user pressed the scan pairing button on the sync authentication page
User registered a new Firefox Account, and was signed into it
bugs:
- 1190
- 4971
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/2745#issuecomment-494918532
- https://github.com/mozilla-mobile/fenix/pull/4931#issuecomment-529740300
notification_emails:
- fenix-core@mozilla.com
- fenix-core@mozilla.com
expires: "2020-03-01"
paired:
type: event
description: >
User signed into FxA by pairing with a different Firefox browser, using a QR code
bugs:
- 4971
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/4931#issuecomment-529740300
notification_emails:
- fenix-core@mozilla.com
expires: "2020-03-01"
auto_login:
type: event
description: >
User signed into FxA via an account shared from another locally installed Mozilla application (e.g. Fennec)
bugs:
- 4971
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/4931#issuecomment-529740300
notification_emails:
- fenix-core@mozilla.com
expires: "2020-03-01"
recovered:
type: event
description: >
Account manager automatically recovered FxA authentication state without direct user involvement
bugs:
- 4971
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/4931#issuecomment-529740300
notification_emails:
- fenix-core@mozilla.com
expires: "2020-03-01"
create_account:
other_external:
type: event
description: >
A user pressed the create account button on the sync authentication page
User authenticated via FxA using an unknown mechanism. "Known" mechanisms are currently sign-in, sign-up and pairing
bugs:
- 4971
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/4931#issuecomment-529740300
notification_emails:
- fenix-core@mozilla.com
expires: "2020-03-01"
scan_pairing:
type: event
description: >
A user pressed the scan pairing button on the sync authentication page
bugs:
- 1190
data_reviews:
Expand Down
9 changes: 7 additions & 2 deletions app/src/main/java/org/mozilla/fenix/AppRequestInterceptor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,13 @@ class AppRequestInterceptor(private val context: Context) : RequestInterceptor {
}

adjustTrackingProtection(host, context, session)
// Accounts uses interception to check for a "success URL" in the sign-in flow to finalize authentication.
return context.components.services.accountsAuthFeature.interceptor.onLoadRequest(session, uri)

// WebChannel-driven authentication does not require a separate redirect interceptor.
return if (context.isInExperiment(Experiments.asFeatureWebChannelsDisabled)) {
context.components.services.accountsAuthFeature.interceptor.onLoadRequest(session, uri)
} else {
null
}
}

private fun adjustTrackingProtection(host: String, context: Context, session: EngineSession) {
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/org/mozilla/fenix/Experiments.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ object Experiments {
val asFeatureSyncDisabled = ExperimentDescriptor("asFeatureSyncDisabled")
// application services flag to disable Firefox Accounts pairing button.
val asFeatureFxAPairingDisabled = ExperimentDescriptor("asFeatureFxAPairingDisabled")
// application services flag to disable Firefox Accounts WebChannel integration.
val asFeatureWebChannelsDisabled = ExperimentDescriptor("asFeatureWebChannelsDisabled")
}

val Context.app: FenixApplication
Expand Down
10 changes: 4 additions & 6 deletions app/src/main/java/org/mozilla/fenix/FenixApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -191,16 +191,14 @@ open class FenixApplication : Application() {
// Sets the PushFeature as the singleton instance for push messages to go to.
// We need the push feature setup here to deliver messages in the case where the service
// starts up the app first.
if (components.backgroundServices.pushConfig != null) {
Logger.info("Push configuration found; initializing autopush..")

val push = components.backgroundServices.push
components.backgroundServices.push?.let { autoPushFeature ->
Logger.info("AutoPushFeature is configured, initializing it...")

// Install the AutoPush singleton to receive messages.
PushProcessor.install(push)
PushProcessor.install(autoPushFeature)

// Initialize the service. This could potentially be done in a coroutine in the future.
push.initialize()
autoPushFeature.initialize()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class IntentReceiverActivity : Activity() {
private fun setIntentActivity(intent: Intent) {
val openToBrowser = when {
components.utils.customTabIntentProcessor.matches(intent) -> {
// TODO this needs to change: https://github.com/mozilla-mobile/fenix/issues/5225
val activityClass = if (intent.hasExtra(EXTRA_AUTH_CUSTOM_TAB)) {
AuthCustomTabActivity::class
} else {
Expand Down
18 changes: 18 additions & 0 deletions app/src/main/java/org/mozilla/fenix/browser/BaseBrowserFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import mozilla.components.browser.session.Session
import mozilla.components.browser.session.SessionManager
import mozilla.components.feature.accounts.FxaWebChannelFeature
import mozilla.components.feature.app.links.AppLinksFeature
import mozilla.components.feature.contextmenu.ContextMenuFeature
import mozilla.components.feature.downloads.DownloadsFeature
Expand All @@ -49,6 +50,7 @@ import mozilla.components.support.base.feature.BackHandler
import mozilla.components.support.base.feature.PermissionsFeature
import mozilla.components.support.base.feature.ViewBoundFeatureWrapper
import mozilla.components.support.ktx.android.view.exitImmersiveModeIfNeeded
import org.mozilla.fenix.Experiments
import org.mozilla.fenix.FeatureFlags
import org.mozilla.fenix.HomeActivity
import org.mozilla.fenix.IntentReceiverActivity
Expand All @@ -70,6 +72,7 @@ import org.mozilla.fenix.ext.components
import org.mozilla.fenix.ext.enterToImmersiveMode
import org.mozilla.fenix.ext.requireComponents
import org.mozilla.fenix.ext.settings
import org.mozilla.fenix.isInExperiment
import org.mozilla.fenix.quickactionsheet.QuickActionSheetBehavior
import org.mozilla.fenix.settings.SupportUtils
import org.mozilla.fenix.theme.ThemeManager
Expand All @@ -96,6 +99,7 @@ abstract class BaseBrowserFragment : Fragment(), BackHandler, SessionManager.Obs
private val sitePermissionsFeature = ViewBoundFeatureWrapper<SitePermissionsFeature>()
private val fullScreenFeature = ViewBoundFeatureWrapper<FullScreenFeature>()
private val swipeRefreshFeature = ViewBoundFeatureWrapper<SwipeRefreshFeature>()
private val webchannelIntegration = ViewBoundFeatureWrapper<FxaWebChannelFeature>()

var customTabSessionId: String? = null

Expand Down Expand Up @@ -374,6 +378,20 @@ abstract class BaseBrowserFragment : Fragment(), BackHandler, SessionManager.Obs
view.swipeRefresh.setOnChildScrollUpCallback { _, _ -> true }
}

if (!requireContext().isInExperiment(Experiments.asFeatureWebChannelsDisabled)) {
webchannelIntegration.set(
feature = FxaWebChannelFeature(
requireContext(),
customTabSessionId,
requireComponents.core.engine,
requireComponents.core.sessionManager,
requireComponents.backgroundServices.accountManager
),
owner = this,
view = view
)
}

(activity as HomeActivity).updateThemeForSession(session)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ class BrowserFragment : BaseBrowserFragment(), BackHandler {
val sessionManager = context.components.core.sessionManager

return super.initializeUI(view)?.also {

readerViewFeature.set(
feature = ReaderViewFeature(
context,
Expand Down
Loading