Supervised user import: Listen for profile creation/deletion
[chromium-blink-merge.git] / components / navigation_metrics / navigation_metrics.cc
blob214c75fc1d2c60adc9657631ee65c462555d9bf5
1 // Copyright 2013 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 #include "components/navigation_metrics/navigation_metrics.h"
7 #include "base/metrics/histogram.h"
8 #include "url/gurl.h"
10 namespace {
12 enum Scheme {
13 SCHEME_UNKNOWN,
14 SCHEME_HTTP,
15 SCHEME_HTTPS,
16 SCHEME_FILE,
17 SCHEME_FTP,
18 SCHEME_DATA,
19 SCHEME_JAVASCRIPT,
20 SCHEME_ABOUT,
21 SCHEME_CHROME,
22 SCHEME_MAX,
25 const char* const kSchemeNames[] = {
26 "unknown",
27 url::kHttpScheme,
28 url::kHttpsScheme,
29 url::kFileScheme,
30 url::kFtpScheme,
31 url::kDataScheme,
32 url::kJavaScriptScheme,
33 url::kAboutScheme,
34 "chrome",
35 "max",
38 static_assert(arraysize(kSchemeNames) == SCHEME_MAX + 1,
39 "kSchemeNames should have SCHEME_MAX + 1 elements");
41 } // namespace
43 namespace navigation_metrics {
45 void RecordMainFrameNavigation(const GURL& url, bool is_in_page) {
46 Scheme scheme = SCHEME_UNKNOWN;
47 for (int i = 1; i < SCHEME_MAX; ++i) {
48 if (url.SchemeIs(kSchemeNames[i])) {
49 scheme = static_cast<Scheme>(i);
50 break;
53 UMA_HISTOGRAM_ENUMERATION("Navigation.MainFrameScheme", scheme, SCHEME_MAX);
54 if (!is_in_page) {
55 UMA_HISTOGRAM_ENUMERATION(
56 "Navigation.MainFrameSchemeDifferentPage", scheme, SCHEME_MAX);
60 } // namespace navigation_metrics