Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(171)

Side by Side Diff: chrome/browser/tab_contents/navigation_metrics_recorder.cc

Issue 35693009: Move Navigation.MainFrameScheme UMA recording to //components. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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/tab_contents/navigation_metrics_recorder.h" 5 #include "chrome/browser/tab_contents/navigation_metrics_recorder.h"
6 6
7 #include "base/metrics/histogram.h" 7 #include "base/metrics/histogram.h"
8 #include "components/navigation_metrics/navigation_metrics.h"
8 #include "content/public/browser/navigation_details.h" 9 #include "content/public/browser/navigation_details.h"
9 #include "content/public/browser/navigation_entry.h" 10 #include "content/public/browser/navigation_entry.h"
10 #include "content/public/browser/render_view_host.h" 11 #include "content/public/browser/render_view_host.h"
11 #include "content/public/browser/render_widget_host_view.h" 12 #include "content/public/browser/render_widget_host_view.h"
12 13
13 #if defined(OS_WIN) 14 #if defined(OS_WIN)
14 #include "base/win/windows_version.h" 15 #include "base/win/windows_version.h"
15 #include "chrome/browser/metro_utils/metro_chrome_win.h" 16 #include "chrome/browser/metro_utils/metro_chrome_win.h"
16 #endif 17 #endif
17 18
18 DEFINE_WEB_CONTENTS_USER_DATA_KEY(NavigationMetricsRecorder); 19 DEFINE_WEB_CONTENTS_USER_DATA_KEY(NavigationMetricsRecorder);
19 20
20 namespace {
21
22 enum Scheme {
23 SCHEME_UNKNOWN,
24 SCHEME_HTTP,
25 SCHEME_HTTPS,
26 SCHEME_FILE,
27 SCHEME_FTP,
28 SCHEME_DATA,
29 SCHEME_JAVASCRIPT,
30 SCHEME_ABOUT,
31 SCHEME_CHROME,
32 SCHEME_MAX,
33 };
34
35 static const char* kSchemeNames[] = {
36 "unknown",
37 "http",
38 "https",
39 "file",
40 "ftp",
41 "data",
42 "javascript",
43 "about",
44 "chrome",
45 "max",
46 };
47
48 COMPILE_ASSERT(arraysize(kSchemeNames) == SCHEME_MAX + 1,
49 NavigationMetricsRecorder_name_count_mismatch);
50
51 void RecordMainFrameNavigation(const content::LoadCommittedDetails& details) {
52 GURL url = details.entry->GetVirtualURL();
53 Scheme scheme = SCHEME_UNKNOWN;
54 for (int i = 1; i < SCHEME_MAX; ++i) {
55 if (url.SchemeIs(kSchemeNames[i])) {
56 scheme = static_cast<Scheme>(i);
57 break;
58 }
59 }
60 UMA_HISTOGRAM_ENUMERATION(
61 "Navigation.MainFrameScheme", scheme, SCHEME_MAX);
62 }
63
64 } // namespace
65
66 NavigationMetricsRecorder::NavigationMetricsRecorder( 21 NavigationMetricsRecorder::NavigationMetricsRecorder(
67 content::WebContents* web_contents) 22 content::WebContents* web_contents)
68 : content::WebContentsObserver(web_contents) { 23 : content::WebContentsObserver(web_contents) {
69 } 24 }
70 25
71 NavigationMetricsRecorder::~NavigationMetricsRecorder() { 26 NavigationMetricsRecorder::~NavigationMetricsRecorder() {
72 } 27 }
73 28
74 void NavigationMetricsRecorder::DidNavigateMainFrame( 29 void NavigationMetricsRecorder::DidNavigateMainFrame(
75 const content::LoadCommittedDetails& details, 30 const content::LoadCommittedDetails& details,
76 const content::FrameNavigateParams& params) { 31 const content::FrameNavigateParams& params) {
77 RecordMainFrameNavigation(details); 32 navigation_metrics::RecordMainFrameNavigation(details.entry->GetVirtualURL());
78 } 33 }
79 34
80 void NavigationMetricsRecorder::DidStartLoading( 35 void NavigationMetricsRecorder::DidStartLoading(
81 content::RenderViewHost* render_view_host) { 36 content::RenderViewHost* render_view_host) {
82 #if defined(OS_WIN) && defined(USE_ASH) 37 #if defined(OS_WIN) && defined(USE_ASH)
83 if (base::win::GetVersion() >= base::win::VERSION_WIN8) { 38 if (base::win::GetVersion() >= base::win::VERSION_WIN8) {
84 gfx::NativeView view = render_view_host->GetView()->GetNativeView(); 39 gfx::NativeView view = render_view_host->GetView()->GetNativeView();
85 if (view) { 40 if (view) {
86 chrome::HostDesktopType desktop = 41 chrome::HostDesktopType desktop =
87 chrome::GetHostDesktopTypeForNativeView(view); 42 chrome::GetHostDesktopTypeForNativeView(view);
88 UMA_HISTOGRAM_ENUMERATION("Win8.PageLoad", 43 UMA_HISTOGRAM_ENUMERATION("Win8.PageLoad",
89 chrome::GetWin8Environment(desktop), 44 chrome::GetWin8Environment(desktop),
90 chrome::WIN_8_ENVIRONMENT_MAX); 45 chrome::WIN_8_ENVIRONMENT_MAX);
91 } 46 }
92 } 47 }
93 #endif 48 #endif
94 } 49 }
95 50
96 51
OLDNEW
« no previous file with comments | « chrome/browser/DEPS ('k') | chrome/chrome_browser.gypi » ('j') | chrome/chrome_browser.gypi » ('J')

Powered by Google App Engine
This is Rietveld 408576698