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_io_data.h" | |
10 #include "components/navigation_metrics/navigation_metrics.h" | 11 #include "components/navigation_metrics/navigation_metrics.h" |
11 #include "components/rappor/rappor_utils.h" | 12 #include "components/rappor/rappor_utils.h" |
13 #include "content/public/browser/browser_context.h" | |
12 #include "content/public/browser/browser_thread.h" | 14 #include "content/public/browser/browser_thread.h" |
13 #include "content/public/browser/navigation_details.h" | 15 #include "content/public/browser/navigation_details.h" |
14 #include "content/public/browser/navigation_entry.h" | 16 #include "content/public/browser/navigation_entry.h" |
15 #include "content/public/browser/render_view_host.h" | 17 #include "content/public/browser/render_view_host.h" |
16 #include "content/public/browser/render_widget_host.h" | 18 #include "content/public/browser/render_widget_host.h" |
17 #include "content/public/browser/render_widget_host_view.h" | 19 #include "content/public/browser/render_widget_host_view.h" |
20 #include "content/public/browser/web_contents.h" | |
18 #include "content/public/common/frame_navigate_params.h" | 21 #include "content/public/common/frame_navigate_params.h" |
19 #include "url/gurl.h" | 22 #include "url/gurl.h" |
20 | 23 |
21 #if defined(OS_WIN) | 24 #if defined(OS_WIN) |
22 #include "base/win/windows_version.h" | 25 #include "base/win/windows_version.h" |
23 #endif | 26 #endif |
24 | 27 |
25 DEFINE_WEB_CONTENTS_USER_DATA_KEY(NavigationMetricsRecorder); | 28 DEFINE_WEB_CONTENTS_USER_DATA_KEY(NavigationMetricsRecorder); |
26 | 29 |
27 NavigationMetricsRecorder::NavigationMetricsRecorder( | 30 NavigationMetricsRecorder::NavigationMetricsRecorder( |
28 content::WebContents* web_contents) | 31 content::WebContents* web_contents) |
29 : content::WebContentsObserver(web_contents) { | 32 : content::WebContentsObserver(web_contents) { |
30 } | 33 } |
31 | 34 |
32 NavigationMetricsRecorder::~NavigationMetricsRecorder() { | 35 NavigationMetricsRecorder::~NavigationMetricsRecorder() { |
33 } | 36 } |
34 | 37 |
35 void NavigationMetricsRecorder::DidNavigateMainFrame( | 38 void NavigationMetricsRecorder::DidNavigateMainFrame( |
36 const content::LoadCommittedDetails& details, | 39 const content::LoadCommittedDetails& details, |
37 const content::FrameNavigateParams& params) { | 40 const content::FrameNavigateParams& params) { |
38 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 41 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
39 navigation_metrics::RecordMainFrameNavigation(details.entry->GetVirtualURL(), | 42 bool is_otr = web_contents()->GetBrowserContext()->IsOffTheRecord(); |
felt
2016/04/01 00:01:59
IsOffTheRecord only returns true for Incognito, ri
palmer
2016/04/05 23:42:18
OTR is for Incognito and Guest Mode. Rather than t
| |
40 details.is_in_page); | 43 bool should_record_main_frame_navigation = true; |
44 if (is_otr) { | |
45 content::ResourceContext* context = | |
46 web_contents()->GetBrowserContext()->GetResourceContext(); | |
47 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context); | |
48 url::Origin origin(details.entry->GetVirtualURL()); | |
49 if (io_data->HaveAlreadySeenOrigin(origin)) | |
50 should_record_main_frame_navigation = false; | |
51 } | |
52 if (should_record_main_frame_navigation) { | |
53 navigation_metrics::RecordMainFrameNavigation( | |
54 details.entry->GetVirtualURL(), details.is_in_page, is_otr); | |
55 } | |
41 // Record the domain and registry of the URL that resulted in a navigation to | 56 // 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. | 57 // a |data:| URL, either by redirects or user clicking a link. |
43 if (details.entry->GetVirtualURL().SchemeIs(url::kDataScheme) && | 58 if (details.entry->GetVirtualURL().SchemeIs(url::kDataScheme) && |
44 params.transition != ui::PAGE_TRANSITION_TYPED && | 59 params.transition != ui::PAGE_TRANSITION_TYPED && |
45 !details.previous_url.is_empty()) { | 60 !details.previous_url.is_empty()) { |
46 rappor::SampleDomainAndRegistryFromGURL(g_browser_process->rappor_service(), | 61 rappor::SampleDomainAndRegistryFromGURL(g_browser_process->rappor_service(), |
47 "Navigation.Scheme.Data", | 62 "Navigation.Scheme.Data", |
48 details.previous_url); | 63 details.previous_url); |
49 } | 64 } |
50 } | 65 } |
OLD | NEW |