... |
... |
@@ -544,58 +544,71 @@ class PromptFeature private constructor( |
544
|
544
|
*
|
545
|
545
|
* @param session The session which requested the dialog.
|
546
|
546
|
*/
|
547
|
|
- @Suppress("NestedBlockDepth")
|
548
|
547
|
@VisibleForTesting(otherwise = PRIVATE)
|
549
|
548
|
internal fun onPromptRequested(session: SessionState) {
|
550
|
549
|
// Some requests are handle with intents
|
551
|
550
|
session.content.promptRequests.lastOrNull()?.let { promptRequest ->
|
552
|
|
- store.state.findTabOrCustomTabOrSelectedTab(customTabId)?.let {
|
553
|
|
- promptRequest.executeIfWindowedPrompt { exitFullscreenUsecase(it.id) }
|
|
551
|
+ if (session.content.permissionRequestsList.isNotEmpty()) {
|
|
552
|
+ onCancel(session.id, promptRequest.uid)
|
|
553
|
+ } else {
|
|
554
|
+ processPromptRequest(promptRequest, session)
|
554
|
555
|
}
|
|
556
|
+ }
|
|
557
|
+ }
|
555
|
558
|
|
556
|
|
- when (promptRequest) {
|
557
|
|
- is File -> {
|
558
|
|
- emitPromptDisplayedFact(promptName = "FilePrompt")
|
559
|
|
- filePicker.handleFileRequest(promptRequest)
|
560
|
|
- }
|
|
559
|
+ @Suppress("NestedBlockDepth")
|
|
560
|
+ private fun processPromptRequest(
|
|
561
|
+ promptRequest: PromptRequest,
|
|
562
|
+ session: SessionState,
|
|
563
|
+ ) {
|
|
564
|
+ store.state.findTabOrCustomTabOrSelectedTab(customTabId)?.let {
|
|
565
|
+ promptRequest.executeIfWindowedPrompt { exitFullscreenUsecase(it.id) }
|
|
566
|
+ }
|
561
|
567
|
|
562
|
|
- is Share -> handleShareRequest(promptRequest, session)
|
563
|
|
- is SelectCreditCard -> {
|
564
|
|
- emitSuccessfulCreditCardAutofillFormDetectedFact()
|
565
|
|
- if (isCreditCardAutofillEnabled() && promptRequest.creditCards.isNotEmpty()) {
|
566
|
|
- creditCardPicker?.handleSelectCreditCardRequest(promptRequest)
|
567
|
|
- }
|
|
568
|
+ when (promptRequest) {
|
|
569
|
+ is File -> {
|
|
570
|
+ emitPromptDisplayedFact(promptName = "FilePrompt")
|
|
571
|
+ filePicker.handleFileRequest(promptRequest)
|
|
572
|
+ }
|
|
573
|
+
|
|
574
|
+ is Share -> handleShareRequest(promptRequest, session)
|
|
575
|
+ is SelectCreditCard -> {
|
|
576
|
+ emitSuccessfulCreditCardAutofillFormDetectedFact()
|
|
577
|
+ if (isCreditCardAutofillEnabled() && promptRequest.creditCards.isNotEmpty()) {
|
|
578
|
+ creditCardPicker?.handleSelectCreditCardRequest(promptRequest)
|
568
|
579
|
}
|
|
580
|
+ }
|
569
|
581
|
|
570
|
|
- is SelectLoginPrompt -> {
|
571
|
|
- if (!isLoginAutofillEnabled()) {
|
572
|
|
- return
|
573
|
|
- }
|
574
|
|
- if (promptRequest.generatedPassword != null && isSuggestStrongPasswordEnabled) {
|
575
|
|
- val currentUrl =
|
576
|
|
- store.state.findTabOrCustomTabOrSelectedTab(customTabId)?.content?.url
|
577
|
|
- if (currentUrl != null) {
|
578
|
|
- strongPasswordPromptViewListener?.handleSuggestStrongPasswordRequest(
|
579
|
|
- promptRequest,
|
580
|
|
- currentUrl,
|
581
|
|
- onSaveLoginWithStrongPassword,
|
582
|
|
- )
|
583
|
|
- }
|
584
|
|
- } else {
|
585
|
|
- loginPicker?.handleSelectLoginRequest(promptRequest)
|
586
|
|
- }
|
587
|
|
- emitPromptDisplayedFact(promptName = "SelectLoginPrompt")
|
|
582
|
+ is SelectLoginPrompt -> {
|
|
583
|
+ if (!isLoginAutofillEnabled()) {
|
|
584
|
+ return
|
588
|
585
|
}
|
589
|
586
|
|
590
|
|
- is SelectAddress -> {
|
591
|
|
- emitSuccessfulAddressAutofillFormDetectedFact()
|
592
|
|
- if (isAddressAutofillEnabled() && promptRequest.addresses.isNotEmpty()) {
|
593
|
|
- addressPicker?.handleSelectAddressRequest(promptRequest)
|
|
587
|
+ if (promptRequest.generatedPassword != null && isSuggestStrongPasswordEnabled) {
|
|
588
|
+ val currentUrl =
|
|
589
|
+ store.state.findTabOrCustomTabOrSelectedTab(customTabId)?.content?.url
|
|
590
|
+ if (currentUrl != null) {
|
|
591
|
+ strongPasswordPromptViewListener?.handleSuggestStrongPasswordRequest(
|
|
592
|
+ promptRequest,
|
|
593
|
+ currentUrl,
|
|
594
|
+ onSaveLoginWithStrongPassword,
|
|
595
|
+ )
|
594
|
596
|
}
|
|
597
|
+ strongPasswordPromptViewListener?.handleSuggestStrongPasswordRequest()
|
|
598
|
+ } else {
|
|
599
|
+ loginPicker?.handleSelectLoginRequest(promptRequest)
|
595
|
600
|
}
|
|
601
|
+ emitPromptDisplayedFact(promptName = "SelectLoginPrompt")
|
|
602
|
+ }
|
596
|
603
|
|
597
|
|
- else -> handleDialogsRequest(promptRequest, session)
|
|
604
|
+ is SelectAddress -> {
|
|
605
|
+ emitSuccessfulAddressAutofillFormDetectedFact()
|
|
606
|
+ if (isAddressAutofillEnabled() && promptRequest.addresses.isNotEmpty()) {
|
|
607
|
+ addressPicker?.handleSelectAddressRequest(promptRequest)
|
|
608
|
+ }
|
598
|
609
|
}
|
|
610
|
+
|
|
611
|
+ else -> handleDialogsRequest(promptRequest, session)
|
599
|
612
|
}
|
600
|
613
|
}
|
601
|
614
|
|