| OLD | NEW | 
|---|
| 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_macros.h" | 7 #include "base/metrics/histogram_macros.h" | 
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" | 
| 9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" | 
| 10 #include "components/navigation_metrics/navigation_metrics.h" | 10 #include "components/navigation_metrics/navigation_metrics.h" | 
| 11 #include "components/rappor/rappor_utils.h" | 11 #include "components/rappor/rappor_utils.h" | 
| 12 #include "content/public/browser/browser_thread.h" | 12 #include "content/public/browser/browser_thread.h" | 
| 13 #include "content/public/browser/navigation_details.h" | 13 #include "content/public/browser/navigation_details.h" | 
| 14 #include "content/public/browser/navigation_entry.h" | 14 #include "content/public/browser/navigation_entry.h" | 
| 15 #include "content/public/browser/render_view_host.h" | 15 #include "content/public/browser/render_view_host.h" | 
| 16 #include "content/public/browser/render_widget_host.h" | 16 #include "content/public/browser/render_widget_host.h" | 
| 17 #include "content/public/browser/render_widget_host_view.h" | 17 #include "content/public/browser/render_widget_host_view.h" | 
| 18 #include "content/public/common/frame_navigate_params.h" | 18 #include "content/public/common/frame_navigate_params.h" | 
| 19 #include "url/gurl.h" | 19 #include "url/gurl.h" | 
| 20 | 20 | 
| 21 #if defined(OS_WIN) | 21 #if defined(OS_WIN) | 
| 22 #include "base/win/windows_version.h" | 22 #include "base/win/windows_version.h" | 
| 23 #include "chrome/browser/metro_utils/metro_chrome_win.h" |  | 
| 24 #endif | 23 #endif | 
| 25 | 24 | 
| 26 DEFINE_WEB_CONTENTS_USER_DATA_KEY(NavigationMetricsRecorder); | 25 DEFINE_WEB_CONTENTS_USER_DATA_KEY(NavigationMetricsRecorder); | 
| 27 | 26 | 
| 28 NavigationMetricsRecorder::NavigationMetricsRecorder( | 27 NavigationMetricsRecorder::NavigationMetricsRecorder( | 
| 29     content::WebContents* web_contents) | 28     content::WebContents* web_contents) | 
| 30     : content::WebContentsObserver(web_contents) { | 29     : content::WebContentsObserver(web_contents) { | 
| 31 } | 30 } | 
| 32 | 31 | 
| 33 NavigationMetricsRecorder::~NavigationMetricsRecorder() { | 32 NavigationMetricsRecorder::~NavigationMetricsRecorder() { | 
| 34 } | 33 } | 
| 35 | 34 | 
| 36 void NavigationMetricsRecorder::DidNavigateMainFrame( | 35 void NavigationMetricsRecorder::DidNavigateMainFrame( | 
| 37       const content::LoadCommittedDetails& details, | 36       const content::LoadCommittedDetails& details, | 
| 38       const content::FrameNavigateParams& params) { | 37       const content::FrameNavigateParams& params) { | 
| 39   DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 38   DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 
| 40   navigation_metrics::RecordMainFrameNavigation(details.entry->GetVirtualURL(), | 39   navigation_metrics::RecordMainFrameNavigation(details.entry->GetVirtualURL(), | 
| 41                                                 details.is_in_page); | 40                                                 details.is_in_page); | 
| 42   // Record the domain and registry of the URL that resulted in a navigation to | 41   // Record the domain and registry of the URL that resulted in a navigation to | 
| 43   // a |data:| URL, either by redirects or user clicking a link. | 42   // a |data:| URL, either by redirects or user clicking a link. | 
| 44   if (details.entry->GetVirtualURL().SchemeIs(url::kDataScheme) && | 43   if (details.entry->GetVirtualURL().SchemeIs(url::kDataScheme) && | 
| 45       params.transition != ui::PAGE_TRANSITION_TYPED && | 44       params.transition != ui::PAGE_TRANSITION_TYPED && | 
| 46       !details.previous_url.is_empty()) { | 45       !details.previous_url.is_empty()) { | 
| 47     rappor::SampleDomainAndRegistryFromGURL(g_browser_process->rappor_service(), | 46     rappor::SampleDomainAndRegistryFromGURL(g_browser_process->rappor_service(), | 
| 48                                             "Navigation.Scheme.Data", | 47                                             "Navigation.Scheme.Data", | 
| 49                                             details.previous_url); | 48                                             details.previous_url); | 
| 50   } | 49   } | 
| 51 } | 50 } | 
| 52 |  | 
| 53 void NavigationMetricsRecorder::DidStartLoading() { |  | 
| 54 #if defined(OS_WIN) && defined(USE_ASH) |  | 
| 55   content::RenderViewHost* rvh = web_contents()->GetRenderViewHost(); |  | 
| 56 |  | 
| 57   if (rvh && base::win::GetVersion() >= base::win::VERSION_WIN8) { |  | 
| 58     content::RenderWidgetHostView* rwhv = rvh->GetWidget()->GetView(); |  | 
| 59     if (rwhv) { |  | 
| 60       gfx::NativeView native_view = rwhv->GetNativeView(); |  | 
| 61       if (native_view) { |  | 
| 62         chrome::HostDesktopType desktop = |  | 
| 63             chrome::GetHostDesktopTypeForNativeView(native_view); |  | 
| 64         UMA_HISTOGRAM_ENUMERATION("Win8.PageLoad", |  | 
| 65                                   chrome::GetWin8Environment(desktop), |  | 
| 66                                   chrome::WIN_8_ENVIRONMENT_MAX); |  | 
| 67       } |  | 
| 68     } |  | 
| 69   } |  | 
| 70 #endif |  | 
| 71 } |  | 
| OLD | NEW | 
|---|