1 // Copyright (c) 2012 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 cr.define('print_preview', function() {
9 * Object used to measure usage statistics.
12 function Metrics() {};
15 * Enumeration of metrics bucket groups. Each group describes a set of events
16 * that can happen in order. This implies that an event cannot occur twice and
17 * an event that occurs semantically before another event, should not occur
21 Metrics.BucketGroup = {
22 DESTINATION_SEARCH: 0,
27 * Enumeration of buckets that a user can enter while using the destination
31 Metrics.DestinationSearchBucket = {
32 // Used when the print destination search widget is shown.
34 // Used when the user selects a print destination.
35 DESTINATION_SELECTED: 1,
36 // Used when the print destination search widget is closed without selecting
37 // a print destination.
39 // Used when the Google Cloud Print promotion (shown in the destination
40 // search widget) is shown to the user.
41 CLOUDPRINT_PROMO_SHOWN: 3,
42 // Used when the user chooses to sign-in to their Google account.
44 // Used when a user selects the privet printer in a pair of duplicate
45 // privet and cloud printers.
46 PRIVET_DUPLICATE_SELECTED: 5,
47 // Used when a user selects the cloud printer in a pair of duplicate
48 // privet and cloud printers.
49 CLOUD_DUPLICATE_SELECTED: 6
53 * Enumeration of buckets that a user can enter while using the Google Cloud
57 Metrics.GcpPromoBucket = {
58 // Used when the Google Cloud Print pomotion (shown above the pdf preview
59 // plugin) is shown to the user.
61 // Used when the user clicks the "Get started" link in the promotion shown
62 // in CLOUDPRINT_BIG_PROMO_SHOWN.
64 // Used when the user dismisses the promotion shown in
65 // CLOUDPRINT_BIG_PROMO_SHOWN.
70 * Name of the C++ function to call to increment bucket counts.
75 Metrics.NATIVE_FUNCTION_NAME_ = 'reportUiEvent';
79 * Increments the counter of a destination-search bucket.
80 * @param {!Metrics.DestinationSearchBucket} bucket Bucket to increment.
82 incrementDestinationSearchBucket: function(bucket) {
83 chrome.send(Metrics.NATIVE_FUNCTION_NAME_,
84 [Metrics.BucketGroup.DESTINATION_SEARCH, bucket]);
88 * Increments the counter of a gcp-promo bucket.
89 * @param {!Metrics.GcpPromoBucket} bucket Bucket to increment.
91 incrementGcpPromoBucket: function(bucket) {
92 chrome.send(Metrics.NATIVE_FUNCTION_NAME_,
93 [Metrics.BucketGroup.GCP_PROMO, bucket]);