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 "chrome/browser/tab_contents/origins_seen_service.h" | |
11 #include "chrome/browser/tab_contents/origins_seen_service_factory.h" | 10 #include "chrome/browser/tab_contents/origins_seen_service_factory.h" |
12 #include "components/navigation_metrics/navigation_metrics.h" | 11 #include "components/navigation_metrics/navigation_metrics.h" |
| 12 #include "components/navigation_metrics/origins_seen_service.h" |
13 #include "components/rappor/rappor_utils.h" | 13 #include "components/rappor/rappor_utils.h" |
14 #include "content/public/browser/browser_context.h" | 14 #include "content/public/browser/browser_context.h" |
15 #include "content/public/browser/browser_thread.h" | 15 #include "content/public/browser/browser_thread.h" |
16 #include "content/public/browser/navigation_details.h" | 16 #include "content/public/browser/navigation_details.h" |
17 #include "content/public/browser/navigation_entry.h" | 17 #include "content/public/browser/navigation_entry.h" |
18 #include "content/public/browser/render_view_host.h" | 18 #include "content/public/browser/render_view_host.h" |
19 #include "content/public/browser/render_widget_host.h" | 19 #include "content/public/browser/render_widget_host.h" |
20 #include "content/public/browser/render_widget_host_view.h" | 20 #include "content/public/browser/render_widget_host_view.h" |
21 #include "content/public/common/frame_navigate_params.h" | 21 #include "content/public/common/frame_navigate_params.h" |
22 #include "url/gurl.h" | 22 #include "url/gurl.h" |
(...skipping 12 matching lines...) Expand all Loading... |
35 | 35 |
36 NavigationMetricsRecorder::~NavigationMetricsRecorder() { | 36 NavigationMetricsRecorder::~NavigationMetricsRecorder() { |
37 } | 37 } |
38 | 38 |
39 void NavigationMetricsRecorder::DidNavigateMainFrame( | 39 void NavigationMetricsRecorder::DidNavigateMainFrame( |
40 const content::LoadCommittedDetails& details, | 40 const content::LoadCommittedDetails& details, |
41 const content::FrameNavigateParams& params) { | 41 const content::FrameNavigateParams& params) { |
42 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 42 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
43 | 43 |
44 content::BrowserContext* context = web_contents()->GetBrowserContext(); | 44 content::BrowserContext* context = web_contents()->GetBrowserContext(); |
45 OriginsSeenService* service = | 45 navigation_metrics::OriginsSeenService* service = |
46 OriginsSeenServiceFactory::GetForBrowserContext(context); | 46 OriginsSeenServiceFactory::GetForBrowserContext(context); |
47 const url::Origin origin(details.entry->GetVirtualURL()); | 47 const url::Origin origin(details.entry->GetVirtualURL()); |
48 bool have_already_seen_origin = service->Insert(origin); | 48 bool have_already_seen_origin = service->Insert(origin); |
49 | 49 |
50 navigation_metrics::RecordMainFrameNavigation( | 50 navigation_metrics::RecordMainFrameNavigation( |
51 details.entry->GetVirtualURL(), details.is_in_page, | 51 details.entry->GetVirtualURL(), details.is_in_page, |
52 context->IsOffTheRecord(), have_already_seen_origin); | 52 context->IsOffTheRecord(), have_already_seen_origin); |
53 | 53 |
54 // Record the domain and registry of the URL that resulted in a navigation to | 54 // Record the domain and registry of the URL that resulted in a navigation to |
55 // a |data:| URL, either by redirects or user clicking a link. | 55 // a |data:| URL, either by redirects or user clicking a link. |
56 if (details.entry->GetVirtualURL().SchemeIs(url::kDataScheme) && | 56 if (details.entry->GetVirtualURL().SchemeIs(url::kDataScheme) && |
57 params.transition != ui::PAGE_TRANSITION_TYPED && | 57 params.transition != ui::PAGE_TRANSITION_TYPED && |
58 !details.previous_url.is_empty()) { | 58 !details.previous_url.is_empty()) { |
59 rappor::SampleDomainAndRegistryFromGURL(g_browser_process->rappor_service(), | 59 rappor::SampleDomainAndRegistryFromGURL(g_browser_process->rappor_service(), |
60 "Navigation.Scheme.Data", | 60 "Navigation.Scheme.Data", |
61 details.previous_url); | 61 details.previous_url); |
62 } | 62 } |
63 } | 63 } |
OLD | NEW |