summaryrefslogtreecommitdiffstats
path: root/chrome/common/extensions/extension_metrics.cc
blob: eef45a4928c7a1e1fa2210dfaee07282aa31d6b2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Copyright 2014 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.

#include "chrome/common/extensions/extension_metrics.h"

#include "base/metrics/histogram.h"
#include "extensions/common/constants.h"
#include "extensions/common/extension.h"

namespace extensions {

void RecordAppLaunchType(extension_misc::AppLaunchBucket bucket,
                         extensions::Manifest::Type app_type) {
  DCHECK_LT(bucket, extension_misc::APP_LAUNCH_BUCKET_BOUNDARY);
  if (app_type == extensions::Manifest::TYPE_PLATFORM_APP) {
    UMA_HISTOGRAM_ENUMERATION("Apps.AppLaunch", bucket,
                              extension_misc::APP_LAUNCH_BUCKET_BOUNDARY);
  } else {
    UMA_HISTOGRAM_ENUMERATION("Extensions.AppLaunch", bucket,
                              extension_misc::APP_LAUNCH_BUCKET_BOUNDARY);
  }
}

void RecordAppListSearchLaunch(const extensions::Extension* extension) {
  extension_misc::AppLaunchBucket bucket =
      extension_misc::APP_LAUNCH_APP_LIST_SEARCH;
  if (extension->id() == extensions::kWebStoreAppId)
    bucket = extension_misc::APP_LAUNCH_APP_LIST_SEARCH_WEBSTORE;
  else if (extension->id() == extension_misc::kChromeAppId)
    bucket = extension_misc::APP_LAUNCH_APP_LIST_SEARCH_CHROME;
  RecordAppLaunchType(bucket, extension->GetType());
}

void RecordAppListMainLaunch(const extensions::Extension* extension) {
  extension_misc::AppLaunchBucket bucket =
      extension_misc::APP_LAUNCH_APP_LIST_MAIN;
  if (extension->id() == extensions::kWebStoreAppId)
    bucket = extension_misc::APP_LAUNCH_APP_LIST_MAIN_WEBSTORE;
  else if (extension->id() == extension_misc::kChromeAppId)
    bucket = extension_misc::APP_LAUNCH_APP_LIST_MAIN_CHROME;
  RecordAppLaunchType(bucket, extension->GetType());
}

void RecordWebStoreLaunch() {
  RecordAppLaunchType(extension_misc::APP_LAUNCH_NTP_WEBSTORE,
                      extensions::Manifest::TYPE_HOSTED_APP);
}

}  // namespace extensions