Commit b6845321 authored by Jimmy Gong's avatar Jimmy Gong Committed by Commit Bot

Display ongoing print job errors

- Introduce a "stopped" state when the printer is in an error state and
  is waiting for the user to fix the issue.
- For example, if a user prints to a printer that is out of paper, the
  ongoing print job will now update to reflect that status.
- Updated browser and unit tests to reflect this change.

Screenshot (full view): https://screenshot.googleplex.com/YPR4R40jNeV
Screenshot (collapsed view): https://screenshot.googleplex.com/A64F7TvHspR

Bug: 1093527
Test: BrowserTest and UnitTest
Change-Id: Ia72f23d67066d5640698163759ddf4151a59e07a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2342309
Commit-Queue: Jimmy Gong <jimmyxgong@chromium.org>
Reviewed-by: default avatarTom Sepez <tsepez@chromium.org>
Reviewed-by: default avatarKyle Horimoto <khorimoto@chromium.org>
Cr-Commit-Position: refs/heads/master@{#796514}
parent fb005beb
......@@ -153,10 +153,12 @@ bool UpdatePrintJob(const ::printing::PrinterStatus& printer_status,
print_job->set_state(State::STATE_ERROR);
} else {
print_job->set_state(State::STATE_STARTED);
print_job->set_error_code(PrinterErrorCode::NO_ERROR);
}
break;
case ::printing::CupsJob::COMPLETED:
DCHECK_GE(job.current_pages, print_job->total_page_number());
print_job->set_error_code(PrinterErrorCode::NO_ERROR);
print_job->set_state(State::STATE_DOCUMENT_DONE);
break;
case ::printing::CupsJob::STOPPED:
......@@ -165,6 +167,7 @@ bool UpdatePrintJob(const ::printing::PrinterStatus& printer_status,
print_job->set_error_code(PrinterErrorCode::FILTER_FAILED);
print_job->set_state(State::STATE_FAILED);
} else {
print_job->set_error_code(PrinterErrorCode::NO_ERROR);
print_job->set_state(ConvertState(job.state));
}
break;
......
......@@ -10,6 +10,7 @@
#include "base/time/time.h"
#include "chrome/browser/chromeos/printing/cups_print_job.h"
#include "chrome/browser/chromeos/printing/history/print_job_info.pb.h"
#include "chrome/browser/chromeos/printing/printer_error_codes.h"
#include "url/gurl.h"
namespace chromeos {
......@@ -91,6 +92,34 @@ mojom::PrinterErrorCode PrinterErrorCodeProtoToMojom(
return mojom::PrinterErrorCode::kUnknownError;
}
mojom::PrinterErrorCode PrinterErrorCodeToMojom(PrinterErrorCode error_code) {
switch (error_code) {
case PrinterErrorCode::NO_ERROR:
return mojom::PrinterErrorCode::kNoError;
case PrinterErrorCode::PAPER_JAM:
return mojom::PrinterErrorCode::kPaperJam;
case PrinterErrorCode::OUT_OF_PAPER:
return mojom::PrinterErrorCode::kOutOfPaper;
case PrinterErrorCode::OUT_OF_INK:
return mojom::PrinterErrorCode::kOutOfInk;
case PrinterErrorCode::DOOR_OPEN:
return mojom::PrinterErrorCode::kDoorOpen;
case PrinterErrorCode::PRINTER_UNREACHABLE:
return mojom::PrinterErrorCode::kPrinterUnreachable;
case PrinterErrorCode::TRAY_MISSING:
return mojom::PrinterErrorCode::kTrayMissing;
case PrinterErrorCode::OUTPUT_FULL:
return mojom::PrinterErrorCode::kOutputFull;
case PrinterErrorCode::STOPPED:
return mojom::PrinterErrorCode::kStopped;
case PrinterErrorCode::FILTER_FAILED:
return mojom::PrinterErrorCode::kFilterFailed;
case PrinterErrorCode::UNKNOWN_ERROR:
return mojom::PrinterErrorCode::kUnknownError;
}
return mojom::PrinterErrorCode::kUnknownError;
}
} // namespace
mojom::PrintJobInfoPtr PrintJobProtoToMojom(
......@@ -100,8 +129,6 @@ mojom::PrintJobInfoPtr PrintJobProtoToMojom(
completed_info_mojom->completion_status =
PrintJobStatusProtoToMojom(print_job_info_proto.status());
completed_info_mojom->printer_error_code =
PrinterErrorCodeProtoToMojom(print_job_info_proto.printer_error_code());
mojom::PrintJobInfoPtr print_job_mojom = mojom::PrintJobInfo::New();
print_job_mojom->id = print_job_info_proto.id();
......@@ -112,6 +139,8 @@ mojom::PrintJobInfoPtr PrintJobProtoToMojom(
print_job_mojom->printer_name =
base::UTF8ToUTF16(print_job_info_proto.printer().name());
print_job_mojom->printer_uri = GURL(print_job_info_proto.printer().uri());
print_job_mojom->printer_error_code =
PrinterErrorCodeProtoToMojom(print_job_info_proto.printer_error_code());
print_job_mojom->completed_info = std::move(completed_info_mojom);
return print_job_mojom;
}
......@@ -133,6 +162,8 @@ mojom::PrintJobInfoPtr CupsPrintJobToMojom(const CupsPrintJob& job) {
print_job_mojom->printer_name =
base::UTF8ToUTF16(job.printer().display_name());
print_job_mojom->printer_uri = GURL(job.printer().uri().GetNormalized());
print_job_mojom->printer_error_code =
PrinterErrorCodeToMojom(job.error_code());
return print_job_mojom;
}
......
......@@ -86,7 +86,7 @@ TEST(PrintJobInfoMojomConversionsTest, PrintJobProtoToMojom) {
EXPECT_EQ(mojom::PrintJobCompletionStatus::kPrinted,
print_job_mojo->completed_info->completion_status);
EXPECT_EQ(mojom::PrinterErrorCode::kNoError,
print_job_mojo->completed_info->printer_error_code);
print_job_mojo->printer_error_code);
}
TEST(PrintJobInfoMojomConversionsTest, CupsPrintJobToMojom) {
......@@ -104,6 +104,8 @@ TEST(PrintJobInfoMojomConversionsTest, CupsPrintJobToMojom) {
print_job_mojo->active_print_job_info->printed_pages);
EXPECT_EQ(mojom::ActivePrintJobState::kStarted,
print_job_mojo->active_print_job_info->active_state);
EXPECT_EQ(mojom::PrinterErrorCode::kNoError,
print_job_mojo->printer_error_code);
}
} // namespace chromeos
......@@ -375,6 +375,9 @@ Try tapping the mic to ask me anything.
<message name="IDS_PRINT_MANAGEMENT_ONGOING_JOB_ARIA_LABEL" desc="The aria label that describes an ongoing print job that includes the print job documenet title, printer name, creation time, and ongoing status. Also notifies users that the ongoing print job can be cancelled with the 'Enter' key. This is only used for ChromeVox voice transcriptions.">
<ph name="DOCUMENT_TITLE">$1<ex>my_essay.doc</ex></ph>, <ph name="PRINTER_NAME">$2<ex>canon 6450</ex></ph>, <ph name="CREATION_TIME">$3<ex>February 8, 2020</ex></ph>, <ph name="PRINTED_PAGE_NUMBER">$4<ex>5</ex></ph> out of <ph name="TOTAL_PAGE_NUMBER">$5<ex>7</ex></ph>. Press enter to cancel the print job.
</message>
<message name="IDS_PRINT_MANAGEMENT_STOPPED_ONGOING_JOB_ARIA_LABEL" desc="The aria label that describes a stopped print job that includes the print job documenet title, printer name, creation time, and error status. This is a sentence with commas and spaces (minor pause) between placeholders.">
<ph name="DOCUMENT_TITLE">$1<ex>my_essay.doc</ex></ph>, <ph name="PRINTER_NAME">$2<ex>canon 6450</ex></ph>, <ph name="CREATION_TIME">$3<ex>February 8, 2020</ex></ph>, <ph name="ERROR_STATUS">$4<ex>Stopped - Out of paper</ex></ph>
</message>
<message name="IDS_PRINT_MANAGEMENT_PAPER_JAM_ERROR_STATUS" desc="The error status displayed next to a print job to indicate to users that their print job failed because of a printer paper jam.">
Failed - Paper jam
</message>
......@@ -408,6 +411,30 @@ Try tapping the mic to ask me anything.
<message name="IDS_PRINT_MANAGEMENT_NO_PRINT_JOBS_IN_PROGRESS_MESSAGE" desc="The message shown to users if they do not have any print jobs in progress i.e. being printed.">
No print jobs in progress
</message>
<message name="IDS_PRINT_MANAGEMENT_PAPER_JAM_STOPPED_ERROR_STATUS" desc="The error status displayed next to a print job to indicate to users that their print job has stopped because of a printer paper jam.">
Stopped - Paper jam
</message>
<message name="IDS_PRINT_MANAGEMENT_OUT_OF_PAPER_STOPPED_ERROR_STATUS" desc="The error status displayed next to a print job to indicate to users that their print job has stopped because their printer is out out of paper.">
Stopped - Out of paper
</message>
<message name="IDS_PRINT_MANAGEMENT_OUT_OF_INK_STOPPED_ERROR_STATUS" desc="The error status displayed next to a print job to indicate to users that their print job has stopped because their printer is out of ink.">
Stopped - Out of ink
</message>
<message name="IDS_PRINT_MANAGEMENT_DOOR_OPEN_STOPPED_ERROR_STATUS" desc="The error status displayed next to a print job to indicate to users that their print job stopped because their printer door is open.">
Stopped - Door open
</message>
<message name="IDS_PRINT_MANAGEMENT_TRAY_MISSING_STOPPED_ERROR_STATUS" desc="The error status displayed next to a print job to indicate to users that their print job stopped because their printer's tray is missing.">
Stopped - Tray missing
</message>
<message name="IDS_PRINT_MANAGEMENT_OUTPUT_FULL_STOPPED_ERROR_STATUS" desc="The error status displayed next to a print job to indicate to users that their print job stopped because their printer's output is full .">
Stopped - Output full
</message>
<message name="IDS_PRINT_MANAGEMENT_GENERIC_STOPPED_ERROR_STATUS" desc="The error status displayed next to a print job to indicate to users that their print job stopped.">
Stopped
</message>
<message name="IDS_PRINT_MANAGEMENT_UNKNOWN_STOPPED_ERROR_STATUS" desc="The error status displayed next to a print job to indicate to users that their print job stopped due to an unknown error.">
Stopped - Unknown error
</message>
<message name="IDS_PRINT_MANAGEMENT_CLEAR_ALL_POLICY_PRINT_JOB_INDICATOR_MESSAGE" desc="The message shown to indicate that a user policy is in place to prevent the user from deleting their print job history.">
This action is managed by your administrator
</message>
......
3435b3dfa0ec33e7f49785d878f8505f1381bfc5
\ No newline at end of file
ec79956fbc34a9f5997227b7555eb9de18240937
\ No newline at end of file
8fce89e590bbb68ebb5939bebc1543e361ab54d2
\ No newline at end of file
e4ef53b665ccf938847ceefa80005728edfe8fb1
\ No newline at end of file
38413e52a373824b1f5c6f7504650cbd7675e8fc
\ No newline at end of file
b204006d99806a80ea0757654308ba141cc8bf4a
\ No newline at end of file
5382da288464b6ab5ccdc6359abc00d44264be42
\ No newline at end of file
b52e5c1c7a9af19f1c9530faa882c8871a706324
\ No newline at end of file
3337a9cc8cc5756e6ae58b25186b82d5d3cb6278
\ No newline at end of file
......@@ -39,9 +39,6 @@ enum PrinterErrorCode {
struct CompletedPrintJobInfo {
// Corresponds to the status of the print job after it has completed.
PrintJobCompletionStatus completion_status;
// Corresponds to the error code reported by the printer.
PrinterErrorCode printer_error_code;
};
// Enumeration of ongoing print job status.
......@@ -86,6 +83,9 @@ struct PrintJobInfo {
// The URI of the printer the print job was requested to.
url.mojom.Url printer_uri;
// Corresponds to the error code reported by the printer.
PrinterErrorCode printer_error_code;
// Information of a completed print job. Null struct if the print job is
// currently being printed.
CompletedPrintJobInfo? completed_info;
......
......@@ -68,6 +68,8 @@ void AddPrintManagementStrings(content::WebUIDataSource* html_source) {
IDS_PRINT_MANAGEMENT_PRINTED_PAGES_PROGRESS_FRACTION},
{"completePrintJobLabel", IDS_PRINT_MANAGEMENT_COMPLETED_JOB_ARIA_LABEL},
{"ongoingPrintJobLabel", IDS_PRINT_MANAGEMENT_ONGOING_JOB_ARIA_LABEL},
{"stoppedOngoingPrintJobLabel",
IDS_PRINT_MANAGEMENT_STOPPED_ONGOING_JOB_ARIA_LABEL},
{"paperJam", IDS_PRINT_MANAGEMENT_PAPER_JAM_ERROR_STATUS},
{"outOfPaper", IDS_PRINT_MANAGEMENT_OUT_OF_PAPER_ERROR_STATUS},
{"outOfInk", IDS_PRINT_MANAGEMENT_OUT_OF_INK_ERROR_STATUS},
......@@ -79,6 +81,18 @@ void AddPrintManagementStrings(content::WebUIDataSource* html_source) {
{"stopped", IDS_PRINT_MANAGEMENT_STOPPED_ERROR_STATUS},
{"filterFailed", IDS_PRINT_MANAGEMENT_FILTERED_FAILED_ERROR_STATUS},
{"unknownPrinterError", IDS_PRINT_MANAGEMENT_UNKNOWN_ERROR_STATUS},
{"paperJamStopped", IDS_PRINT_MANAGEMENT_PAPER_JAM_STOPPED_ERROR_STATUS},
{"outOfPaperStopped",
IDS_PRINT_MANAGEMENT_OUT_OF_PAPER_STOPPED_ERROR_STATUS},
{"outOfInkStopped", IDS_PRINT_MANAGEMENT_OUT_OF_INK_STOPPED_ERROR_STATUS},
{"doorOpenStopped", IDS_PRINT_MANAGEMENT_DOOR_OPEN_STOPPED_ERROR_STATUS},
{"trayMissingStopped",
IDS_PRINT_MANAGEMENT_TRAY_MISSING_STOPPED_ERROR_STATUS},
{"outputFullStopped",
IDS_PRINT_MANAGEMENT_OUTPUT_FULL_STOPPED_ERROR_STATUS},
{"stoppedGeneric", IDS_PRINT_MANAGEMENT_GENERIC_STOPPED_ERROR_STATUS},
{"unknownPrinterErrorStopped",
IDS_PRINT_MANAGEMENT_UNKNOWN_STOPPED_ERROR_STATUS},
{"noPrintJobInProgress",
IDS_PRINT_MANAGEMENT_NO_PRINT_JOBS_IN_PROGRESS_MESSAGE},
{"clearAllPrintJobPolicyIndicatorToolTip",
......
......@@ -4,6 +4,11 @@
color: var(--print-management-default-text-color);
}
.collapsed-status {
@apply --print-management-header-font;
color: var(--google-blue-600);
}
/* Override focus CSS for selectable items. */
.list-item:focus,
.list-item > :focus {
......@@ -27,11 +32,6 @@
padding-bottom: 2px;
}
#collapsedStatus {
@apply --print-management-header-font;
color: var(--google-blue-600);
}
#fileIcon {
margin-inline-end: 16px;
min-width: 22px;
......@@ -85,34 +85,47 @@
</template>
<template is="dom-if" if="[[!isCompletedPrintJob_(jobEntry)]]" restamp>
<iron-media-query query="(min-width: 768px)"
query-matches="{{showFullOngoingStatus_}}">
</iron-media-query>
<div id="activeStatusContainer"
class="status-column padded-left flex-center">
<template is="dom-if" if="[[showFullOngoingStatus_]]">
<div id="numericalProgress" aria-hidden="true">
[[readableProgress_]]
</div>
<paper-progress
value="[[computePrintPagesProgress_(
jobEntry.activePrintJobInfo.printedPages,
jobEntry.numberOfPages)]]"
aria-hidden="true">
</paper-progress>
</template>
<div id="collapsedStatus" hidden="[[showFullOngoingStatus_]]"
aria-hidden="true">
[[i18n('collapsedPrintingText')]]
</div>
<cr-icon-button id="cancelPrintJobButton"
iron-icon="print-management:cancel"
focus-row-control
focus-type="cancelPrintJob"
aria-hidden="true"
<iron-media-query query="(min-width: 768px)"
query-matches="{{showFullOngoingStatus_}}">
</iron-media-query>
<div id="activeStatusContainer"
class="status-column padded-left flex-center">
<!-- Non-error printing status -->
<template is="dom-if" if="[[!ongoingErrorStatus_]]" restamp>
<template is="dom-if" if="[[showFullOngoingStatus_]]">
<div id="numericalProgress" aria-hidden="true">
[[readableProgress_]]
</div>
<paper-progress
value="[[computePrintPagesProgress_(
jobEntry.activePrintJobInfo.printedPages,
jobEntry.numberOfPages)]]"
aria-hidden="true">
</paper-progress>
</template>
<div class="collapsed-status" hidden="[[showFullOngoingStatus_]]"
aria-hidden="true">
[[i18n('collapsedPrintingText')]]
</div>
</template>
<!-- Error printing status -->
<template is="dom-if" if="[[ongoingErrorStatus_]]" restamp>
<div id="ongoingError" class="overflow-ellipsis" aria-hidden="true"
hidden="[[!showFullOngoingStatus_]]">
[[ongoingErrorStatus_]]
</div>
<div hidden="[[showFullOngoingStatus_]]" aria-hidden="true">
[[i18n('stoppedGeneric')]]
</div>
</template>
<cr-icon-button id="cancelPrintJobButton"
iron-icon="print-management:cancel"
focus-row-control
focus-type="cancelPrintJob"
aria-hidden="true"
on-click="onCancelPrintJobClicked_">
</cr-icon-button>
</div>
</cr-icon-button>
</div>
</template>
</div>
</div>
......@@ -195,6 +195,15 @@ Polymer({
computed: 'computeCompletionStatus_(jobEntry.completedInfo)',
},
/**
* Empty if there is no ongoing error.
* @private
*/
ongoingErrorStatus_: {
type: String,
computed: 'getOngoingErrorStatus_(jobEntry.printerErrorCode)',
},
/**
* A representation in fraction form of pages printed versus total number
* of pages to be printed. E.g. 5/7 (5 pages printed / 7 total pages to
......@@ -336,7 +345,7 @@ Polymer({
case chromeos.printing.printingManager.mojom.PrintJobCompletionStatus
.kFailed:
return this.getFailedStatusString_(
this.jobEntry.completedInfo.printerErrorCode);
this.jobEntry.printerErrorCode);
case chromeos.printing.printingManager.mojom.PrintJobCompletionStatus
.kCanceled:
return loadTimeData.getString('completionStatusCanceled');
......@@ -380,6 +389,11 @@ Polymer({
return loadTimeData.getStringF('completePrintJobLabel', this.jobTitle_,
this.printerName_, this.creationTime_, this.completionStatus_);
}
if (this.ongoingErrorStatus_) {
return loadTimeData.getStringF('stoppedOngoingPrintJobLabel',
this.jobTitle_, this.printerName_, this.creationTime_,
this.ongoingErrorStatus_);
}
return loadTimeData.getStringF('ongoingPrintJobLabel', this.jobTitle_,
this.printerName_, this.creationTime_,
this.jobEntry.activePrintJobInfo.printedPages.toString(),
......@@ -464,5 +478,42 @@ Polymer({
return loadTimeData.getString('unknownPrinterError');
}
},
/**
* @param {number} mojoPrinterErrorCode
* @return {string}
* @private
*/
getOngoingErrorStatus_(mojoPrinterErrorCode) {
if (this.isCompletedPrintJob_()) {
return '';
}
switch (mojoPrinterErrorCode) {
case chromeos.printing.printingManager.mojom.PrinterErrorCode.kNoError:
return '';
case chromeos.printing.printingManager.mojom.PrinterErrorCode.kPaperJam:
return loadTimeData.getString('paperJamStopped');
case chromeos.printing.printingManager.mojom.PrinterErrorCode.kOutOfPaper:
return loadTimeData.getString('outOfPaperStopped');
case chromeos.printing.printingManager.mojom.PrinterErrorCode.kOutOfInk:
return loadTimeData.getString('outOfInkStopped');
case chromeos.printing.printingManager.mojom.PrinterErrorCode.kDoorOpen:
return loadTimeData.getString('doorOpenStopped');
case chromeos.printing.printingManager.mojom.PrinterErrorCode
.kTrayMissing:
return loadTimeData.getString('trayMissingStopped');
case chromeos.printing.printingManager.mojom.PrinterErrorCode.kOutputFull:
return loadTimeData.getString('outputFullStopped');
case chromeos.printing.printingManager.mojom.PrinterErrorCode.kStopped:
return loadTimeData.getString('stoppedGeneric');
case chromeos.printing.printingManager.mojom.PrinterErrorCode
.kUnknownError:
return loadTimeData.getString('unknownPrinterErrorStopped');
default:
assertNotReached();
return loadTimeData.getString('unknownPrinterErrorStopped');
}
},
});
})()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment