-
Notifications
You must be signed in to change notification settings - Fork 908
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add feature flag for importing passwords via Google Password Manager
- Loading branch information
Showing
1 changed file
with
76 additions
and
0 deletions.
There are no files selected for viewing
76 changes: 76 additions & 0 deletions
76
...java/com/duckduckgo/autofill/impl/importing/gpm/feature/AutofillImportPasswordsFeature.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,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()) { | ||
} | ||
} | ||
} |