Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(736)

Side by Side Diff: chrome/browser/tab_contents/navigation_metrics_recorder.cc

Issue 1844753002: Histogram the scheme of an origin on the 1st navigation to it. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Respond to comments. Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/tab_contents/origins_seen_service.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "components/navigation_metrics/navigation_metrics.h" 12 #include "components/navigation_metrics/navigation_metrics.h"
11 #include "components/rappor/rappor_utils.h" 13 #include "components/rappor/rappor_utils.h"
14 #include "content/public/browser/browser_context.h"
12 #include "content/public/browser/browser_thread.h" 15 #include "content/public/browser/browser_thread.h"
13 #include "content/public/browser/navigation_details.h" 16 #include "content/public/browser/navigation_details.h"
14 #include "content/public/browser/navigation_entry.h" 17 #include "content/public/browser/navigation_entry.h"
15 #include "content/public/browser/render_view_host.h" 18 #include "content/public/browser/render_view_host.h"
16 #include "content/public/browser/render_widget_host.h" 19 #include "content/public/browser/render_widget_host.h"
17 #include "content/public/browser/render_widget_host_view.h" 20 #include "content/public/browser/render_widget_host_view.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"
23 #include "url/origin.h"
20 24
21 #if defined(OS_WIN) 25 #if defined(OS_WIN)
22 #include "base/win/windows_version.h" 26 #include "base/win/windows_version.h"
23 #endif 27 #endif
24 28
25 DEFINE_WEB_CONTENTS_USER_DATA_KEY(NavigationMetricsRecorder); 29 DEFINE_WEB_CONTENTS_USER_DATA_KEY(NavigationMetricsRecorder);
26 30
27 NavigationMetricsRecorder::NavigationMetricsRecorder( 31 NavigationMetricsRecorder::NavigationMetricsRecorder(
28 content::WebContents* web_contents) 32 content::WebContents* web_contents)
29 : content::WebContentsObserver(web_contents) { 33 : content::WebContentsObserver(web_contents) {
30 } 34 }
31 35
32 NavigationMetricsRecorder::~NavigationMetricsRecorder() { 36 NavigationMetricsRecorder::~NavigationMetricsRecorder() {
33 } 37 }
34 38
35 void NavigationMetricsRecorder::DidNavigateMainFrame( 39 void NavigationMetricsRecorder::DidNavigateMainFrame(
36 const content::LoadCommittedDetails& details, 40 const content::LoadCommittedDetails& details,
37 const content::FrameNavigateParams& params) { 41 const content::FrameNavigateParams& params) {
38 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 42 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
39 navigation_metrics::RecordMainFrameNavigation(details.entry->GetVirtualURL(), 43
40 details.is_in_page); 44 content::BrowserContext* context = web_contents()->GetBrowserContext();
45 OriginsSeenService* service =
46 OriginsSeenServiceFactory::GetForBrowserContext(context);
47 const url::Origin origin(details.entry->GetVirtualURL());
48 bool have_already_seen_origin = service->Insert(origin);
49
50 navigation_metrics::RecordMainFrameNavigation(
51 details.entry->GetVirtualURL(), details.is_in_page,
52 context->IsOffTheRecord(), have_already_seen_origin);
53
41 // 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
42 // a |data:| URL, either by redirects or user clicking a link. 55 // a |data:| URL, either by redirects or user clicking a link.
43 if (details.entry->GetVirtualURL().SchemeIs(url::kDataScheme) && 56 if (details.entry->GetVirtualURL().SchemeIs(url::kDataScheme) &&
44 params.transition != ui::PAGE_TRANSITION_TYPED && 57 params.transition != ui::PAGE_TRANSITION_TYPED &&
45 !details.previous_url.is_empty()) { 58 !details.previous_url.is_empty()) {
46 rappor::SampleDomainAndRegistryFromGURL(g_browser_process->rappor_service(), 59 rappor::SampleDomainAndRegistryFromGURL(g_browser_process->rappor_service(),
47 "Navigation.Scheme.Data", 60 "Navigation.Scheme.Data",
48 details.previous_url); 61 details.previous_url);
49 } 62 }
50 } 63 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/tab_contents/origins_seen_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698