OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/webui/log_web_ui_url.h" | 5 #include "chrome/browser/ui/webui/log_web_ui_url.h" |
6 | 6 |
7 #include "base/hash.h" | 7 #include "base/hash.h" |
8 #include "base/metrics/histogram_base.h" | 8 #include "base/metrics/histogram_base.h" |
9 #include "base/metrics/sparse_histogram.h" | 9 #include "base/metrics/sparse_histogram.h" |
10 #include "chrome/common/url_constants.h" | 10 #include "chrome/common/url_constants.h" |
11 #include "content/public/common/url_constants.h" | 11 #include "content/public/common/url_constants.h" |
12 #include "url/gurl.h" | 12 #include "url/gurl.h" |
13 | 13 |
14 #if defined(ENABLE_EXTENSIONS) | 14 #if defined(ENABLE_EXTENSIONS) |
15 #include "chrome/common/extensions/extension_constants.h" | 15 #include "chrome/common/extensions/extension_constants.h" |
16 #include "extensions/common/constants.h" | 16 #include "extensions/common/constants.h" |
17 #endif | 17 #endif |
18 | 18 |
19 namespace webui { | 19 namespace webui { |
20 | 20 |
| 21 const char kWebUICreatedForUrl[] = "WebUI.CreatedForUrl"; |
| 22 |
21 bool LogWebUIUrl(const GURL& web_ui_url) { | 23 bool LogWebUIUrl(const GURL& web_ui_url) { |
22 bool should_log = web_ui_url.SchemeIs(content::kChromeUIScheme) || | 24 bool should_log = web_ui_url.SchemeIs(content::kChromeUIScheme) || |
23 web_ui_url.SchemeIs(content::kChromeDevToolsScheme); | 25 web_ui_url.SchemeIs(content::kChromeDevToolsScheme); |
24 | 26 |
25 #if defined(ENABLE_EXTENSIONS) | 27 #if defined(ENABLE_EXTENSIONS) |
26 if (web_ui_url.SchemeIs(extensions::kExtensionScheme)) | 28 if (web_ui_url.SchemeIs(extensions::kExtensionScheme)) |
27 should_log = web_ui_url.host() == extension_misc::kBookmarkManagerId; | 29 should_log = web_ui_url.host() == extension_misc::kBookmarkManagerId; |
28 #endif | 30 #endif |
29 | 31 |
30 if (should_log) { | 32 if (should_log) { |
31 uint32 hash = base::Hash(web_ui_url.GetOrigin().spec()); | 33 uint32 hash = base::Hash(web_ui_url.GetOrigin().spec()); |
32 UMA_HISTOGRAM_SPARSE_SLOWLY("WebUI.CreatedForUrl", | 34 UMA_HISTOGRAM_SPARSE_SLOWLY(kWebUICreatedForUrl, |
33 static_cast<base::HistogramBase::Sample>(hash)); | 35 static_cast<base::HistogramBase::Sample>(hash)); |
34 } | 36 } |
35 | 37 |
36 return should_log; | 38 return should_log; |
37 } | 39 } |
38 | 40 |
39 } // namespace webui | 41 } // namespace webui |
OLD | NEW |