Switch global error menu icon to vectorized MD asset
[chromium-blink-merge.git] / chrome / browser / tab_contents / navigation_metrics_recorder.cc
blobadcbf94e570c07ce790390303727763efe2ba39e
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
3 // found in the LICENSE file.
5 #include "chrome/browser/tab_contents/navigation_metrics_recorder.h"
7 #include "base/metrics/histogram_macros.h"
8 #include "chrome/browser/browser_process.h"
9 #include "components/navigation_metrics/navigation_metrics.h"
10 #include "components/rappor/rappor_utils.h"
11 #include "content/public/browser/browser_thread.h"
12 #include "content/public/browser/navigation_details.h"
13 #include "content/public/browser/navigation_entry.h"
14 #include "content/public/browser/render_view_host.h"
15 #include "content/public/browser/render_widget_host_view.h"
16 #include "content/public/common/frame_navigate_params.h"
17 #include "url/gurl.h"
19 #if defined(OS_WIN)
20 #include "base/win/windows_version.h"
21 #include "chrome/browser/metro_utils/metro_chrome_win.h"
22 #endif
24 DEFINE_WEB_CONTENTS_USER_DATA_KEY(NavigationMetricsRecorder);
26 NavigationMetricsRecorder::NavigationMetricsRecorder(
27 content::WebContents* web_contents)
28 : content::WebContentsObserver(web_contents) {
31 NavigationMetricsRecorder::~NavigationMetricsRecorder() {
34 void NavigationMetricsRecorder::DidNavigateMainFrame(
35 const content::LoadCommittedDetails& details,
36 const content::FrameNavigateParams& params) {
37 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
38 navigation_metrics::RecordMainFrameNavigation(details.entry->GetVirtualURL(),
39 details.is_in_page);
40 // Record the domain and registry of the URL that resulted in a navigation to
41 // a |data:| URL, either by redirects or user clicking a link.
42 if (details.entry->GetVirtualURL().SchemeIs(url::kDataScheme) &&
43 params.transition != ui::PAGE_TRANSITION_TYPED &&
44 !details.previous_url.is_empty()) {
45 rappor::SampleDomainAndRegistryFromGURL(g_browser_process->rappor_service(),
46 "Navigation.Scheme.Data",
47 details.previous_url);
51 void NavigationMetricsRecorder::DidStartLoading() {
52 #if defined(OS_WIN) && defined(USE_ASH)
53 content::RenderViewHost* rvh = web_contents()->GetRenderViewHost();
55 if (rvh && base::win::GetVersion() >= base::win::VERSION_WIN8) {
56 content::RenderWidgetHostView* rwhv = rvh->GetView();
57 if (rwhv) {
58 gfx::NativeView native_view = rwhv->GetNativeView();
59 if (native_view) {
60 chrome::HostDesktopType desktop =
61 chrome::GetHostDesktopTypeForNativeView(native_view);
62 UMA_HISTOGRAM_ENUMERATION("Win8.PageLoad",
63 chrome::GetWin8Environment(desktop),
64 chrome::WIN_8_ENVIRONMENT_MAX);
68 #endif