Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(225)

Unified Diff: ui/file_manager/file_manager/foreground/js/quick_view_uma.js

Issue 2081603003: Add UMA for Quick View (file type and volume type). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/file_manager/file_manager/foreground/js/quick_view_controller.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/file_manager/file_manager/foreground/js/quick_view_uma.js
diff --git a/ui/file_manager/file_manager/foreground/js/quick_view_uma.js b/ui/file_manager/file_manager/foreground/js/quick_view_uma.js
new file mode 100644
index 0000000000000000000000000000000000000000..7f43d93e1597797d5ef898f7657dd09983461d26
--- /dev/null
+++ b/ui/file_manager/file_manager/foreground/js/quick_view_uma.js
@@ -0,0 +1,64 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+/**
+ * UMA exporter for Quick View.
+ *
+ * @param {!VolumeManagerWrapper} volumeManager
+ *
+ * @constructor
+ */
+function QuickViewUma(volumeManager) {
+
+ /**
+ * @type {!VolumeManagerWrapper}
+ * @private
+ */
+ this.volumeManager_ = volumeManager;
+}
+
+/**
+ * Keep the order of this in sync with FileManagerVolumeType in
+ * tools/metrics/histograms/histograms.xml.
+ *
+ * @type {!Array<VolumeManagerCommon.VolumeType>}
+ * @const
+ */
+QuickViewUma.VolumeType = [
+ VolumeManagerCommon.VolumeType.DRIVE,
+ VolumeManagerCommon.VolumeType.DOWNLOADS,
+ VolumeManagerCommon.VolumeType.REMOVABLE,
+ VolumeManagerCommon.VolumeType.ARCHIVE,
+ VolumeManagerCommon.VolumeType.PROVIDED,
+ VolumeManagerCommon.VolumeType.MTP,
+];
+
+/**
+ * Exports UMA based on the entry shown in Quick View.
+ *
+ * @param {!FileEntry} entry
+ */
+QuickViewUma.prototype.onEntryChanged = function(entry) {
+ var extension = FileType.getExtension(entry).toLowerCase();
+ if (FileTasks.UMA_INDEX_KNOWN_EXTENSIONS.indexOf(extension) < 0) {
+ extension = 'other';
+ }
+ metrics.recordEnum(
+ 'QuickView.FileType', extension, FileTasks.UMA_INDEX_KNOWN_EXTENSIONS);
+};
+
+/**
+ * Exports UMA based on the entry selected when Quick View is opened.
+ *
+ * @param {!FileEntry} entry
+ */
+QuickViewUma.prototype.onOpened = function(entry) {
+ var volumeType = this.volumeManager_.getVolumeInfo(entry).volumeType;
+ if (QuickViewUma.VolumeType.includes(volumeType)) {
+ metrics.recordEnum(
+ 'QuickView.VolumeType', volumeType, QuickViewUma.VolumeType);
+ } else {
+ console.error('Unknown volume type: ' + volumeType);
+ }
+};
« no previous file with comments | « ui/file_manager/file_manager/foreground/js/quick_view_controller.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698