-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Streamline importing passwords from Google #6746
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
46 changes: 46 additions & 0 deletions
46
autofill/autofill-impl/src/main/java/com/duckduckgo/autofill/impl/InternalCallback.kt
This file contains hidden or 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,46 @@ | ||
/* | ||
* Copyright (c) 2025 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 | ||
|
||
import com.duckduckgo.autofill.api.Callback | ||
import com.duckduckgo.autofill.api.domain.app.LoginCredentials | ||
import com.duckduckgo.autofill.api.domain.app.LoginTriggerType | ||
import com.duckduckgo.autofill.impl.jsbridge.request.SupportedAutofillInputSubType | ||
|
||
/** | ||
* Internal extension of the public Callback interface for extensions that isn't required outside of this module | ||
*/ | ||
interface InternalCallback : Callback { | ||
|
||
/** | ||
* Called when we've determined we have credentials we can offer to autofill for the user, | ||
* with additional re-authentication context. | ||
* * @param originalUrl The URL where autofill was requested | ||
* @param credentials List of available stored credentials for this URL | ||
* @param triggerType How this autofill request was triggered | ||
* @param requestSubType The type of autofill request (USERNAME or PASSWORD) | ||
*/ | ||
suspend fun onCredentialsAvailableToInjectWithReauth( | ||
originalUrl: String, | ||
credentials: List<LoginCredentials>, | ||
triggerType: LoginTriggerType, | ||
requestSubType: SupportedAutofillInputSubType, | ||
) { | ||
// Default implementation delegates to the public API | ||
onCredentialsAvailableToInject(originalUrl, credentials, triggerType) | ||
} | ||
} |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
37 changes: 37 additions & 0 deletions
37
...in/java/com/duckduckgo/autofill/impl/configuration/InternalBrowserAutofillConfigurator.kt
This file contains hidden or 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,37 @@ | ||
/* | ||
* Copyright (c) 2025 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.configuration | ||
|
||
import android.webkit.WebView | ||
import com.duckduckgo.autofill.api.BrowserAutofill.Configurator | ||
import com.duckduckgo.autofill.impl.store.ReAuthenticationDetails | ||
|
||
interface InternalBrowserAutofillConfigurator : Configurator { | ||
/** | ||
* Configures autofill for the current webpage with optional automatic re-authentication support. | ||
* This should be called once per page load (e.g., onPageStarted()) | ||
* | ||
* @param webView The WebView to configure | ||
* @param url The URL of the current page | ||
* @param reauthenticationDetails Whether to enable automatic re-authentication for this page | ||
*/ | ||
fun configureAutofillForCurrentPage( | ||
webView: WebView, | ||
url: String?, | ||
reauthenticationDetails: ReAuthenticationDetails, | ||
) | ||
} |
74 changes: 74 additions & 0 deletions
74
.../java/com/duckduckgo/autofill/impl/configuration/RealInlineBrowserAutofillConfigurator.kt
This file contains hidden or 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,74 @@ | ||
/* | ||
* Copyright (c) 2025 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.configuration | ||
|
||
import android.webkit.WebView | ||
import com.duckduckgo.app.di.AppCoroutineScope | ||
import com.duckduckgo.autofill.api.AutofillCapabilityChecker | ||
import com.duckduckgo.autofill.impl.store.ReAuthenticationDetails | ||
import com.duckduckgo.common.utils.DefaultDispatcherProvider | ||
import com.duckduckgo.common.utils.DispatcherProvider | ||
import com.duckduckgo.di.scopes.AppScope | ||
import com.squareup.anvil.annotations.ContributesBinding | ||
import javax.inject.Inject | ||
import kotlinx.coroutines.CoroutineScope | ||
import kotlinx.coroutines.launch | ||
import kotlinx.coroutines.withContext | ||
import logcat.LogPriority.VERBOSE | ||
import logcat.logcat | ||
|
||
@ContributesBinding(AppScope::class) | ||
class RealInlineBrowserAutofillConfigurator @Inject constructor( | ||
private val autofillRuntimeConfigProvider: AutofillRuntimeConfigProvider, | ||
@AppCoroutineScope private val coroutineScope: CoroutineScope, | ||
private val dispatchers: DispatcherProvider = DefaultDispatcherProvider(), | ||
private val autofillCapabilityChecker: AutofillCapabilityChecker, | ||
private val autofillJavascriptLoader: AutofillJavascriptLoader, | ||
) : InternalBrowserAutofillConfigurator { | ||
override fun configureAutofillForCurrentPage( | ||
webView: WebView, | ||
url: String?, | ||
) { | ||
configureAutofillForCurrentPage(webView, url, ReAuthenticationDetails()) | ||
} | ||
|
||
override fun configureAutofillForCurrentPage( | ||
webView: WebView, | ||
url: String?, | ||
reauthenticationDetails: ReAuthenticationDetails, | ||
) { | ||
coroutineScope.launch(dispatchers.io()) { | ||
if (canJsBeInjected(url)) { | ||
val rawJs = autofillJavascriptLoader.getAutofillJavascript() | ||
val formatted = autofillRuntimeConfigProvider.getRuntimeConfiguration(rawJs, url, reauthenticationDetails) | ||
|
||
withContext(dispatchers.main()) { | ||
webView.evaluateJavascript("javascript:$formatted", null) | ||
} | ||
} else { | ||
logcat(VERBOSE) { "Won't inject autofill JS into WebView for: $url" } | ||
} | ||
} | ||
} | ||
|
||
private suspend fun canJsBeInjected(url: String?): Boolean { | ||
url?.let { | ||
// note, we don't check for autofillEnabledByUser here, as the user-facing preference doesn't cover email | ||
return autofillCapabilityChecker.isAutofillEnabledByConfiguration(it) | ||
} | ||
return false | ||
} | ||
} |
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.