Skip to content

Commit

Permalink
Migrate lock_screen_constants.js to typescript
Browse files Browse the repository at this point in the history
Fixed: b/281496121
Change-Id: I5c376bbc48f7345f4333700e00311be8047a0b7e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4574669
Reviewed-by: Denis Kuznetsov <antrim@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Auto-Submit: Martin Bidlingmaier <mbid@google.com>
Commit-Queue: Martin Bidlingmaier <mbid@google.com>
Reviewed-by: Wes Okuhara <wesokuhara@google.com>
Cr-Commit-Position: refs/heads/main@{#1152896}
  • Loading branch information
mbid authored and Chromium LUCI CQ committed Jun 3, 2023
1 parent 1a1f0d6 commit a921fee
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 71 deletions.
2 changes: 1 addition & 1 deletion PRESUBMIT.py
Expand Up @@ -312,7 +312,7 @@ class BanRule:
# cleaned up.
'ash/webui/common/resources/cr.m.js',
'ash/webui/common/resources/multidevice_setup/multidevice_setup_browser_proxy.js',
'ash/webui/common/resources/quick_unlock/lock_screen_constants.js',
'ash/webui/common/resources/quick_unlock/lock_screen_constants.ts',
'ash/webui/common/resources/smb_shares/smb_browser_proxy.js',
'ash/webui/connectivity_diagnostics/resources/connectivity_diagnostics.js',
'ash/webui/diagnostics_ui/resources/diagnostics_browser_proxy.ts',
Expand Down
9 changes: 5 additions & 4 deletions ash/webui/common/resources/BUILD.gn
Expand Up @@ -143,7 +143,6 @@ non_web_component_files = [
"store/store.js",
"store/store_client.js",
"traffic_counters/traffic_counters_adapter.js",
"quick_unlock/lock_screen_constants.js",
"util.js",
"web_ui_listener_behavior.js",
]
Expand All @@ -158,6 +157,7 @@ non_web_component_files_ts = [
"hotspot/cros_hotspot_config.ts",
"hotspot/fake_hotspot_config.ts",
"typescript_utils/strict_query.ts",
"quick_unlock/lock_screen_constants.ts",
]

mojo_files_ts = [
Expand Down Expand Up @@ -246,7 +246,10 @@ ts_library("build_ts") {
"//ui/webui/resources/js:build_ts",
"//ui/webui/resources/mojo:build_ts",
]
definitions = [ "//tools/typescript/definitions/quick_unlock_private.d.ts" ]
definitions = [
"//tools/typescript/definitions/quick_unlock_private.d.ts",
"//tools/typescript/definitions/chrome_send.d.ts",
]
extra_deps = [
":generate_definitions",
":preprocess",
Expand Down Expand Up @@ -397,7 +400,6 @@ generate_definitions_js_files = [
"network/network_listener_behavior.js",
"network/network_shared.css.js",
"network/onc_mojo.js",
"quick_unlock/lock_screen_constants.js",
"quick_unlock/pin_keyboard.html.js",
"quick_unlock/pin_keyboard_icons.html.js",
"quick_unlock/setup_pin_keyboard.html.js",
Expand Down Expand Up @@ -508,7 +510,6 @@ group("closure_compile") {
"network:closure_compile_module",
"network_health:closure_compile_module",
"post_message_api:closure_compile",
"quick_unlock:closure_compile_module",
"smb_shares:closure_compile_module",
"store:closure_compile_module",
"traffic_counters:closure_compile_module",
Expand Down
20 changes: 0 additions & 20 deletions ash/webui/common/resources/quick_unlock/BUILD.gn

This file was deleted.

45 changes: 0 additions & 45 deletions ash/webui/common/resources/quick_unlock/lock_screen_constants.js

This file was deleted.

42 changes: 42 additions & 0 deletions ash/webui/common/resources/quick_unlock/lock_screen_constants.ts
@@ -0,0 +1,42 @@
// Copyright 2016 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

/**
* @fileoverview Constants used for logging the pin unlock setup uma.
*/

/**
* Name of the pin unlock setup uma histogram.
*/
const PIN_UNLOCK_UMA_HISTOGRAM_NAME = 'Settings.PinUnlockSetup';

/**
* Stages the user can enter while setting up pin unlock.
*/
export enum LockScreenProgress {
START_SCREEN_LOCK = 0,
ENTER_PASSWORD_CORRECTLY = 1,
CHOOSE_PIN_OR_PASSWORD = 2,
ENTER_PIN = 3,
CONFIRM_PIN = 4,
}

const LOCK_SCREEN_PROGRESS_BUCKET_NUMBER = LockScreenProgress.CONFIRM_PIN + 1;

/**
* Helper function to send the progress of the pin setup to be recorded in the
* histogram.
*/
export function recordLockScreenProgress(currentProgress: LockScreenProgress) {
if (currentProgress >= LOCK_SCREEN_PROGRESS_BUCKET_NUMBER) {
console.error(`Expected an enumeration value lower than ${
LOCK_SCREEN_PROGRESS_BUCKET_NUMBER}, got ${currentProgress}.`);
return;
}
chrome.send('metricsHandler:recordInHistogram', [
PIN_UNLOCK_UMA_HISTOGRAM_NAME,
currentProgress,
LOCK_SCREEN_PROGRESS_BUCKET_NUMBER,
]);
}
Expand Up @@ -520,7 +520,6 @@ js_library("pin_setup") {
"../../components/buttons:oobe_text_button",
"../../components/dialogs:oobe_adaptive_dialog",
"//ash/webui/common/resources:cr.m",
"//ash/webui/common/resources/quick_unlock:lock_screen_constants",
]
extra_deps = [ ":web_components" ]
externs_list = [
Expand Down

0 comments on commit a921fee

Please sign in to comment.