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/profiles/profile.h" | |
Avi (use Gerrit)
2016/04/14 19:08:02
Do you still need this, as you don't use profiles
palmer
2016/04/14 20:13:41
Done.
| |
11 #include "chrome/browser/tab_contents/origins_seen_service.h" | |
12 #include "chrome/browser/tab_contents/origins_seen_service_factory.h" | |
10 #include "components/navigation_metrics/navigation_metrics.h" | 13 #include "components/navigation_metrics/navigation_metrics.h" |
11 #include "components/rappor/rappor_utils.h" | 14 #include "components/rappor/rappor_utils.h" |
15 #include "content/public/browser/browser_context.h" | |
12 #include "content/public/browser/browser_thread.h" | 16 #include "content/public/browser/browser_thread.h" |
13 #include "content/public/browser/navigation_details.h" | 17 #include "content/public/browser/navigation_details.h" |
14 #include "content/public/browser/navigation_entry.h" | 18 #include "content/public/browser/navigation_entry.h" |
15 #include "content/public/browser/render_view_host.h" | 19 #include "content/public/browser/render_view_host.h" |
16 #include "content/public/browser/render_widget_host.h" | 20 #include "content/public/browser/render_widget_host.h" |
17 #include "content/public/browser/render_widget_host_view.h" | 21 #include "content/public/browser/render_widget_host_view.h" |
18 #include "content/public/common/frame_navigate_params.h" | 22 #include "content/public/common/frame_navigate_params.h" |
19 #include "url/gurl.h" | 23 #include "url/gurl.h" |
24 #include "url/origin.h" | |
20 | 25 |
21 #if defined(OS_WIN) | 26 #if defined(OS_WIN) |
22 #include "base/win/windows_version.h" | 27 #include "base/win/windows_version.h" |
23 #endif | 28 #endif |
24 | 29 |
25 DEFINE_WEB_CONTENTS_USER_DATA_KEY(NavigationMetricsRecorder); | 30 DEFINE_WEB_CONTENTS_USER_DATA_KEY(NavigationMetricsRecorder); |
26 | 31 |
27 NavigationMetricsRecorder::NavigationMetricsRecorder( | 32 NavigationMetricsRecorder::NavigationMetricsRecorder( |
28 content::WebContents* web_contents) | 33 content::WebContents* web_contents) |
29 : content::WebContentsObserver(web_contents) { | 34 : content::WebContentsObserver(web_contents) { |
30 } | 35 } |
31 | 36 |
32 NavigationMetricsRecorder::~NavigationMetricsRecorder() { | 37 NavigationMetricsRecorder::~NavigationMetricsRecorder() { |
33 } | 38 } |
34 | 39 |
35 void NavigationMetricsRecorder::DidNavigateMainFrame( | 40 void NavigationMetricsRecorder::DidNavigateMainFrame( |
36 const content::LoadCommittedDetails& details, | 41 const content::LoadCommittedDetails& details, |
37 const content::FrameNavigateParams& params) { | 42 const content::FrameNavigateParams& params) { |
38 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 43 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
39 navigation_metrics::RecordMainFrameNavigation(details.entry->GetVirtualURL(), | 44 |
40 details.is_in_page); | 45 content::BrowserContext* context = web_contents()->GetBrowserContext(); |
46 OriginsSeenService* service = | |
47 OriginsSeenServiceFactory::GetForBrowserContext(context); | |
48 const url::Origin origin(details.entry->GetVirtualURL()); | |
49 bool have_already_seen_origin = service->HaveAlreadySeenOrigin(origin); | |
50 | |
51 navigation_metrics::RecordMainFrameNavigation( | |
52 details.entry->GetVirtualURL(), details.is_in_page, | |
53 context->IsOffTheRecord(), have_already_seen_origin); | |
54 | |
41 // Record the domain and registry of the URL that resulted in a navigation to | 55 // Record the domain and registry of the URL that resulted in a navigation to |
42 // a |data:| URL, either by redirects or user clicking a link. | 56 // a |data:| URL, either by redirects or user clicking a link. |
43 if (details.entry->GetVirtualURL().SchemeIs(url::kDataScheme) && | 57 if (details.entry->GetVirtualURL().SchemeIs(url::kDataScheme) && |
44 params.transition != ui::PAGE_TRANSITION_TYPED && | 58 params.transition != ui::PAGE_TRANSITION_TYPED && |
45 !details.previous_url.is_empty()) { | 59 !details.previous_url.is_empty()) { |
46 rappor::SampleDomainAndRegistryFromGURL(g_browser_process->rappor_service(), | 60 rappor::SampleDomainAndRegistryFromGURL(g_browser_process->rappor_service(), |
47 "Navigation.Scheme.Data", | 61 "Navigation.Scheme.Data", |
48 details.previous_url); | 62 details.previous_url); |
49 } | 63 } |
50 } | 64 } |
OLD | NEW |