Allow only one bookmark to be added for multiple fast starring
[chromium-blink-merge.git] / components / navigation_metrics / navigation_metrics.cc
blobffebe68681a7158d3782effbd2738d0d6a6fc740
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 // This enum is used in building the histogram. So, this is append only,
13 // any new scheme should be added at the end, before SCHEME_MAX
14 enum Scheme {
15 SCHEME_UNKNOWN,
16 SCHEME_HTTP,
17 SCHEME_HTTPS,
18 SCHEME_FILE,
19 SCHEME_FTP,
20 SCHEME_DATA,
21 SCHEME_JAVASCRIPT,
22 SCHEME_ABOUT,
23 SCHEME_CHROME,
24 SCHEME_BLOB,
25 SCHEME_MAX,
28 const char* const kSchemeNames[] = {
29 "unknown",
30 url::kHttpScheme,
31 url::kHttpsScheme,
32 url::kFileScheme,
33 url::kFtpScheme,
34 url::kDataScheme,
35 url::kJavaScriptScheme,
36 url::kAboutScheme,
37 "chrome",
38 url::kBlobScheme,
39 "max",
42 static_assert(arraysize(kSchemeNames) == SCHEME_MAX + 1,
43 "kSchemeNames should have SCHEME_MAX + 1 elements");
45 } // namespace
47 namespace navigation_metrics {
49 void RecordMainFrameNavigation(const GURL& url, bool is_in_page) {
50 Scheme scheme = SCHEME_UNKNOWN;
51 for (int i = 1; i < SCHEME_MAX; ++i) {
52 if (url.SchemeIs(kSchemeNames[i])) {
53 scheme = static_cast<Scheme>(i);
54 break;
57 UMA_HISTOGRAM_ENUMERATION("Navigation.MainFrameScheme", scheme, SCHEME_MAX);
58 if (!is_in_page) {
59 UMA_HISTOGRAM_ENUMERATION(
60 "Navigation.MainFrameSchemeDifferentPage", scheme, SCHEME_MAX);
64 } // namespace navigation_metrics