Don't show supervised user as "already on this device" while they're being imported.
[chromium-blink-merge.git] / ui / file_manager / video_player / js / video_player_metrics.js
blobd49ddd6528ceb5b4313f49f369c8e84dc5d52eee
1 // Copyright (c) 2014 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.
5 /**
6 * @fileoverview Utility methods for accessing chrome.metricsPrivate API.
8 * To be included as a first script in main.html
9 */
11 /**
12 * @extends {metricsBase}
14 var metrics = metricsBase;
16 /**
17 * Values for "VideoPlayer.CastAPIExtensionStaus" metrics.
18 * @enum {number}
20 metrics.CAST_API_EXTENSION_STATUS = {
21 // Cast API extension is not loaded since the cast extension, which is requred
22 // by the cast API extension, is not installed or load failed.
23 SKIPPED: 0,
24 // Installation of Cast API extension is failed.
25 INSTALLATION_FAILED: 1,
26 // Load of Cast API extension is failed.
27 LOAD_FAILED: 2,
28 // Cast API extension is newly installed and loaded.
29 INSTALLED_AND_LOADED: 3,
30 // Cast API extension is loaded.
31 LOADED: 4,
32 // (sentinel)
33 MAX_VALUE: 5,
36 /**
37 * Values for "VideoPlayer.PlayType" metrics.
38 * @enum {number}
40 metrics.PLAY_TYPE = {
41 LOCAL: 0,
42 CAST: 1,
43 MAX_VALUE: 2,
46 /**
47 * Utility function to check if the given value is in the given values.
48 * @param {!Object} values
49 * @param {*} value
50 * @return {boolean} True if one or more elements of the given values hash have
51 * the given value as value. False otherwise.
53 metrics.hasValue_ = function(values, value) {
54 return Object.keys(values).some(function(key) {
55 return values[key] === value;
56 });
59 /**
60 * Record "VideoPlayer.CastAPIExtensionStatsu" metrics.
61 * @param {metrics.CAST_API_EXTENSION_STATUS} status Status to be recorded.
63 metrics.recordCastAPIExtensionStatus = function(status) {
64 if (!metrics.hasValue_(metrics.CAST_API_EXTENSION_STATUS, status)) {
65 console.error('The given value "' + status + '" is invalid.');
66 return;
69 metrics.recordEnum('CastAPIExtensionStatus',
70 status,
71 metrics.CAST_API_EXTENSION_STATUS.MAX_VALUE);
74 /**
75 * Record "VideoPlayer.NumberOfCastDevices" metrics.
76 * @param {number} number Value to be recorded.
78 metrics.recordNumberOfCastDevices = function(number) {
79 metrics.recordSmallCount('NumberOfCastDevices', number);
82 /**
83 * Record "VideoPlayer.NumberOfOpenedFile" metrics.
84 * @param {number} number Value to be recorded.
86 metrics.recordNumberOfOpenedFiles = function(number) {
87 metrics.recordSmallCount('NumberOfOpenedFiles', number);
90 /**
91 * Record "VideoPlayer.CastedVideoLength" metrics.
92 * @param {number} seconds Value to be recorded.
94 metrics.recordCastedVideoLength = function(seconds) {
95 metrics.recordMediumCount('CastedVideoLength', seconds);
98 /**
99 * Record "VideoPlayer.CastVideoError" metrics.
101 metrics.recordCastVideoErrorAction = function() {
102 metrics.recordUserAction('CastVideoError');
106 * Record "VideoPlayer.OpenVideoPlayer" action.
108 metrics.recordOpenVideoPlayerAction = function() {
109 metrics.recordUserAction('OpenVideoPlayer');
113 * Record "VideoPlayer.PlayType" metrics.
114 * @param {metrics.PLAY_TYPE} type Value to be recorded.
116 metrics.recordPlayType = function(type) {
117 if (!metrics.hasValue_(metrics.PLAY_TYPE, type)) {
118 console.error('The given value "' + type + '" is invalid.');
119 return;
122 metrics.recordEnum('PlayType',
123 type,
124 metrics.PLAY_TYPE.MAX_VALUE);
128 * Convert a short metric name to the full format.
130 * @param {string} name Short metric name.
131 * @return {string} Full metric name.
132 * @override
133 * @private
135 metrics.convertName_ = function(name) {
136 return 'VideoPlayer.' + name;