From b81edbf02a6ab821e51ba5128b3984fc2e8653c2 Mon Sep 17 00:00:00 2001 From: Rebekah Potter Date: Wed, 22 Jun 2022 00:39:37 +0000 Subject: [PATCH 31/59] [M102] Print Preview: Fix missing destinations in dialog Print Preview's dialog fails to display destinations in cases where all printers have already been loaded into the backing destination store before the dialog is opened. This can happen if users have all printer types represented in their recent printers + system default printer, as such printers are pre-loaded at startup to populate the dropdown. Note the system default printer is a local/native printer. This bug previously did not manifest because users did not have an extension, privet, and cloud printer all in their recent destinations. However, with the removal of privet and cloud printer types, this bug could be triggered by simply having a recent extension printer + having a system default native printer. (cherry picked from commit 76e2dc10bc759469dcaea1604a582fd2c6bd55fa) Bug: 1330678 Change-Id: Ia0684b908690cca6691c9d44ad94296dadfb9536 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3696838 Reviewed-by: Lei Zhang Commit-Queue: Rebekah Potter Reviewed-by: Demetrios Papadopoulos Cr-Original-Commit-Position: refs/heads/main@{#1012174} Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3698743 Cr-Commit-Position: refs/branch-heads/5005@{#1190} Cr-Branched-From: 5b4d9450fee01f821b6400e947b3839727643a71-refs/heads/main@{#992738} --- .../resources/print_preview/ui/destination_dialog.ts | 7 ++++++- .../resources/print_preview/ui/destination_dialog_cros.ts | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/chrome/browser/resources/print_preview/ui/destination_dialog.ts b/chrome/browser/resources/print_preview/ui/destination_dialog.ts index 64ededd87966..2b8ad610c167 100644 --- a/chrome/browser/resources/print_preview/ui/destination_dialog.ts +++ b/chrome/browser/resources/print_preview/ui/destination_dialog.ts @@ -174,8 +174,13 @@ export class PrintPreviewDestinationDialogElement extends this.metrics_ = MetricsContext.destinationSearch(); } this.$.dialog.showModal(); - this.loadingDestinations_ = this.destinationStore === undefined || + const loading = this.destinationStore === undefined || this.destinationStore.isPrintDestinationSearchInProgress; + if (!loading) { + // All destinations have already loaded. + this.updateDestinations_(); + } + this.loadingDestinations_ = loading; this.metrics_.record(DestinationSearchBucket.DESTINATION_SHOWN); } diff --git a/chrome/browser/resources/print_preview/ui/destination_dialog_cros.ts b/chrome/browser/resources/print_preview/ui/destination_dialog_cros.ts index a164805bde4a..4c7b53daafc0 100644 --- a/chrome/browser/resources/print_preview/ui/destination_dialog_cros.ts +++ b/chrome/browser/resources/print_preview/ui/destination_dialog_cros.ts @@ -293,8 +293,13 @@ export class PrintPreviewDestinationDialogCrosElement extends this.metrics_ = MetricsContext.destinationSearch(); } this.$.dialog.showModal(); - this.loadingDestinations_ = this.destinationStore === undefined || + const loading = this.destinationStore === undefined || this.destinationStore.isPrintDestinationSearchInProgress; + if (!loading) { + // All destinations have already loaded. + this.updateDestinations_(); + } + this.loadingDestinations_ = loading; this.metrics_.record(DestinationSearchBucket.DESTINATION_SHOWN); } -- 2.37.0