Skip to content

Commit

Permalink
Add feature flag for importing passwords via Google Password Manager
Browse files Browse the repository at this point in the history
  • Loading branch information
CDRussell committed Oct 4, 2024
1 parent 587ad2c commit 845c86d
Showing 1 changed file with 76 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/*
* Copyright (c) 2024 DuckDuckGo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.duckduckgo.autofill.impl.importing.gpm.feature

import com.duckduckgo.anvil.annotations.ContributesRemoteFeature
import com.duckduckgo.app.di.AppCoroutineScope
import com.duckduckgo.common.utils.DispatcherProvider
import com.duckduckgo.di.scopes.AppScope
import com.duckduckgo.feature.toggles.api.FeatureSettings
import com.duckduckgo.feature.toggles.api.RemoteFeatureStoreNamed
import com.duckduckgo.feature.toggles.api.Toggle
import com.duckduckgo.feature.toggles.api.Toggle.InternalAlwaysEnabled
import com.squareup.anvil.annotations.ContributesBinding
import javax.inject.Inject
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.launch

@ContributesRemoteFeature(
scope = AppScope::class,
boundType = AutofillImportPasswordsFeature::class,
featureName = "autofillImportPasswords",
settingsStore = SettingsStore::class,
)
/**
* This is the class that represents the feature flag for allowing users to import passwords.
*/
interface AutofillImportPasswordsFeature {
/**
* @return `true` when the remote config has the global "autofillImportPasswords" feature flag enabled
*
* If the remote feature is not present defaults to `false`
*/

@InternalAlwaysEnabled
@Toggle.DefaultValue(false)
fun self(): Toggle

@InternalAlwaysEnabled
@Toggle.DefaultValue(false)
fun canImportFromGooglePasswordManager(): Toggle

@InternalAlwaysEnabled
@Toggle.DefaultValue(false)
fun canImportFromCsvFile(): Toggle

@InternalAlwaysEnabled
@Toggle.DefaultValue(false)
fun canHighlightExportButton(): Toggle
}

@ContributesBinding(AppScope::class)
@RemoteFeatureStoreNamed(AutofillImportPasswordsFeature::class)
class SettingsStore @Inject constructor(
@AppCoroutineScope private val appCoroutineScope: CoroutineScope,
private val dispatchers: DispatcherProvider,
) : FeatureSettings.Store {

override fun store(jsonString: String) {
appCoroutineScope.launch(dispatchers.io()) {
}
}
}

0 comments on commit 845c86d

Please sign in to comment.