Skip to content

Commit 845c86d

Browse files
committed
Add feature flag for importing passwords via Google Password Manager
1 parent 587ad2c commit 845c86d

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/*
2+
* Copyright (c) 2024 DuckDuckGo
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.duckduckgo.autofill.impl.importing.gpm.feature
18+
19+
import com.duckduckgo.anvil.annotations.ContributesRemoteFeature
20+
import com.duckduckgo.app.di.AppCoroutineScope
21+
import com.duckduckgo.common.utils.DispatcherProvider
22+
import com.duckduckgo.di.scopes.AppScope
23+
import com.duckduckgo.feature.toggles.api.FeatureSettings
24+
import com.duckduckgo.feature.toggles.api.RemoteFeatureStoreNamed
25+
import com.duckduckgo.feature.toggles.api.Toggle
26+
import com.duckduckgo.feature.toggles.api.Toggle.InternalAlwaysEnabled
27+
import com.squareup.anvil.annotations.ContributesBinding
28+
import javax.inject.Inject
29+
import kotlinx.coroutines.CoroutineScope
30+
import kotlinx.coroutines.launch
31+
32+
@ContributesRemoteFeature(
33+
scope = AppScope::class,
34+
boundType = AutofillImportPasswordsFeature::class,
35+
featureName = "autofillImportPasswords",
36+
settingsStore = SettingsStore::class,
37+
)
38+
/**
39+
* This is the class that represents the feature flag for allowing users to import passwords.
40+
*/
41+
interface AutofillImportPasswordsFeature {
42+
/**
43+
* @return `true` when the remote config has the global "autofillImportPasswords" feature flag enabled
44+
*
45+
* If the remote feature is not present defaults to `false`
46+
*/
47+
48+
@InternalAlwaysEnabled
49+
@Toggle.DefaultValue(false)
50+
fun self(): Toggle
51+
52+
@InternalAlwaysEnabled
53+
@Toggle.DefaultValue(false)
54+
fun canImportFromGooglePasswordManager(): Toggle
55+
56+
@InternalAlwaysEnabled
57+
@Toggle.DefaultValue(false)
58+
fun canImportFromCsvFile(): Toggle
59+
60+
@InternalAlwaysEnabled
61+
@Toggle.DefaultValue(false)
62+
fun canHighlightExportButton(): Toggle
63+
}
64+
65+
@ContributesBinding(AppScope::class)
66+
@RemoteFeatureStoreNamed(AutofillImportPasswordsFeature::class)
67+
class SettingsStore @Inject constructor(
68+
@AppCoroutineScope private val appCoroutineScope: CoroutineScope,
69+
private val dispatchers: DispatcherProvider,
70+
) : FeatureSettings.Store {
71+
72+
override fun store(jsonString: String) {
73+
appCoroutineScope.launch(dispatchers.io()) {
74+
}
75+
}
76+
}

0 commit comments

Comments
 (0)