| 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);
|
| + }
|
| +};
|
|
|