blob: fa6a821949498b1bae971cfedbca5d5cc29e51a7 [file] [log] [blame]
Jesse Schettlerbf41a9feb2020-09-09 22:52:251// Copyright 2020 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
Jesse Schettler447bd4182020-09-28 23:05:415import {assertNotReached} from 'chrome://resources/js/assert.m.js';
6
7/**
8 * Converts a chromeos.scanning.mojom.SourceType to a string that can be
9 * displayed in the source dropdown.
10 * @param {number} mojoSourceType
11 * @return {!string}
12 */
13export function getSourceTypeString(mojoSourceType) {
14 // TODO(jschettler): Replace with finalized i18n strings.
15 switch (mojoSourceType) {
16 case chromeos.scanning.mojom.SourceType.kFlatbed:
17 return 'Flatbed';
18 case chromeos.scanning.mojom.SourceType.kAdfSimplex:
19 return 'Document Feeder (Simplex)';
20 case chromeos.scanning.mojom.SourceType.kAdfDuplex:
21 return 'Document Feeder (Duplex)';
Jesse Schettler5bd67af2020-10-08 01:51:1722 case chromeos.scanning.mojom.SourceType.kDefault:
23 return 'Default';
24 case chromeos.scanning.mojom.SourceType.kUnknown:
Jesse Schettler447bd4182020-09-28 23:05:4125 default:
26 assertNotReached();
27 return 'Unknown';
28 }
29}
30
Jesse Schettlerbf41a9feb2020-09-09 22:52:2531/**
32 * Converts an unguessable token to a string by combining the high and low
33 * values as strings with a hashtag as the separator.
34 * @param {!mojoBase.mojom.UnguessableToken} token
35 * @return {!string}
36 */
37export function tokenToString(token) {
38 return `${token.high.toString()}#${token.low.toString()}`;
39}